@myoc/excalidraw 0.19.522 → 0.19.524

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +123 -1
  2. package/dist/dev/{chunk-BCNQXIBK.js → chunk-3SND5YQP.js} +50 -6
  3. package/dist/dev/chunk-3SND5YQP.js.map +7 -0
  4. package/dist/dev/{chunk-6T5HZJCI.js → chunk-W3K3P2GO.js} +2 -2
  5. package/dist/dev/data/{image-NFLICJEW.js → image-F4TDOTKO.js} +3 -3
  6. package/dist/dev/index.css +774 -622
  7. package/dist/dev/index.css.map +3 -3
  8. package/dist/dev/index.js +11072 -10660
  9. package/dist/dev/index.js.map +4 -4
  10. package/dist/dev/subset-shared.chunk.js +1 -1
  11. package/dist/dev/subset-worker.chunk.js +1 -1
  12. package/dist/prod/{chunk-SZWH77NQ.js → chunk-GPFWSM2Y.js} +1 -1
  13. package/dist/prod/chunk-H5UC5NY3.js +4 -0
  14. package/dist/prod/data/image-FQV7KQIF.js +1 -0
  15. package/dist/prod/index.css +1 -1
  16. package/dist/prod/index.js +16 -16
  17. package/dist/prod/subset-shared.chunk.js +1 -1
  18. package/dist/prod/subset-worker.chunk.js +1 -1
  19. package/dist/types/excalidraw/actions/actionCanvas.d.ts +6 -6
  20. package/dist/types/excalidraw/actions/index.d.ts +1 -1
  21. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  22. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  23. package/dist/types/excalidraw/components/Actions.d.ts +1 -2
  24. package/dist/types/excalidraw/components/App.d.ts +9 -3
  25. package/dist/types/excalidraw/components/MobileToolbar.d.ts +3 -1
  26. package/dist/types/excalidraw/components/Toolbar.d.ts +3 -1
  27. package/dist/types/excalidraw/components/Tools.d.ts +9 -4
  28. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +0 -2
  29. package/dist/types/excalidraw/types.d.ts +9 -1
  30. package/dist/types/excalidraw/viewport.d.ts +7 -1
  31. package/package.json +4 -4
  32. package/dist/dev/chunk-BCNQXIBK.js.map +0 -7
  33. package/dist/prod/chunk-66O5T5YX.js +0 -4
  34. package/dist/prod/data/image-AAJBLI3M.js +0 -1
  35. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +0 -191
  36. /package/dist/dev/{chunk-6T5HZJCI.js.map → chunk-W3K3P2GO.js.map} +0 -0
  37. /package/dist/dev/data/{image-NFLICJEW.js.map → image-F4TDOTKO.js.map} +0 -0
@@ -1,24 +1,24 @@
1
- import{$ as Ja,A as iu,B as $a,C as rc,D as au,E as Wb,F as ic,G as Za,H as ac,I as sc,J as ja,K as Vb,L as Yb,M as Kb,N as lc,O as yr,P as KM,Q as vr,R as ci,T as Xb,V as $b,W as Zb,X as cc,Y as jb,Z as dc,_ as qa,a as nu,aa as qb,b as Rn,ba as mc,c as Mo,ca as Jb,d as wr,da as Qb,e as ai,ea as ex,f as no,fa as su,g as Bb,ga as tx,h as Me,ha as nx,i as Ob,ia as ox,j as ie,ja as di,k as si,l as Ao,m as Fb,n as ou,o as zb,p as Ka,q as Hb,r as oc,s as Gb,t as ru,u as oo,v as Lo,w as qt,x as Xa,y as li,z as Ub}from"./chunk-66O5T5YX.js";import{a as S}from"./chunk-SZWH77NQ.js";import{G as tu}from"./chunk-DARW3V66.js";import{c as Nb}from"./chunk-5XKZK2GL.js";import{b as Rb,c as YM,d as T}from"./chunk-SRAX5OIU.js";import xK,{useCallback as wK,useContext as yK,useEffect as vK,useRef as TK,useState as IK}from"react";import{applyDarkModeFilter as sWe,DEFAULT_IMAGE_OPTIONS as Po,DEFAULT_UI_OPTIONS as UM,getStrokeWidthByKey as lWe,isShallowEqual as SK}from"@excalidraw/common";import fk from"clsx";import XW from"lodash.throttle";import hn,{useContext as Co}from"react";import{flushSync as Ht}from"react-dom";import $W from"roughjs/bin/rough";import{nanoid as ZW}from"nanoid";import{clamp as Bl,pointFrom as ne,pointDistance as qn,vector as Ek,pointRotateRads as VE,vectorFromPoint as YE,vectorSubtract as bk,vectorDot as xk,vectorNormalize as wk}from"@excalidraw/math";import{CODES as pr,shouldResizeFromCenter as yk,shouldMaintainAspectRatio as Ol,shouldRotateWithDiscreteAngle as vk,isArrowKey as KE,KEYS as K,APP_NAME as jW,CURSOR_TYPE as Pe,DEFAULT_STROKE_STREAMLINE as qW,DEFAULT_STROKE_STREAMLINE_PRECISE as JW,DEFAULT_TRANSFORM_HANDLE_SPACING as QW,DEFAULT_VERTICAL_ALIGN as Tk,DRAGGING_THRESHOLD as Ik,ELEMENT_SHIFT_TRANSLATE_AMOUNT as eV,ELEMENT_TRANSLATE_AMOUNT as Sk,EVENT as J,FRAME_STYLE as wo,IMAGE_MIME_TYPES as tV,IMAGE_RENDER_TIMEOUT as nV,LINE_CONFIRM_THRESHOLD as XE,MIME_TYPES as Ba,MQ_RIGHT_SIDEBAR_MIN_WIDTH as oV,POINTER_BUTTON as yo,ROUNDNESS as _p,SCROLL_TIMEOUT as rV,TAP_TWICE_TIMEOUT as Ck,TEXT_TO_CENTER_SNAP_THRESHOLD as iV,THEME as Fl,TOUCH_CTX_MENU_TIMEOUT as aV,VERTICAL_ALIGN as sV,YOUTUBE_STATES as Rp,ZOOM_STEP as lV,MIN_ZOOM as cV,POINTER_EVENTS as Oa,TOOL_TYPE as Ln,supportsResizeObserver as dV,DEFAULT_COLLISION_THRESHOLD as Pk,DEFAULT_TEXT_ALIGN as mV,ARROW_TYPE as ur,DEFAULT_REDUCED_GLOBAL_ALPHA as pV,isLocalLink as uV,normalizeLink as $E,toValidURL as hV,getGridPoint as Ct,getLineHeight as kk,debounce as Mk,distance as Fa,getFontString as ZE,getNearestScrollableContainer as gV,isInputLike as Ak,isToolIcon as fV,isWritableElement as zl,sceneCoordsToViewportCoords as Np,tupleToCoors as jE,viewportCoordsToSceneCoords as Se,wrapEvent as EV,updateObject as qE,updateActiveTool as Zt,isTransparent as bV,muteFSAbortError as xV,isTestEnv as bM,isDevEnv as xM,updateStable as Hl,addEventListener as fe,normalizeEOL as wV,getDateTime as Lk,isShallowEqual as Dk,arrayToMap as Gl,applyDarkModeFilter as yV,AppEventBus as vV,randomInteger as TV,CLASSES as JE,Emitter as Jn,MINIMUM_ARROW_SIZE as IV,DOUBLE_TAP_POSITION_THRESHOLD as _k,BIND_MODE_TIMEOUT as SV,invariant as Qn,getFeatureFlag as vo,createUserAgentDescriptor as wM,getFormFactor as CV,deriveStylesPanelMode as Kp,isIOS as PV,isBrave as kV,isSafari as MV,loadDesktopUIModePreference as AV,setDesktopUIMode as LV,isSelectionLikeTool as Bp,oneOf as Rk,getStrokeWidthByKey as DV}from"@excalidraw/common";import{getObservedAppState as _V,getCommonBounds as za,getElementAbsoluteCoords as Nk,bindOrUnbindBindingElements as Bk,fixBindingsAfterDeletion as RV,getHoveredElementForBinding as hr,isBindingEnabled as Op,updateBoundElements as Fp,LinearElementEditor as ce,newElementWith as gr,newFrameElement as NV,newFreeDrawElement as BV,newEmbeddableElement as Ok,newMagicFrameElement as OV,newIframeElement as FV,newArrowElement as zV,newElement as HV,newImageElement as GV,newLinearElement as UV,newTextElement as Fk,refreshTextDimensions as WV,deepCopyElement as zk,duplicateElements as Hk,hasBoundTextElement as Gk,isArrowElement as Ul,isBindingElement as eo,isBindingElementType as VV,isBoundToContainer as Uk,isFrameLikeElement as vt,isImageElement as fr,isEmbeddableElement as To,isInitializedImageElement as Ha,isLinearElement as Rt,isLinearElementType as YV,isUsingAdaptiveRadius as KV,isIframeElement as QE,isIframeLikeElement as Wl,isTextBindableContainer as Wk,isElbowArrow as Gt,isBindableElement as eb,isTextElement as Ut,getNormalizedDimensions as XV,isElementCompletelyInViewport as $V,isElementInViewport as Vk,isInvisiblySmallElement as Yk,getCornerRadius as ZV,isPathALoop as Kk,embeddableURLValidator as tb,maybeParseEmbedSrc as jV,getEmbedLink as zp,getInitializedImageElements as qV,normalizeSVG as Xk,updateImageCache as JV,getBoundTextElement as nb,getContainerCenter as ob,getContainerElement as $k,isValidTextContainer as Zk,redrawTextBoundingBox as QV,hasBoundingBox as eY,getCommonFrameId as jk,getFrameChildren as rb,getFrameChildrenInsertionIndex as tY,isCursorInFrame as qk,addElementsToFrame as ib,replaceAllElementsInFrame as nY,removeElementsFromFrame as oY,getElementsInResizingFrame as ab,getElementsInNewFrame as rY,getContainingFrame as sb,elementOverlapsWithFrame as iY,updateFrameMembershipOfSelectedElements as Jk,isElementInFrame as Qk,getFrameLikeTitle as aY,filterElementsEligibleAsFrameChildren as sY,hitElementBoundText as lY,hitElementBoundingBoxOnly as cY,hitElementItself as Vl,getVisibleSceneBounds as dY,cropElement as mY,wrapText as pY,isElementLink as uY,isMeasureTextSupported as hY,normalizeText as gY,measureText as eM,getLineHeightInPx as tM,getApproxMinLineWidth as fY,getApproxMinLineHeight as EY,getMinTextElementWidth as bY,ShapeCache as Ga,getRenderOpacity as xY,editGroupForSelectedElement as wY,getElementsInGroup as ri,getSelectedGroupIdForElement as yY,getSelectedGroupIds as vY,isElementInGroup as nM,isSelectedViaGroup as TY,selectGroupsForSelectedElements as Dn,syncInvalidIndices as yM,syncMovedIndices as oM,excludeElementsInFramesFromSelection as IY,getSelectionStateForElements as rM,makeNextSelectedElementIds as ke,getResizeOffsetXY as SY,getResizeArrowDirection as CY,transformElements as PY,getCursorForResizingElement as iM,getElementWithTransformHandleType as aM,getTransformHandleTypeFromCoords as sM,dragNewElement as lM,dragSelectedElements as kY,getDragOffsetXY as MY,Scene as cM,Store as AY,CaptureUpdateAction as jt,hitElementBoundingBox as LY,isLineElement as lb,isSimpleArrow as cb,StoreDelta as dM,positionElementsOnGrid as mM,calculateFixedPointForNonElbowArrowBinding as pM,bindOrUnbindBindingElement as DY,mutateElement as Hp,getElementBounds as uM,doBoundsIntersect as _Y,isPointInElement as hM,maxBindingDistance_simple as gM,convertToExcalidrawElements as RY,getSnapOutlineMidPoint as db,handleFocusPointDrag as NY,handleFocusPointHover as BY,handleFocusPointPointerDown as OY,handleFocusPointPointerUp as FY,maybeHandleArrowPointlikeDrag as Gp,getUncroppedWidthAndHeight as zY,getActiveTextElement as fM,isEligibleFrameChildType as HY,getBindingStrategyForDraggingBindingElementEndpoints as GY,isNonDeletedElement as Up}from"@excalidraw/element";import{KEYS as Ou,MOBILE_ACTION_BUTTON_BG as a3,updateActiveTool as s3}from"@excalidraw/common";import{getNonDeletedElements as Rc}from"@excalidraw/element";import{fixBindingsAfterDeletion as l3}from"@excalidraw/element";import{LinearElementEditor as J1}from"@excalidraw/element/linearElementEditor";import{newElementWith as _c}from"@excalidraw/element";import{getContainerElement as Q1}from"@excalidraw/element";import{isBoundToContainer as Lc,isElbowArrow as c3,isFrameLikeElement as d3}from"@excalidraw/element";import{getFrameChildren as m3}from"@excalidraw/element";import{getElementsInGroup as Fu,selectGroupsForSelectedElements as p3}from"@excalidraw/element";import{CaptureUpdateAction as Dc}from"@excalidraw/element";import{isDevEnv as jM}from"@excalidraw/common";import{atom as Ze,createStore as XM}from"jotai";import{createIsolation as $M}from"jotai-scope";var rx=$M();var{useAtom:Fe,useSetAtom:ix,useAtomValue:ax,useStore:LK}=rx,sx=rx.Provider,gt=XM();var ZM=Rb({"./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 qM=85,Nn={code:"en",label:"English"},pi=[Nn,...[{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=>Nb[e.code]>=qM).sort((e,n)=>e.label>n.label?1:-1)],uc="__test__";jM()&&pi.unshift({code:uc,label:"test language"},{code:`${uc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var mi=Nn,pc={},hc=async e=>{if(mi=e,document.documentElement.dir=mi.rtl?"rtl":"ltr",document.documentElement.lang=mi.code,e.code.startsWith(uc))pc={};else try{pc=await ZM(`./locales/${mi.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),pc=tu}gt.set(cx,e.code)},Bn=()=>mi,lx=(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(mi.code.startsWith(uc))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=lx(pc,o)||lx(tu,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},cx=Ze(Nn.code),Ce=()=>{let e=ax(cx);return{t:f,langCode:e}};import JM from"clsx";import je from"react";import{THEME as QM}from"@excalidraw/common";import{Fragment as Te,jsx as h,jsxs as R}from"react/jsx-runtime";var fn=e=>"var(--icon-fill-color)",dx=e=>e===QM.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:JM({"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"},re={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Pt={width:40,height:20},KK=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),XK=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),Qa=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),mx=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),px=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),lu=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),es=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"})})]}),re),gc=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"})]}),re),ux=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}),hx=M(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"}),gx=M(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"}),fx=M(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"}),$K=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"}),fc=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}),ts=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}),ui=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),hi=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),gi=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),Ec=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),Do=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),re),Ex=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),On=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"})]}),re),En=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),bx=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),Tr=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"})]}),re),bc=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),cu=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),re),du=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),re),xx=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),Ir=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"}),re),_o=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"})]}),re),ns=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"})]}),re),os=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"}),re),rs=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"})}),{...re,strokeWidth:1.5}),wx=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),is=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"}),re),fi=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),yx=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),ZK=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"}),re),vx=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"}),re),Tx=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"})]}),re),Ix=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),xc=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),as=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"})]}),re),Sx=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}),Cx=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}),wc=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"}),re),jK=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}),qK=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"),mu=["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"],Fn=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),mu.map(e=>h("path",{d:e},e))]}),H),Px=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),Mx=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}),JK=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}),QK=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}),Ax=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"),eX=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"),pu=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"}),re),uu=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"}),re),Lx=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}),Dx=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"}),re),tX=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"),nX=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}),oX=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),rX=M(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}),iX=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}),_x=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"})]}),Rx=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"})]}),hu=M(Rx,H),gu=M(Rx,{...H,style:{transform:"rotate(180deg)"}}),fu=M(_x,H),Eu=M(_x,{...H,style:{transform:"rotate(180deg)"}}),bu=M(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"})})})]}),re),xu=M(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"})})})]}),re),wu=M(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"})})})]}),re),yu=M(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"})})})]}),re),Nx=M(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"})})})]}),re),Bx=M(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"})})})]}),re),vu=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"})]}),re),Tu=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"})]}),re),yc=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),aX=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"),sX=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"),zn=M(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"})})})]}),re),lX=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}),cX=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}),dX=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}),Iu=je.memo(({theme:e})=>M(R(Te,{children:[h("path",{d:"M25 26H111V111H25",fill:fn(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:fn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:fn(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:fn(e),strokeWidth:"2"}),R("g",{fill:dx(e),stroke:fn(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})),Su=je.memo(({theme:e})=>M(R(Te,{children:[h("path",{d:"M25 26H111V111H25",fill:fn(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:fn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:fn(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:fn(e),strokeWidth:"2"}),R("g",{fill:dx(e),stroke:fn(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})),Ox=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"})}),re),Fx=M(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"})})]}),re),zx=M(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"})})})]}),re),Hx=M(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"})})})]}),{...re,fill:"currentColor"}),Cu=M(h(Te,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),re),Gx=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),re),Ux=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),re),mX=je.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:fn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Wx=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),Vx=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),Yx=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"}),re),Kx=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"}),re),Xx=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"}),re),Pu=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),ku=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),$x=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"})]}),re),Zx=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),jx=je.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"})]}),Pt)),qx=je.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"})}),Pt)),Jx=je.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"})]}),Pt)),Qx=je.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"})]}),Pt)),e1=je.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"})]}),Pt)),t1=je.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"})]}),Pt)),n1=je.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"})]}),Pt)),o1=je.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"})]}),Pt)),r1=je.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"})}),Pt)),i1=je.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"})}),Pt)),a1=je.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"})}),Pt)),s1=je.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"})}),Pt)),l1=je.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"})}),Pt)),c1=je.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"})]}),Pt)),d1=je.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"})]}),Pt)),m1=M(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"})})})]}),re),p1=M(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"})})})]}),re),u1=M(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"})})})]}),re),h1=M(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"})}),re),Sr=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),g1=M(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),ss=M(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"})})}),re),e3=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),vc=e3,f1=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),E1=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),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:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),H),x1=je.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)),w1=je.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)),y1=je.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)),Tc=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),pX=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}),uX=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"})),v1=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),Mu=M(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),Ic=M(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),T1=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),I1=M(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),hX=M(R(Te,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),gX=M(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),S1=M(R(Te,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),C1=M(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),Au=["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"],P1=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Au.map(e=>h("path",{d:e},e))]}),H),Hn=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),fX=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),EX=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),bX=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"})]}),re),Cr=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),Gn=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),xX=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),wX=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),yX=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),vX=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),Pr=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),k1=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),TX=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),IX=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),Un=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),SX=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),CX=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),M1=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),A1=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),PX=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),L1=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),D1=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),_1=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),R1=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),Lu=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),Sc=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),N1=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),B1=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),O1=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),F1=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),z1=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}),kX=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),MX=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),H1=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),G1=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),Ro=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),No=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),Bo=M(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),Cc=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),U1=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),W1=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),Du=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),Pc=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),_u=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),Ru=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),AX=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),LX=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"})})),V1=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),Y1=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),K1=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),DX=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),_X=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),RX=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),NX=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),kc=h("div",{style:{width:"1rem",height:"1rem"}}),X1=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),$1=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),Z1=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 j1 from"clsx";import Bu,{useEffect as o3,useRef as q1,useState as r3}from"react";import{isPromiseLike as i3}from"@excalidraw/common";import t3 from"react";import{jsx as Nu}from"react/jsx-runtime";var n3=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(t3.useRef(Date.now()).current%1600);return Nu("div",{className:`Spinner ${o}`,children:Nu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Nu("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},ro=n3;import{jsx as ls,jsxs as Mc}from"react/jsx-runtime";var $=Bu.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=Bu.useRef(null);Bu.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=r3(!1),c=q1(!0),d=async m=>{let u="onClick"in o&&o.onClick?.(m);if(i3(u))try{l(!0),await u}catch(E){if(E instanceof oc)console.warn(E);else throw E}finally{c.current&&l(!1)}};o3(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=q1(null);return o.type==="button"||o.type==="icon"?Mc("button",{className:j1("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)&&Mc("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&ls("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&ls(ro,{})]}),o.showAriaLabel&&Mc("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&ls(ro,{})]}),o.children]}):ls("button",{className:j1("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:m=>{p.current=m.pointerType||null},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},onClick:()=>{o.onSelect?.({pointerType:p.current})},ref:i,children:Mc("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&ls("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});$.displayName="IconButton";var Ac=[],F=e=>(Ac=Ac.concat(e),e);import{jsx as h3}from"react/jsx-runtime";var u3=(e,n,t)=>{let o=new Set(ie(e.filter(d=>d3(d)),n).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of o){let p=m3(e,d);for(let m of p)if(!a.has(m.id)){if(Lc(m)){let u=Q1(m,i);u&&(r[u.id]=!0)}else r[m.id]=!0;a.add(m.id)}}let s=!0,l=e.map(d=>{if(n.selectedElementIds[d.id]){let p=Lc(d)?Q1(d,i):null;return d.frameId&&o.has(d.frameId)?(s=!1,r[d.id]=!0,d):p?.frameId&&o.has(p?.frameId)?d:(d.boundElements&&d.boundElements.forEach(m=>{let u=t.scene.getNonDeletedElementsMap().get(m.id);u&&c3(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),_c(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,Lc(d)||(r[d.id]=!0),_c(d,{frameId:null})):Lc(d)&&n.selectedElementIds[d.containerId]?_c(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=Fu(l,n.editingGroupId).filter(p=>!p.isDeleted);if(d.length>1)d[0]&&(r[d[0].id]=!0);else{c=null,d[0]&&(r[d[0].id]=!0);let p=d[0];if(p){let m=p.groupIds.findIndex(E=>E===n.editingGroupId),u=p.groupIds[m+1];if(u){let E=Fu(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...p3({selectedElementIds:r,editingGroupId:c},Rc(l),n,null)}}},e0=(e,n)=>{if(e.editingGroupId){let t=Fu(Rc(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},cs=F({name:"deleteSelectedElements",label:"labels.delete",icon:Ir,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=J1.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(m=>m.id===c.id?_c(m,{isDeleted:!0}):m),p=e0(n,d);return{elements:d,appState:{...p,selectedLinearElement:null},captureUpdate:Dc.IMMEDIATELY}}return J1.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:Dc.IMMEDIATELY}}let{elements:r,appState:i}=u3(e,n,o);return l3(r,r.filter(a=>a.isDeleted)),i=e0(i,r),{elements:r,appState:{...i,activeTool:s3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Me(Rc(e),n)?Dc.IMMEDIATELY:Dc.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===Ou.BACKSPACE||e.key===Ou.DELETE)&&!e[Ou.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=rt()==="mobile";return h3($,{type:"button",icon:Ir,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Me(Rc(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?a3:{}}})}});import{KEYS as Ei,CODES as bi,isDarwin as Nc}from"@excalidraw/common";import{moveOneLeft as g3,moveOneRight as f3,moveAllLeft as E3,moveAllRight as b3}from"@excalidraw/element";import{CaptureUpdateAction as Bc}from"@excalidraw/element";import{isDarwin as t0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,t0?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,t0?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 Oc}from"react/jsx-runtime";var zu=F({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:gu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:g3(e,n,o.scene),appState:n,captureUpdate:Bc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Ei.CTRL_OR_CMD]&&!e.shiftKey&&e.code===bi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>Oc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:gu})}),Hu=F({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:hu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:f3(e,n,o.scene),appState:n,captureUpdate:Bc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Ei.CTRL_OR_CMD]&&!e.shiftKey&&e.code===bi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>Oc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:hu})}),Gu=F({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Eu,trackEvent:{category:"element"},perform:(e,n)=>({elements:E3(e,n),appState:n,captureUpdate:Bc.IMMEDIATELY}),keyTest:e=>Nc?e[Ei.CTRL_OR_CMD]&&e.altKey&&e.code===bi.BRACKET_LEFT:e[Ei.CTRL_OR_CMD]&&e.shiftKey&&e.code===bi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>Oc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Nc?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Eu})}),Uu=F({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:fu,trackEvent:{category:"element"},perform:(e,n)=>({elements:b3(e,n),appState:n,captureUpdate:Bc.IMMEDIATELY}),keyTest:e=>Nc?e[Ei.CTRL_OR_CMD]&&e.altKey&&e.code===bi.BRACKET_RIGHT:e[Ei.CTRL_OR_CMD]&&e.shiftKey&&e.code===bi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>Oc("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Nc?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:fu})});import{getNonDeletedElements as x3}from"@excalidraw/element";import{LinearElementEditor as w3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as y3,isTextElement as v3}from"@excalidraw/element";import{arrayToMap as T3,KEYS as n0}from"@excalidraw/common";import{selectGroupsForSelectedElements as I3}from"@excalidraw/element";import{CaptureUpdateAction as S3}from"@excalidraw/element";var Wu=F({name:"selectAll",label:"labels.selectAll",icon:L1,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(v3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...I3({editingGroupId:null,selectedElementIds:r},x3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&y3(e[0])?new w3(e[0],T3(e)):null},captureUpdate:S3.IMMEDIATELY}},keyTest:e=>e[n0.CTRL_OR_CMD]&&e.key===n0.A});import{DEFAULT_GRID_SIZE as o0,KEYS as r0,MOBILE_ACTION_BUTTON_BG as C3,arrayToMap as i0}from"@excalidraw/common";import{getNonDeletedElements as a0}from"@excalidraw/element";import{LinearElementEditor as P3}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as k3,getSelectionStateForElements as M3}from"@excalidraw/element";import{syncMovedIndices as A3}from"@excalidraw/element";import{duplicateElements as L3}from"@excalidraw/element";import{CaptureUpdateAction as s0}from"@excalidraw/element";import{jsx as D3}from"react/jsx-runtime";var Vu=F({name:"duplicateSelection",label:"labels.duplicateSelection",icon:ns,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=P3.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:s0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=L3({type:"in-place",elements:e,idsOfElementsToDuplicate:i0(k3(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+o0/2,y:a.y+o0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:A3(i,i0(r)),appState:{...n,...M3(r,a0(i),n)},captureUpdate:s0.IMMEDIATELY}},keyTest:e=>e[r0.CTRL_OR_CMD]&&e.key===r0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=rt()==="mobile";return D3($,{type:"button",icon:ns,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Me(a0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?C3:{}}})}});import{pointFrom as m4}from"@excalidraw/math";import{useEffect as mh,useMemo as hh,useRef as ph,useState as p4}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as u4,COLOR_PALETTE as h4,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as hw,DEFAULT_ELEMENT_BACKGROUND_PICKS as g4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as f4,DEFAULT_ELEMENT_STROKE_PICKS as E4,ARROW_TYPE as tn,DEFAULT_FONT_FAMILY as b4,DEFAULT_FONT_SIZE as x4,FONT_FAMILY as w4,ROUNDNESS as rd,STROKE_WIDTH_KEYS as y4,VERTICAL_ALIGN as nd,KEYS as ki,randomInteger as v4,arrayToMap as gh,getFontFamilyString as T4,getLineHeight as I4,isTransparent as S4,getStrokeWidthByKey as gw,reduceToCommonValue as C4,invariant as ad,FONT_SIZES as od}from"@excalidraw/common";import{canBecomePolygon as P4,getNonDeletedElements as fw,isNonDeletedElement as k4}from"@excalidraw/element";import{bindBindingElement as cw,calculateFixedPointForElbowArrowBinding as dw,updateBoundElements as M4}from"@excalidraw/element";import{LinearElementEditor as Mr}from"@excalidraw/element/linearElementEditor";import{newElementWith as et}from"@excalidraw/element";import{getArrowheadForPicker as mw}from"@excalidraw/element";import{getBoundTextElement as Yo,redrawTextBoundingBox as vs}from"@excalidraw/element";import{isArrowElement as id,isBoundToContainer as A4,isElbowArrow as Ew,isLinearElement as uh,isLineElement as pw,isTextElement as Bt,isUsingAdaptiveRadius as L4}from"@excalidraw/element";import{hasStrokeColor as D4}from"@excalidraw/element";import{updateElbowArrowPoints as _4,CaptureUpdateAction as qe,toggleLinePolygonState as R4}from"@excalidraw/element";import{deriveStylesPanelMode as N4}from"@excalidraw/common";import{isDevEnv as _3}from"@excalidraw/common";var R3=new Set(["command_palette","export"]),Re=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!R3.has(e)||_3())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 F3 from"clsx";import N3 from"clsx";import{forwardRef as B3}from"react";import{jsx as O3}from"react/jsx-runtime";var l0=B3((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return O3("button",{type:"button",ref:n,title:t,"data-testid":r,className:N3(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as H3,jsx as Yu,jsxs as z3}from"react/jsx-runtime";var Wt=e=>Yu(H3,{children:e.options.map(n=>e.type==="button"?Yu(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):z3("label",{className:F3({active:e.value===n.value}),title:n.text,children:[Yu("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 G0}from"radix-ui";import U0 from"clsx";import{memo as s5,useRef as W0,useEffect as l5}from"react";import{applyDarkModeFilter as c5,COLOR_OUTLINE_CONTRAST_THRESHOLD as z0,COLOR_PALETTE as V0,DEFAULT_ELEMENT_BACKGROUND_PICKS as d5,DEFAULT_ELEMENT_STROKE_PICKS as m5,isColorDark as H0,isWritableElement as p5,THEME as u5}from"@excalidraw/common";import{jsx as G3}from"react/jsx-runtime";var Fc=()=>G3("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as X3,useLayoutEffect as $3,useRef as Z3}from"react";import{createPortal as j3}from"react-dom";import{EVENT as Oo,isColorDark as q3,KEYS as J3,MIME_TYPES as Q3,THEME as eA,removeDarkModeFilter as tA,rgbToHex as nA}from"@excalidraw/common";import c0 from"react";var Ku=c0.createContext(null),he=()=>c0.useContext(Ku);import{useState as U3,useLayoutEffect as d0}from"react";import{THEME as W3}from"@excalidraw/common";var zc=e=>{let[n,t]=U3(null),o=ue(),{theme:r}=he(),{container:i}=Ae();return d0(()=>{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===W3.DARK))},[n,r,o.formFactor,e?.className]),d0(()=>{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 V3}from"react";import{EVENT as Hc}from"@excalidraw/common";function xi(e,n,t){V3(()=>{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(Hc.POINTER_DOWN,o),document.addEventListener(Hc.TOUCH_START,o),()=>{document.removeEventListener(Hc.POINTER_DOWN,o),document.removeEventListener(Hc.TOUCH_START,o)}},[e,n,t])}import{useRef as Y3}from"react";var wi=e=>{let n=Y3(e);return Object.assign(n.current,e),n.current};import{clamp as K3}from"@excalidraw/math";var m0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return K3(r,0,Math.max(0,t-n))},Gc=({cursor:e,element:n,container:t,gap:o})=>({left:m0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:m0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as rA}from"react/jsx-runtime";var p0=Au.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),oA=`url(data:${Q3.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">${p0}</g><g stroke="#1b1b1f" stroke-width="1.25">${p0}</g></svg>`)}) 2 21, auto`,Nt=Ze(null),u0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=zc({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=he(),a=yi(),s=Tt(),l=ie(a,i),c=wi({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=Ae();$3(()=>{if(r)return r.style.cursor=oA,()=>{r.style.cursor=""}},[r]),X3(()=>{let m=p.current;if(!m||!s.canvas||!r)return;let u=!1,E=s.canvas.getContext("2d"),g=({clientX:P,clientY:A})=>{let L=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(A-i.offsetTop)*window.devicePixelRatio,1,1).data;return nA(L[0],L[1],L[2])},b=P=>i.theme===eA.DARK?tA(P):P,y=({clientX:P,clientY:A,altKey:L})=>{let{top:_,left:k}=Gc({cursor:{x:P,y:A},element:{width:m.offsetWidth,height:m.offsetHeight},container:r.getBoundingClientRect(),gap:7});m.style.top=`${_}px`,m.style.left=`${k}px`;let D=g({clientX:P,clientY:A});u&&c.onChange(o,b(D),c.selectedElements,{altKey:L}),m.style.background=D,m.style.setProperty("--eye-dropper-preview-border-color",q3(D)?"#fff":"#222")},w=()=>{c.onCancel()},x=(P,A)=>{c.onSelect(P,A)},v=P=>{u=!0,P.stopImmediatePropagation()},I=P=>{u=!1,d?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===J3.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(Oo.KEYDOWN,C),r.addEventListener(Oo.POINTER_DOWN,v),r.addEventListener(Oo.POINTER_UP,I),window.addEventListener("pointermove",y,{passive:!0}),window.addEventListener(Oo.BLUR,w),()=>{u=!1,r.removeEventListener(Oo.KEYDOWN,C),r.removeEventListener(Oo.POINTER_DOWN,v),r.removeEventListener(Oo.POINTER_UP,I),window.removeEventListener("pointermove",y),window.removeEventListener(Oo.BLUR,w)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let p=Z3(null);return xi(p,()=>{e()},m=>!!m.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?j3(rA("div",{ref:p,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as Xu}from"radix-ui";import lA from"clsx";import cA from"react";import{isInteractive as dA}from"@excalidraw/common";import iA from"react";import aA from"clsx";import{jsx as sA}from"react/jsx-runtime";var Ue=iA.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>sA("div",{className:aA("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as $u,jsxs as mA}from"react/jsx-runtime";var io=cA.forwardRef(({className:e,container:n,children:t,style:o,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l,preventAutoFocusOnTouch:c=!1},d)=>{let p=ue(),m=p.formFactor==="phone"&&!p.isLandscape;return $u(Xu.Portal,{container:n,children:mA(Xu.Content,{ref:d,className:lA("focus-visible-none",e),"data-prevent-outside-click":!0,side:m?"bottom":"right",align:m?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:n??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:p.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onOpenAutoFocus:u=>{c&&p.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),n&&!dA(document.activeElement)&&n.focus(),r()},children:[$u(Ue,{padding:3,style:o,children:t}),$u(Xu.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 pA,useCallback as Zu}from"react";var Uc=()=>document.querySelector(".excalidraw-wysiwyg"),Wc=()=>{let e=Uc();return e?{start:e.selectionStart,end:e.selectionEnd}:null},ds=e=>{setTimeout(()=>{let n=Uc();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},ms=(e,n,t,o)=>{n&&o&&o();let r=n&&t?Wc():null;e(),n&&t&&ds(r)},h0=()=>{let[e,n]=pA(null),t=Zu(()=>{let i=Wc();n(i)},[]),o=Zu(()=>{setTimeout(()=>{let i=Uc();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=Zu(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},g0=(e=100)=>{let n=Uc();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import E0 from"clsx";import{useCallback as gA,useEffect as qu,useRef as b0,useState as x0}from"react";import{KEYS as Ju,normalizeInputColor as fA}from"@excalidraw/common";import{isTransparent as uA,MAX_CUSTOM_COLORS_USED_IN_CANVAS as hA}from"@excalidraw/common";var Fo=({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},ps=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),ju=({color:e,palette:n})=>!Object.values(n).flat().includes(e),f0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!uA(s)&&ju({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,hA)},Jt=Ze(null);import{Fragment as EA,jsx as us,jsxs as Qu}from"react/jsx-runtime";var w0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=ue(),[a,s]=x0(e),[l,c]=x0(null),[d,p]=Fe(Jt);qu(()=>{s(e)},[e]);let m=gA(y=>{let w=y.toLowerCase().trim(),x=fA(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=b0(null),E=b0(null);qu(()=>{u.current&&u.current.focus()},[d]);let[g,b]=Fe(Nt);return qu(()=>()=>{b(null)},[b]),Qu("div",{className:"color-picker__input-label-container",children:[Qu("div",{className:E0("color-picker__input-label",{"has-error":l}),children:[us("div",{className:"color-picker__input-hash",children:"#"}),us("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=>{m(y.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e),c(null)},tabIndex:-1,onFocus:()=>p("hex"),onKeyDown:y=>{y.key!==Ju.TAB&&(y.key===Ju.ESCAPE&&E.current?.focus(),y.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&Qu(EA,{children:[us("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),us("div",{ref:E,className:E0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(y=>y?null:{keepOpenOnAlt:!1,onSelect:w=>n(w),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${Ju.I.toLocaleUpperCase()} or ${N("Alt")} `,children:P1})]})]}),l&&us("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import nh,{useEffect as oh,useImperativeHandle as ZA,useState as jA}from"react";import{EVENT as R0}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as qA,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as JA,KEYS as QA}from"@excalidraw/common";import CA from"clsx";import{useEffect as PA,useRef as kA}from"react";import{applyDarkModeFilter as MA,THEME as AA}from"@excalidraw/common";import{isColorDark as bA}from"@excalidraw/common";import{jsxs as wA}from"react/jsx-runtime";var xA=({color:e,keyLabel:n,isShade:t=!1})=>wA("div",{className:"color-picker__button__hotkey-label",style:{color:bA(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),vi=xA;import{createContext as yA,useContext as vA,useEffect as TA,useMemo as y0,useRef as v0,useState as IA}from"react";import{colorToHex as T0,isTransparent as SA}from"@excalidraw/common";var kr="excalidraw-color-dnd-ghost",I0="excalidraw-color-dnd-active",S0=10,C0=100,P0=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=T0(e);return t!==null&&t===T0(n)},eh=yA(null),Qt=()=>vA(eh),k0=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=IA(null),i=v0(null),a=v0({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 D=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((j,X)=>Number(j.dataset.topPickIndex)-Number(X.dataset.topPickIndex));if(!D.length)return!1;l.slotRects=D.map(j=>j.getBoundingClientRect());let[O,G]=l.slotRects;l.slotSpan=G?G.left-O.left:O.width+4;let z=k.getBoundingClientRect(),W=Math.max(Math.abs(l.slotSpan)/2,10);return l.hitRect={left:z.left-W,right:z.right+W,top:z.top-14,bottom:z.bottom+14},!0},p=(k,D)=>{l?.ghost&&(l.ghost.style.transform=`translate(${k-l.ghostW/2}px, ${D-l.ghostH/2}px)`)},m=(k,D,O,G)=>{l?.ghost&&(l.ghostW!==k||l.ghostH!==D)&&(l.ghostW=k,l.ghostH=D,l.ghost.style.width=`${k}px`,l.ghost.style.height=`${D}px`,p(O,G))},u=(k,D)=>{if(!l)return;let{sourceRect:O,sourceEl:G,color:z}=l,W=document.createElement("div");W.className=kr;let j=document.createElement("div");if(j.className=`${kr}__swatch`,SA(z))j.classList.add("is-transparent");else{let X=getComputedStyle(G).backgroundColor;j.style.backgroundColor=X&&X!=="rgba(0, 0, 0, 0)"?X:z}W.appendChild(j),document.body.appendChild(W),l.ghost=W,l.ghostW=O.width,l.ghostH=O.height,W.style.width=`${O.width}px`,W.style.height=`${O.height}px`,p(k,D),requestAnimationFrame(()=>{l?.ghost===W&&W.classList.add(`${kr}--lifted`)}),document.body.classList.add(I0),l.activated=!0,c()},E=(k,D)=>{if(!l?.hitRect)return;let{hitRect:O,slotRects:G}=l,z=null,W=null;if(k>=O.left&&k<=O.right&&D>=O.top&&D<=O.bottom){let j=0,X=1/0;if(G.forEach((oe,B)=>{let U=Math.abs(k-(oe.left+oe.width/2));U<X&&(X=U,j=B)}),l.origin.kind==="swatch"){let oe=a.current.picks.findIndex(B=>P0(B,l.color));oe!==-1?W=oe:z=j}else z=j}if(z!==l.overIndex||W!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=W;let{ghost:j}=l;j&&(j.classList.toggle(`${kr}--over`,z!==null),j.classList.toggle(`${kr}--blocked`,W!==null)),c()}if(z!==null){let j=l.slotRects[z];m(j.width,j.height,k,D)}else m(l.sourceRect.width,l.sourceRect.height,k,D)},g=k=>{if(!l?.ghost)return;let{ghost:D}=l;l.ghost=null,D.classList.add(`${kr}--dropping`);let O=k.rect;O&&(D.style.width=`${O.width}px`,D.style.height=`${O.height}px`,D.style.transform=`translate(${O.left}px, ${O.top}px)`),window.setTimeout(()=>{D.classList.add(`${kr}--fade`)},160),window.setTimeout(()=>{D.remove()},340)},b=()=>{let k=i.current;if(!k||!l?.activated)return;let D=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let O of D)O.style.transition="none",O.style.transform="none";k.offsetWidth;for(let O of D)O.style.transition=""},y=()=>{let k=D=>{D.preventDefault(),D.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",L,!0)},x=()=>{w(),document.body.classList.remove(I0),l?.activationTimer!=null&&window.clearTimeout(l.activationTimer),l=null,r(null)},v=k=>{l&&(b(),l.ghost&&(k?g({rect:l.sourceRect}):(l.ghost.remove(),l.ghost=null)),x())},I=(k,D)=>{if(!(!l||l.activated)){if(!d()){x();return}u(k,D),E(k,D)}},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)<S0){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let D=performance.now()-l.startTime;if(D<C0){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=S0&&I(l.lastX,l.lastY))},C0-D));return}if(I(k.clientX,k.clientY),!l?.activated)return}k.preventDefault(),p(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:D,origin:O,color:G,slotRects:z}=l,{picks:W,onPicksChange:j}=a.current;if(b(),D!==null){if(O.kind==="swatch"){if(!W.some(X=>P0(X,G))){let X=[...W];X[D]=G,j(X)}}else if(O.index!==D){let X=[...W],[oe]=X.splice(O.index,1);X.splice(D,0,oe),j(X)}g({rect:z[D]})}else g({rect:l.sourceRect});x()},A=k=>{l&&k.pointerId===l.pointerId&&v(!0)},L=k=>{l?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),v(!0))};return{begin:(k,D,O)=>{!a.current.enabled||l||k.button!==0||!D||(l={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:D,origin:O,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",L,!0))},destroy:()=>v(!1)}},[]);return TA(()=>()=>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 th,jsxs as LA}from"react/jsx-runtime";var M0=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=Fe(Jt),s=Qt(),l=kA(null);return PA(()=>{l.current&&l.current.focus()},[t,i]),th("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let p=MA(c,e===AA.DARK);return LA("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:CA("color-picker__button color-picker__button--large has-outline",{active:t===c,"is-transparent":c==="transparent"||!c}),onClick:()=>{o(c),a("custom")},onPointerDown:s?m=>s.startSwatchDrag(m,c):void 0,title:c,"aria-label":r,style:{"--swatch-color":p},children:[th("div",{className:"color-picker__button-outline"}),th(vi,{color:p,keyLabel:d+1})]},d)})})};import DA from"clsx";import{useEffect as _A,useRef as RA}from"react";import{applyDarkModeFilter as NA,isColorDark as BA,THEME as OA}from"@excalidraw/common";import{jsx as Vc,jsxs as zA}from"react/jsx-runtime";var FA=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=Fo({color:t,palette:n}),[l,c]=Fe(Jt),d=Qt(),p=RA(null);return _A(()=>{p.current&&l==="baseColors"&&p.current.focus()},[s?.colorName,l]),Vc("div",{className:"color-picker-content--default",children:Object.entries(n).map(([m,u],E)=>{let g=(Array.isArray(u)?u[r]:u)||"transparent";if(a?.includes(g))return Vc("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},m);let b=ps[E],y=NA(g,e===OA.DARK),w=f(`colors.${m.replace(/\d+/,"")}`,null,"");return zA("button",{ref:s?.colorName===m?p:void 0,tabIndex:-1,type:"button",className:DA("color-picker__button color-picker__button--large",{"has-outline":!BA(g,255),active:s?.colorName===m,"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-${m}`,children:[Vc("div",{className:"color-picker__button-outline"}),i&&Vc(vi,{color:y,keyLabel:b})]},m)})})},A0=FA;import{jsx as GA}from"react/jsx-runtime";var HA=({children:e})=>GA("div",{className:"color-picker__heading",children:e}),Ti=HA;import UA from"clsx";import{useEffect as WA,useRef as VA}from"react";import{applyDarkModeFilter as YA,THEME as KA}from"@excalidraw/common";import{jsx as hs,jsxs as L0}from"react/jsx-runtime";var D0=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=Fo({color:n||"transparent",palette:o}),[a,s]=Fe(Jt),l=Qt(),c=VA(null);if(WA(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:p}=i,m=o[d];if(Array.isArray(m))return hs("div",{className:"color-picker-content--default shades",children:m.map((u,E)=>{let g=YA(u,e===KA.DARK);return L0("button",{ref:E===p&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:UA("color-picker__button color-picker__button--large",{active:E===p}),"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:[hs("div",{className:"color-picker__button-outline"}),r&&hs(vi,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return L0("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[hs("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),hs("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 Ii,COLOR_PALETTE as XA,KEYS as gs}from"@excalidraw/common";var Yc=(e,n,t)=>{let o=Math.ceil(t/Ii);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+Ii;return r>=t?n%Ii:r}case"ArrowUp":{let r=n-Ii,i=r<0?Ii*o+r:r;return i>=t?void 0:i}}},$A=({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(ps.includes(e.key)){let l=ps.indexOf(e.key),c=Object.keys(o)[l],d=o[c],p=Array.isArray(d)?d[a]:d;return p==null||s?.includes(p)||(t(p),i("baseColors")),!0}return!1},_0=({event:e,activeColorPickerSection:n,palette:t,color:o,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d,excludedColors:p})=>{if(e[gs.CTRL_OR_CMD])return!1;if(e.key===gs.ESCAPE)return d(e),!0;if(e.key===gs.ALT)return c(!0),!0;if(e.key===gs.I)return c(),!0;let m=Fo({color:o,palette:t});if(e.key===gs.TAB){let u={custom:!!i.length,baseColors:!0,shades:m?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[v,I])=>(I&&x.push(v),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(([v,I])=>Array.isArray(I)?I.includes(o):I===o?v:null)||r(XA.black)),e.preventDefault(),e.stopPropagation(),!0}if($A({e,colorObj:m,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:l,excludedColors:p}))return!0;if(n==="shades"&&m){let{shade:u}=m,E=Yc(e.key,u,Ii);if(E!==void 0)return r(t[m.colorName][E]),!0}if(n==="baseColors"&&m){let{colorName:u}=m,E=Object.keys(t),g=E.indexOf(u),b=Yc(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(!p?.includes(x))break;b=Yc(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=Yc(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as ao,jsxs as Kc}from"react/jsx-runtime";var N0=nh.forwardRef(({theme:e,color:n,onChange:t,type:o,elements:r,palette:i,updateData:a,children:s,showTitle:l,onEyeDropperToggle:c,onEscape:d,showHotKey:p=!0,excludedColors:m},u)=>{let E=l?o==="elementStroke"?f("labels.stroke"):o==="elementBackground"?f("labels.background"):null:null,[g]=nh.useState(()=>o==="canvasBackground"?[]:f0(r,o,i)),[b,y]=Fe(Jt),w=Qt(),x=Fo({color:n,palette:i});oh(()=>{if(!b){let P=!!n&&ju({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[v,I]=jA(x?.shade??(o==="elementBackground"?qA:JA));oh(()=>{x?.shade!=null&&I(x.shade);let P=A=>{A.key===QA.ALT&&c(!1)};return document.addEventListener(R0.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(R0.KEYUP,P,{capture:!0})}},[x,c]);let C=nh.useRef(null);return ZA(u,()=>C.current),oh(()=>{C?.current?.focus()},[]),ao("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:Kc("div",{ref:C,onKeyDown:P=>{_0({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:c,customColors:g,setActiveColorPickerSection:y,updateData:a,activeShade:v,onEscape:d,excludedColors:m})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&ao("div",{className:"color-picker__title",children:E}),!!g.length&&Kc("div",{children:[ao(Ti,{children:f("colorPicker.mostUsedCustomColors")}),ao(M0,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),Kc("div",{children:[ao(Ti,{children:f("colorPicker.colors")}),ao(A0,{theme:e,color:n,palette:i,onChange:t,activeShade:v,showHotKey:p,excludedColors:m})]}),Kc("div",{children:[ao(Ti,{children:f("colorPicker.shades")}),ao(D0,{theme:e,color:n,onChange:t,palette:i,showHotKey:p})]}),s,w&&ao("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import B0 from"clsx";import{ContextMenu as fs}from"radix-ui";import{applyDarkModeFilter as e5,COLOR_OUTLINE_CONTRAST_THRESHOLD as t5,DEFAULT_CANVAS_BACKGROUND_PICKS as n5,DEFAULT_ELEMENT_BACKGROUND_PICKS as o5,DEFAULT_ELEMENT_STROKE_PICKS as r5,isColorDark as i5,THEME as a5}from"@excalidraw/common";import{jsx as zo,jsxs as O0}from"react/jsx-runtime";var F0=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=Qt(),l=s?.dragState??null,{container:c}=Ae(),d;if(t==="elementStroke"&&(d=r5),t==="elementBackground"&&(d=o5),t==="canvasBackground"&&(d=n5),r&&(d=r),!d)return console.error("Invalid type for TopPicks"),null;let p=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},m=O0("div",{className:B0("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&zo("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:zo("rect",{})}),d.map((u,E)=>{let g=p(E),b=e5(u,e===a5.DARK);return zo("button",{className:B0("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!i5(u,t5),"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:zo("div",{className:"color-picker__button-outline"})},u)})]});return i?O0(fs.Root,{children:[zo(fs.Trigger,{asChild:!0,children:m}),zo(fs.Portal,{container:c,children:zo(fs.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:zo(fs.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):m};import{jsx as en,jsxs as Xc}from"react/jsx-runtime";var h5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=V0,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=Ae(),p=rt(),m=p!=="full",u=p==="mobile",[,E]=Fe(Jt),[g,b]=Fe(Nt),y=Xc("div",{children:[en(Ti,{children:f("colorPicker.hexCode")}),en(w0,{color:n||"",label:o,onChange:v=>{t(v)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),w=W0(null),x=()=>{w.current?.focus()};return en(io,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:v=>{if(v.target instanceof HTMLElement&&v.target.closest(".color-picker__context-menu")){v.preventDefault();return}p5(v.target)||(v.target instanceof HTMLElement&&v.target.matches(":active")?window.addEventListener("pointerup",x,{once:!0}):x()),v.preventDefault()},onPointerDownOutside:v=>{g&&v.preventDefault()},onClose:()=>{s()===e&&a({openPopup:null}),E(null),l.editingTextElement&&setTimeout(()=>{let v=document.querySelector(".excalidraw-wysiwyg");v&&v.focus()},0)},children:i?en(N0,{ref:w,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:v=>{let I=l.editingTextElement?Wc():null;t(v),l.editingTextElement&&I&&ds(I)},onEyeDropperToggle:v=>{b(I=>v?(I=I||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},I.keepOpenOnAlt=!0,I):v===!1||I?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:v=>{g?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:m,showHotKey:!u,children:y}):y})},g5=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",f5=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let s=rt(),l=s!=="full",c=s==="mobile",d=Qt(),p=n?c5(n,o===u5.DARK):null,m=u=>{u.preventDefault(),u.stopPropagation(),a&&g0(),i()};return Xc(G0.Trigger,{type:"button",className:U0("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!H0(n,z0),"compact-sizing":l,"mobile-border":c}),"aria-label":e,style:p?{"--swatch-color":p}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),"data-openpopup":t,onClick:m,onPointerDown:d?u=>d.startSwatchDrag(u,n):void 0,children:[en("div",{className:"color-picker__button-outline",children:!n&&Px}),l&&n&&r==="stroke"&&en("div",{className:"color-picker__button-background",children:en("span",{style:{color:p&&H0(p,z0)?"#fff":"#111"},children:Y1})})]})},E5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=V0,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let p=W0(l.openPopup);l5(()=>{p.current=l.openPopup},[l.openPopup]);let u=rt()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?m5:d5),y=k0({enabled:E,picks:b,onPicksChange:w=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:w}})}});return en(eh.Provider,{value:E?y:null,children:Xc("div",{role:"dialog","aria-modal":"true",className:U0("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&en(F0,{theme:l.theme,activeColor:n,onChange:w=>{t(w),g5(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&&en(Fc,{}),Xc(G0.Root,{open:l.openPopup===e,onOpenChange:w=>{w&&s({openPopup:e})},children:[en(f5,{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&&en(h5,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>p.current,appState:l})]})]})})},b5=(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,Si=s5(E5,b5);import{Popover as K5}from"radix-ui";import X5 from"clsx";import $5,{useCallback as Z5,useMemo as j5}from"react";import{FONT_FAMILY as sh}from"@excalidraw/common";import B5,{useMemo as Wo,useState as O5,useRef as $0,useEffect as Z0,useCallback as j0}from"react";import{arrayToList as F5,debounce as z5,FONT_FAMILY as Vo,getFontFamilyString as H5}from"@excalidraw/common";import x5 from"clsx";import w5 from"react";import{jsx as y5,jsxs as v5}from"react/jsx-runtime";var $c=w5.forwardRef(({className:e,placeholder:n,onChange:t},o)=>v5("div",{className:x5("QuickSearch__wrapper",e),children:[Un,y5("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import T5 from"clsx";import{Children as I5}from"react";import{jsx as Y0}from"react/jsx-runtime";var Zc=({className:e,placeholder:n,children:t})=>{let o=!I5.count(t);return Y0("div",{className:T5("ScrollableList__wrapper",e),role:"menu",children:o?Y0("div",{className:"empty",children:n}):t})};import{jsx as S5,jsxs as C5}from"react/jsx-runtime";var K0=({children:e,className:n="",style:t,title:o})=>C5("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&S5("p",{className:"dropdown-menu-group-title",children:o}),e]}),Es=K0;K0.displayName="DropdownMenuGroup";import{THEME as R5}from"@excalidraw/common";import{DropdownMenu as N5}from"radix-ui";import P5,{useContext as k5}from"react";import{composeEventHandlers as M5}from"@excalidraw/common";var rh=P5.createContext({}),Ho=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),jc=e=>{let n=k5(rh);return M5(e,t=>{n.onSelect?.(t)})};import{jsx as A5}from"react/jsx-runtime";var bs=({children:e,...n})=>A5("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as D5,jsx as xs,jsxs as _5}from"react/jsx-runtime";var L5=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=ue();return _5(D5,{children:[n&&xs("div",{className:"dropdown-menu-item__icon",children:n}),xs("div",{style:e,className:"dropdown-menu-item__text",children:xs(bs,{children:o})}),r&&xs("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&xs("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Go=L5;import{jsx as qc}from"react/jsx-runtime";var ih=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=jc(s);return qc(N5.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:qc("button",{...l,value:t,className:Ho(i,a),title:l.title??l["aria-label"],children:qc(Go,{icon:e,shortcut:r,badge:n,children:o})})})};ih.displayName="DropdownMenuItem";var Ci={GREEN:"green",RED:"red",BLUE:"blue"},Jc=({type:e=Ci.BLUE,children:n})=>{let{theme:t}=Uo(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===R5.LIGHT?"1.5px solid white":"none"};switch(e){case Ci.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Ci.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Ci.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return qc("div",{className:"DropDownMenuItemBadge",style:o,children:n})};Jc.displayName="DropdownMenuItemBadge";ih.Badge=Jc;var Vt=ih;import{KEYS as Pi}from"@excalidraw/common";var X0=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[Pi.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Pi.F)return n.current?.focus(),!0;if(e.key===Pi.ESCAPE)return r(),!0;if(e.key===Pi.ENTER)return t?.value&&i(t.value),!0;if(e.key===Pi.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===Pi.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as so,jsxs as W5}from"react/jsx-runtime";var G5=e=>{switch(e){case Vo.Excalifont:case Vo.Virgil:return On;case Vo.Nunito:case Vo.Helvetica:return ss;case Vo["Lilita One"]:return g1;case Vo["Comic Shanns"]:case Vo.Cascadia:return vc;default:return ss}},U5=(e,n)=>Object.entries(Vo).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",q0=B5.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=Ae(),l=Tt(),{fonts:c}=l,{showDeprecatedFonts:d}=bn(),p=rt(),[m,u]=O5(""),E=$0(null),g=Wo(()=>Array.from(oo.registered.entries()).filter(([k,{metadata:D}])=>!D.private&&!D.fallback).map(([k,{metadata:D,fontFaces:O}])=>{let G={value:k,icon:G5(k),text:U5(k,O)};return D.deprecated&&Object.assign(G,{deprecated:D.deprecated,badge:{type:Ci.RED,placeholder:f("fontList.badge.old")}}),G}).sort((k,D)=>k.text.toLowerCase()>D.text.toLowerCase()?1:-1),[]),b=Wo(()=>new Set(c.getSceneFamilies()),[e]),y=Wo(()=>g.filter(k=>b.has(k.value)),[g,b]),w=Wo(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=Wo(()=>F5([...y,...w].filter(k=>k.text?.toLowerCase().includes(m))),[y,w,m]),v=Wo(()=>{let k;return n?k=x.find(D=>D.value===n):e&&(k=x.find(D=>D.value===e)),!k&&m&&(x[0]?.value?o(x[0].value):r()),k},[n,e,m,x,o,r]),I=j0(k=>{let D=null;if(l.state.editingTextElement){let O=document.querySelector(".excalidraw-wysiwyg");O&&(D={start:O.selectionStart,end:O.selectionEnd})}t(k),l.state.editingTextElement&&D&&setTimeout(()=>{let O=document.querySelector(".excalidraw-wysiwyg");O&&D&&(O.focus(),O.selectionStart=D.start,O.selectionEnd=D.end)},0)},[t,l.state.editingTextElement]),C=j0(k=>{X0({event:k,inputRef:E,hoveredFont:v,filteredFonts:x,onSelect:I,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[v,x,I,o,a]);Z0(()=>(i(),()=>{a()}),[]);let P=Wo(()=>x.filter(k=>b.has(k.value)),[x,b]),A=Wo(()=>x.filter(k=>!b.has(k.value)),[x,b]),L=({font:k,order:D})=>{let O=$0(null),G=k.value===v?.value,z=k.value===e;return Z0(()=>{G&&(D===0?O.current?.scrollIntoView?.({block:"end"}):O.current?.scrollIntoView?.({block:"nearest"}))},[G,D]),so("button",{ref:O,type:"button",value:k.value,className:Ho("",z,G),title:k.text,tabIndex:z?0:-1,onClick:W=>{I(Number(W.currentTarget.value))},onMouseMove:()=>{v?.value!==k.value&&o(k.value)},children:so(Go,{icon:k.icon,badge:k.badge&&so(Jc,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:H5({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(so(Es,{title:f("fontList.sceneFonts"),children:P.map((k,D)=>so(L,{font:k,order:D},k.value))},"group_1")),A.length&&_.push(so(Es,{title:f("fontList.availableFonts"),children:A.map((k,D)=>so(L,{font:k,order:D+P.length},k.value))},"group_2")),W5(io,{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:[p==="full"&&so($c,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:z5(u,20)}),so(Zc,{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 V5}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as Y5}from"@excalidraw/common";import{jsx as ah}from"react/jsx-runtime";var J0=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Ne(),r=t?{...Y5,width:"2rem",height:"2rem"}:{};return ah(V5.Trigger,{asChild:!0,children:ah("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:ah($,{type:"toggle",icon:En,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 Q0}from"react/jsx-runtime";var ew=[{value:sh.Excalifont,icon:On,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:sh.Nunito,icon:ss,text:f("labels.normal"),testId:"font-family-normal"},{value:sh["Comic Shanns"],icon:vc,text:f("labels.code"),testId:"font-family-code"}],lee=new Set(ew.map(e=>e.value));var tw=$5.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=j5(()=>ew,[]),c=Z5(d=>{d&&o(d)},[o]);return Q0("div",{role:"dialog","aria-modal":"true",className:X5("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&ws("div",{className:"buttonList",children:ws(Wt,{type:"button",options:l,value:n,onClick:c})}),!s&&ws(Fc,{}),Q0(K5.Root,{open:e,onOpenChange:a,children:[ws(J0,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&ws(q0,{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 lh}from"radix-ui";import e4 from"clsx";import iw,{useEffect as t4,useMemo as n4}from"react";import{isArrowKey as o4,KEYS as lo}from"@excalidraw/common";import{jsx as q5}from"react/jsx-runtime";var Qc=({className:e,icon:n,size:t="1em"})=>q5("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 Q5,jsx as nw,jsxs as ow}from"react/jsx-runtime";var J5=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>ow(Q5,{children:[ow("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&nw(Qc,{icon:n?U1:Cc})]}),n&&nw("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),ys=J5;import{jsx as Wn,jsxs as td}from"react/jsx-runtime";var r4=Ze(!1),ed=4,i4="default",a4=e=>e.flatMap(n=>n.options),rw=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},s4=(e,n)=>e.some(t=>t.options.some(n)),l4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/ed)},(t,o)=>n.options.slice(o*ed,o*ed+ed)));function c4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=Ae(),[s,l]=Fe(r4),c=[...e,...n],d=a4(c),p=l4([...e,...s?n:[]]),m=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===lo.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(o4(g.key)){let y=Bn().rtl,w=d.findIndex(x=>x.value===t);if(w!==-1){let x=d.length,v=w;switch(g.key){case(y?lo.ARROW_LEFT:lo.ARROW_RIGHT):v=(w+1)%x;break;case(y?lo.ARROW_RIGHT:lo.ARROW_LEFT):v=(x+w-1)%x;break;case lo.ARROW_DOWN:{let I=p.findIndex(P=>P.some(A=>A.value===t)),C=p[I];if(I!==-1&&C){let P=C.findIndex(_=>_.value===t),A=p[(I+1)%p.length],L=A[Math.min(P,A.length-1)]??d[w];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case lo.ARROW_UP:{let I=p.findIndex(P=>P.some(A=>A.value===t)),C=p[I];if(I!==-1&&C){let P=C.findIndex(_=>_.value===t),A=p[(p.length+I-1)%p.length],L=A[Math.min(P,A.length-1)]??d[w];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(d[v].value)}g.preventDefault()}else(g.key===lo.ESCAPE||g.key===lo.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};t4(()=>{s4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>Wn("div",{className:"picker-content",children:g.map(b=>td("button",{type:"button",className:e4("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&&Wn("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,y)=>b.name===i4?Wn(iw.Fragment,{children:u(b.options)},`${b.name}-${y}`):td("div",{className:"picker-section",children:[Wn("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${y}`));return Wn(lh.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:m,collisionBoundary:a??void 0,children:td("div",{className:"picker-sections",children:[E(e),n.length>0&&Wn(ys,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:Wn("div",{className:"picker-sections",children:E(n)})})]})})}function ch({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=iw.useState(!1),s=n4(()=>rw(t,l=>l.value===e)??rw(o??[],l=>l.value===e),[t,o,e]);return Wn("div",{children:td(lh.Root,{open:i,onOpenChange:l=>a(l),children:[Wn(lh.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&Wn(c4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import aw,{useEffect as d4}from"react";import{jsx as dh,jsxs as sw}from"react/jsx-runtime";var lw=({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=aw.useRef(null),d=aw.useRef(null);return d4(()=>{if(c.current&&d.current){let p=c.current,m=d.current,u=p.offsetWidth,E=parseFloat(getComputedStyle(p).getPropertyValue("--slider-thumb-size"))||16,g=(n-o)/(r-o||1)*100,b=g/100*(u-E)+E/2;m.style.left=`${b}px`,p.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${g}%, var(--button-bg) ${g}%, var(--button-bg) 100%)`}},[r,o,n]),sw("label",{className:"control-label",children:[e,sw("div",{className:"range-wrapper",children:[dh("input",{style:{"--color-slider-track":s?void 0:"var(--button-bg)"},ref:c,type:"range",min:o,max:r,step:i,onChange:p=>{t(+p.target.value)},value:n,className:"range-input","data-testid":l}),dh("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),dh("div",{className:"zero-label",children:a})]})]})};import{Fragment as ld,jsx as Q,jsxs as ft}from"react/jsx-runtime";var bw=.1,Ar=e=>{let n=N4(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},It=(e,n,t,o=!1)=>{let r=gh(ie(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(k4(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},st=function(e,n,t,o,r){let i=n.state.editingTextElement,a=fw(e),s=null;if(i&&(s=t(i)),!s)if(Me(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(p=>o(p));s=C4(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},B4=(e,n,t)=>A4(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}),fh=(e,n,t,o,r)=>{let i=new Set,a=It(e,n,s=>{if(Bt(s)){let l=o(s);i.add(l);let c=et(s,{fontSize:l});return vs(c,t.scene.getContainerElement(s),t.scene),c=B4(s,c,t.scene),c}return s},!0);return ie(e,n,{includeBoundTextElement:!0}).forEach(s=>{Bt(s)&&M4(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:qe.IMMEDIATELY}},O4=F({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:It(e,n,o=>D4(o.type)?et(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?qe.IMMEDIATELY:qe.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Ar(o);return ft(ld,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.stroke")}),Q(Si,{topPicks:E4,palette:f4,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:st(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),F4=F({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:qe.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!S4(t.currentItemBackgroundColor)&&i.every(s=>pw(s)&&P4(s.points))){let s=gh(i);r=e.map(l=>s.has(l.id)&&pw(l)?et(l,{backgroundColor:t.currentItemBackgroundColor,...R4(l,!0)}):l)}else r=It(e,n,s=>et(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:qe.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Ar(o);return ft(ld,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Si,{topPicks:g4,palette:hw,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:st(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),sd=F({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:qe.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=Ar(o);return ft(ld,{children:[r==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Si,{topPicks:u4,palette:hw,excludedColors:[h4.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})]})}}),z4=F({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Re("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:It(e,n,r=>et(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ie(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return ft("fieldset",{children:[Q("legend",{children:f("labels.fill")}),Q("div",{className:"buttonList",children:Q(Wt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?Ox:Fx,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:zx,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:Hx,testId:"fill-solid"}],value:st(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)}})})]})}}),H4=e=>y4.find(n=>gw(e.type,n)===e.strokeWidth)??null,G4=(e,n)=>gw(e.type,n),U4=F({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(ad(t,"actionChangeStrokeWidth: value must be defined"),{elements:It(e,n,o=>et(o,{strokeWidth:G4(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Wt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:Cu,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:Gx,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:Ux,testId:"strokeWidth-bold"}],value:st(e,o,H4,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),W4=F({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:It(e,n,o=>et(o,{seed:v4(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Wt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:Yx},{value:1,text:f("labels.artist"),icon:Kx},{value:2,text:f("labels.cartoonist"),icon:Xx}],value:st(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),V4=F({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:It(e,n,r=>r.type!=="freedraw"?r:et(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:qe.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=st(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?ku:Pu,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return ft("fieldset",{children:[Q("legend",{children:f("labels.pressure")}),Q("div",{className:"buttonList",children:Q(Wt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:Pu},{value:"variable",text:f("labels.pressure_variable"),icon:ku}],value:i,onChange:a=>t(a)})})]})}}),hte=F({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:It(e,n,o=>et(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Wt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Cu},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:Wx},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:Vx}],value:st(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),Y4=F({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:It(e,n,o=>et(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=st(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return Q(lw,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),K4=F({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>fh(e,n,o,()=>(ad(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Ar(o);return ft("fieldset",{children:[Q("legend",{children:f("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Wt,{group:"font-size",options:[{value:od.sm,text:f("labels.small"),icon:m1,testId:"fontSize-small"},{value:od.md,text:f("labels.medium"),icon:p1,testId:"fontSize-medium"},{value:od.lg,text:f("labels.large"),icon:u1,testId:"fontSize-large"},{value:od.xl,text:f("labels.veryLarge"),icon:h1,testId:"fontSize-veryLarge"}],value:st(e,o,a=>{if(Bt(a))return a.fontSize;let s=Yo(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Bt(a)||Yo(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||x4),onChange:a=>{ms(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),Eh=F({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Sr,trackEvent:!1,perform:(e,n,t,o)=>fh(e,n,o,r=>Math.round(1/(1+bw)*r.fontSize)),keyTest:e=>e[ki.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ki.CHEVRON_LEFT||e.key===ki.COMMA)}),bh=F({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Sr,trackEvent:!1,perform:(e,n,t,o)=>fh(e,n,o,r=>Math.round(r.fontSize*(1+bw))),keyTest:e=>e[ki.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ki.CHEVRON_RIGHT||e.key===ki.PERIOD)}),X4=F({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:It(e,n,g=>{let b=r?.get(g.id);return b?et(g,{...b}):g},!0),appState:{...n,...s},captureUpdate:qe.NEVER};ad(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=qe.EVENTUALLY,p,m=!1;if(l)p=l,d=qe.IMMEDIATELY;else if(c){p=c,d=qe.EVENTUALLY;let E=ie(e,n,{includeBoundTextElement:!0}).filter(g=>Bt(g));if(E.length>200)m=!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&&(m=!0)}}let u={appState:{...n,...s},captureUpdate:d};if(p&&!m){let E=new Map,g=new Set,b=!1,y=Array.from(oo.loadedFontsCache.values()),w=Object.entries(w4).find(([I,C])=>C===p)?.[0];c&&w&&y.some(I=>I.startsWith(w))&&(b=!0),Object.assign(u,{elements:It(e,n,I=>{if(Bt(I)&&(I.fontFamily!==p||l)){let C=et(I,{fontFamily:p,lineHeight:I4(p)}),P=r?.get(I.containerId||"")||{},A=o.scene.getContainerElement(I);return a&&A&&P&&o.scene.mutateElement(A,{...P}),b||(g=new Set([...g,...Array.from(C.originalText)])),E.set(C,A),C}return I},!0)});let x=`10px ${T4({fontFamily:p})}`,v=Array.from(g.values()).join();if(b||window.document.fonts.check(x,v))for(let[I,C]of E)vs(I,C,o.scene);else window.document.fonts.load(x,v).then(I=>{for(let[C,P]of E){let A=o.scene.getElement(C.id),L=P?o.scene.getElement(P.id):null;A&&vs(A,L,o.scene)}o.fonts.onLoaded(I)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=ph(new Map),i=ph(null),[a,s]=p4({}),l=ph(!0),{stylesPanelMode:c,isCompact:d}=Ar(t),p=hh(()=>{let m=(u,E)=>st(u,t,g=>{if(Bt(g))return g.fontFamily;let b=Yo(g,E);return b?b.fontFamily:null},g=>Bt(g)||Yo(g,E)!==null,g=>g?null:n.currentItemFontFamily||b4);return a.openPopup==="fontFamily"&&n.openPopup==="fontFamily"?m(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&n.openPopup!=="fontFamily"?m(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,n,e,t]);return mh(()=>{i.current=p},[p]),mh(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),mh(()=>(l.current=!1,()=>{l.current=!0}),[]),ft(ld,{children:[c==="full"&&Q("legend",{children:f("labels.fontFamily")}),Q(tw,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:p,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:m=>{ms(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:m}),r.current.clear()},d,!!n.editingTextElement)},onHover:m=>{s({currentHoveredFontFamily:m,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:m=>{if(m){r.current.clear();let{editingTextElement:u}=n;if(u?.type==="text"){let E=t.scene.getElement(u.id);r.current.set(u.id,et(E||u,{},!0))}else{let E=ie(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,et(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&&ds(null)}}})]})}}),$4=F({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:It(e,n,r=>{if(Bt(r)){let i=et(r,{textAlign:t});return vs(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=Ar(o);return ft("fieldset",{children:[Q("legend",{children:f("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Wt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:f1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:E1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:b1,testId:"align-right"}],value:st(e,o,s=>{if(Bt(s))return s.textAlign;let l=Yo(s,i);return l?l.textAlign:null},s=>Bt(s)||Yo(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{ms(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),Z4=F({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:It(e,n,r=>{if(Bt(r)){let i=et(r,{verticalAlign:t});return vs(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Ar(o);return Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Wt,{group:"text-align",options:[{value:nd.TOP,text:f("labels.alignTop"),icon:Q(x1,{theme:n.theme}),testId:"align-top"},{value:nd.MIDDLE,text:f("labels.centerVertically"),icon:Q(y1,{theme:n.theme}),testId:"align-middle"},{value:nd.BOTTOM,text:f("labels.alignBottom"),icon:Q(w1,{theme:n.theme}),testId:"align-bottom"}],value:st(e,o,a=>{if(Bt(a)&&a.containerId)return a.verticalAlign;let s=Yo(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Bt(a)||Yo(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:nd.MIDDLE),onChange:a=>{ms(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),gte=F({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:It(e,n,o=>Ew(o)?o:et(o,{roundness:t==="round"?{type:L4(o.type)?rd.ADAPTIVE_RADIUS:rd.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=si(fw(e),n).some(s=>s.roundness?.type===rd.LEGACY);return ft("fieldset",{children:[Q("legend",{children:f("labels.edges")}),ft("div",{className:"buttonList",children:[Q(Wt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:$x},{value:"round",text:f("labels.round"),icon:Zx}],value:st(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!id(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),uw=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:Q(jx,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(qx,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:Q(Jx,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:Q(Qx,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:Q(e1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(t1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:Q(n1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:Q(o1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:Q(r1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:Q(i1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:Q(a1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:Q(s1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:Q(l1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:Q(c1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:Q(d1,{flip:e}),keyBinding:null}]}]}),fte=F({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(ad(t,"actionChangeArrowhead: value must be defined"),{elements:It(e,n,o=>{if(uh(o)){let{position:r,type:i}=t;if(r==="start")return et(o,{startArrowhead:i});if(r==="end")return et(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=Bn().rtl,i=hh(()=>uw(!r),[r]),a=hh(()=>uw(!!r),[r]);return ft("fieldset",{children:[Q("legend",{children:f("labels.arrowheads")}),ft("div",{className:"iconSelectList buttonList",children:[Q(ch,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:st(e,o,s=>uh(s)&&Ka(s.type)?mw(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),Q(ch,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:st(e,o,s=>uh(s)&&Ka(s.type)?mw(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),j4=F({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})=>ft("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),Ete=F({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=It(e,n,s=>{if(!id(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=Mr.getPointAtIndexGlobalCoordinates(s,0,l),d=Mr.getPointAtIndexGlobalCoordinates(s,-1,l),p=et(s,{x:t===tn.elbow?c[0]:s.x,y:t===tn.elbow?c[1]:s.y,roundness:t===tn.round?{type:rd.PROPORTIONAL_RADIUS}:null,elbowed:t===tn.elbow,angle:t===tn.elbow?0:s.angle,points:t===tn.elbow||s.elbowed?[Mr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),Mr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(Ew(p)){p.fixedSegments=null;let m=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=Mr.getPointAtIndexGlobalCoordinates(p,0,m),E=Mr.getPointAtIndexGlobalCoordinates(p,-1,m),g=p.startBinding&&m.get(p.startBinding.elementId),b=p.endBinding&&m.get(p.endBinding.elementId),y=g&&p.startBinding?{...p.startBinding,...dw(p,g,"start",m,n.isBindingEnabled)}:null,w=b&&p.endBinding?{...p.endBinding,...dw(p,b,"end",m,n.isBindingEnabled)}:null;p={...p,startBinding:y,endBinding:w,..._4(p,m,{points:[u,E].map(x=>m4(x[0]-p.x,x[1]-p.y)),startBinding:y,endBinding:w,fixedSegments:null})}}else{let m=o.scene.getNonDeletedElementsMap();if(p.startBinding){let u=m.get(p.startBinding.elementId);u&&cw(p,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(p.endBinding){let u=m.get(p.endBinding.elementId);u&&cw(p,u,n.bindMode==="inside"?"inside":"orbit","end",o.scene)}}return p}),i={...n,currentItemArrowType:t},a=n.selectedLinearElement?.elementId;if(a){let s=r.find(l=>l.id===a);s&&(i.selectedLinearElement=new Mr(s,gh(e)))}return{elements:r,appState:i,captureUpdate:qe.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ft("fieldset",{children:[Q("legend",{children:f("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Wt,{group:"arrowtypes",options:[{value:tn.sharp,text:f("labels.arrowtype_sharp"),icon:Ro,testId:"sharp-arrow"},{value:tn.round,text:f("labels.arrowtype_round"),icon:Bo,testId:"round-arrow"},{value:tn.elbow,text:f("labels.arrowtype_elbowed"),icon:No,testId:"elbow-arrow"}],value:st(e,o,r=>id(r)?r.elbowed?tn.elbow:r.roundness?tn.round:tn.sharp:null,r=>id(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as o6,MAX_ZOOM as r6,MIN_ZOOM as i6,THEME as Ts,ZOOM_STEP as yw,CODES as Vn,KEYS as Lr}from"@excalidraw/common";import{getNonDeletedElements as Is}from"@excalidraw/element";import{getCommonBounds as Ss}from"@excalidraw/element";import{CaptureUpdateAction as Li}from"@excalidraw/element";import{useEffect as q4}from"react";import{jsx as Q4}from"react/jsx-runtime";var Mi=()=>{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},xh=(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`})},J4=(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();xh(n,r)},lt=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(q4(()=>()=>Mi().classList.remove("excalidraw-tooltip--visible"),[]),r?null:Q4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>J4(i.currentTarget,Mi(),n,t),onPointerLeave:()=>Mi().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as xw,useRef as ww,useState as e6}from"react";var t6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],wh=(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},Lo())}return t6(o,n)};function Ai(e,n=!0){let t=cd(),[,o]=e6(0),r=ww(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:wh(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=wh(t,e,n)),xw(()=>{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 n6(e,n){let t=cd(),o=ww({selector:e,callback:n});o.current.selector=e,o.current.callback=n,xw(()=>{if(!(!t||t.isDestroyed))return o.current.callback(wh(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as hd,jsxs as l6}from"react/jsx-runtime";var a6=F({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?Li.IMMEDIATELY:Li.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>hd(Si,{palette:null,topPicks:o6,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=F({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:cu,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...Mo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:no(n.zoom.value+yw)},n)},captureUpdate:Li.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ai(t=>t.zoom.value);return hd($,{type:"button",className:"zoom-in-button zoom-button",icon:cu,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=r6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Vn.EQUAL||e.code===Vn.NUM_ADD)&&(e[Lr.CTRL_OR_CMD]||e.shiftKey)}),md=F({name:"zoomOut",label:"buttons.zoomOut",icon:du,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...Mo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:no(n.zoom.value-yw)},n)},captureUpdate:Li.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ai(t=>t.zoom.value);return hd($,{type:"button",className:"zoom-out-button zoom-button",icon:du,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=i6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Vn.MINUS||e.code===Vn.NUM_SUBTRACT)&&(e[Lr.CTRL_OR_CMD]||e.shiftKey)}),pd=F({name:"resetZoom",label:"buttons.resetZoom",icon:xx,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,...Mo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:no(r)},n)},captureUpdate:Li.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=Ai(t=>t.zoom.value);return hd(lt,{label:f("buttons.resetZoom"),style:{height:"100%"},children:l6($,{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===Vn.ZERO||e.code===Vn.NUM_ZERO)&&(e[Lr.CTRL_OR_CMD]||e.shiftKey)}),yh=e=>[e.x,e.y,e.x+e.width,e.y+e.height],$te=F({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Sc,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?Ss(Is(r)):n.scrollConstraints?yh(n.scrollConstraints):Ss(Is(e)),a=wr({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Rn(a.appState)}}},keyTest:e=>e.code===Vn.TWO&&e.shiftKey&&!e.altKey&&!e[Lr.CTRL_OR_CMD]}),Zte=F({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Sc,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?Ss(Is(r)):n.scrollConstraints?yh(n.scrollConstraints):Ss(Is(e)),a=wr({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Rn(a.appState)}}},keyTest:e=>e.code===Vn.THREE&&e.shiftKey&&!e.altKey&&!e[Lr.CTRL_OR_CMD]}),s6=F({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Sc,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?yh(n.scrollConstraints):Ss(Is(e)),i=wr({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...Rn(i.appState)}}},keyTest:e=>e.code===Vn.ONE&&e.shiftKey&&!e.altKey&&!e[Lr.CTRL_OR_CMD]}),ud=F({name:"toggleTheme",label:(e,n)=>n.theme===Ts.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===Ts.LIGHT?os:rs,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===Ts.LIGHT?Ts.DARK:Ts.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:Li.EVENTUALLY}},keyTest:e=>!e[Lr.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Vn.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as f6}from"@excalidraw/math";import{bindOrUnbindBindingElement as Rw}from"@excalidraw/element/binding";import{isValidPolygon as Nw,newElementWith as Ih}from"@excalidraw/element";import{LinearElementEditor as Ps}from"@excalidraw/element/linearElementEditor";import{isBindingElement as Sh,isFreeDrawElement as Bw,isLinearElement as Ow,isLineElement as Td}from"@excalidraw/element";import{KEYS as Id,arrayToMap as E6,invariant as Fw,shouldRotateWithDiscreteAngle as b6,updateActiveTool as zw}from"@excalidraw/common";import{isPathALoop as x6}from"@excalidraw/element";import{isInvisiblySmallElement as Ch}from"@excalidraw/element";import{CaptureUpdateAction as Ph}from"@excalidraw/element";import p6 from"clsx";import{useEffect as u6,useState as h6}from"react";import{KEYS as ze,capitalizeString as Dr}from"@excalidraw/common";import{useEffect as c6,useState as d6}from"react";import vw from"clsx";import{capitalizeString as gd}from"@excalidraw/common";import{Popover as vh}from"radix-ui";import{jsx as fd,jsxs as m6}from"react/jsx-runtime";var Di=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=d6(!1),c=t.type,d=a.type===c,p=16,{container:m}=Ae();return!n.some(u=>u.type===c)&&s&&l(!1),c6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),m6(vh.Root,{open:s,children:[fd(vh.Trigger,{asChild:!0,children:fd($,{className:vw({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>it(e,u.type)),title:gd(a.title),"aria-label":gd(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),fd(vh.Content,{className:"tool-popover-content",sideOffset:p,collisionBoundary:m??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>fd($,{className:vw({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:it(e,u),title:gd(u),"aria-label":gd(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(Re("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as Th}from"react/jsx-runtime";var g6=e=>e,Je=g6({hand:{icon:v1,letterKey:ze.H,toggle:!0},selection:{icon:fc,letterKey:ze.V,numericKey:ze[1],fillable:!0},rectangle:{icon:ui,letterKey:ze.R,numericKey:ze[2],fillable:!0},diamond:{icon:hi,letterKey:ze.D,numericKey:ze[3],fillable:!0},ellipse:{icon:gi,letterKey:ze.O,numericKey:ze[4],fillable:!0},arrow:{icon:Ec,letterKey:ze.A,numericKey:ze[5],fillable:!0},line:{icon:Do,letterKey:ze.L,numericKey:ze[6],fillable:!0},freedraw:{icon:On,letterKey:[ze.P,ze.X],numericKey:ze[7]},text:{icon:En,letterKey:ze.T,numericKey:ze[8]},image:{icon:Tr,numericKey:ze[9]},eraser:{icon:bc,letterKey:ze.E,numericKey:ze[0],toggle:!0},frame:{icon:Hn,letterKey:ze.F},autoshape:{icon:Cr,letterKey:ze.X,shiftKey:!0,fillable:!1},embeddable:{icon:_o},laser:{icon:Gn,letterKey:ze.K},bucketfill:{icon:Fn,letterKey:ze.B},lasso:{icon:ts,fillable:!1}}),_i=Object.keys(Je).filter(e=>Je[e].toggle),Tw=e=>{let{letterKey:n,shiftKey:t}=Je[e];if(!n)return n;let o=Dr(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},Cs=e=>{let n=Tw(e),{numericKey:t}=Je[e];return n&&t!=null?`${n} ${f("helpDialog.or")} ${t}`:`${n||t}`},Iw=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(Je)){let{letterKey:i,numericKey:a,shiftKey:s}=Je[r];if(t===!!s&&(a!=null&&e===a||i&&(typeof i=="string"?i===o:i.includes(o))))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},it=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Yt=(e,n)=>{let t=Je[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=Dr(f(`toolBar.${e}`)),d=l?null:Cs(o);return Th($,{className:p6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:it(i,e),title:d?`${c} \u2014 ${d}`:c,keyBindingLabel:s||l?void 0:Je[o].numericKey||Tw(o),"aria-label":c,"aria-keyshortcuts":d??void 0,"data-testid":`toolbar-${e}`,onSelect:({pointerType:p})=>{if(!i.state.penDetected&&p==="pen"&&i.togglePenMode(!0),n?.onSelect){n.onSelect(i,{pointerType:p});return}i.state.activeTool.type!==e&&(Re("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${Dr(e)}IconButton`,r},Ed=Yt("hand"),Sw=Yt("rectangle"),Cw=Yt("diamond"),Pw=Yt("ellipse"),kw=Yt("arrow"),Mw=Yt("line"),Aw=Yt("freedraw"),bd=Yt("text"),xd=Yt("image"),wd=Yt("eraser"),Lw=Yt("frame"),Dw=Yt("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Re("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),_w=Yt("lasso",{shortcutType:"selection"}),yd=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:Je.selection.icon,fillable:Je.selection.fillable,title:Dr(f("toolBar.selection"))},{type:"lasso",icon:Je.lasso.icon,fillable:Je.lasso.fillable,title:Dr(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return Th(Di,{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})},vd=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:Je.freedraw.icon,fillable:Je.freedraw.fillable,title:Dr(f("toolBar.freedraw"))},{type:"autoshape",icon:Je.autoshape.icon,fillable:Je.autoshape.fillable,title:Dr(f("toolBar.autoshape"))}],[o,r]=h6(n.type==="autoshape"?"autoshape":"freedraw");u6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return Th(Di,{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 w6}from"react/jsx-runtime";var ct=F({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=Ps.getElement(n.selectedLinearElement.elementId,l);Fw(w,"Arrow element should exist if selectedLinearElement is set"),Fw(y,"sceneCoords should be defined if actionFinalize is called with event");let x=Ps.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(Sh(w)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let v=!!n.newElement,I=v||!n.selectedLinearElement.selectedPointsIndices?[w.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=b6(b),P=b[Id.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),A=I.reduce((L,_)=>(L.set(_,{point:C?w.points[_]:Ps.createPointAt(w,l,y.x-x.pointerOffset.x,y.y-x.pointerOffset.y,P)}),L),new Map)??new Map;Rw(w,A,y.x,y.y,s,n,{newArrow:v,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else Td(w)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!Nw(w.points)&&s.mutateElement(w,{polygon:!1});if(x!==n.selectedLinearElement){w&&Ch(w)&&(i=i.map(I=>I.id===w.id?Ih(I,{isDeleted:!0}):I));let v=n.activeTool?.locked;return{elements:w.points.length<2||Ch(w)?e.map(I=>I.id===w.id?Ih(I,{isDeleted:!0}):I):i,appState:{...n,cursorButton:"up",selectedElementIds:c?{}:n.selectedElementIds,selectedLinearElement:v||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:Ph.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let d=o.drawShape.hasPendingGesture();(d||c)&&(o.drawShape.finalize(),d&&(i=o.scene.getElementsIncludingDeleted()));let p=null;if(n.multiElement)p=n.multiElement;else if(!c&&!d&&(n.newElement?.type==="freedraw"||Sh(n.newElement)))p=n.newElement;else if(Object.keys(n.selectedElementIds).length===1){let b=l.get(Object.keys(n.selectedElementIds)[0]);b&&(p=b)}if(p){if(n.selectedLinearElement&&n.multiElement&&p.type!=="freedraw"&&n.lastPointerDownWith!=="touch"){let{points:b}=p,{lastCommittedPoint:y}=n.selectedLinearElement;if((!y||b[b.length-1]!==y)&&(r=!1,s.mutateElement(p,{points:p.points.slice(0,-1)}),Sh(p)&&p.endBinding&&p.points.length>1)){let w=!!n.newElement,x=new Map([[p.points.length-1,{point:p.points[p.points.length-1],isDragging:!1}]]),v=Ps.getPointAtIndexGlobalCoordinates(p,-1,l);Rw(p,x,v[0],v[1],s,n,{newArrow:w})}}if(p&&Ch(p)&&(i=i.map(b=>b.id===p?.id?Ih(b,{isDeleted:!0}):b)),Ow(p)||Bw(p)){if(x6(p.points,n.zoom.value)&&(Td(p)||Bw(p))){let y=p.points,w=y[0],x=y.map((v,I)=>I===y.length-1?f6(w[0],w[1]):v);Td(p)?s.mutateElement(p,{points:x,polygon:!0}):s.mutateElement(p,{points:x})}Td(p)&&!Nw(p.points)&&s.mutateElement(p,{polygon:!1})}}let m;_i.includes(n.activeTool.type)?m=zw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):m=zw(n,{type:o.state.preferredSelectionTool.type});let u=o.isToolLocked(),E=n.activeTool.type==="autoshape"||(u||n.activeTool.type==="freedraw")&&!!p;E||o.cursor.applyForTool(m);let g=p&&Ow(p)?new Ps(p,E6(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:m,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:c?{}:p&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[p.id]:!0}:n.selectedElementIds,selectedLinearElement:c?null:g},captureUpdate:r?Ph.IMMEDIATELY:Ph.NEVER}},keyTest:(e,n)=>e.key===Id.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===Id.ESCAPE||e.key===Id.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>w6($,{type:"button",icon:Ax,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 Uw,isSomeElementSelected as y6,makeNextSelectedElementIds as v6,selectGroupsForSelectedElements as T6}from"@excalidraw/element";import{CaptureUpdateAction as Hw}from"@excalidraw/element";import{KEYS as I6,isWritableElement as S6,updateActiveTool as Gw}from"@excalidraw/common";var C6=(e,n)=>_i.includes(e.activeTool.type)?Gw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):Gw(e,{type:n.state.preferredSelectionTool.type}),P6=(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:Uw(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},k6=F({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=C6(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:Uw(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...T6({editingGroupId:P6(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:Hw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:v6({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:Hw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==I6.ESCAPE||S6(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||y6(o.scene.getNonDeletedElements(),n))});import{KEYS as Dd,THEME as Ls}from"@excalidraw/common";import{CaptureUpdateAction as xn}from"@excalidraw/element";import M6 from"clsx";import{jsx as Ww,jsxs as A6}from"react/jsx-runtime";var kh=({children:e,checked:n,onChange:t,className:o})=>A6("div",{className:M6("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[Ww("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:xc}),Ww("div",{className:"Checkbox-label",children:e})]});import{THEME as ks}from"@excalidraw/common";import{jsx as Ms}from"react/jsx-runtime";var Yw=e=>{let n=e.title||(e.value===ks.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return Ms($,{type:"icon",icon:e.value===ks.LIGHT?Vw.MOON:Vw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===ks.DARK?ks.LIGHT:ks.DARK),"data-testid":"toggle-dark-mode"})},Vw={SUN:Ms("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ms("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:Ms("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ms("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 L6}from"react";import{focusNearestParent as D6,KEYS as _6}from"@excalidraw/common";import{jsx as Kw,jsxs as R6}from"react/jsx-runtime";var Xw=e=>{let{id:n}=Ae(),[t,o]=L6(e.value),r=a=>{e.ignoreFocus||D6(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===_6.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return R6("div",{className:"ProjectName",children:[Kw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Kw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as N6,useEffect as B6,useRef as O6}from"react";import{jsx as Sd,jsxs as G6}from"react/jsx-runtime";var F6=5e3,z6=({progress:e})=>Sd("div",{className:"Toast__progress-bar",children:Sd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),H6=({message:e,onClose:n,closable:t=!1,duration:o=F6,style:r})=>{let i=O6(0),a=o!==1/0,s=N6(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return B6(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),G6("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Sd("div",{className:"Toast__message",children:e}),t&&Sd($,{icon:zn,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},Cd=Object.assign(H6,{ProgressBar:z6});import{DEFAULT_EXPORT_PADDING as sL,DEFAULT_FILENAME as lL,IMAGE_MIME_TYPES as Qw,isFirefox as cL,MIME_TYPES as dL,cloneJSON as mL,SVG_DOCUMENT_PREAMBLE as pL,arrayToMap as uL}from"@excalidraw/common";import{getNonDeletedElements as hL}from"@excalidraw/element";import{isFrameLikeElement as gL}from"@excalidraw/element";import{getElementsOverlappingFrame as fL}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as U6,EXPORT_DATA_TYPES as As,MIME_TYPES as dt,arrayToMap as W6,isMemberOf as V6,isPromiseLike as Y6,EVENT as Pd}from"@excalidraw/common";import{mutateElement as K6}from"@excalidraw/element";import{deepCopyElement as X6}from"@excalidraw/element";import{isFrameLikeElement as $6,isInitializedImageElement as Z6}from"@excalidraw/element";import{getContainingFrame as $w}from"@excalidraw/element";var Hoe="clipboard"in navigator&&"readText"in navigator.clipboard,kd="clipboard"in navigator&&"writeText"in navigator.clipboard,Ko="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,j6=e=>!!([As.excalidraw,As.excalidrawClipboard,As.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Zw=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Pd.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},q6=({elements:e,files:n})=>{let t=W6(e),o=new Set(e.filter(s=>$6(s))),r=!1,i=e.reduce((s,l)=>(Z6(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:As.excalidrawClipboard,elements:e.map(s=>{if($w(s,t)&&!o.has($w(s,t))){let l=X6(s);return K6(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},Md=async(e,n,t)=>{let o=q6({elements:e,files:n});await co({[dt.excalidrawClipboard]:o,[dt.text]:o},t)};function jw(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(jw(t));return n}var J6=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,dt.html),o=jw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},qw=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{[dt.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(V6(U6,o))try{if(o===dt.text||o===dt.html)e[o]=await(await t.getType(o)).text();else if(jb(o)){let r=await t.getType(o),i=ox(r,o,void 0);e[o]=i}else throw new ru(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof ru?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},Q6=async(e,n=!1)=>{try{let t=e.findByType(dt.html),o=!n&&t&&J6(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(dt.text)??o.value.map(r=>r.value).join(`
2
- `).trim()}:o:{type:"text",value:(e.getData(dt.text)||"").trim()}}catch{return{type:"text",value:""}}},eL=function(e){return this.find(n=>n.type===e)||null},tL=function(e){return this.find(t=>t.type===e)?.value??null},nL=function(){return this.filter(e=>e.kind==="file")},oL=e=>{let n=Mh(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),dt.text,dt.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}},rL=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}}),iL=(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===dt.html)try{let E=new DOMParser().parseFromString(u.value,dt.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===dt.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:rL(e)};c.forEach((u,E)=>{let g=l[E],b=i[E];g&&(u.src=g),b&&(u.alt=b),u.rawDragData=d});let p=l.slice(c.length),m=c[0];return m&&p.length>0&&p.forEach((u,E)=>{m[`additionalUrl${E+1}`]=u}),c},Jw=e=>{let n;Mh(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},_r=async e=>{let n;Mh(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 nx(o);return r=await di(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:eL,getData:tL,getFiles:nL})},Ad=async(e,n=!1)=>{let t=await Q6(e,n);if(t.type==="mixedContent")return{mixedContent:t.value};try{let o=JSON.parse(t.value),r=o.type===As.excalidrawClipboardWithAPI;if(j6(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}},Ld=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[dt.png]:e})])}catch(n){if(Y6(e))await navigator.clipboard.write([new ClipboardItem({[dt.png]:await e})]);else throw n}},co=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[dt.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===dt.text);if(kd&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!aL(o[1]))throw new Error("Error copying to clipboard.")},aL=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},Mh=e=>e.type===Pd.PASTE||e.type===Pd.COPY||e.type===Pd.CUT;var Rr=(e,{selectedElementIds:n},t)=>{let o=hL(e),r=uL(o),i=t&&Me(o,{selectedElementIds:n}),a=null,s=i?ie(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&gL(l)?(a=l,s=fL(o,l,r)):s.length>1&&(s=ie(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:mL(s)}},Nr=async(e,n,t,o,{exportBackground:r,exportPadding:i=sL,viewBackgroundColor:a,name:s=t.name||lL,fileHandle:l=null,exportingFrame:c=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let p=yr(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 iu(p.then(m=>new Blob([pL+m.outerHTML],{type:dL.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Qw.svg],fileHandle:l});if(e==="clipboard-svg"){let m=await p.then(u=>u.outerHTML);try{await co(m)}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 p=Ja(d);return t.exportEmbedScene&&(p=p.then(m=>import("./data/image-AAJBLI3M.js").then(({encodePngMetadata:u})=>u({blob:m,metadata:$a(n,t,o,"local")})))),iu(p,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Qw.png],fileHandle:l})}else if(e==="clipboard")try{let p=Ja(d);await Ld(p)}catch(p){throw console.warn(p),p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):cL&&p.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
1
+ import{$ as ls,A as du,B as rs,C as gc,D as mu,E as Zb,F as fc,G as is,H as Ec,I as bc,J as as,K as jb,L as qb,M as Jb,N as xc,O as Tr,P as ZM,Q as Sr,R as pi,T as Qb,V as ex,W as tx,X as wc,Y as nx,Z as yc,_ as ss,a as su,aa as ox,b as Nn,ba as vc,c as oo,ca as rx,d as Ir,da as ix,e as ci,ea as ax,f as Bn,fa as pu,g as Ub,ga as sx,h as Me,ha as lx,i as Wb,ia as cx,j as ie,ja as ui,k as di,l as _o,m as Vb,n as lu,o as Yb,p as ns,q as Xb,r as hc,s as Kb,t as cu,u as ro,v as Ro,w as qt,x as os,y as mi,z as $b}from"./chunk-H5UC5NY3.js";import{a as S}from"./chunk-GPFWSM2Y.js";import{G as au}from"./chunk-DARW3V66.js";import{c as Gb}from"./chunk-5XKZK2GL.js";import{b as Hb,c as $M,d as I}from"./chunk-SRAX5OIU.js";import NX,{useCallback as BX,useContext as OX,useEffect as FX,useRef as zX,useState as HX}from"react";import{applyDarkModeFilter as kWe,DEFAULT_IMAGE_OPTIONS as Lo,DEFAULT_UI_OPTIONS as YM,getStrokeWidthByKey as MWe,isShallowEqual as GX}from"@excalidraw/common";import yk from"clsx";import hV from"lodash.throttle";import En,{useContext as Ao}from"react";import{flushSync as Gt}from"react-dom";import gV from"roughjs/bin/rough";import{nanoid as fV}from"nanoid";import{clamp as Kl,pointFrom as ne,pointDistance as qn,vector as vk,pointRotateRads as qE,vectorFromPoint as JE,vectorSubtract as Ik,vectorDot as Tk,vectorNormalize as Sk}from"@excalidraw/math";import{CODES as br,shouldResizeFromCenter as Ck,shouldMaintainAspectRatio as $l,shouldRotateWithDiscreteAngle as Pk,isArrowKey as QE,KEYS as X,APP_NAME as EV,CURSOR_TYPE as Pe,DEFAULT_STROKE_STREAMLINE as bV,DEFAULT_STROKE_STREAMLINE_PRECISE as xV,DEFAULT_TRANSFORM_HANDLE_SPACING as wV,DEFAULT_VERTICAL_ALIGN as kk,DRAGGING_THRESHOLD as Mk,ELEMENT_SHIFT_TRANSLATE_AMOUNT as yV,ELEMENT_TRANSLATE_AMOUNT as Ak,EVENT as J,FRAME_STYLE as Io,IMAGE_MIME_TYPES as vV,IMAGE_RENDER_TIMEOUT as IV,LINE_CONFIRM_THRESHOLD as eb,MIME_TYPES as Xa,MQ_RIGHT_SIDEBAR_MIN_WIDTH as TV,POINTER_BUTTON as To,ROUNDNESS as Op,SCROLL_TIMEOUT as SV,TAP_TWICE_TIMEOUT as Lk,TEXT_TO_CENTER_SNAP_THRESHOLD as CV,THEME as Zl,TOUCH_CTX_MENU_TIMEOUT as PV,VERTICAL_ALIGN as kV,YOUTUBE_STATES as Fp,ZOOM_STEP as MV,MIN_ZOOM as AV,POINTER_EVENTS as Ka,TOOL_TYPE as Dn,supportsResizeObserver as LV,DEFAULT_COLLISION_THRESHOLD as Dk,DEFAULT_TEXT_ALIGN as DV,ARROW_TYPE as xr,DEFAULT_REDUCED_GLOBAL_ALPHA as _V,isLocalLink as RV,normalizeLink as tb,toValidURL as NV,getGridPoint as Ct,getLineHeight as _k,debounce as Rk,distance as $a,getFontString as nb,getNearestScrollableContainer as BV,isInputLike as Nk,isToolIcon as OV,isWritableElement as jl,sceneCoordsToViewportCoords as zp,tupleToCoors as ob,viewportCoordsToSceneCoords as Ce,wrapEvent as FV,updateObject as rb,updateActiveTool as Zt,isTransparent as zV,muteFSAbortError as HV,isTestEnv as TM,isDevEnv as SM,updateStable as ql,addEventListener as be,normalizeEOL as GV,getDateTime as Bk,isShallowEqual as Ok,arrayToMap as Jl,applyDarkModeFilter as UV,AppEventBus as WV,randomInteger as VV,CLASSES as ib,Emitter as Jn,MINIMUM_ARROW_SIZE as YV,DOUBLE_TAP_POSITION_THRESHOLD as Fk,BIND_MODE_TIMEOUT as XV,invariant as Qn,getFeatureFlag as So,createUserAgentDescriptor as CM,getFormFactor as KV,deriveStylesPanelMode as qp,isIOS as $V,isBrave as ZV,isSafari as jV,loadDesktopUIModePreference as qV,setDesktopUIMode as JV,isSelectionLikeTool as Hp,oneOf as zk,getStrokeWidthByKey as QV}from"@excalidraw/common";import{getObservedAppState as eY,getCommonBounds as Za,getElementAbsoluteCoords as Hk,bindOrUnbindBindingElements as Gk,fixBindingsAfterDeletion as tY,getHoveredElementForBinding as wr,isBindingEnabled as Gp,updateBoundElements as Up,LinearElementEditor as me,newElementWith as Co,newFrameElement as nY,newFreeDrawElement as oY,newEmbeddableElement as Uk,newMagicFrameElement as rY,newIframeElement as iY,newArrowElement as aY,newElement as sY,newImageElement as lY,newLinearElement as cY,newTextElement as Wk,refreshTextDimensions as dY,deepCopyElement as Vk,duplicateElements as Yk,hasBoundTextElement as Xk,isArrowElement as Ql,isBindingElement as eo,isBindingElementType as mY,isBoundToContainer as Kk,isFrameLikeElement as vt,isImageElement as to,isEmbeddableElement as Po,isInitializedImageElement as ja,isLinearElement as Rt,isLinearElementType as pY,isUsingAdaptiveRadius as uY,isIframeElement as ab,isIframeLikeElement as ec,isTextBindableContainer as $k,isElbowArrow as Ut,isBindableElement as sb,isTextElement as Wt,getNormalizedDimensions as hY,isElementCompletelyInViewport as gY,isElementInViewport as Zk,isInvisiblySmallElement as jk,generateThumbHash as fY,getCornerRadius as EY,isPathALoop as qk,embeddableURLValidator as lb,maybeParseEmbedSrc as bY,getEmbedLink as Wp,getInitializedImageElements as xY,normalizeSVG as Jk,updateImageCache as Qk,getBoundTextElement as cb,getContainerCenter as db,getContainerElement as eM,isValidTextContainer as tM,redrawTextBoundingBox as wY,hasBoundingBox as yY,getCommonFrameId as nM,getFrameChildren as mb,getFrameChildrenInsertionIndex as vY,isCursorInFrame as oM,addElementsToFrame as pb,replaceAllElementsInFrame as IY,removeElementsFromFrame as TY,getElementsInResizingFrame as ub,getElementsInNewFrame as SY,getContainingFrame as hb,elementOverlapsWithFrame as CY,updateFrameMembershipOfSelectedElements as rM,isElementInFrame as iM,getFrameLikeTitle as PY,filterElementsEligibleAsFrameChildren as kY,hitElementBoundText as MY,hitElementBoundingBoxOnly as AY,hitElementItself as tc,getVisibleSceneBounds as LY,cropElement as DY,wrapText as _Y,isElementLink as RY,isMeasureTextSupported as NY,normalizeText as BY,measureText as aM,getLineHeightInPx as sM,getApproxMinLineWidth as OY,getApproxMinLineHeight as FY,getMinTextElementWidth as zY,ShapeCache as qa,getRenderOpacity as HY,editGroupForSelectedElement as GY,getElementsInGroup as si,getSelectedGroupIdForElement as UY,getSelectedGroupIds as WY,isElementInGroup as lM,isSelectedViaGroup as VY,selectGroupsForSelectedElements as _n,syncInvalidIndices as PM,syncMovedIndices as cM,excludeElementsInFramesFromSelection as YY,getSelectionStateForElements as dM,makeNextSelectedElementIds as ke,getResizeOffsetXY as XY,getResizeArrowDirection as KY,transformElements as $Y,getCursorForResizingElement as mM,getElementWithTransformHandleType as pM,getTransformHandleTypeFromCoords as uM,dragNewElement as hM,dragSelectedElements as ZY,getDragOffsetXY as jY,Scene as gM,Store as qY,CaptureUpdateAction as jt,hitElementBoundingBox as JY,isLineElement as gb,isSimpleArrow as fb,StoreDelta as fM,positionElementsOnGrid as EM,calculateFixedPointForNonElbowArrowBinding as bM,bindOrUnbindBindingElement as QY,mutateElement as Vp,getElementBounds as xM,doBoundsIntersect as eX,isPointInElement as wM,maxBindingDistance_simple as yM,convertToExcalidrawElements as tX,getSnapOutlineMidPoint as Eb,handleFocusPointDrag as nX,handleFocusPointHover as oX,handleFocusPointPointerDown as rX,handleFocusPointPointerUp as iX,maybeHandleArrowPointlikeDrag as Yp,getUncroppedWidthAndHeight as aX,getActiveTextElement as vM,isEligibleFrameChildType as sX,getBindingStrategyForDraggingBindingElementEndpoints as lX,isNonDeletedElement as Xp}from"@excalidraw/element";import{KEYS as Wu,MOBILE_ACTION_BUTTON_BG as c3,updateActiveTool as d3}from"@excalidraw/common";import{getNonDeletedElements as Vc}from"@excalidraw/element";import{fixBindingsAfterDeletion as m3}from"@excalidraw/element";import{LinearElementEditor as t0}from"@excalidraw/element/linearElementEditor";import{newElementWith as Wc}from"@excalidraw/element";import{getContainerElement as n0}from"@excalidraw/element";import{isBoundToContainer as Gc,isElbowArrow as p3,isFrameLikeElement as u3}from"@excalidraw/element";import{getFrameChildren as h3}from"@excalidraw/element";import{getElementsInGroup as Vu,selectGroupsForSelectedElements as g3}from"@excalidraw/element";import{CaptureUpdateAction as Uc}from"@excalidraw/element";import{isDevEnv as QM}from"@excalidraw/common";import{atom as je,createStore as jM}from"jotai";import{createIsolation as qM}from"jotai-scope";var dx=qM();var{useAtom:Fe,useSetAtom:mx,useAtomValue:px,useStore:KX}=dx,ux=dx.Provider,gt=jM();var JM=Hb({"./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 e3=85,On={code:"en",label:"English"},gi=[On,...[{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=>Gb[e.code]>=e3).sort((e,n)=>e.label>n.label?1:-1)],Tc="__test__";QM()&&gi.unshift({code:Tc,label:"test language"},{code:`${Tc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var hi=On,Ic={},Sc=async e=>{if(hi=e,document.documentElement.dir=hi.rtl?"rtl":"ltr",document.documentElement.lang=hi.code,e.code.startsWith(Tc))Ic={};else try{Ic=await JM(`./locales/${hi.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Ic=au}gt.set(gx,e.code)},Fn=()=>hi,hx=(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(hi.code.startsWith(Tc))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=hx(Ic,o)||hx(au,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},gx=je(On.code),Ae=()=>{let e=px(gx);return{t:f,langCode:e}};import t3 from"clsx";import qe from"react";import{THEME as n3}from"@excalidraw/common";import{Fragment as Te,jsx as h,jsxs as R}from"react/jsx-runtime";var xn=e=>"var(--icon-fill-color)",fx=e=>e===n3.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:t3({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},G={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"},Pt={width:40,height:20},lK=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"})]}),G),cK=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"})]}),G),cs=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"})]}),G),Ex=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"})]}),G),bx=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"})]}),G),uu=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"})]}),G),io=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"})})]}),ae),No=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"})]}),ae),xx=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}),wx=M(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"}),yx=M(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"}),vx=M(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"}),dK=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"}),Cc=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}),fi=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}),Ei=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"})]}),G),bi=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"})]}),G),xi=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),G),Pc=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"})]}),G),Bo=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ae),Ix=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"})]}),G),zn=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"})]}),ae),wn=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"})]}),G),Tx=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"})]}),G),Cr=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"})]}),ae),kc=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"})]}),G),hu=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ae),gu=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),ae),Sx=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"})]}),G),Pr=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"}),ae),Oo=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"})]}),ae),ds=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"})]}),ae),ms=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"}),ae),ps=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"})}),{...ae,strokeWidth:1.5}),Cx=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"})]}),G),us=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"}),ae),wi=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"})]}),G),Px=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"})]}),G),mK=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"}),ae),kx=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"}),ae),Mx=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"})]}),ae),Ax=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"})]}),G),Mc=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),hs=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"})]}),ae),Lx=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}),Dx=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}),Ac=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"}),ae),pK=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}),uK=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"),fu=["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"],Hn=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),fu.map(e=>h("path",{d:e},e))]}),G),_x=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),G),Rx=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"})]}),G),Nx=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}),hK=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}),gK=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}),Bx=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"),fK=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"),Eu=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"}),ae),bu=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"}),ae),Ox=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}),Fx=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"}),ae),EK=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"),bK=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}),xK=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"})]}),G),wK=M(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}),yK=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}),zx=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"})]}),Hx=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"})]}),xu=M(Hx,G),wu=M(Hx,{...G,style:{transform:"rotate(180deg)"}}),yu=M(zx,G),vu=M(zx,{...G,style:{transform:"rotate(180deg)"}}),Iu=M(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),Tu=M(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),Su=M(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),Cu=M(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),Gx=M(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),Ux=M(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),Pu=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"})]}),ae),ku=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"})]}),ae),Lc=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"})]}),G),vK=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"),IK=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"),Jt=M(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),TK=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}),SK=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}),CK=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}),Mu=qe.memo(({theme:e})=>M(R(Te,{children:[h("path",{d:"M25 26H111V111H25",fill:xn(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:xn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:xn(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:xn(e),strokeWidth:"2"}),R("g",{fill:fx(e),stroke:xn(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})),Au=qe.memo(({theme:e})=>M(R(Te,{children:[h("path",{d:"M25 26H111V111H25",fill:xn(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:xn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:xn(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:xn(e),strokeWidth:"2"}),R("g",{fill:fx(e),stroke:xn(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})),Wx=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"})}),ae),Vx=M(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),Yx=M(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),Xx=M(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"}),Lu=M(h(Te,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ae),Kx=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ae),$x=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ae),PK=qe.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:xn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Zx=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"})]}),G),jx=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"})]}),G),qx=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"}),ae),Jx=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"}),ae),Qx=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"}),ae),Du=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"})]}),G),_u=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"})]}),G),e1=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"})]}),ae),t1=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"})]}),G),n1=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"})]}),Pt)),o1=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"})}),Pt)),r1=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"})]}),Pt)),i1=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"})]}),Pt)),a1=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"})]}),Pt)),s1=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"})]}),Pt)),l1=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"})]}),Pt)),c1=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"})]}),Pt)),d1=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"})}),Pt)),m1=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"})}),Pt)),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,11 L7,5 M15,11 L7,17"})}),Pt)),u1=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"})}),Pt)),h1=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"})}),Pt)),g1=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"})]}),Pt)),f1=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"})]}),Pt)),E1=M(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),b1=M(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),x1=M(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),w1=M(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),kr=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"})]}),G),y1=M(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"})]})}),G),gs=M(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),o3=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"})]}),G),Dc=o3,v1=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"})]}),G),I1=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"})]}),G),T1=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"})]}),G),S1=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"})]}),G)),C1=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"})]}),G)),P1=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"})]}),G)),_c=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"})]}),G),kK=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}),MK=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"})),k1=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"})]}),G),Ru=M(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"})]}),G),Rc=M(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"})]}),G),M1=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"})]}),G),A1=M(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"})]}),G),AK=M(R(Te,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),G),LK=M(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"})]}),G),L1=M(R(Te,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),G),D1=M(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"})]}),G),Nu=["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"],yi=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Nu.map(e=>h("path",{d:e},e))]}),G),Gn=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"})]}),G),DK=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"})]}),G),_K=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"})]}),G),RK=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"})]}),ae),Mr=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"})]}),G),Un=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),NK=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"})]}),G),BK=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"})]}),G),OK=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"})]}),G),FK=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"})]}),G),Ar=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"})]}),G),_1=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"})]}),G),zK=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"})]}),G),HK=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"})]}),G),Wn=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"})]}),G),GK=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"})]}),G),UK=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"})]}),G),R1=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"})]}),G),N1=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"})]}),G),WK=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"})]}),G),B1=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"})]}),G),O1=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"})]}),G),F1=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"})]}),G),z1=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"})]}),G),Bu=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"})]}),G),Nc=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"})]}),G),H1=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"})]}),G),G1=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"})]}),G),Fo=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"})]}),G),VK=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"})]}),G),U1=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"})]}),{...G,strokeWidth:1.5}),YK=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"})]}),G),XK=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"})]}),G),W1=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"})]}),G),V1=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"})]}),G),zo=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"})]}),G),Ho=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"})]}),G),Go=M(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),G),Bc=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),G),Y1=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),G),X1=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),G),Ou=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"})]}),G),Oc=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"})]}),G),Fu=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"})]}),G),zu=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"})]}),G),KK=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"})]}),G),Hu=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"})})),K1=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"})]}),G),$1=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"})]}),G),Z1=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"})]}),G),$K=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"})]}),G),ZK=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"})]}),G),jK=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"})]}),G),qK=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"})]}),G),Fc=h("div",{style:{width:"1rem",height:"1rem"}}),j1=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"})]}),G),q1=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"})]}),G),J1=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"})]}),G);import Q1 from"clsx";import Uu,{useEffect as a3,useRef as e0,useState as s3}from"react";import{isPromiseLike as l3}from"@excalidraw/common";import r3 from"react";import{jsx as Gu}from"react/jsx-runtime";var i3=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(r3.useRef(Date.now()).current%1600);return Gu("div",{className:`Spinner ${o}`,children:Gu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Gu("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},ao=i3;import{jsx as fs,jsxs as zc}from"react/jsx-runtime";var K=Uu.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=Uu.useRef(null);Uu.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=s3(!1),c=e0(!0),d=async p=>{let u="onClick"in o&&o.onClick?.(p);if(l3(u))try{l(!0),await u}catch(E){if(E instanceof hc)console.warn(E);else throw E}finally{c.current&&l(!1)}};a3(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=e0(null);return o.type==="button"||o.type==="icon"?zc("button",{className:Q1("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&&fs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&fs(ao,{})]}),o.showAriaLabel&&zc("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&fs(ao,{})]}),o.children]}):fs("button",{className:Q1("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&&fs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});K.displayName="IconButton";var Hc=[],O=e=>(Hc=Hc.concat(e),e);import{jsx as E3}from"react/jsx-runtime";var f3=(e,n,t)=>{let o=new Set(ie(e.filter(d=>u3(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(Gc(p)){let u=n0(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=Gc(d)?n0(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&&p3(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),Wc(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,Gc(d)||(r[d.id]=!0),Wc(d,{frameId:null})):Gc(d)&&n.selectedElementIds[d.containerId]?Wc(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=Vu(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=Vu(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...g3({selectedElementIds:r,editingGroupId:c},Vc(l),n,null)}}},o0=(e,n)=>{if(e.editingGroupId){let t=Vu(Vc(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Es=O({name:"deleteSelectedElements",label:"labels.delete",icon:Pr,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=t0.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(p=>p.id===c.id?Wc(p,{isDeleted:!0}):p),m=o0(n,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:Uc.IMMEDIATELY}}return t0.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:Uc.IMMEDIATELY}}let{elements:r,appState:i}=f3(e,n,o);return m3(r,r.filter(a=>a.isDeleted)),i=o0(i,r),{elements:r,appState:{...i,activeTool:d3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Me(Vc(e),n)?Uc.IMMEDIATELY:Uc.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===Wu.BACKSPACE||e.key===Wu.DELETE)&&!e[Wu.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=it()==="mobile";return E3(K,{type:"button",icon:Pr,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Me(Vc(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?c3:{}}})}});import{KEYS as vi,CODES as Ii,isDarwin as Yc}from"@excalidraw/common";import{moveOneLeft as b3,moveOneRight as x3,moveAllLeft as w3,moveAllRight as y3}from"@excalidraw/element";import{CaptureUpdateAction as Xc}from"@excalidraw/element";import{isDarwin as r0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,r0?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,r0?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 Kc}from"react/jsx-runtime";var Yu=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:wu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:b3(e,n,o.scene),appState:n,captureUpdate:Xc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[vi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ii.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>Kc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:wu})}),Xu=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:xu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:x3(e,n,o.scene),appState:n,captureUpdate:Xc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[vi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ii.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>Kc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:xu})}),Ku=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:vu,trackEvent:{category:"element"},perform:(e,n)=>({elements:w3(e,n),appState:n,captureUpdate:Xc.IMMEDIATELY}),keyTest:e=>Yc?e[vi.CTRL_OR_CMD]&&e.altKey&&e.code===Ii.BRACKET_LEFT:e[vi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ii.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>Kc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Yc?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:vu})}),$u=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:yu,trackEvent:{category:"element"},perform:(e,n)=>({elements:y3(e,n),appState:n,captureUpdate:Xc.IMMEDIATELY}),keyTest:e=>Yc?e[vi.CTRL_OR_CMD]&&e.altKey&&e.code===Ii.BRACKET_RIGHT:e[vi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ii.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>Kc("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Yc?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:yu})});import{getNonDeletedElements as v3}from"@excalidraw/element";import{LinearElementEditor as I3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as T3,isTextElement as S3}from"@excalidraw/element";import{arrayToMap as C3,KEYS as i0}from"@excalidraw/common";import{selectGroupsForSelectedElements as P3}from"@excalidraw/element";import{CaptureUpdateAction as k3}from"@excalidraw/element";var Zu=O({name:"selectAll",label:"labels.selectAll",icon:B1,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(S3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...P3({editingGroupId:null,selectedElementIds:r},v3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&T3(e[0])?new I3(e[0],C3(e)):null},captureUpdate:k3.IMMEDIATELY}},keyTest:e=>e[i0.CTRL_OR_CMD]&&e.key===i0.A});import{DEFAULT_GRID_SIZE as a0,KEYS as s0,MOBILE_ACTION_BUTTON_BG as M3,arrayToMap as l0}from"@excalidraw/common";import{getNonDeletedElements as c0}from"@excalidraw/element";import{LinearElementEditor as A3}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as L3,getSelectionStateForElements as D3}from"@excalidraw/element";import{syncMovedIndices as _3}from"@excalidraw/element";import{duplicateElements as R3}from"@excalidraw/element";import{CaptureUpdateAction as d0}from"@excalidraw/element";import{jsx as N3}from"react/jsx-runtime";var ju=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:ds,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=A3.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:d0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=R3({type:"in-place",elements:e,idsOfElementsToDuplicate:l0(L3(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+a0/2,y:a.y+a0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:_3(i,l0(r)),appState:{...n,...D3(r,c0(i),n)},captureUpdate:d0.IMMEDIATELY}},keyTest:e=>e[s0.CTRL_OR_CMD]&&e.key===s0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=it()==="mobile";return N3(K,{type:"button",icon:ds,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Me(c0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?M3:{}}})}});import{pointFrom as h4}from"@excalidraw/math";import{useEffect as Eh,useMemo as wh,useRef as bh,useState as g4}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as f4,COLOR_PALETTE as E4,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Ew,DEFAULT_ELEMENT_BACKGROUND_PICKS as b4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as x4,DEFAULT_ELEMENT_STROKE_PICKS as w4,ARROW_TYPE as nn,DEFAULT_FONT_FAMILY as y4,DEFAULT_FONT_SIZE as v4,FONT_FAMILY as I4,ROUNDNESS as hd,STROKE_WIDTH_KEYS as T4,VERTICAL_ALIGN as pd,KEYS as _i,randomInteger as S4,arrayToMap as yh,getFontFamilyString as C4,getLineHeight as P4,isTransparent as k4,getStrokeWidthByKey as bw,reduceToCommonValue as M4,invariant as fd,FONT_SIZES as ud}from"@excalidraw/common";import{canBecomePolygon as A4,getNonDeletedElements as xw,isNonDeletedElement as L4}from"@excalidraw/element";import{bindBindingElement as pw,calculateFixedPointForElbowArrowBinding as uw,updateBoundElements as D4}from"@excalidraw/element";import{LinearElementEditor as Dr}from"@excalidraw/element/linearElementEditor";import{newElementWith as nt}from"@excalidraw/element";import{getArrowheadForPicker as hw}from"@excalidraw/element";import{getBoundTextElement as jo,redrawTextBoundingBox as As}from"@excalidraw/element";import{isArrowElement as gd,isBoundToContainer as _4,isElbowArrow as ww,isLinearElement as xh,isLineElement as gw,isTextElement as Bt,isUsingAdaptiveRadius as R4}from"@excalidraw/element";import{hasStrokeColor as N4}from"@excalidraw/element";import{updateElbowArrowPoints as B4,CaptureUpdateAction as Je,toggleLinePolygonState as O4}from"@excalidraw/element";import{deriveStylesPanelMode as F4}from"@excalidraw/common";import{isDevEnv as B3}from"@excalidraw/common";var O3=new Set(["command_palette","export"]),Ne=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!O3.has(e)||B3())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 G3 from"clsx";import F3 from"clsx";import{forwardRef as z3}from"react";import{jsx as H3}from"react/jsx-runtime";var m0=z3((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return H3("button",{type:"button",ref:n,title:t,"data-testid":r,className:F3(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as W3,jsx as qu,jsxs as U3}from"react/jsx-runtime";var Vt=e=>qu(W3,{children:e.options.map(n=>e.type==="button"?qu(m0,{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):U3("label",{className:G3({active:e.value===n.value}),title:n.text,children:[qu("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 V0}from"radix-ui";import Y0 from"clsx";import{memo as d5,useRef as X0,useEffect as m5}from"react";import{applyDarkModeFilter as p5,COLOR_OUTLINE_CONTRAST_THRESHOLD as U0,COLOR_PALETTE as K0,DEFAULT_ELEMENT_BACKGROUND_PICKS as u5,DEFAULT_ELEMENT_STROKE_PICKS as h5,isColorDark as W0,isWritableElement as g5,THEME as f5}from"@excalidraw/common";import{jsx as V3}from"react/jsx-runtime";var $c=()=>V3("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as j3,useLayoutEffect as q3,useRef as J3}from"react";import{createPortal as Q3}from"react-dom";import{EVENT as Uo,isColorDark as eA,KEYS as tA,MIME_TYPES as nA,THEME as oA,removeDarkModeFilter as rA,rgbToHex as iA}from"@excalidraw/common";import p0 from"react";var Ju=p0.createContext(null),fe=()=>p0.useContext(Ju);import{useState as Y3,useLayoutEffect as u0}from"react";import{THEME as X3}from"@excalidraw/common";var Zc=e=>{let[n,t]=Y3(null),o=ge(),{theme:r}=fe(),{container:i}=De();return u0(()=>{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===X3.DARK))},[n,r,o.formFactor,e?.className]),u0(()=>{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 K3}from"react";import{EVENT as jc}from"@excalidraw/common";function Ti(e,n,t){K3(()=>{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(jc.POINTER_DOWN,o),document.addEventListener(jc.TOUCH_START,o),()=>{document.removeEventListener(jc.POINTER_DOWN,o),document.removeEventListener(jc.TOUCH_START,o)}},[e,n,t])}import{useRef as $3}from"react";var Si=e=>{let n=$3(e);return Object.assign(n.current,e),n.current};import{clamp as Z3}from"@excalidraw/math";var h0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return Z3(r,0,Math.max(0,t-n))},qc=({cursor:e,element:n,container:t,gap:o})=>({left:h0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:h0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as sA}from"react/jsx-runtime";var g0=Nu.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),aA=`url(data:${nA.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">${g0}</g><g stroke="#1b1b1f" stroke-width="1.25">${g0}</g></svg>`)}) 2 21, auto`,Nt=je(null),f0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=Zc({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=fe(),a=Ci(),s=It(),l=ie(a,i),c=Si({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=De();q3(()=>{if(r)return r.style.cursor=aA,()=>{r.style.cursor=""}},[r]),j3(()=>{let p=m.current;if(!p||!s.canvas||!r)return;let u=!1,E=s.canvas.getContext("2d"),g=({clientX:P,clientY:A})=>{let L=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(A-i.offsetTop)*window.devicePixelRatio,1,1).data;return iA(L[0],L[1],L[2])},b=P=>i.theme===oA.DARK?rA(P):P,y=({clientX:P,clientY:A,altKey:L})=>{let{top:_,left:k}=qc({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 D=g({clientX:P,clientY:A});u&&c.onChange(o,b(D),c.selectedElements,{altKey:L}),p.style.background=D,p.style.setProperty("--eye-dropper-preview-border-color",eA(D)?"#fff":"#222")},w=()=>{c.onCancel()},x=(P,A)=>{c.onSelect(P,A)},v=P=>{u=!0,P.stopImmediatePropagation()},T=P=>{u=!1,d?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===tA.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(Uo.KEYDOWN,C),r.addEventListener(Uo.POINTER_DOWN,v),r.addEventListener(Uo.POINTER_UP,T),window.addEventListener("pointermove",y,{passive:!0}),window.addEventListener(Uo.BLUR,w),()=>{u=!1,r.removeEventListener(Uo.KEYDOWN,C),r.removeEventListener(Uo.POINTER_DOWN,v),r.removeEventListener(Uo.POINTER_UP,T),window.removeEventListener("pointermove",y),window.removeEventListener(Uo.BLUR,w)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let m=J3(null);return Ti(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?Q3(sA("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as Qu}from"radix-ui";import mA from"clsx";import pA from"react";import{isInteractive as uA}from"@excalidraw/common";import lA from"react";import cA from"clsx";import{jsx as dA}from"react/jsx-runtime";var ze=lA.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>dA("div",{className:cA("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as eh,jsxs as hA}from"react/jsx-runtime";var so=pA.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=ge(),p=m.formFactor==="phone"&&!m.isLandscape;return eh(Qu.Portal,{container:n,children:hA(Qu.Content,{ref:d,className:mA("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&&!uA(document.activeElement)&&n.focus(),r()},children:[eh(ze,{padding:3,style:o,children:t}),eh(Qu.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 gA,useCallback as th}from"react";var Jc=()=>document.querySelector(".excalidraw-wysiwyg"),Qc=()=>{let e=Jc();return e?{start:e.selectionStart,end:e.selectionEnd}:null},bs=e=>{setTimeout(()=>{let n=Jc();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},xs=(e,n,t,o)=>{n&&o&&o();let r=n&&t?Qc():null;e(),n&&t&&bs(r)},E0=()=>{let[e,n]=gA(null),t=th(()=>{let i=Qc();n(i)},[]),o=th(()=>{setTimeout(()=>{let i=Jc();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=th(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},b0=(e=100)=>{let n=Jc();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import w0 from"clsx";import{useCallback as bA,useEffect as oh,useRef as y0,useState as v0}from"react";import{KEYS as rh,normalizeInputColor as xA}from"@excalidraw/common";import{isTransparent as fA,MAX_CUSTOM_COLORS_USED_IN_CANVAS as EA}from"@excalidraw/common";var Wo=({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},ws=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),nh=({color:e,palette:n})=>!Object.values(n).flat().includes(e),x0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!fA(s)&&nh({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,EA)},Qt=je(null);import{Fragment as wA,jsx as ys,jsxs as ih}from"react/jsx-runtime";var I0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=ge(),[a,s]=v0(e),[l,c]=v0(null),[d,m]=Fe(Qt);oh(()=>{s(e)},[e]);let p=bA(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=y0(null),E=y0(null);oh(()=>{u.current&&u.current.focus()},[d]);let[g,b]=Fe(Nt);return oh(()=>()=>{b(null)},[b]),ih("div",{className:"color-picker__input-label-container",children:[ih("div",{className:w0("color-picker__input-label",{"has-error":l}),children:[ys("div",{className:"color-picker__input-hash",children:"#"}),ys("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!==rh.TAB&&(y.key===rh.ESCAPE&&E.current?.focus(),y.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&ih(wA,{children:[ys("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),ys("div",{ref:E,className:w0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(y=>y?null:{keepOpenOnAlt:!1,onSelect:w=>n(w),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${rh.I.toLocaleUpperCase()} or ${N("Alt")} `,children:yi})]})]}),l&&ys("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import lh,{useEffect as ch,useImperativeHandle as JA,useState as QA}from"react";import{EVENT as O0}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as e5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as t5,KEYS as n5}from"@excalidraw/common";import MA from"clsx";import{useEffect as AA,useRef as LA}from"react";import{applyDarkModeFilter as DA,THEME as _A}from"@excalidraw/common";import{isColorDark as yA}from"@excalidraw/common";import{jsxs as IA}from"react/jsx-runtime";var vA=({color:e,keyLabel:n,isShade:t=!1})=>IA("div",{className:"color-picker__button__hotkey-label",style:{color:yA(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),Pi=vA;import{createContext as TA,useContext as SA,useEffect as CA,useMemo as T0,useRef as S0,useState as PA}from"react";import{colorToHex as C0,isTransparent as kA}from"@excalidraw/common";var Lr="excalidraw-color-dnd-ghost",P0="excalidraw-color-dnd-active",k0=10,M0=100,A0=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=C0(e);return t!==null&&t===C0(n)},ah=TA(null),en=()=>SA(ah),L0=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=PA(null),i=S0(null),a=S0({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=T0(()=>{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 D=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort(($,H)=>Number($.dataset.topPickIndex)-Number(H.dataset.topPickIndex));if(!D.length)return!1;l.slotRects=D.map($=>$.getBoundingClientRect());let[F,Y]=l.slotRects;l.slotSpan=Y?Y.left-F.left:F.width+4;let z=k.getBoundingClientRect(),W=Math.max(Math.abs(l.slotSpan)/2,10);return l.hitRect={left:z.left-W,right:z.right+W,top:z.top-14,bottom:z.bottom+14},!0},m=(k,D)=>{l?.ghost&&(l.ghost.style.transform=`translate(${k-l.ghostW/2}px, ${D-l.ghostH/2}px)`)},p=(k,D,F,Y)=>{l?.ghost&&(l.ghostW!==k||l.ghostH!==D)&&(l.ghostW=k,l.ghostH=D,l.ghost.style.width=`${k}px`,l.ghost.style.height=`${D}px`,m(F,Y))},u=(k,D)=>{if(!l)return;let{sourceRect:F,sourceEl:Y,color:z}=l,W=document.createElement("div");W.className=Lr;let $=document.createElement("div");if($.className=`${Lr}__swatch`,kA(z))$.classList.add("is-transparent");else{let H=getComputedStyle(Y).backgroundColor;$.style.backgroundColor=H&&H!=="rgba(0, 0, 0, 0)"?H:z}W.appendChild($),document.body.appendChild(W),l.ghost=W,l.ghostW=F.width,l.ghostH=F.height,W.style.width=`${F.width}px`,W.style.height=`${F.height}px`,m(k,D),requestAnimationFrame(()=>{l?.ghost===W&&W.classList.add(`${Lr}--lifted`)}),document.body.classList.add(P0),l.activated=!0,c()},E=(k,D)=>{if(!l?.hitRect)return;let{hitRect:F,slotRects:Y}=l,z=null,W=null;if(k>=F.left&&k<=F.right&&D>=F.top&&D<=F.bottom){let $=0,H=1/0;if(Y.forEach((re,B)=>{let U=Math.abs(k-(re.left+re.width/2));U<H&&(H=U,$=B)}),l.origin.kind==="swatch"){let re=a.current.picks.findIndex(B=>A0(B,l.color));re!==-1?W=re:z=$}else z=$}if(z!==l.overIndex||W!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=W;let{ghost:$}=l;$&&($.classList.toggle(`${Lr}--over`,z!==null),$.classList.toggle(`${Lr}--blocked`,W!==null)),c()}if(z!==null){let $=l.slotRects[z];p($.width,$.height,k,D)}else p(l.sourceRect.width,l.sourceRect.height,k,D)},g=k=>{if(!l?.ghost)return;let{ghost:D}=l;l.ghost=null,D.classList.add(`${Lr}--dropping`);let F=k.rect;F&&(D.style.width=`${F.width}px`,D.style.height=`${F.height}px`,D.style.transform=`translate(${F.left}px, ${F.top}px)`),window.setTimeout(()=>{D.classList.add(`${Lr}--fade`)},160),window.setTimeout(()=>{D.remove()},340)},b=()=>{let k=i.current;if(!k||!l?.activated)return;let D=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let F of D)F.style.transition="none",F.style.transform="none";k.offsetWidth;for(let F of D)F.style.transition=""},y=()=>{let k=D=>{D.preventDefault(),D.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",L,!0)},x=()=>{w(),document.body.classList.remove(P0),l?.activationTimer!=null&&window.clearTimeout(l.activationTimer),l=null,r(null)},v=k=>{l&&(b(),l.ghost&&(k?g({rect:l.sourceRect}):(l.ghost.remove(),l.ghost=null)),x())},T=(k,D)=>{if(!(!l||l.activated)){if(!d()){x();return}u(k,D),E(k,D)}},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)<k0){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let D=performance.now()-l.startTime;if(D<M0){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=k0&&T(l.lastX,l.lastY))},M0-D));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:D,origin:F,color:Y,slotRects:z}=l,{picks:W,onPicksChange:$}=a.current;if(b(),D!==null){if(F.kind==="swatch"){if(!W.some(H=>A0(H,Y))){let H=[...W];H[D]=Y,$(H)}}else if(F.index!==D){let H=[...W],[re]=H.splice(F.index,1);H.splice(D,0,re),$(H)}g({rect:z[D]})}else g({rect:l.sourceRect});x()},A=k=>{l&&k.pointerId===l.pointerId&&v(!0)},L=k=>{l?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),v(!0))};return{begin:(k,D,F)=>{!a.current.enabled||l||k.button!==0||!D||(l={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:D,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",A,!0),window.addEventListener("keydown",L,!0))},destroy:()=>v(!1)}},[]);return CA(()=>()=>s.destroy(),[s]),T0(()=>({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 sh,jsxs as RA}from"react/jsx-runtime";var D0=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=Fe(Qt),s=en(),l=LA(null);return AA(()=>{l.current&&l.current.focus()},[t,i]),sh("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let m=DA(c,e===_A.DARK);return RA("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:MA("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:[sh("div",{className:"color-picker__button-outline"}),sh(Pi,{color:m,keyLabel:d+1})]},d)})})};import NA from"clsx";import{useEffect as BA,useRef as OA}from"react";import{applyDarkModeFilter as FA,isColorDark as zA,THEME as HA}from"@excalidraw/common";import{jsx as ed,jsxs as UA}from"react/jsx-runtime";var GA=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=Wo({color:t,palette:n}),[l,c]=Fe(Qt),d=en(),m=OA(null);return BA(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),ed("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 ed("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=ws[E],y=FA(g,e===HA.DARK),w=f(`colors.${p.replace(/\d+/,"")}`,null,"");return UA("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:NA("color-picker__button color-picker__button--large",{"has-outline":!zA(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:[ed("div",{className:"color-picker__button-outline"}),i&&ed(Pi,{color:y,keyLabel:b})]},p)})})},_0=GA;import{jsx as VA}from"react/jsx-runtime";var WA=({children:e})=>VA("div",{className:"color-picker__heading",children:e}),ki=WA;import YA from"clsx";import{useEffect as XA,useRef as KA}from"react";import{applyDarkModeFilter as $A,THEME as ZA}from"@excalidraw/common";import{jsx as vs,jsxs as R0}from"react/jsx-runtime";var N0=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=Wo({color:n||"transparent",palette:o}),[a,s]=Fe(Qt),l=en(),c=KA(null);if(XA(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:m}=i,p=o[d];if(Array.isArray(p))return vs("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=$A(u,e===ZA.DARK);return R0("button",{ref:E===m&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:YA("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:[vs("div",{className:"color-picker__button-outline"}),r&&vs(Pi,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return R0("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[vs("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),vs("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 Mi,COLOR_PALETTE as jA,KEYS as Is}from"@excalidraw/common";var td=(e,n,t)=>{let o=Math.ceil(t/Mi);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+Mi;return r>=t?n%Mi:r}case"ArrowUp":{let r=n-Mi,i=r<0?Mi*o+r:r;return i>=t?void 0:i}}},qA=({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(ws.includes(e.key)){let l=ws.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},B0=({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[Is.CTRL_OR_CMD])return!1;if(e.key===Is.ESCAPE)return d(e),!0;if(e.key===Is.ALT)return c(!0),!0;if(e.key===Is.I)return c(),!0;let p=Wo({color:o,palette:t});if(e.key===Is.TAB){let u={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[v,T])=>(T&&x.push(v),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(([v,T])=>Array.isArray(T)?T.includes(o):T===o?v:null)||r(jA.black)),e.preventDefault(),e.stopPropagation(),!0}if(qA({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=td(e.key,u,Mi);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=td(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=td(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=td(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as lo,jsxs as nd}from"react/jsx-runtime";var F0=lh.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]=lh.useState(()=>o==="canvasBackground"?[]:x0(r,o,i)),[b,y]=Fe(Qt),w=en(),x=Wo({color:n,palette:i});ch(()=>{if(!b){let P=!!n&&nh({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[v,T]=QA(x?.shade??(o==="elementBackground"?e5:t5));ch(()=>{x?.shade!=null&&T(x.shade);let P=A=>{A.key===n5.ALT&&c(!1)};return document.addEventListener(O0.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(O0.KEYUP,P,{capture:!0})}},[x,c]);let C=lh.useRef(null);return JA(u,()=>C.current),ch(()=>{C?.current?.focus()},[]),lo("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:nd("div",{ref:C,onKeyDown:P=>{B0({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:c,customColors:g,setActiveColorPickerSection:y,updateData:a,activeShade:v,onEscape:d,excludedColors:p})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&lo("div",{className:"color-picker__title",children:E}),!!g.length&&nd("div",{children:[lo(ki,{children:f("colorPicker.mostUsedCustomColors")}),lo(D0,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),nd("div",{children:[lo(ki,{children:f("colorPicker.colors")}),lo(_0,{theme:e,color:n,palette:i,onChange:t,activeShade:v,showHotKey:m,excludedColors:p})]}),nd("div",{children:[lo(ki,{children:f("colorPicker.shades")}),lo(N0,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,w&&lo("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import z0 from"clsx";import{ContextMenu as Ts}from"radix-ui";import{applyDarkModeFilter as o5,COLOR_OUTLINE_CONTRAST_THRESHOLD as r5,DEFAULT_CANVAS_BACKGROUND_PICKS as i5,DEFAULT_ELEMENT_BACKGROUND_PICKS as a5,DEFAULT_ELEMENT_STROKE_PICKS as s5,isColorDark as l5,THEME as c5}from"@excalidraw/common";import{jsx as Vo,jsxs as H0}from"react/jsx-runtime";var G0=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=en(),l=s?.dragState??null,{container:c}=De(),d;if(t==="elementStroke"&&(d=s5),t==="elementBackground"&&(d=a5),t==="canvasBackground"&&(d=i5),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=H0("div",{className:z0("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&Vo("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:Vo("rect",{})}),d.map((u,E)=>{let g=m(E),b=o5(u,e===c5.DARK);return Vo("button",{className:z0("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!l5(u,r5),"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:Vo("div",{className:"color-picker__button-outline"})},u)})]});return i?H0(Ts.Root,{children:[Vo(Ts.Trigger,{asChild:!0,children:p}),Vo(Ts.Portal,{container:c,children:Vo(Ts.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:Vo(Ts.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as tn,jsxs as od}from"react/jsx-runtime";var E5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=K0,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=De(),m=it(),p=m!=="full",u=m==="mobile",[,E]=Fe(Qt),[g,b]=Fe(Nt),y=od("div",{children:[tn(ki,{children:f("colorPicker.hexCode")}),tn(I0,{color:n||"",label:o,onChange:v=>{t(v)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),w=X0(null),x=()=>{w.current?.focus()};return tn(so,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:v=>{if(v.target instanceof HTMLElement&&v.target.closest(".color-picker__context-menu")){v.preventDefault();return}g5(v.target)||(v.target instanceof HTMLElement&&v.target.matches(":active")?window.addEventListener("pointerup",x,{once:!0}):x()),v.preventDefault()},onPointerDownOutside:v=>{g&&v.preventDefault()},onClose:()=>{s()===e&&a({openPopup:null}),E(null),l.editingTextElement&&setTimeout(()=>{let v=document.querySelector(".excalidraw-wysiwyg");v&&v.focus()},0)},children:i?tn(F0,{ref:w,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:v=>{let T=l.editingTextElement?Qc():null;t(v),l.editingTextElement&&T&&bs(T)},onEyeDropperToggle:v=>{b(T=>v?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):v===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:v=>{g?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!u,children:y}):y})},b5=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=it(),l=s!=="full",c=s==="mobile",d=en(),m=n?p5(n,o===f5.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&b0(),i()};return od(V0.Trigger,{type:"button",className:Y0("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!W0(n,U0),"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:[tn("div",{className:"color-picker__button-outline",children:!n&&_x}),l&&n&&r==="stroke"&&tn("div",{className:"color-picker__button-background",children:tn("span",{style:{color:m&&W0(m,U0)?"#fff":"#111"},children:$1})})]})},w5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=K0,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let m=X0(l.openPopup);m5(()=>{m.current=l.openPopup},[l.openPopup]);let u=it()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?h5:u5),y=L0({enabled:E,picks:b,onPicksChange:w=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:w}})}});return tn(ah.Provider,{value:E?y:null,children:od("div",{role:"dialog","aria-modal":"true",className:Y0("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&tn(G0,{theme:l.theme,activeColor:n,onChange:w=>{t(w),b5(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&&tn($c,{}),od(V0.Root,{open:l.openPopup===e,onOpenChange:w=>{w&&s({openPopup:e})},children:[tn(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&&tn(E5,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},y5=(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,Ai=d5(w5,y5);import{Popover as Z5}from"radix-ui";import j5 from"clsx";import q5,{useCallback as J5,useMemo as Q5}from"react";import{FONT_FAMILY as uh}from"@excalidraw/common";import z5,{useMemo as $o,useState as H5,useRef as q0,useEffect as J0,useCallback as Q0}from"react";import{arrayToList as G5,debounce as U5,FONT_FAMILY as Zo,getFontFamilyString as W5}from"@excalidraw/common";import v5 from"clsx";import I5 from"react";import{jsx as T5,jsxs as S5}from"react/jsx-runtime";var rd=I5.forwardRef(({className:e,placeholder:n,onChange:t},o)=>S5("div",{className:v5("QuickSearch__wrapper",e),children:[Wn,T5("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import C5 from"clsx";import{Children as P5}from"react";import{jsx as $0}from"react/jsx-runtime";var id=({className:e,placeholder:n,children:t})=>{let o=!P5.count(t);return $0("div",{className:C5("ScrollableList__wrapper",e),role:"menu",children:o?$0("div",{className:"empty",children:n}):t})};import{jsx as k5,jsxs as M5}from"react/jsx-runtime";var Z0=({children:e,className:n="",style:t,title:o})=>M5("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&k5("p",{className:"dropdown-menu-group-title",children:o}),e]}),Ss=Z0;Z0.displayName="DropdownMenuGroup";import{THEME as O5}from"@excalidraw/common";import{DropdownMenu as F5}from"radix-ui";import A5,{useContext as L5}from"react";import{composeEventHandlers as D5}from"@excalidraw/common";var dh=A5.createContext({}),Yo=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),ad=e=>{let n=L5(dh);return D5(e,t=>{n.onSelect?.(t)})};import{jsx as _5}from"react/jsx-runtime";var Cs=({children:e,...n})=>_5("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as N5,jsx as Ps,jsxs as B5}from"react/jsx-runtime";var R5=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=ge();return B5(N5,{children:[n&&Ps("div",{className:"dropdown-menu-item__icon",children:n}),Ps("div",{style:e,className:"dropdown-menu-item__text",children:Ps(Cs,{children:o})}),r&&Ps("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Ps("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Xo=R5;import{jsx as sd}from"react/jsx-runtime";var mh=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=ad(s);return sd(F5.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:sd("button",{...l,value:t,className:Yo(i,a),title:l.title??l["aria-label"],children:sd(Xo,{icon:e,shortcut:r,badge:n,children:o})})})};mh.displayName="DropdownMenuItem";var Li={GREEN:"green",RED:"red",BLUE:"blue"},ld=({type:e=Li.BLUE,children:n})=>{let{theme:t}=Ko(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===O5.LIGHT?"1.5px solid white":"none"};switch(e){case Li.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Li.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Li.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return sd("div",{className:"DropDownMenuItemBadge",style:o,children:n})};ld.displayName="DropdownMenuItemBadge";mh.Badge=ld;var Yt=mh;import{KEYS as Di}from"@excalidraw/common";var j0=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[Di.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Di.F)return n.current?.focus(),!0;if(e.key===Di.ESCAPE)return r(),!0;if(e.key===Di.ENTER)return t?.value&&i(t.value),!0;if(e.key===Di.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===Di.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as co,jsxs as X5}from"react/jsx-runtime";var V5=e=>{switch(e){case Zo.Excalifont:case Zo.Virgil:return zn;case Zo.Nunito:case Zo.Helvetica:return gs;case Zo["Lilita One"]:return y1;case Zo["Comic Shanns"]:case Zo.Cascadia:return Dc;default:return gs}},Y5=(e,n)=>Object.entries(Zo).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",ew=z5.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=De(),l=It(),{fonts:c}=l,{showDeprecatedFonts:d}=yn(),m=it(),[p,u]=H5(""),E=q0(null),g=$o(()=>Array.from(ro.registered.entries()).filter(([k,{metadata:D}])=>!D.private&&!D.fallback).map(([k,{metadata:D,fontFaces:F}])=>{let Y={value:k,icon:V5(k),text:Y5(k,F)};return D.deprecated&&Object.assign(Y,{deprecated:D.deprecated,badge:{type:Li.RED,placeholder:f("fontList.badge.old")}}),Y}).sort((k,D)=>k.text.toLowerCase()>D.text.toLowerCase()?1:-1),[]),b=$o(()=>new Set(c.getSceneFamilies()),[e]),y=$o(()=>g.filter(k=>b.has(k.value)),[g,b]),w=$o(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=$o(()=>G5([...y,...w].filter(k=>k.text?.toLowerCase().includes(p))),[y,w,p]),v=$o(()=>{let k;return n?k=x.find(D=>D.value===n):e&&(k=x.find(D=>D.value===e)),!k&&p&&(x[0]?.value?o(x[0].value):r()),k},[n,e,p,x,o,r]),T=Q0(k=>{let D=null;if(l.state.editingTextElement){let F=document.querySelector(".excalidraw-wysiwyg");F&&(D={start:F.selectionStart,end:F.selectionEnd})}t(k),l.state.editingTextElement&&D&&setTimeout(()=>{let F=document.querySelector(".excalidraw-wysiwyg");F&&D&&(F.focus(),F.selectionStart=D.start,F.selectionEnd=D.end)},0)},[t,l.state.editingTextElement]),C=Q0(k=>{j0({event:k,inputRef:E,hoveredFont:v,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[v,x,T,o,a]);J0(()=>(i(),()=>{a()}),[]);let P=$o(()=>x.filter(k=>b.has(k.value)),[x,b]),A=$o(()=>x.filter(k=>!b.has(k.value)),[x,b]),L=({font:k,order:D})=>{let F=q0(null),Y=k.value===v?.value,z=k.value===e;return J0(()=>{Y&&(D===0?F.current?.scrollIntoView?.({block:"end"}):F.current?.scrollIntoView?.({block:"nearest"}))},[Y,D]),co("button",{ref:F,type:"button",value:k.value,className:Yo("",z,Y),title:k.text,tabIndex:z?0:-1,onClick:W=>{T(Number(W.currentTarget.value))},onMouseMove:()=>{v?.value!==k.value&&o(k.value)},children:co(Xo,{icon:k.icon,badge:k.badge&&co(ld,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:W5({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(co(Ss,{title:f("fontList.sceneFonts"),children:P.map((k,D)=>co(L,{font:k,order:D},k.value))},"group_1")),A.length&&_.push(co(Ss,{title:f("fontList.availableFonts"),children:A.map((k,D)=>co(L,{font:k,order:D+P.length},k.value))},"group_2")),X5(so,{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"&&co(rd,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:U5(u,20)}),co(id,{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 K5}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as $5}from"@excalidraw/common";import{jsx as ph}from"react/jsx-runtime";var tw=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Ue(),r=t?{...$5,width:"2rem",height:"2rem"}:{};return ph(K5.Trigger,{asChild:!0,children:ph("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:ph(K,{type:"toggle",icon:wn,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 ks,jsxs as nw}from"react/jsx-runtime";var ow=[{value:uh.Excalifont,icon:zn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:uh.Nunito,icon:gs,text:f("labels.normal"),testId:"font-family-normal"},{value:uh["Comic Shanns"],icon:Dc,text:f("labels.code"),testId:"font-family-code"}],Tee=new Set(ow.map(e=>e.value));var rw=q5.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=Q5(()=>ow,[]),c=J5(d=>{d&&o(d)},[o]);return nw("div",{role:"dialog","aria-modal":"true",className:j5("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&ks("div",{className:"buttonList",children:ks(Vt,{type:"button",options:l,value:n,onClick:c})}),!s&&ks($c,{}),nw(Z5.Root,{open:e,onOpenChange:a,children:[ks(tw,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&ks(ew,{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 hh}from"radix-ui";import o4 from"clsx";import lw,{useEffect as r4,useMemo as i4}from"react";import{isArrowKey as a4,KEYS as mo}from"@excalidraw/common";import{jsx as e4}from"react/jsx-runtime";var cd=({className:e,icon:n,size:t="1em"})=>e4("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 n4,jsx as iw,jsxs as aw}from"react/jsx-runtime";var t4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>aw(n4,{children:[aw("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&iw(cd,{icon:n?Y1:Bc})]}),n&&iw("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),Ms=t4;import{jsx as Vn,jsxs as md}from"react/jsx-runtime";var s4=je(!1),dd=4,l4="default",c4=e=>e.flatMap(n=>n.options),sw=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},d4=(e,n)=>e.some(t=>t.options.some(n)),m4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/dd)},(t,o)=>n.options.slice(o*dd,o*dd+dd)));function p4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=De(),[s,l]=Fe(s4),c=[...e,...n],d=c4(c),m=m4([...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===mo.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(a4(g.key)){let y=Fn().rtl,w=d.findIndex(x=>x.value===t);if(w!==-1){let x=d.length,v=w;switch(g.key){case(y?mo.ARROW_LEFT:mo.ARROW_RIGHT):v=(w+1)%x;break;case(y?mo.ARROW_RIGHT:mo.ARROW_LEFT):v=(x+w-1)%x;break;case mo.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],L=A[Math.min(P,A.length-1)]??d[w];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case mo.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],L=A[Math.min(P,A.length-1)]??d[w];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(d[v].value)}g.preventDefault()}else(g.key===mo.ESCAPE||g.key===mo.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};r4(()=>{d4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>Vn("div",{className:"picker-content",children:g.map(b=>md("button",{type:"button",className:o4("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&&Vn("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,y)=>b.name===l4?Vn(lw.Fragment,{children:u(b.options)},`${b.name}-${y}`):md("div",{className:"picker-section",children:[Vn("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${y}`));return Vn(hh.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:md("div",{className:"picker-sections",children:[E(e),n.length>0&&Vn(Ms,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:Vn("div",{className:"picker-sections",children:E(n)})})]})})}function gh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=lw.useState(!1),s=i4(()=>sw(t,l=>l.value===e)??sw(o??[],l=>l.value===e),[t,o,e]);return Vn("div",{children:md(hh.Root,{open:i,onOpenChange:l=>a(l),children:[Vn(hh.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&Vn(p4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import cw,{useEffect as u4}from"react";import{jsx as fh,jsxs as dw}from"react/jsx-runtime";var mw=({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=cw.useRef(null),d=cw.useRef(null);return u4(()=>{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]),dw("label",{className:"control-label",children:[e,dw("div",{className:"range-wrapper",children:[fh("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}),fh("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),fh("div",{className:"zero-label",children:a})]})]})};import{Fragment as bd,jsx as Q,jsxs as ft}from"react/jsx-runtime";var yw=.1,_r=e=>{let n=F4(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Tt=(e,n,t,o=!1)=>{let r=yh(ie(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(L4(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},lt=function(e,n,t,o,r){let i=n.state.editingTextElement,a=xw(e),s=null;if(i&&(s=t(i)),!s)if(Me(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(m=>o(m));s=M4(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},z4=(e,n,t)=>_4(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}),vh=(e,n,t,o,r)=>{let i=new Set,a=Tt(e,n,s=>{if(Bt(s)){let l=o(s);i.add(l);let c=nt(s,{fontSize:l});return As(c,t.scene.getContainerElement(s),t.scene),c=z4(s,c,t.scene),c}return s},!0);return ie(e,n,{includeBoundTextElement:!0}).forEach(s=>{Bt(s)&&D4(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:Je.IMMEDIATELY}},H4=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Tt(e,n,o=>N4(o.type)?nt(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?Je.IMMEDIATELY:Je.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=_r(o);return ft(bd,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.stroke")}),Q(Ai,{topPicks:w4,palette:x4,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:lt(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),G4=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:Je.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!k4(t.currentItemBackgroundColor)&&i.every(s=>gw(s)&&A4(s.points))){let s=yh(i);r=e.map(l=>s.has(l.id)&&gw(l)?nt(l,{backgroundColor:t.currentItemBackgroundColor,...O4(l,!0)}):l)}else r=Tt(e,n,s=>nt(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:Je.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=_r(o);return ft(bd,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Ai,{topPicks:b4,palette:Ew,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:lt(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),Ed=O({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:Je.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=_r(o);return ft(bd,{children:[r==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Ai,{topPicks:f4,palette:Ew,excludedColors:[E4.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})]})}}),U4=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Ne("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Tt(e,n,r=>nt(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ie(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return ft("fieldset",{children:[Q("legend",{children:f("labels.fill")}),Q("div",{className:"buttonList",children:Q(Vt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?Wx:Vx,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:Yx,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:Xx,testId:"fill-solid"}],value:lt(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)}})})]})}}),W4=e=>T4.find(n=>bw(e.type,n)===e.strokeWidth)??null,V4=(e,n)=>bw(e.type,n),Y4=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(fd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Tt(e,n,o=>nt(o,{strokeWidth:V4(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:Lu,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:Kx,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:$x,testId:"strokeWidth-bold"}],value:lt(e,o,W4,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),X4=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>nt(o,{seed:S4(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:qx},{value:1,text:f("labels.artist"),icon:Jx},{value:2,text:f("labels.cartoonist"),icon:Qx}],value:lt(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),K4=O({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Tt(e,n,r=>r.type!=="freedraw"?r:nt(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:Je.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=lt(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(K,{type:"button",icon:a?_u:Du,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return ft("fieldset",{children:[Q("legend",{children:f("labels.pressure")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:Du},{value:"variable",text:f("labels.pressure_variable"),icon:_u}],value:i,onChange:a=>t(a)})})]})}}),Ate=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>nt(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Lu},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:Zx},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:jx}],value:lt(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),$4=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>nt(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=lt(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return Q(mw,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),Z4=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>vh(e,n,o,()=>(fd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=_r(o);return ft("fieldset",{children:[Q("legend",{children:f("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"font-size",options:[{value:ud.sm,text:f("labels.small"),icon:E1,testId:"fontSize-small"},{value:ud.md,text:f("labels.medium"),icon:b1,testId:"fontSize-medium"},{value:ud.lg,text:f("labels.large"),icon:x1,testId:"fontSize-large"},{value:ud.xl,text:f("labels.veryLarge"),icon:w1,testId:"fontSize-veryLarge"}],value:lt(e,o,a=>{if(Bt(a))return a.fontSize;let s=jo(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Bt(a)||jo(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||v4),onChange:a=>{xs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),Ih=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:kr,trackEvent:!1,perform:(e,n,t,o)=>vh(e,n,o,r=>Math.round(1/(1+yw)*r.fontSize)),keyTest:e=>e[_i.CTRL_OR_CMD]&&e.shiftKey&&(e.key===_i.CHEVRON_LEFT||e.key===_i.COMMA)}),Th=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:kr,trackEvent:!1,perform:(e,n,t,o)=>vh(e,n,o,r=>Math.round(r.fontSize*(1+yw))),keyTest:e=>e[_i.CTRL_OR_CMD]&&e.shiftKey&&(e.key===_i.CHEVRON_RIGHT||e.key===_i.PERIOD)}),j4=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:Tt(e,n,g=>{let b=r?.get(g.id);return b?nt(g,{...b}):g},!0),appState:{...n,...s},captureUpdate:Je.NEVER};fd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=Je.EVENTUALLY,m,p=!1;if(l)m=l,d=Je.IMMEDIATELY;else if(c){m=c,d=Je.EVENTUALLY;let E=ie(e,n,{includeBoundTextElement:!0}).filter(g=>Bt(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(ro.loadedFontsCache.values()),w=Object.entries(I4).find(([T,C])=>C===m)?.[0];c&&w&&y.some(T=>T.startsWith(w))&&(b=!0),Object.assign(u,{elements:Tt(e,n,T=>{if(Bt(T)&&(T.fontFamily!==m||l)){let C=nt(T,{fontFamily:m,lineHeight:P4(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 ${C4({fontFamily:m})}`,v=Array.from(g.values()).join();if(b||window.document.fonts.check(x,v))for(let[T,C]of E)As(T,C,o.scene);else window.document.fonts.load(x,v).then(T=>{for(let[C,P]of E){let A=o.scene.getElement(C.id),L=P?o.scene.getElement(P.id):null;A&&As(A,L,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=bh(new Map),i=bh(null),[a,s]=g4({}),l=bh(!0),{stylesPanelMode:c,isCompact:d}=_r(t),m=wh(()=>{let p=(u,E)=>lt(u,t,g=>{if(Bt(g))return g.fontFamily;let b=jo(g,E);return b?b.fontFamily:null},g=>Bt(g)||jo(g,E)!==null,g=>g?null:n.currentItemFontFamily||y4);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 Eh(()=>{i.current=m},[m]),Eh(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),Eh(()=>(l.current=!1,()=>{l.current=!0}),[]),ft(bd,{children:[c==="full"&&Q("legend",{children:f("labels.fontFamily")}),Q(rw,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{xs(()=>{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,nt(E||u,{},!0))}else{let E=ie(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,nt(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&&bs(null)}}})]})}}),q4=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Tt(e,n,r=>{if(Bt(r)){let i=nt(r,{textAlign:t});return As(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=_r(o);return ft("fieldset",{children:[Q("legend",{children:f("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:v1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:I1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:T1,testId:"align-right"}],value:lt(e,o,s=>{if(Bt(s))return s.textAlign;let l=jo(s,i);return l?l.textAlign:null},s=>Bt(s)||jo(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{xs(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),J4=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Tt(e,n,r=>{if(Bt(r)){let i=nt(r,{verticalAlign:t});return As(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=_r(o);return Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Vt,{group:"text-align",options:[{value:pd.TOP,text:f("labels.alignTop"),icon:Q(S1,{theme:n.theme}),testId:"align-top"},{value:pd.MIDDLE,text:f("labels.centerVertically"),icon:Q(P1,{theme:n.theme}),testId:"align-middle"},{value:pd.BOTTOM,text:f("labels.alignBottom"),icon:Q(C1,{theme:n.theme}),testId:"align-bottom"}],value:lt(e,o,a=>{if(Bt(a)&&a.containerId)return a.verticalAlign;let s=jo(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Bt(a)||jo(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:pd.MIDDLE),onChange:a=>{xs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),Lte=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>ww(o)?o:nt(o,{roundness:t==="round"?{type:R4(o.type)?hd.ADAPTIVE_RADIUS:hd.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=di(xw(e),n).some(s=>s.roundness?.type===hd.LEGACY);return ft("fieldset",{children:[Q("legend",{children:f("labels.edges")}),ft("div",{className:"buttonList",children:[Q(Vt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:e1},{value:"round",text:f("labels.round"),icon:t1}],value:lt(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!gd(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),fw=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:Q(n1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(o1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:Q(r1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:Q(i1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:Q(a1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(s1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:Q(l1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:Q(c1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:Q(d1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:Q(m1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:Q(p1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:Q(u1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:Q(h1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:Q(g1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:Q(f1,{flip:e}),keyBinding:null}]}]}),Dte=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(fd(t,"actionChangeArrowhead: value must be defined"),{elements:Tt(e,n,o=>{if(xh(o)){let{position:r,type:i}=t;if(r==="start")return nt(o,{startArrowhead:i});if(r==="end")return nt(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=Fn().rtl,i=wh(()=>fw(!r),[r]),a=wh(()=>fw(!!r),[r]);return ft("fieldset",{children:[Q("legend",{children:f("labels.arrowheads")}),ft("div",{className:"iconSelectList buttonList",children:[Q(gh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:lt(e,o,s=>xh(s)&&ns(s.type)?hw(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),Q(gh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:lt(e,o,s=>xh(s)&&ns(s.type)?hw(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),Q4=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})=>ft("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),_te=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Tt(e,n,s=>{if(!gd(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=Dr.getPointAtIndexGlobalCoordinates(s,0,l),d=Dr.getPointAtIndexGlobalCoordinates(s,-1,l),m=nt(s,{x:t===nn.elbow?c[0]:s.x,y:t===nn.elbow?c[1]:s.y,roundness:t===nn.round?{type:hd.PROPORTIONAL_RADIUS}:null,elbowed:t===nn.elbow,angle:t===nn.elbow?0:s.angle,points:t===nn.elbow||s.elbowed?[Dr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),Dr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(ww(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=Dr.getPointAtIndexGlobalCoordinates(m,0,p),E=Dr.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,...uw(m,g,"start",p,n.isBindingEnabled)}:null,w=b&&m.endBinding?{...m.endBinding,...uw(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:y,endBinding:w,...B4(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&&pw(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&pw(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 Dr(s,yh(e)))}return{elements:r,appState:i,captureUpdate:Je.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ft("fieldset",{children:[Q("legend",{children:f("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"arrowtypes",options:[{value:nn.sharp,text:f("labels.arrowtype_sharp"),icon:zo,testId:"sharp-arrow"},{value:nn.round,text:f("labels.arrowtype_round"),icon:Go,testId:"round-arrow"},{value:nn.elbow,text:f("labels.arrowtype_elbowed"),icon:Ho,testId:"elbow-arrow"}],value:lt(e,o,r=>gd(r)?r.elbowed?nn.elbow:r.roundness?nn.round:nn.sharp:null,r=>gd(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as a6,MAX_ZOOM as s6,MIN_ZOOM as l6,THEME as Ls,ZOOM_STEP as Tw,CODES as Rr,KEYS as wd}from"@excalidraw/common";import{getNonDeletedElements as Ds}from"@excalidraw/element";import{getCommonBounds as _s}from"@excalidraw/element";import{CaptureUpdateAction as Bi}from"@excalidraw/element";import{useEffect as e6}from"react";import{jsx as n6}from"react/jsx-runtime";var Ri=()=>{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},Sh=(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`})},t6=(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();Sh(n,r)},ct=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(e6(()=>()=>Ri().classList.remove("excalidraw-tooltip--visible"),[]),r?null:n6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>t6(i.currentTarget,Ri(),n,t),onPointerLeave:()=>Ri().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as vw,useRef as Iw,useState as o6}from"react";var r6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Ch=(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},Ro())}return r6(o,n)};function Ni(e,n=!0){let t=xd(),[,o]=o6(0),r=Iw(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Ch(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Ch(t,e,n)),vw(()=>{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 i6(e,n){let t=xd(),o=Iw({selector:e,callback:n});o.current.selector=e,o.current.callback=n,vw(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Ch(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Sd,jsxs as m6}from"react/jsx-runtime";var c6=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?Bi.IMMEDIATELY:Bi.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Sd(Ai,{palette:null,topPicks:a6,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})}),yd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:hu,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...oo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Bn(n.zoom.value+Tw)},n)},captureUpdate:Bi.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ni(t=>t.zoom.value);return Sd(K,{type:"button",className:"zoom-in-button zoom-button",icon:hu,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=s6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Rr.EQUAL||e.code===Rr.NUM_ADD)&&(e[wd.CTRL_OR_CMD]||e.shiftKey)}),vd=O({name:"zoomOut",label:"buttons.zoomOut",icon:gu,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...oo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Bn(n.zoom.value-Tw)},n)},captureUpdate:Bi.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ni(t=>t.zoom.value);return Sd(K,{type:"button",className:"zoom-out-button zoom-button",icon:gu,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=l6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Rr.MINUS||e.code===Rr.NUM_SUBTRACT)&&(e[wd.CTRL_OR_CMD]||e.shiftKey)}),Id=O({name:"resetZoom",label:"buttons.resetZoom",icon:Sx,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,...oo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Bn(r)},n)},captureUpdate:Bi.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=Ni(t=>t.zoom.value);return Sd(ct,{label:f("buttons.resetZoom"),style:{height:"100%"},children:m6(K,{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===Rr.ZERO||e.code===Rr.NUM_ZERO)&&(e[wd.CTRL_OR_CMD]||e.shiftKey)}),Ph=e=>[e.x,e.y,e.x+e.width,e.y+e.height],dne=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Nc,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(Ds(r)):n.scrollConstraints?Ph(n.scrollConstraints):_s(Ds(e)),a=Ir({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Nn(a.appState)}}},keyTest:void 0}),mne=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Nc,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(Ds(r)):n.scrollConstraints?Ph(n.scrollConstraints):_s(Ds(e)),a=Ir({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Nn(a.appState)}}},keyTest:void 0}),d6=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Nc,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?Ph(n.scrollConstraints):_s(Ds(e)),i=Ir({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...Nn(i.appState)}}},keyTest:void 0}),Td=O({name:"toggleTheme",label:(e,n)=>n.theme===Ls.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===Ls.LIGHT?ms:ps,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===Ls.LIGHT?Ls.DARK:Ls.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:Bi.EVENTUALLY}},keyTest:e=>!e[wd.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Rr.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as w6}from"@excalidraw/math";import{bindOrUnbindBindingElement as Nw}from"@excalidraw/element/binding";import{isValidPolygon as Bw,newElementWith as Ah}from"@excalidraw/element";import{LinearElementEditor as Fs}from"@excalidraw/element/linearElementEditor";import{isBindingElement as Lh,isFreeDrawElement as Ow,isLinearElement as Fw,isLineElement as Dd}from"@excalidraw/element";import{KEYS as _d,arrayToMap as y6,invariant as zw,shouldRotateWithDiscreteAngle as v6,updateActiveTool as Hw}from"@excalidraw/common";import{isPathALoop as I6}from"@excalidraw/element";import{isInvisiblySmallElement as Dh}from"@excalidraw/element";import{CaptureUpdateAction as _h}from"@excalidraw/element";import g6 from"clsx";import{useEffect as f6,useState as E6}from"react";import{KEYS as on,capitalizeString as Nr}from"@excalidraw/common";import{useEffect as p6,useState as u6}from"react";import Sw from"clsx";import{capitalizeString as Cd}from"@excalidraw/common";import{Popover as kh}from"radix-ui";import{jsx as Pd,jsxs as h6}from"react/jsx-runtime";var Oi=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=u6(!1),c=t.type,d=a.type===c,m=16,{container:p}=De();return!n.some(u=>u.type===c)&&s&&l(!1),p6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),h6(kh.Root,{open:s,children:[Pd(kh.Trigger,{asChild:!0,children:Pd(K,{className:Sw({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>$e(e,u.type)),title:Cd(a.title),"aria-label":Cd(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),Pd(kh.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>Pd(K,{className:Sw({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:$e(e,u),title:Cd(u),"aria-label":Cd(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(Ne("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as Mh}from"react/jsx-runtime";var b6=e=>e,We=b6({hand:{icon:k1,letterKey:on.H,toggle:!0},selection:{icon:Cc,letterKey:on.V,fillable:!0},rectangle:{icon:Ei,letterKey:on.R,fillable:!0},diamond:{icon:bi,letterKey:on.D,fillable:!0},ellipse:{icon:xi,letterKey:on.O,fillable:!0},arrow:{icon:Pc,letterKey:on.A,fillable:!0},line:{icon:Bo,letterKey:on.L,fillable:!0},freedraw:{icon:zn,letterKey:on.P},text:{icon:wn,letterKey:on.T},image:{icon:Cr},eraser:{icon:kc,letterKey:on.E,toggle:!0},frame:{icon:Gn,letterKey:on.F},autoshape:{icon:Mr,letterKey:on.X,fillable:!1},embeddable:{icon:Oo},laser:{icon:Un},bucketfill:{icon:Hn},lasso:{icon:fi,fillable:!1}});var Fi=["autoshape","rectangle","diamond","ellipse","arrow","line"],zi=Object.keys(We).filter(e=>We[e].toggle),kd=e=>{let{letterKey:n,shiftKey:t}=We[e];if(!n)return n;let o=Nr(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},Hi=e=>kd(e),x6=e=>{let n=kd(e);return n?.length===1?n:void 0},Cw=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(We)){let{letterKey:i,shiftKey:a}=We[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},$e=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Ot=(e,n)=>{let t=We[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=Nr(f(`toolBar.${e}`)),d=l?null:Hi(o);return Mh(K,{className:g6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:$e(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&&(Ne("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${Nr(e)}IconButton`,r},Md=Ot("hand"),Pw=Ot("rectangle"),kw=Ot("diamond"),Mw=Ot("ellipse"),Aw=Ot("arrow"),Lw=Ot("line"),Rs=Ot("freedraw"),Ns=Ot("text"),Bs=Ot("image"),Os=Ot("eraser"),Dw=Ot("frame"),zne=Ot("autoshape"),_w=Ot("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Ne("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),Rw=Ot("lasso",{shortcutType:"selection"}),Ad=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:We.selection.icon,fillable:We.selection.fillable,title:Nr(f("toolBar.selection"))},{type:"lasso",icon:We.lasso.icon,fillable:We.lasso.fillable,title:Nr(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return Mh(Oi,{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})},Ld=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:We.freedraw.icon,fillable:We.freedraw.fillable,title:Nr(f("toolBar.freedraw"))},{type:"autoshape",icon:We.autoshape.icon,fillable:We.autoshape.fillable,title:Nr(f("toolBar.autoshape"))}],[o,r]=E6(n.type==="autoshape"?"autoshape":"freedraw");f6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return Mh(Oi,{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 T6}from"react/jsx-runtime";var dt=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=Fs.getElement(n.selectedLinearElement.elementId,l);zw(w,"Arrow element should exist if selectedLinearElement is set"),zw(y,"sceneCoords should be defined if actionFinalize is called with event");let x=Fs.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(Lh(w)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let v=!!n.newElement,T=v||!n.selectedLinearElement.selectedPointsIndices?[w.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=v6(b),P=b[_d.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),A=T.reduce((L,_)=>(L.set(_,{point:C?w.points[_]:Fs.createPointAt(w,l,y.x-x.pointerOffset.x,y.y-x.pointerOffset.y,P)}),L),new Map)??new Map;Nw(w,A,y.x,y.y,s,n,{newArrow:v,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else Dd(w)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!Bw(w.points)&&s.mutateElement(w,{polygon:!1});if(x!==n.selectedLinearElement){w&&Dh(w)&&(i=i.map(T=>T.id===w.id?Ah(T,{isDeleted:!0}):T));let v=n.activeTool?.locked;return{elements:w.points.length<2||Dh(w)?e.map(T=>T.id===w.id?Ah(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:c?{}:n.selectedElementIds,selectedLinearElement:v||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:_h.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"||Lh(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)}),Lh(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}]]),v=Fs.getPointAtIndexGlobalCoordinates(m,-1,l);Nw(m,x,v[0],v[1],s,n,{newArrow:w})}}if(m&&Dh(m)&&(i=i.map(b=>b.id===m?.id?Ah(b,{isDeleted:!0}):b)),Fw(m)||Ow(m)){if(I6(m.points,n.zoom.value)&&(Dd(m)||Ow(m))){let y=m.points,w=y[0],x=y.map((v,T)=>T===y.length-1?w6(w[0],w[1]):v);Dd(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}Dd(m)&&!Bw(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;zi.includes(n.activeTool.type)?p=Hw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=Hw(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&&Fw(m)?new Fs(m,y6(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?_h.IMMEDIATELY:_h.NEVER}},keyTest:(e,n)=>e.key===_d.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===_d.ESCAPE||e.key===_d.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>T6(K,{type:"button",icon:Bx,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 Ww,isSomeElementSelected as S6,makeNextSelectedElementIds as C6,selectGroupsForSelectedElements as P6}from"@excalidraw/element";import{CaptureUpdateAction as Gw}from"@excalidraw/element";import{KEYS as k6,isWritableElement as M6,updateActiveTool as Uw}from"@excalidraw/common";var A6=(e,n)=>zi.includes(e.activeTool.type)?Uw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):Uw(e,{type:n.state.preferredSelectionTool.type}),L6=(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:Ww(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},D6=O({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=A6(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:Ww(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...P6({editingGroupId:L6(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:Gw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:C6({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:Gw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==k6.ESCAPE||M6(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||S6(o.scene.getNonDeletedElements(),n))});import{KEYS as Gd,THEME as Us}from"@excalidraw/common";import{CaptureUpdateAction as vn}from"@excalidraw/element";import _6 from"clsx";import{jsx as Vw,jsxs as R6}from"react/jsx-runtime";var Rh=({children:e,checked:n,onChange:t,className:o})=>R6("div",{className:_6("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[Vw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:Mc}),Vw("div",{className:"Checkbox-label",children:e})]});import{THEME as zs}from"@excalidraw/common";import{jsx as Hs}from"react/jsx-runtime";var Xw=e=>{let n=e.title||(e.value===zs.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return Hs(K,{type:"icon",icon:e.value===zs.LIGHT?Yw.MOON:Yw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===zs.DARK?zs.LIGHT:zs.DARK),"data-testid":"toggle-dark-mode"})},Yw={SUN:Hs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Hs("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:Hs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Hs("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 N6}from"react";import{focusNearestParent as B6,KEYS as O6}from"@excalidraw/common";import{jsx as Kw,jsxs as F6}from"react/jsx-runtime";var $w=e=>{let{id:n}=De(),[t,o]=N6(e.value),r=a=>{e.ignoreFocus||B6(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===O6.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return F6("div",{className:"ProjectName",children:[Kw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Kw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as z6,useEffect as H6,useRef as G6}from"react";import{jsx as Rd,jsxs as Y6}from"react/jsx-runtime";var U6=5e3,W6=({progress:e})=>Rd("div",{className:"Toast__progress-bar",children:Rd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),V6=({message:e,onClose:n,closable:t=!1,duration:o=U6,style:r})=>{let i=G6(0),a=o!==1/0,s=z6(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return H6(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),Y6("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Rd("div",{className:"Toast__message",children:e}),t&&Rd(K,{icon:Jt,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},Nd=Object.assign(V6,{ProgressBar:W6});import{DEFAULT_EXPORT_PADDING as cL,DEFAULT_FILENAME as dL,IMAGE_MIME_TYPES as ey,isFirefox as mL,MIME_TYPES as pL,cloneJSON as uL,SVG_DOCUMENT_PREAMBLE as hL,arrayToMap as gL}from"@excalidraw/common";import{getNonDeletedElements as fL}from"@excalidraw/element";import{isFrameLikeElement as EL}from"@excalidraw/element";import{getElementsOverlappingFrame as bL}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as X6,EXPORT_DATA_TYPES as Gs,MIME_TYPES as mt,arrayToMap as K6,isMemberOf as $6,isPromiseLike as Z6,EVENT as Bd}from"@excalidraw/common";import{mutateElement as j6}from"@excalidraw/element";import{deepCopyElement as q6}from"@excalidraw/element";import{isFrameLikeElement as J6,isInitializedImageElement as Q6}from"@excalidraw/element";import{getContainingFrame as Zw}from"@excalidraw/element";var ore="clipboard"in navigator&&"readText"in navigator.clipboard,Od="clipboard"in navigator&&"writeText"in navigator.clipboard,qo="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,eL=e=>!!([Gs.excalidraw,Gs.excalidrawClipboard,Gs.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),jw=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Bd.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},tL=({elements:e,files:n})=>{let t=K6(e),o=new Set(e.filter(s=>J6(s))),r=!1,i=e.reduce((s,l)=>(Q6(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:Gs.excalidrawClipboard,elements:e.map(s=>{if(Zw(s,t)&&!o.has(Zw(s,t))){let l=q6(s);return j6(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},Fd=async(e,n,t)=>{let o=tL({elements:e,files:n});await po({[mt.excalidrawClipboard]:o,[mt.text]:o},t)};function qw(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(qw(t));return n}var nL=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,mt.html),o=qw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Jw=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{[mt.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($6(X6,o))try{if(o===mt.text||o===mt.html)e[o]=await(await t.getType(o)).text();else if(nx(o)){let r=await t.getType(o),i=cx(r,o,void 0);e[o]=i}else throw new cu(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof cu?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},oL=async(e,n=!1)=>{try{let t=e.findByType(mt.html),o=!n&&t&&nL(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(mt.text)??o.value.map(r=>r.value).join(`
2
+ `).trim()}:o:{type:"text",value:(e.getData(mt.text)||"").trim()}}catch{return{type:"text",value:""}}},rL=function(e){return this.find(n=>n.type===e)||null},iL=function(e){return this.find(t=>t.type===e)?.value??null},aL=function(){return this.filter(e=>e.kind==="file")},Nh=e=>{let n=Oh(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),mt.text,mt.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}},sL=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}}),Bh=(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===mt.html)try{let E=new DOMParser().parseFromString(u.value,mt.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===mt.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:sL(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},Qw=e=>{let n;Oh(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},Br=async e=>{let n;Oh(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 lx(o);return r=await ui(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:rL,getData:iL,getFiles:aL})},zd=async(e,n=!1)=>{let t=await oL(e,n);if(t.type==="mixedContent")return{mixedContent:t.value};try{let o=JSON.parse(t.value),r=o.type===Gs.excalidrawClipboardWithAPI;if(eL(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}},Hd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[mt.png]:e})])}catch(n){if(Z6(e))await navigator.clipboard.write([new ClipboardItem({[mt.png]:await e})]);else throw n}},po=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[mt.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===mt.text);if(Od&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!lL(o[1]))throw new Error("Error copying to clipboard.")},lL=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},Oh=e=>e.type===Bd.PASTE||e.type===Bd.COPY||e.type===Bd.CUT;var Or=(e,{selectedElementIds:n},t)=>{let o=fL(e),r=gL(o),i=t&&Me(o,{selectedElementIds:n}),a=null,s=i?ie(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&EL(l)?(a=l,s=bL(o,l,r)):s.length>1&&(s=ie(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:uL(s)}},Fr=async(e,n,t,o,{exportBackground:r,exportPadding:i=cL,viewBackgroundColor:a,name:s=t.name||dL,fileHandle:l=null,exportingFrame:c=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Tr(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 du(m.then(p=>new Blob([hL+p.outerHTML],{type:pL.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[ey.svg],fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await po(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let d=xc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=ls(d);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-FQV7KQIF.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:rs(n,t,o,"local")})))),du(m,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[ey.png],fileHandle:l})}else if(e==="clipboard")try{let m=ls(d);await Hd(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):mL&&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 ey=async(e,n,t)=>{let o=$b(n);if(!Zb(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}=Rr(r,i,!1);return await Nr(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as bL,jsx as Xo,jsxs as ry}from"react/jsx-runtime";var Lh=F({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:xn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>Xo(Xw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),ty=F({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:xn.EVENTUALLY})}),Dh=F({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:xn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Xo(kh,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),_d=F({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:xn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>ry(kh,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),Xo(lt,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:Xo("div",{className:"excalidraw-tooltip-icon",children:Lx})})]})}),Ri=!1,Ah=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?ry(bL,{children:[t,Xo(Cd.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function EL(e,n){if(n.app.state.isLoading&&(Ah(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")Ah(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(Ah(n.app,{progress:null}),await e)}function ny(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await EL(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 Br=F({name:"saveToActiveFile",label:"buttons.save",icon:is,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(Ri)return!1;Ri=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=ny(e,n,o.files,o);try{let{fileHandle:l}=cc(r)?await ey(s,r,i):await rc({data:s,filename:i,fileHandle:r});return{captureUpdate:xn.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:xn.NEVER,appState:{toast:null}}}finally{Ri=!1}},keyTest:e=>!1}),Ds=F({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:is,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(Ri)return!1;Ri=!0;let{abortController:r,data:i}=ny(e,n,o.files,o);try{let{fileHandle:a}=await rc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:xn.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:xn.NEVER,appState:{toast:null}}}finally{Ri=!1}},keyTest:e=>e.key.toLowerCase()===Dd.S&&e.shiftKey&&e[Dd.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Xo($,{type:"button",icon:Cx,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:ue().formFactor==="phone",hidden:!li,onClick:()=>e(null),"data-testid":"save-as-button"})}),Ni=F({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 au(n,e);return{elements:r,appState:i,files:a,captureUpdate:xn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:xn.EVENTUALLY}}},keyTest:e=>e[Dd.CTRL_OR_CMD]&&e.key===Dd.O}),oy=F({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?Ls.DARK:Ls.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:xn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Xo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Xo(Yw,{value:e.exportWithDarkMode?Ls.DARK:Ls.LIGHT,onChange:t=>{n(t===Ls.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as xL,DEFAULT_FONT_FAMILY as wL,DEFAULT_TEXT_ALIGN as yL,getLineHeight as vL}from"@excalidraw/common";import{newElementWith as Rd}from"@excalidraw/element";import{hasBoundTextElement as TL,canApplyRoundnessTypeToElement as IL,getDefaultRoundnessTypeForElement as SL,isFrameLikeElement as CL,isArrowElement as PL,isExcalidrawElement as kL,isTextElement as iy}from"@excalidraw/element";import{getBoundTextElement as ML,redrawTextBoundingBox as AL}from"@excalidraw/element";import{CaptureUpdateAction as _h}from"@excalidraw/element";var ay="{}",Rh=F({name:"copyStyles",label:"labels.copyStyles",icon:Lu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&TL(i)){let a=ML(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(ay=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:_h.EVENTUALLY}}}),Nh=F({name:"pasteStyles",label:"labels.pasteStyles",icon:Lu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(ay),i=r[0],a=r[1];if(!kL(i))return{elements:e,captureUpdate:_h.EVENTUALLY};let s=ie(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(iy(c)&&c.containerId&&(d=a),!d)return c;let p=Rd(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?IL(d.roundness.type,c)?d.roundness:SL(c):null});if(iy(p)){let m=d.fontSize||xL,u=d.fontFamily||wL,E=Rd(p,{fontSize:m,fontFamily:u,textAlign:d.textAlign||yL,lineHeight:d.lineHeight||vL(u)});p=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),AL(E,g,o.scene)}return p.type==="arrow"&&PL(d)&&(p=Rd(p,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),CL(c)&&(p=Rd(p,{roundness:null,backgroundColor:"transparent"})),p}return c}),captureUpdate:_h.IMMEDIATELY}}});import{KEYS as LL}from"@excalidraw/common";import{CaptureUpdateAction as DL}from"@excalidraw/element";var Or=F({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:yx,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:DL.EVENTUALLY}),keyTest:e=>e.key===LL.QUESTION_MARK});import{getNonDeletedElements as Bd}from"@excalidraw/element";import{newElementWith as ly}from"@excalidraw/element";import{isBoundToContainer as _L}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as RL,getElementsInResizingFrame as NL,getFrameLikeElements as BL,getRootElements as OL,groupByFrameLikes as FL,removeElementsFromFrame as zL,replaceAllElementsInFrame as HL}from"@excalidraw/element";import{KEYS as Od,randomId as GL,arrayToMap as Oh}from"@excalidraw/common";import{getSelectedGroupIds as Nd,selectGroup as UL,selectGroupsForSelectedElements as WL,getElementsInGroup as sy,addToGroup as VL,removeFromSelectedGroups as YL,isElementInGroup as cy}from"@excalidraw/element";import{syncMovedIndices as KL}from"@excalidraw/element";import{CaptureUpdateAction as _s}from"@excalidraw/element";import{jsx as Bi}from"react/jsx-runtime";var XL=(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=>cy(i,r)))return!0}return!1},Bh=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!XL(t,e.editingGroupId)&&!RL(t)},Fh=F({name:"group",label:"labels.group",icon:e=>Bi(Iu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!Bh(n,o))return!1;let r=OL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:_s.EVENTUALLY};let i=Nd(n);if(i.length===1){let b=i[0],y=new Set(sy(e,b).map(v=>v.id)),w=new Set(r.map(v=>v.id));if(new Set([...Array.from(y),...Array.from(w)]).size===y.size)return{appState:n,elements:e,captureUpdate:_s.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&FL(r).forEach((y,w)=>{zL(y,o.scene.getNonDeletedElementsMap())});let l=GL(),c=Oh(r);a=a.map(b=>c.get(b.id)?ly(b,{groupIds:VL(b.groupIds,l,n.editingGroupId)}):b);let d=sy(a,l),p=d[d.length-1],m=a.lastIndexOf(p),u=a.slice(m+1),E=a.slice(0,m).filter(b=>!cy(b,l)),g=KL([...E,...d,...u],Oh(d));return{appState:{...n,...UL(l,{...n,selectedGroupIds:{}},Bd(a))},elements:g,captureUpdate:_s.IMMEDIATELY}},predicate:(e,n,t,o)=>Bh(n,o),keyTest:e=>!e.shiftKey&&e[Od.CTRL_OR_CMD]&&e.key===Od.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Bi($,{hidden:!Bh(n,o),type:"button",icon:Bi(Iu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Me(Bd(e),n)})}),zh=F({name:"ungroup",label:"labels.ungroup",icon:e=>Bi(Su,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=Nd(n),i=Oh(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:_s.EVENTUALLY};let a=[...e],s=[];a=a.map(m=>{_L(m)&&s.push(m.id);let u=YL(m.groupIds,n.selectedGroupIds);return u.length===m.groupIds.length?m:ly(m,{groupIds:u})});let l=WL(n,Bd(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(m=>m.frameId).map(m=>m.frameId));return BL(e).filter(m=>d.has(m.id)).forEach(m=>{m&&(a=HL(a,NL(a,m,n,i),m))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((m,[u,E])=>(E&&!s.includes(u)&&(m[u]=!0),m),{}),{appState:{...n,...l},elements:a,captureUpdate:_s.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Od.CTRL_OR_CMD]&&e.key===Od.G.toUpperCase(),predicate:(e,n)=>Nd(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>Bi($,{type:"button",hidden:Nd(n).length===0,icon:Bi(Su,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Me(Bd(e),n)})});import eD from"clsx";import{CaptureUpdateAction as hy}from"@excalidraw/element";import{invariant as tD}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as $L,COLOR_VOICE_CALL as ZL,COLOR_WHITE as zd,THEME as jL,UserIdleState as dy}from"@excalidraw/common";var Fd=(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 qL(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 Fr=(e,n)=>`hsl(${Math.abs(qL(n?.id||e))%37*10}, 100%, 83%)`,my=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},py=({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,p=14,m=s<0||s>o-d||l<0||l>r-p;s=Math.max(s,0),s=Math.min(s,o-d),l=Math.max(l,0),l=Math.min(l,r-p);let u=Fr(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=m||E===dy.IDLE||E===dy.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===jL.DARK?"#2f6330":ZL,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=zd,e.strokeStyle=zd,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(!m&&w){e.font="600 12px sans-serif";let x=(y?s+0:s)+d/2,v=(y?l+0:l)+p+2,I=5,C=3,P=e.measureText(w),A=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,L=Math.max(A,12),_=x-1,k=v-1,D=P.width+2+I*2+2,O=L+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,D,O,8),e.fillStyle=u,e.fill(),e.strokeStyle=zd,e.stroke(),y&&(e.beginPath(),e.roundRect(_-2,k-2,D+4,O+4,8),e.strokeStyle=b,e.stroke())):Fd(e,_,k,D,O,8,zd),e.fillStyle=$L,e.fillText(w,x+I+1,v+C+P.actualBoundingBoxAscent+Math.floor((L-A)/2)+2),y){e.fillStyle=b;let G=8,z=8,W=5;e.fillRect(_+D+z,k+(O/2-G/2),2,G),e.fillRect(_+D+z+W,k+(O/2-G*2/2),2,G*2),e.fillRect(_+D+z+W*2,k+(O/2-G/2),2,G)}}e.restore(),e.closePath()}};import JL from"clsx";import{useState as QL}from"react";import{jsx as uy}from"react/jsx-runtime";var Hh=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=my(t),[a,s]=QL(!1),l=!a&&o,c=l?void 0:{background:e};return uy("div",{className:JL("Avatar",r),style:c,onClick:n,children:l?uy("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as Yn,jsxs as Hd}from"react/jsx-runtime";var nD=F({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(tD(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:hy.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:hy.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=Fr(o,r),l=eD({"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?Hd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[Yn("div",{}),Yn("div",{}),Yn("div",{})]}):r.isMuted?Yn("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:A1}):Yn("div",{title:f("userList.hint.inCall"),children:M1}):null;return i?Hd("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:[Yn(Hh,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),Yn("div",{className:"UserList__collaborator-name",children:r.username}),Hd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Yn("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Pr}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):Hd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[Yn(Hh,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&Yn("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as Oi}from"@excalidraw/element";import{isFrameLikeElement as oD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as rD}from"@excalidraw/element";import{KEYS as $o,arrayToMap as iD}from"@excalidraw/common";import{alignElements as aD}from"@excalidraw/element";import{CaptureUpdateAction as Fi}from"@excalidraw/element";import{getSelectedElementsByGroup as sD}from"@excalidraw/element";import{jsx as Hi}from"react/jsx-runtime";var mt=(e,n)=>{let t=n.scene.getSelectedElements(e);return sD(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>oD(o))},zi=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=aD(r,o,t.scene,n),a=iD(i);return rD(e.map(s=>a.get(s.id)||s),n,t)},lD=F({name:"alignTop",label:"labels.alignTop",icon:bu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>({appState:n,elements:zi(e,n,o,{position:"start",axis:"y"}),captureUpdate:Fi.IMMEDIATELY}),keyTest:e=>e[$o.CTRL_OR_CMD]&&e.shiftKey&&e.key===$o.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Hi($,{hidden:!mt(n,o),type:"button",icon:bu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Me(Oi(e),n)})}),cD=F({name:"alignBottom",label:"labels.alignBottom",icon:xu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>({appState:n,elements:zi(e,n,o,{position:"end",axis:"y"}),captureUpdate:Fi.IMMEDIATELY}),keyTest:e=>e[$o.CTRL_OR_CMD]&&e.shiftKey&&e.key===$o.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Hi($,{hidden:!mt(n,o),type:"button",icon:xu,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Me(Oi(e),n)})}),dD=F({name:"alignLeft",label:"labels.alignLeft",icon:wu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>({appState:n,elements:zi(e,n,o,{position:"start",axis:"x"}),captureUpdate:Fi.IMMEDIATELY}),keyTest:e=>e[$o.CTRL_OR_CMD]&&e.shiftKey&&e.key===$o.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Hi($,{hidden:!mt(n,o),type:"button",icon:wu,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Me(Oi(e),n)})}),mD=F({name:"alignRight",label:"labels.alignRight",icon:yu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>({appState:n,elements:zi(e,n,o,{position:"end",axis:"x"}),captureUpdate:Fi.IMMEDIATELY}),keyTest:e=>e[$o.CTRL_OR_CMD]&&e.shiftKey&&e.key===$o.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Hi($,{hidden:!mt(n,o),type:"button",icon:yu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Me(Oi(e),n)})}),pD=F({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:vu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>({appState:n,elements:zi(e,n,o,{position:"center",axis:"y"}),captureUpdate:Fi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Hi($,{hidden:!mt(n,o),type:"button",icon:vu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Me(Oi(e),n)})}),uD=F({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Tu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>mt(n,o),perform:(e,n,t,o)=>({appState:n,elements:zi(e,n,o,{position:"center",axis:"x"}),captureUpdate:Fi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Hi($,{hidden:!mt(n,o),type:"button",icon:Tu,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Me(Oi(e),n)})});import{getNonDeletedElements as gy}from"@excalidraw/element";import{isFrameLikeElement as hD}from"@excalidraw/element";import{CODES as fy,KEYS as Ey,arrayToMap as gD}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as fD}from"@excalidraw/element";import{distributeElements as ED}from"@excalidraw/element";import{CaptureUpdateAction as by}from"@excalidraw/element";import{getSelectedElementsByGroup as bD}from"@excalidraw/element";import{jsx as yy}from"react/jsx-runtime";var xy=(e,n)=>{let t=n.scene.getSelectedElements(e);return bD(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>hD(o))},wy=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=ED(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=gD(i);return fD(e.map(s=>a.get(s.id)||s),n,t)},xD=F({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:wy(e,n,o,{space:"between",axis:"x"}),captureUpdate:by.IMMEDIATELY}),keyTest:e=>!e[Ey.CTRL_OR_CMD]&&e.altKey&&e.code===fy.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>yy($,{hidden:!xy(n,o),type:"button",icon:Nx,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Me(gy(e),n)})}),wD=F({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:wy(e,n,o,{space:"between",axis:"y"}),captureUpdate:by.IMMEDIATELY}),keyTest:e=>!e[Ey.CTRL_OR_CMD]&&e.altKey&&e.code===fy.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>yy($,{hidden:!xy(n,o),type:"button",icon:Bx,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Me(gy(e),n)})});import{arrayToMap as vy,KEYS as vD,matchKey as TD}from"@excalidraw/common";import{CaptureUpdateAction as ID}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as SD}from"@excalidraw/element/frame";import{arrangeElements as CD}from"@excalidraw/element/arrange";var yD={fitToViewport:!0,animate:!0,duration:200,viewportZoomFactor:.8},Gd=(e,n)=>({smartZoom:{...yD,...n?.smartZoom},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as AD}from"react/jsx-runtime";var PD=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=vy(e),{arrange:i}=Gd(n,t.props.editorPreferences),a=CD(t.scene,o,r,i.algorithm,i.gap),s=vy(a);return SD(e.map(l=>s.get(l.id)||l),n,t)},kD=mt,MD=F({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:_u,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>kD(n,o),perform:(e,n,t,o)=>({appState:n,elements:PD(e,n,o),captureUpdate:ID.IMMEDIATELY}),keyTest:e=>e.shiftKey&&TD(e,vD.R),PanelComponent:({updateData:e})=>AD("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+R")}`,children:_u})});import{arrayToMap as Ty}from"@excalidraw/common";import{CaptureUpdateAction as LD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as DD}from"@excalidraw/element/frame";import{normaliseElements as _D}from"@excalidraw/element/normalise";import{jsx as OD}from"react/jsx-runtime";var RD=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Ty(e),{normalise:i}=Gd(n,t.props.editorPreferences),a=_D(t.scene,o,r,i.mode,i.metric),s=Ty(a);return DD(e.map(l=>s.get(l.id)||l),n,t)},ND=mt,BD=F({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:Ru,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>ND(n,o),perform:(e,n,t,o)=>({appState:n,elements:RD(e,n,o),captureUpdate:LD.IMMEDIATELY}),PanelComponent:({updateData:e})=>OD("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:Ru})});import{getNonDeletedElements as FD}from"@excalidraw/element";import{bindOrUnbindBindingElements as zD}from"@excalidraw/element";import{getCommonBoundingBox as Iy}from"@excalidraw/element";import{newElementWith as HD}from"@excalidraw/element";import{deepCopyElement as GD}from"@excalidraw/element";import{resizeMultipleElements as UD}from"@excalidraw/element";import{isArrowElement as Sy,isElbowArrow as WD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as Cy}from"@excalidraw/element";import{CODES as Py,KEYS as VD,arrayToMap as YD}from"@excalidraw/common";import{CaptureUpdateAction as ky}from"@excalidraw/element";var Gh=F({name:"flipHorizontal",label:"labels.flipHorizontal",icon:R1,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Cy(My(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:ky.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Py.H}),Uh=F({name:"flipVertical",label:"labels.flipVertical",icon:_1,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Cy(My(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:ky.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Py.V&&!e[VD.CTRL_OR_CMD]}),My=(e,n,t,o,r)=>{let i=ie(FD(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=KD(i,n,o,r),s=YD(a);return e.map(l=>s.get(l.id)||l)},KD=(e,n,t,o)=>{if(e.every(m=>Sy(m)&&(m.startBinding||m.endBinding)))return e.map(m=>{let u=m;return HD(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=Iy(e);UD(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(m=>[m.id,GD(m)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),zD(e.filter(Sy),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((m,u)=>WD(u)?{...m,elbowArrows:m.elbowArrows.concat(u)}:{...m,otherElements:m.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=Iy(e),[d,p]=[r-l,i-c];return s.forEach(m=>o.scene.mutateElement(m,{x:m.x+d,y:m.y+p})),a.forEach(m=>o.scene.mutateElement(m,{x:m.x+d,y:m.y+p})),e};import{isTextElement as XD}from"@excalidraw/element";import{getTextFromElements as $D}from"@excalidraw/element";import{CODES as ZD,KEYS as Ay,isFirefox as jD}from"@excalidraw/common";import{CaptureUpdateAction as Kt}from"@excalidraw/element";var Gi=F({name:"copy",label:"labels.copy",icon:ns,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Md(r,o.files,t)}catch(i){return{captureUpdate:Kt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:Kt.EVENTUALLY}},keyTest:void 0}),Wh=F({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await qw()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),jD?{captureUpdate:Kt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Kt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(Zw({types:r}))}catch(i){return console.error(i),{captureUpdate:Kt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Kt.EVENTUALLY}},keyTest:void 0}),Ud=F({name:"cut",label:"labels.cut",icon:T1,trackEvent:{category:"element"},perform:(e,n,t,o)=>(Gi.perform(e,n,t,o),cs.perform(e,n,null,o)),keyTest:e=>e[Ay.CTRL_OR_CMD]&&e.key===Ay.X}),Wd=F({name:"copyAsSvg",label:"labels.copyAsSvg",icon:N1,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Kt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Rr(e,n,!0);try{await Nr("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:Kt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Kt.EVENTUALLY}}},predicate:e=>kd&&e.length>0,keywords:["svg","clipboard","copy"]}),Vd=F({name:"copyAsPng",label:"labels.copyAsPng",icon:B1,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Kt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Rr(e,n,!0);try{return await Nr("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:Kt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:Kt.EVENTUALLY}}},predicate:e=>Ko&&e.length>0,keyTest:e=>e.code===ZD.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Yd=F({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0});try{co($D(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Kt.EVENTUALLY}},predicate:(e,n,t,o)=>kd&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(XD),keywords:["text","clipboard","copy"]});import{CODES as qD,KEYS as JD}from"@excalidraw/common";import{CaptureUpdateAction as QD}from"@excalidraw/element";var Ui=F({name:"gridMode",icon:H1,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:QD.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[JD.CTRL_OR_CMD]&&e.code===qD.QUOTE});import{CaptureUpdateAction as e_}from"@excalidraw/element";var Zo=F({name:"zenMode",label:"buttons.zenMode",icon:F1,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,n){return{appState:{...n,zenModeEnabled:!this.checked(n)},captureUpdate:e_.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,n,t,o)=>o.editorInterface.formFactor!=="phone"&&typeof t.zenModeEnabled>"u"});import{CODES as t_,KEYS as n_}from"@excalidraw/common";import{CaptureUpdateAction as o_}from"@excalidraw/element";var Rs=F({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:O1,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:o_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[n_.CTRL_OR_CMD]&&e.altKey&&e.code===t_.S});import{CaptureUpdateAction as r_}from"@excalidraw/element";var Ns=F({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:r_.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as i_}from"@excalidraw/element";var Bs=F({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:i_.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as a_,KEYS as s_}from"@excalidraw/common";import{CaptureUpdateAction as l_}from"@excalidraw/element";var jo=F({name:"stats",label:"stats.fullTitle",icon:D1,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:l_.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[s_.CTRL_OR_CMD]&&e.altKey&&e.code===a_.SLASH});import{BOUND_TEXT_PADDING as Ly,ROUNDNESS as Dy,TEXT_ALIGN as Ny,VERTICAL_ALIGN as By,arrayToMap as Oy,getFontString as c_,getStrokeWidthByKey as d_}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as m_,isBoundToContainer as _y,resetOriginalContainerCache as p_,updateOriginalContainerCache as u_}from"@excalidraw/element";import{computeBoundTextPosition as h_,computeContainerDimensionForBoundText as Ry,getBoundTextElement as Fy,redrawTextBoundingBox as zy}from"@excalidraw/element";import{hasBoundTextElement as g_,isArrowElement as f_,isTextBindableContainer as Vh,isTextElement as Os,isUsingAdaptiveRadius as E_}from"@excalidraw/element";import{measureText as b_}from"@excalidraw/element";import{syncMovedIndices as Hy}from"@excalidraw/element";import{newElement as x_}from"@excalidraw/element";import{CaptureUpdateAction as Yh}from"@excalidraw/element";var Kh=F({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>g_(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=Fy(a,i);if(s){let{width:l,height:c}=b_(s.originalText,c_(s),s.lineHeight),d=m_(a.id);p_(a.id);let{x:p,y:m}=h_(a,s,i);o.scene.mutateElement(s,{containerId:null,width:l,height:c,text:s.originalText,x:p,y:m}),o.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:n,captureUpdate:Yh.IMMEDIATELY}}}),Xh=F({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=Os(r[0])||Os(r[1]),a;if(Vh(r[0])?a=r[0]:Vh(r[1])&&(a=r[1]),i&&a&&Fy(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;Os(r[0])&&Vh(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:By.MIDDLE,textAlign:Ny.CENTER,autoResize:!0,angle:f_(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return zy(i,a,o.scene),u_(a.id,s),{elements:w_(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:Yh.IMMEDIATELY}}}),w_=(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),Hy(o,Oy([n,t])),o},y_=(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),Hy(o,Oy([n,t])),o},Gy=F({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>Os(a)&&!_y(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(Os(s)&&!_y(s)){let l=x_({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:d_("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:E_("rectangle")?Dy.ADAPTIVE_RADIUS:Dy.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-Ly,y:s.y-Ly,width:Ry(s.width,"rectangle"),height:Ry(s.height,"rectangle"),groupIds:s.groupIds,frameId:s.frameId});if(s.boundElements?.length){let c=s.boundElements.filter(p=>p.type==="arrow").map(p=>p.id);i.filter(p=>c.includes(p.id)).forEach(p=>{let m=p.startBinding,u=p.endBinding;m?.elementId===s.id&&(m={...m,elementId:l.id}),u?.elementId===s.id&&(u={...u,elementId:l.id}),(m||u)&&o.scene.mutateElement(p,{startBinding:m,endBinding:u})})}o.scene.mutateElement(s,{containerId:l.id,verticalAlign:By.MIDDLE,boundElements:null,textAlign:Ny.CENTER,autoResize:!0}),zy(s,l,o.scene),i=y_([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:Yh.IMMEDIATELY}}});import{getNonDeletedElements as qy,isEmbeddableElement as F_}from"@excalidraw/element";import{KEYS as Jy}from"@excalidraw/common";import{CaptureUpdateAction as z_}from"@excalidraw/element";import{pointFrom as Yy}from"@excalidraw/math";import v_ from"clsx";import{useCallback as Uy,useEffect as Wy,useLayoutEffect as T_,useRef as I_,useState as S_}from"react";import{EVENT as $h,HYPERLINK_TOOLTIP_DELAY as C_,KEYS as Kd}from"@excalidraw/common";import{getElementAbsoluteCoords as Qh}from"@excalidraw/element";import{hitElementBoundingBox as P_}from"@excalidraw/element";import{isElementLink as k_}from"@excalidraw/element";import{getEmbedLink as M_,embeddableURLValidator as A_}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Ky,viewportCoordsToSceneCoords as L_,wrapEvent as D_,isLocalLink as __,normalizeLink as Zh}from"@excalidraw/common";import{isEmbeddableElement as jh}from"@excalidraw/element";import{jsx as Wi,jsxs as Vy}from"react/jsx-runtime";var eg=380,R_=42,qh=5,Xy=85,N_=500,Jh=!1,Xd=new Map,$y=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=Uo(),l=bn(),c=ue(),d=e.link||"",[p,m]=S_(d),u=I_(null),E=s.showHyperlinkPopup==="editor",g=Uy(()=>{if(!u.current)return;let v=Zh(u.current.value)||null;if(!e.link&&v&&Re("hyperlink","create"),jh(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){n.mutateElement(e,{link:null}),i(e,!1);return}if(!A_(v,l.validateEmbeddable))v&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&Xd.set(e.id,e.link),n.mutateElement(e,{link:v}),i(e,!1);else{let{width:I,height:C}=e,P=M_(v);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let A=P?P.intrinsicSize.w/P.intrinsicSize.h:1,L=Xd.get(e.id)!==e.link;n.mutateElement(e,{...L?{width:P?.type==="video"?I>C?I:C*A:I,height:P?.type==="video"&&I>C?I/A:C}:{},link:v}),i(e,!0),Xd.has(e.id)&&Xd.delete(e.id)}}else n.mutateElement(e,{link:v})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);T_(()=>()=>{g()},[g]),Wy(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),Wy(()=>{let v=null,I=C=>{if(E)return;v&&clearTimeout(v),O_(e,a,s,Yy(C.clientX,C.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},N_))};return window.addEventListener($h.POINTER_MOVE,I,!1),()=>{window.removeEventListener($h.POINTER_MOVE,I,!1),v&&clearTimeout(v)}},[s,e,E,t,a]);let b=Uy(()=>{Re("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),y=()=>{Re("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:w,y:x}=Zy(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:Vy("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${w}px`,width:eg,padding:qh},children:[E?Wi("input",{className:v_("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:p,onChange:v=>m(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[Kd.CTRL_OR_CMD]&&v.key===Kd.K&&v.preventDefault(),(v.key===Kd.ENTER||v.key===Kd.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?Wi("a",{href:Zh(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:__(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&o){let I=D_($h.EXCALIDRAW_LINK,v.nativeEvent);o({...e,link:Zh(e.link)},I),I.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Wi("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),Vy("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&Wi($,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:y,className:"excalidraw-hyperlinkContainer--edit",icon:On}),Wi($,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Pc}),d&&!jh(e)&&Wi($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Ir})]})]})},Zy=(e,n,t)=>{let[o,r]=Qh(e,t),{x:i,y:a}=Ky({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-eg/2,l=a-n.offsetTop-Xy;return{x:s,y:l}},tg=(e,n)=>{let t=ie(e,n);return jh(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Fs=null,jy=(e,n,t)=>{Fs&&clearTimeout(Fs),Fs=window.setTimeout(()=>B_(e,n,t),C_)},B_=(e,n,t)=>{if(!e.link)return;let o=Mi();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=k_(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=Qh(e,t),[l,c,d,p]=Wb([r,i,a,s],e.angle,n),m=Ky({sceneX:l,sceneY:c},n);xh(o,{left:m.x,top:m.y,width:d,height:p},"top"),Re("hyperlink","tooltip","link-icon"),Jh=!0},$d=()=>{Fs&&clearTimeout(Fs),Jh&&(Jh=!1,Mi().classList.remove("excalidraw-tooltip--visible"))},O_=(e,n,t,[o,r])=>{let{x:i,y:a}=L_({clientX:o,clientY:r},t),s=15/t.zoom.value;if(P_(Yy(i,a),e,n))return!1;let[l,c,d]=Qh(e,n);if(i>=l&&i<=d&&a>=c-Xy&&a<=c)return!1;let{x:p,y:m}=Zy(e,t,n);return!(o>=p-s&&o<=p+eg+qh*2+s&&r>=m-s&&r<=m+s+qh*2+R_)};import{jsx as H_}from"react/jsx-runtime";var ng=F({name:"hyperlink",label:(e,n)=>tg(qy(e),n),icon:as,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:z_.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[Jy.CTRL_OR_CMD]&&e.key===Jy.K,predicate:(e,n)=>ie(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=ie(e,n);return H_($,{type:"toggle",icon:as,"aria-label":f(tg(qy(e),n)),title:`${F_(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 Qy,arrayToMap as rg,randomId as G_}from"@excalidraw/common";import{elementsAreInSameGroup as U_,getNonDeletedElements as ev,newElementWith as tv,selectGroupsFromGivenElements as nv}from"@excalidraw/element";import{CaptureUpdateAction as ov}from"@excalidraw/element";var og=e=>e.every(n=>!n.locked),zs=F({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return og(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=ie(n,e);return og(t)?gc:es},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=og(r),a=rg(r),s=r.length>1&&U_(r),c=r.length===1||s?null:G_(),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 p=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]),tv(y,{locked:i,groupIds:w.length!==y.groupIds.length?w:y.groupIds})}),m=rg(p),u=i?{}:Object.fromEntries(r.map(y=>[y.id,!0])),E=r.map(y=>m.get(y.id)||y),g=i?{}:nv(ev(E),n),b=i?c||(s?r[0].groupIds.at(-1):r[0].id):null;return{elements:p,appState:{...n,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:n.selectedLinearElement,lockedMultiSelections:d,activeLockedId:b},captureUpdate:ov.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===Qy.L&&e[Qy.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),rv=F({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:es,predicate:(e,n)=>ie(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 tv(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=rg(o),i=t.map(s=>r.get(s.id)||s),a=ev(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:nv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:ov.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as e8,isLinearElement as t8,isLineElement as qi}from"@excalidraw/element";import{arrayToMap as n8,invariant as Uv}from"@excalidraw/common";import{toggleLinePolygonState as o8,CaptureUpdateAction as Wv}from"@excalidraw/element";import{getSizeFromPoints as cTe,randomInteger as JR,getUpdatedTimestamp as QR}from"@excalidraw/common";import{simplify as DR}from"points-on-curve";import{getStroke as _R,getStrokePoints as V2e}from"perfect-freehand";function Ye([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function Vi([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function Qe([e,n,t],o){return[e*o,n*o,t*o]}function Hr([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function Et([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 Ye(e,Qe(Vi(n,e),t))}function ig(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 ag(e){return Math.atan2(Math.sin(e),Math.cos(e))}function sg([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 av(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 W_=(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=W_(((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 Hs(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[...Hs([t,...e.slice(1,i),a],n).slice(0,-1),a,...Hs([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var qo=class qo{constructor(n){T(this,"options");T(this,"originalPoints",[]);T(this,"stablePoints",[]);T(this,"tailPoints",[]);T(this,"isFresh",!0);this.options=Object.assign({},qo.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),av(this.tailPoints)>qo.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=Hs(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 L=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)L.push(Ye(P,Qe(Et([1,0,0],_),A)));return L.push(Ye(P,Qe([1,0,0],this.getSize(n,P[2],0,o,0)))),L}if(o===2){let P=t[0],A=t[1],L=this.getSize(n,P[2],0,o,0),_=this.getSize(n,A[2],0,o,0);if(L<.5||_<.5)return[];let k=[],D=ig(P,[P[0],P[1]-100,P[2]],A);for(let O=D;O<=Math.PI+D;O+=Math.PI/16)k.push(Ye(P,Qe(Et([1,0,0],O),L)));for(let O=Math.PI+D;O<=Math.PI*2+D;O+=Math.PI/16)k.push(Ye(A,Qe(Et([1,0,0],O),_)));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],L=t[P],_=t[P+1],k=L[2],D=zr(A,L);c+=D,a=s+(D-s)*.2;let O=this.getSize(n,k,P,o,c);if(O===0){l=P+1;continue}let G=Hr(Vi(A,L)),z=Hr(Vi(_,L)),W=Et(G,Math.PI/2),j=Et(G,-Math.PI/2),X=Et(z,Math.PI/2),oe=Et(z,-Math.PI/2),B=Ye(L,Qe(W,O)),U=Ye(L,Qe(j,O)),me=Ye(L,Qe(X,O)),be=Ye(L,Qe(oe,O)),de=Ye(W,oe),pe=Ye(j,X),xe=Ye(L,Qe(sg(de)===0?G:Hr(de),O)),ae=Ye(L,Qe(sg(pe)===0?z:Hr(pe),O)),we=ag(ig(L,A,_)),at=qo.constants.cornerDetectionMaxAngle/180*Math.PI*qo.constants.cornerDetectionVariance(a);if(Math.abs(we)<at){let $e=Math.abs(ag(Math.PI-we));if($e===0)continue;if(we<0){i.push(U,ae);for(let _e=0;_e<=$e;_e+=$e/4)r.push(Ye(L,Et(Qe(W,O),_e)));for(let _e=$e;_e>=0;_e-=$e/4)i.push(Ye(L,Et(Qe(W,O),_e)));i.push(ae,me)}else{r.push(B,xe);for(let _e=0;_e<=$e;_e+=$e/4)i.push(Ye(L,Et(Qe(W,-O),-_e)));for(let _e=$e;_e>=0;_e-=$e/4)r.push(Ye(L,Et(Qe(W,-O),-_e)));r.push(xe,be)}}else r.push(xe),i.push(ae);s=a}if(l>=o-2){if(this.options.keepHead){let P=t[o-1],A=[];for(let L=0;L<=Math.PI*2;L+=Math.PI/16)A.push(Ye(P,Qe(Et([1,0,0],L),this.options.size)));return A.push(Ye(P,Qe([1,0,0],this.options.size))),A}return[]}let d=t[l],p=t[l+1],m=t[o-2],u=t[o-1],E=Hr(Vi(p,d)),g=Hr(Vi(m,u)),b=Et(E,-Math.PI/2),y=Et(g,Math.PI/2),w=this.getSize(n,d[2],0,o,0),x=[],v=this.options.keepHead?this.options.size:this.getSize(n,m[2],o-2,o,c),I=[];if(w>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift(Ye(d,Et(Qe(b,w),-P)));x.unshift(Ye(d,Qe(b,-w)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)I.push(Ye(u,Et(Qe(y,-v),-P)));let C=[...x,...r,...I.reverse(),...i.reverse()];return x.length>0&&C.push(x[0]),this.options.simplify>0&&this.options.simplifyPhase==="output"?Hs(C,this.options.simplify):C}};T(qo,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),T(qo,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var Yi=qo;import{pointsOnBezierCurves as rce}from"points-on-curve";import{invariant as ace}from"@excalidraw/common";import{curve as lce,lineSegment as cce,pointFrom as dce,pointDistance as mce,pointFromArray as pce,pointFromVector as uce,pointRotateRads as hce,polygon as gce,polygonFromPoints as fce,PRECISION as Ece,segmentsIntersectAt as bce,vector as xce,vectorAdd as wce,vectorFromPoint as yce,vectorScale as vce}from"@excalidraw/math";import{getElementAbsoluteCoords as Ice}from"@excalidraw/element";var lg=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 RR,pointDistance as Bv,pointRotateRads as $2e}from"@excalidraw/math";import{ROUGHNESS as NR,THEME as Cg,isTransparent as Qs,assertNever as BR,COLOR_PALETTE as OR,LINE_POLYGON_POINT_MERGE_DISTANCE as j2e,applyDarkModeFilter as el,DEFAULT_STROKE_STREAMLINE as FR}from"@excalidraw/common";import{RoughGenerator as zR}from"roughjs/bin/generator";import o2e from"roughjs/bin/rough";import{isRightAngleRads as i2e,lineSegment as a2e,pointFrom as s2e,pointRotateRads as l2e}from"@excalidraw/math";import{BOUND_TEXT_PADDING as d2e,DEFAULT_REDUCED_GLOBAL_ALPHA as m2e,ELEMENT_READY_TO_ERASE_OPACITY as p2e,FRAME_STYLE as u2e,DARK_THEME_FILTER as h2e,MIME_TYPES as Nv,THEME as g2e,distance as f2e,getFontString as E2e,isRTL as b2e,getVerticalOffset as x2e,invariant as w2e,applyDarkModeFilter as y2e,isSafari as v2e}from"@excalidraw/common";import kve from"roughjs/bin/rough";import{arrayToMap as Ave,invariant as Rv,rescalePoints as Lve,sizeOf as Dve}from"@excalidraw/common";import{degreesToRadians as vg,lineSegment as Rve,pointFrom as bt,pointFromArray as SR,pointRotateRads as ji}from"@excalidraw/math";import{pointsOnBezierCurves as Ove}from"points-on-curve";import{pointCenter as Kye,pointFrom as Xye,pointRotateRads as $ye,pointsEqual as Zye,pointDistance as jye,vectorFromPoint as qye,curveLength as Jye,curvePointAtLength as Qye}from"@excalidraw/math";import{DRAGGING_THRESHOLD as nve,KEYS as ove,shouldRotateWithDiscreteAngle as rve,getGridPoint as ive,invariant as ave,isShallowEqual as sve,getFeatureFlag as lve}from"@excalidraw/common";import{arrayToMap as sye,getFeatureFlag as lye,getGridPoint as cye,invariant as dye,isTransparent as mye}from"@excalidraw/common";import{PRECISION as uye,clamp as hye,lineSegment as gye,pointDistance as fye,pointDistanceSq as Eye,pointFrom as bye,pointFromArray as xye,pointFromVector as wye,pointRotateRads as yye,pointsEqual as vye,vectorFromPoint as Tye,vectorNormalize as Iye,vectorScale as Sye}from"@excalidraw/math";import{invariant as kwe,isTransparent as Mwe}from"@excalidraw/common";import{curveIntersectLineSegment as Lwe,isPointWithinBounds as Dwe,lineSegment as _we,lineSegmentIntersectionPoints as Rwe,pointFrom as Nwe,pointFromVector as Bwe,pointRotateRads as Owe,pointsEqual as Fwe,vectorFromPoint as zwe,vectorNormalize as Hwe,vectorScale as Gwe}from"@excalidraw/math";import{ellipse as Wwe,ellipseSegmentInterceptPoints as Vwe}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as X_,DEFAULT_PROPORTIONAL_RADIUS as mg,invariant as Nce,LINE_CONFIRM_THRESHOLD as $_,ROUNDNESS as pg}from"@excalidraw/common";import{bezierEquation as Oce,curve as Fce,curveCatmullRomCubicApproxPoints as zce,curveOffsetPoints as Hce,lineSegment as Gce,lineSegmentIntersectionPoints as Uce,pointDistance as Z_,pointFrom as Wce,pointFromArray as Vce,pointFromVector as Yce,pointRotateRads as Kce,pointTranslate as Xce,rectangle as $ce,vectorFromPoint as Zce,vectorNormalize as jce,vectorScale as qce}from"@excalidraw/math";import{ROUNDNESS as kce,assertNever as Mce}from"@excalidraw/common";import{pointsEqual as Lce}from"@excalidraw/math";var lv=e=>!!e&&e.type==="embeddable",cg=e=>!!e&&e.type==="iframe",dg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),nn=e=>e!=null&&e.type==="text";var Kn=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var on=e=>e!=null&&Y_(e.type);var wn=e=>e!=null&&e.type==="arrow",yn=e=>wn(e)&&e.elbowed;var Y_=e=>e==="arrow"||e==="line";var mo=e=>e!==null&&"containerId"in e&&e.containerId!==null&&nn(e);var Ki=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return Z_(t,o)<=$_/n}return!1},Gs=(e,n)=>{if(n.roundness?.type===pg.PROPORTIONAL_RADIUS||n.roundness?.type===pg.LEGACY)return e*mg;if(n.roundness?.type===pg.ADAPTIVE_RADIUS){let t=n.roundness?.value??X_,o=t/mg;return e<=o?e*mg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as swe,ARROW_LABEL_WIDTH_FRACTION as lwe,BOUND_TEXT_PADDING as cwe,DEFAULT_FONT_SIZE as dwe,TEXT_ALIGN as mwe,VERTICAL_ALIGN as pwe,getFontString as uwe,isProdEnv as hwe,invariant as gwe}from"@excalidraw/common";import{pointFrom as Ewe,pointRotateRads as bwe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as mde,DEFAULT_FONT_SIZE as pde,DEFAULT_FONT_FAMILY as ude,getFontString as hde,isTestEnv as gde,normalizeEOL as fde}from"@excalidraw/common";var Ede="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Ide,isTestEnv as Sde}from"@excalidraw/common";import{toIterable as n0e}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Ade,viewportCoordsToSceneCoords as Lde}from"@excalidraw/common";import{normalizeRadians as _de,radiansBetweenAngles as Rde,radiansDifference as Nde}from"@excalidraw/math";import{pointsEqual as Ode}from"@excalidraw/math";import{arrayToMap as yme,isShallowEqual as Q_}from"@excalidraw/common";import{arrayToMap as tme}from"@excalidraw/common";import{isPointWithinBounds as ome,pointFrom as rme,segmentsIntersectAt as ime}from"@excalidraw/math";import{arrayToMap as Wde}from"@excalidraw/common";import{validateOrderKey as Yde,generateNKeysBetween as Kde}from"@excalidraw/fractional-indexing";var ug=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var Mme=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}(),Ks=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){Gr(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&&mo(i)&&Gr(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{Kn(a)&&ug(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var gg=(e,n)=>Q_(n.selectedElementIds,e)?n.selectedElementIds:e;var eR=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 m of i){let u=m.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={},p=a.reduce((m,u)=>{if(u.isDeleted)return m;let E=u.groupIds.find(g=>c[g]);return E&&(m[u.id]=!0,Array.isArray(d[E])?d[E].push(u.id):d[E]=[u.id]),m},{});for(let m of Object.keys(d))d[m].length<2&&c[m]&&(c[m]=!1);return n=a,e=i,t={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:gg({...s.selectedElementIds,...p},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Ks(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:gg(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var Xme=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as Wpe,VERTICAL_ALIGN as Vpe}from"@excalidraw/common";import{pointDistance as Kpe,pointFromVector as Xpe,pointsEqual as $pe,vector as Zpe,vectorDot as jpe,vectorFromPoint as qpe,vectorNormalize as Jpe,vectorScale as Qpe}from"@excalidraw/math";import{invariant as ipe,isDevEnv as ape,isTestEnv as spe}from"@excalidraw/common";import{pointFrom as cpe,pointFromVector as dpe,pointRotateRads as mpe,pointScaleFromOrigin as ppe,pointsEqual as upe,triangleIncludesPoint as hpe,vectorCross as gpe,vectorFromPoint as oR,vectorScale as fpe}from"@excalidraw/math";var Zs=[1,0],Qd=[0,1],js=[-1,0],em=[0,-1],tm=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?Zs:n<=-r?js:t>o?Qd:em},Ev=(e,n)=>tm(oR(e,n)),nm=(e,n)=>om(Ev(e,n)),$s=(e,n)=>e[0]===n[0]&&e[1]===n[1],om=e=>$s(e,Zs)||$s(e,js);import{DEFAULT_ELEMENT_PROPS as ype,DEFAULT_FONT_FAMILY as vpe,DEFAULT_FONT_SIZE as Tpe,DEFAULT_TEXT_ALIGN as Ipe,DEFAULT_VERTICAL_ALIGN as Spe,DEFAULT_STROKE_STREAMLINE as Cpe,VERTICAL_ALIGN as Ppe,randomInteger as kpe,randomId as Mpe,getFontString as Ape,getUpdatedTimestamp as Lpe,getLineHeight as Dpe}from"@excalidraw/common";import{pointsOnBezierCurves as vue,simplify as Tue}from"points-on-curve";import{curveToBezier as Sue}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as Pue,lineSegment as kue,lineSegmentIntersectionPoints as Mue,pointDistance as Aue,pointFrom as Lue,pointRotateRads as Due,polygonArea as _ue,polygonIncludesPoint as Rue,polygonIncludesPointNonZero as Nue,polygonSignedArea as Bue}from"@excalidraw/math";import{isOpaqueColor as Fue,isTransparent as zue}from"@excalidraw/common";var yv=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as due,distanceToLineSegment as mue,pointRotateRads as pue}from"@excalidraw/math";import{ellipse as hue,ellipseDistanceFromPoint as gue}from"@excalidraw/math/ellipse";import{pointFrom as Que,pointCenter as ehe,pointRotateRads as the,vectorFromPoint as nhe,vectorNormalize as ohe,vectorSubtract as rhe,vectorAdd as ihe,vectorScale as ahe,pointFromVector as she,clamp as lhe,isCloseTo as che}from"@excalidraw/math";import{arrayToMap as Fge,arrayToObject as zge,assertNever as Hge,isDevEnv as Gge,isShallowEqual as Uge,isTestEnv as Wge,randomInteger as Vge}from"@excalidraw/common";import{assertNever as Yhe,COLOR_PALETTE as Khe,isDevEnv as Xhe,isTestEnv as $he,randomId as Zhe,Emitter as jhe,toIterable as qhe}from"@excalidraw/common";import{ORIG_ID as vhe,randomId as The,randomInteger as Ihe,arrayToMap as She,castArray as Che,findLastIndex as Phe,getUpdatedTimestamp as khe,isTestEnv as Mhe}from"@excalidraw/common";import{arrayToMap as hhe}from"@excalidraw/common";import aR from"lodash.throttle";import{randomInteger as pge,arrayToMap as uge,toBrandedType as hge,isDevEnv as Sv,isTestEnv as Cv,toArray as gge}from"@excalidraw/common";import{isNonDeletedElement as Ege}from"@excalidraw/element";import{isFrameLikeElement as xge}from"@excalidraw/element";import{getElementsInGroup as yge}from"@excalidraw/element";import{syncInvalidIndices as Tge,syncMovedIndices as Ige,validateFractionalIndices as sR}from"@excalidraw/element";import{getSelectedElements as Cge}from"@excalidraw/element";import{mutateElement as kge}from"@excalidraw/element";var Mge=aR(e=>{(Sv()||Cv()||window?.DEBUG_FRACTIONAL_INDICES)&&sR(e,{shouldThrow:Sv()||Cv(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as gfe,getGridPoint as ffe,getFontString as Efe,DRAGGING_THRESHOLD as bfe}from"@excalidraw/common";import{clamp as Mfe,pointDistance as Afe,pointFrom as Lfe,pointScaleFromOrigin as Dfe,pointsEqual as _fe,pointTranslate as Rfe,vector as Nfe,vectorCross as Bfe,vectorFromPoint as Ofe,vectorScale as Ffe}from"@excalidraw/math";import{BinaryHeap as Hfe,invariant as Gfe,isAnyTrue as Ufe,getSizeFromPoints as Wfe,isDevEnv as Vfe,arrayToMap as Yfe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as iEe,normalizeLink as aEe}from"@excalidraw/common";import{FONT_FAMILY as mEe,VERTICAL_ALIGN as pEe,escapeDoubleQuotes as uEe,getFontString as hEe}from"@excalidraw/common";import{invariant as TEe,toBrandedType as IEe}from"@excalidraw/common";import{clamp as CEe,pointFrom as PEe}from"@excalidraw/math";import{pointDistance as nbe,pointFrom as obe}from"@excalidraw/math";import{invariant as ibe}from"@excalidraw/common";import{arrayToMap as GEe,findIndex as UEe,findLastIndex as WEe}from"@excalidraw/common";import{isFiniteNumber as YEe}from"@excalidraw/math";import{MIME_TYPES as gbe,SVG_NS as fbe}from"@excalidraw/common";import{rgbaToThumbHash as bbe,thumbHashToRGBA as xbe}from"thumbhash";import{pointCenter as Nbe,normalizeRadians as Bbe,pointFrom as Obe,pointRotateRads as Fbe}from"@excalidraw/math";import{MIN_FONT_SIZE as Hbe,SHIFT_LOCKING_ANGLE as Gbe,rescalePoints as Ube,getFontString as Wbe}from"@excalidraw/common";import{pointFrom as fxe,pointOnLineSegment as Exe,pointRotateRads as bxe}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as wxe}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as oxe}from"@excalidraw/common";import{pointFrom as ixe,pointRotateRads as axe}from"@excalidraw/math";import{KEYS as Tn}from"@excalidraw/common";var Lxe=[{icon:fc,value:"selection",key:Tn.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:ui,value:"rectangle",key:Tn.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:hi,value:"diamond",key:Tn.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:gi,value:"ellipse",key:Tn.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Ec,value:"arrow",key:Tn.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Do,value:"line",key:Tn.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:On,value:"freedraw",key:[Tn.P,Tn.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:En,value:"text",key:Tn.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Tr,value:"image",key:[Tn.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:bc,value:"eraser",key:Tn.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as Wxe}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as Yxe,DEFAULT_FONT_SIZE as Kxe,TEXT_ALIGN as Xxe,VERTICAL_ALIGN as $xe,getSizeFromPoints as Zxe,randomId as jxe,arrayToMap as qxe,assertNever as Jxe,cloneJSON as Qxe,getFontString as e1e,isDevEnv as t1e,toBrandedType as n1e,getLineHeight as o1e}from"@excalidraw/common";import{getBoundsFromPoints as C1e,getElementAbsoluteCoords as P1e}from"@excalidraw/element/bounds";import{newArrowElement as M1e,newElement as A1e,newLinearElement as L1e}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as _1e,getStrokeWidthByKey as R1e,ROUNDNESS as N1e}from"@excalidraw/common";import{convexHull as O1e,distanceToLineSegment as F1e,elongation as z1e,kurtosis as H1e,lineSegment as G1e,orientPrincipalAxes as U1e,pointFrom as W1e,polygonArea as V1e,principalAxes as Y1e,principalCoords as K1e,skewness as X1e}from"@excalidraw/math";var q1e=[{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 Gr=e=>!e.isDeleted;var bR=10/1.5;var Zd=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 CR=20,PR=15,kR=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 PR;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return CR;default:return 15}},MR=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Mt=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=lg(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;Rv(s.length===6,"Op data length is not 6");let l=bt(s[4],s[5]),c=bt(s[2],s[3]),d=bt(s[0],s[1]),p=i[a-1],m=bt(0,0);if(p.op==="move"){let X=SR(p.data);Rv(X!=null,"Op data is not a point"),m=X}else p.op==="bcurveTo"&&(m=bt(p.data[4],p.data[5]));let u=(X,oe)=>Math.pow(1-X,3)*l[oe]+3*X*Math.pow(1-X,2)*c[oe]+3*Math.pow(X,2)*(1-X)*d[oe]+m[oe]*Math.pow(X,3),[E,g]=t==="start"?m:l,[b,y]=[u(.3,0),u(.3,1)],w=Math.hypot(E-b,g-y),x=(E-b)/w,v=(g-y)/w,I=kR(o),C=0;{let[X,oe]=t==="end"?e.points[e.points.length-1]:e.points[0],[B,U]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(X-B,oe-U)}let A=Math.min(I,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),L=E-x*A*r,_=g-v*A*r,k=L-x*A,D=_-v*A;if(o==="circle"||o==="circle_outline"){let X=Math.hypot(D-_,k-L)+e.strokeWidth-2;return[L,_,X]}let O=MR(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[X,oe]=ji(bt(L,_),bt(k,D),vg(-O)),[B,U]=ji(bt(L,_),bt(k,D),vg(O));return[k,D,X,oe,B,U]}let[G,z]=ji(bt(k,D),bt(L,_),-O*Math.PI/180),[W,j]=ji(bt(k,D),bt(L,_),vg(O));if(o==="diamond"||o==="diamond_outline"){let X,oe;if(t==="start"){let[B,U]=e.points.length>1?e.points[1]:[0,0];[X,oe]=ji(bt(L+A*2,_),bt(L,_),Math.atan2(U-_,B-L))}else{let[B,U]=e.points.length>1?e.points[e.points.length-2]:[0,0];[X,oe]=ji(bt(L-A*2,_),bt(L,_),Math.atan2(_-U,L-B))}return[L,_,G,z,X,oe,W,j]}return[L,_,G,z,W,j]};var AR=typeof document<"u"?document.createElement("img"):{src:""};AR.src=`data:${Nv.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 LR=typeof document<"u"?document.createElement("img"):{src:""};LR.src=`data:${Nv.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 Tg=new WeakMap;var Ot=class Ot{};T(Ot,"rg",new zR),T(Ot,"cache",new WeakMap),T(Ot,"get",(n,t)=>{let o=Ot.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),T(Ot,"delete",n=>{Ot.cache.delete(n),Tg.delete(n)}),T(Ot,"destroy",()=>{Ot.cache=new WeakMap}),T(Ot,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Ot.get(n,t?t.theme:null);if(o!==void 0)return o;Tg.delete(n);let r=UR(n,Ot.rg,t||{isExporting:!1,canvasBackgroundColor:OR.white,embedsValidationStatus:null,theme:Cg.LIGHT});return t?.isExporting||Ot.cache.set(n,{shape:r,theme:t?.theme||Cg.LIGHT}),r});var Zi=Ot,HR=e=>[8,8+e],Hv=e=>[1.5,6+e];function GR(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&&yv(e.type)||on(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var uo=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?HR(e.strokeWidth):e.strokeStyle==="dotted"?Hv(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:GR(e),stroke:el(e.strokeColor,t),preserveVertices:n||e.roughness<NR.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=Qs(e.backgroundColor)?void 0:el(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return Ki(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:el(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},Ov=(e,n,t)=>dg(e)&&(n||lv(e)&&t?.get(e.id)!==!0)&&Qs(e.backgroundColor)&&Qs(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:cg(e)?{...e,strokeColor:Qs(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Qs(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Js=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},im=(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)]},Wr=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=Hv(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Ig=(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)]},Fv=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=el(e.strokeColor,s),c=el(a,s),d=-.25,p=.8;switch(o){case"circle":case"circle_outline":return Ig(r,i,l,Mt(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let m=Mt(e,n,t,o);if(m===null)return[];let[u,E,g,b,y,w]=m,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 m=Mt(e,n,t,o);if(m===null)return[];let[u,E,g,b,y,w,x,v]=m,I={...i,fill:o==="diamond_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete I.strokeLineDash,[r.polygon([[u,E],[g,b],[y,w],[x,v],[u,E]],I)]}case"cardinality_one":return Js(r,Mt(e,n,t,o),Wr(e,i));case"cardinality_many":return im(r,Mt(e,n,t,o),Wr(e,i));case"cardinality_one_or_many":{let m=Wr(e,i);return[...im(r,Mt(e,n,t,"cardinality_many"),m),...Js(r,Mt(e,n,t,"cardinality_one",d),m)]}case"cardinality_exactly_one":{let m=Wr(e,i);return[...Js(r,Mt(e,n,t,"cardinality_one",-.5),m),...Js(r,Mt(e,n,t,"cardinality_one"),m)]}case"cardinality_zero_or_one":{let m=Wr(e,i);return[...Ig(r,i,l,Mt(e,n,t,"circle_outline",1.5),c,p),...Js(r,Mt(e,n,t,"cardinality_one",-.5),m)]}case"cardinality_zero_or_many":{let m=Wr(e,i);return[...im(r,Mt(e,n,t,"cardinality_many"),m),...Ig(r,i,l,Mt(e,n,t,"circle_outline",1.5),c,p)]}case"bar":case"arrow":default:return im(r,Mt(e,n,t,o),Wr(e,i))}};var UR=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===Cg.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=Gs(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`,uo(Ov(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,uo(Ov(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,p,m,u,E,g]=Zd(e);if(e.roundness){let b=Gs(Math.abs(l-E),e),y=Gs(Math.abs(p-c),e);s=n.path(`M ${l+b} ${c+y} L ${d-b} ${p-y}
5
- C ${d} ${p}, ${d} ${p}, ${d-b} ${p+y}
6
- L ${m+b} ${u-y}
7
- C ${m} ${u}, ${m} ${u}, ${m-b} ${u-y}
4
+ ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var ty=async(e,n,t)=>{let o=ex(n);if(!tx(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}=Or(r,i,!1);return await Fr(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as wL,jsx as Jo,jsxs as iy}from"react/jsx-runtime";var zh=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>Jo($w,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),ny=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:vn.EVENTUALLY})}),Hh=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Jo(Rh,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),Ud=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>iy(Rh,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),Jo(ct,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:Jo("div",{className:"excalidraw-tooltip-icon",children:Ox})})]})}),Gi=!1,Fh=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?iy(wL,{children:[t,Jo(Nd.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function xL(e,n){if(n.app.state.isLoading&&(Fh(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")Fh(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(Fh(n.app,{progress:null}),await e)}function oy(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await xL(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 zr=O({name:"saveToActiveFile",label:"buttons.save",icon:us,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(Gi)return!1;Gi=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=oy(e,n,o.files,o);try{let{fileHandle:l}=wc(r)?await ty(s,r,i):await gc({data:s,filename:i,fileHandle:r});return{captureUpdate:vn.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:vn.NEVER,appState:{toast:null}}}finally{Gi=!1}},keyTest:e=>!1}),Ws=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:us,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(Gi)return!1;Gi=!0;let{abortController:r,data:i}=oy(e,n,o.files,o);try{let{fileHandle:a}=await gc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:vn.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:vn.NEVER,appState:{toast:null}}}finally{Gi=!1}},keyTest:e=>e.key.toLowerCase()===Gd.S&&e.shiftKey&&e[Gd.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Jo(K,{type:"button",icon:Dx,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:ge().formFactor==="phone",hidden:!mi,onClick:()=>e(null),"data-testid":"save-as-button"})}),Ui=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 mu(n,e);return{elements:r,appState:i,files:a,captureUpdate:vn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:vn.EVENTUALLY}}},keyTest:e=>e[Gd.CTRL_OR_CMD]&&e.key===Gd.O}),ry=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?Us.DARK:Us.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Jo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Jo(Xw,{value:e.exportWithDarkMode?Us.DARK:Us.LIGHT,onChange:t=>{n(t===Us.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as yL,DEFAULT_FONT_FAMILY as vL,DEFAULT_TEXT_ALIGN as IL,getLineHeight as TL}from"@excalidraw/common";import{newElementWith as Wd}from"@excalidraw/element";import{hasBoundTextElement as SL,canApplyRoundnessTypeToElement as CL,getDefaultRoundnessTypeForElement as PL,isFrameLikeElement as kL,isArrowElement as ML,isExcalidrawElement as AL,isTextElement as ay}from"@excalidraw/element";import{getBoundTextElement as LL,redrawTextBoundingBox as DL}from"@excalidraw/element";import{CaptureUpdateAction as Gh}from"@excalidraw/element";var sy="{}",_L=O({name:"copyStyles",label:"labels.copyStyles",icon:Bu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&SL(i)){let a=LL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(sy=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:Gh.EVENTUALLY}}}),RL=O({name:"pasteStyles",label:"labels.pasteStyles",icon:Bu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(sy),i=r[0],a=r[1];if(!AL(i))return{elements:e,captureUpdate:Gh.EVENTUALLY};let s=ie(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(ay(c)&&c.containerId&&(d=a),!d)return c;let m=Wd(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?CL(d.roundness.type,c)?d.roundness:PL(c):null});if(ay(m)){let p=d.fontSize||yL,u=d.fontFamily||vL,E=Wd(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||IL,lineHeight:d.lineHeight||TL(u)});m=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),DL(E,g,o.scene)}return m.type==="arrow"&&ML(d)&&(m=Wd(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),kL(c)&&(m=Wd(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:Gh.IMMEDIATELY}}});import{KEYS as NL}from"@excalidraw/common";import{CaptureUpdateAction as BL}from"@excalidraw/element";var Hr=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Px,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:BL.EVENTUALLY}),keyTest:e=>e.key===NL.QUESTION_MARK});import{getNonDeletedElements as Yd}from"@excalidraw/element";import{newElementWith as cy}from"@excalidraw/element";import{isBoundToContainer as OL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as FL,getElementsInResizingFrame as zL,getFrameLikeElements as HL,getRootElements as GL,groupByFrameLikes as UL,removeElementsFromFrame as WL,replaceAllElementsInFrame as VL}from"@excalidraw/element";import{KEYS as Xd,randomId as YL,arrayToMap as Wh}from"@excalidraw/common";import{getSelectedGroupIds as Vd,selectGroup as XL,selectGroupsForSelectedElements as KL,getElementsInGroup as ly,addToGroup as $L,removeFromSelectedGroups as ZL,isElementInGroup as dy}from"@excalidraw/element";import{syncMovedIndices as jL}from"@excalidraw/element";import{CaptureUpdateAction as Vs}from"@excalidraw/element";import{jsx as Wi}from"react/jsx-runtime";var qL=(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=>dy(i,r)))return!0}return!1},Uh=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!qL(t,e.editingGroupId)&&!FL(t)},Vh=O({name:"group",label:"labels.group",icon:e=>Wi(Mu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!Uh(n,o))return!1;let r=GL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:Vs.EVENTUALLY};let i=Vd(n);if(i.length===1){let b=i[0],y=new Set(ly(e,b).map(v=>v.id)),w=new Set(r.map(v=>v.id));if(new Set([...Array.from(y),...Array.from(w)]).size===y.size)return{appState:n,elements:e,captureUpdate:Vs.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&UL(r).forEach((y,w)=>{WL(y,o.scene.getNonDeletedElementsMap())});let l=YL(),c=Wh(r);a=a.map(b=>c.get(b.id)?cy(b,{groupIds:$L(b.groupIds,l,n.editingGroupId)}):b);let d=ly(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!dy(b,l)),g=jL([...E,...d,...u],Wh(d));return{appState:{...n,...XL(l,{...n,selectedGroupIds:{}},Yd(a))},elements:g,captureUpdate:Vs.IMMEDIATELY}},predicate:(e,n,t,o)=>Uh(n,o),keyTest:e=>!e.shiftKey&&e[Xd.CTRL_OR_CMD]&&e.key===Xd.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Wi(K,{hidden:!Uh(n,o),type:"button",icon:Wi(Mu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Me(Yd(e),n)})}),Yh=O({name:"ungroup",label:"labels.ungroup",icon:e=>Wi(Au,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=Vd(n),i=Wh(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:Vs.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{OL(p)&&s.push(p.id);let u=ZL(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:cy(p,{groupIds:u})});let l=KL(n,Yd(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return HL(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=VL(a,zL(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:Vs.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Xd.CTRL_OR_CMD]&&e.key===Xd.G.toUpperCase(),predicate:(e,n)=>Vd(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>Wi(K,{type:"button",hidden:Vd(n).length===0,icon:Wi(Au,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Me(Yd(e),n)})});import rD from"clsx";import{CaptureUpdateAction as gy}from"@excalidraw/element";import{invariant as iD}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as JL,COLOR_VOICE_CALL as QL,COLOR_WHITE as $d,THEME as eD,UserIdleState as my}from"@excalidraw/common";var Kd=(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 tD(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 Gr=(e,n)=>`hsl(${Math.abs(tD(n?.id||e))%37*10}, 100%, 83%)`,py=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},uy=({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=Gr(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===my.IDLE||E===my.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===eD.DARK?"#2f6330":QL,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=$d,e.strokeStyle=$d,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,v=(y?l+0:l)+m+2,T=5,C=3,P=e.measureText(w),A=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,L=Math.max(A,12),_=x-1,k=v-1,D=P.width+2+T*2+2,F=L+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,D,F,8),e.fillStyle=u,e.fill(),e.strokeStyle=$d,e.stroke(),y&&(e.beginPath(),e.roundRect(_-2,k-2,D+4,F+4,8),e.strokeStyle=b,e.stroke())):Kd(e,_,k,D,F,8,$d),e.fillStyle=JL,e.fillText(w,x+T+1,v+C+P.actualBoundingBoxAscent+Math.floor((L-A)/2)+2),y){e.fillStyle=b;let Y=8,z=8,W=5;e.fillRect(_+D+z,k+(F/2-Y/2),2,Y),e.fillRect(_+D+z+W,k+(F/2-Y*2/2),2,Y*2),e.fillRect(_+D+z+W*2,k+(F/2-Y/2),2,Y)}}e.restore(),e.closePath()}};import nD from"clsx";import{useState as oD}from"react";import{jsx as hy}from"react/jsx-runtime";var Xh=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=py(t),[a,s]=oD(!1),l=!a&&o,c=l?void 0:{background:e};return hy("div",{className:nD("Avatar",r),style:c,onClick:n,children:l?hy("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as Yn,jsxs as Zd}from"react/jsx-runtime";var aD=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(iD(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:gy.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:gy.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=Gr(o,r),l=rD({"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?Zd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[Yn("div",{}),Yn("div",{}),Yn("div",{})]}):r.isMuted?Yn("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:N1}):Yn("div",{title:f("userList.hint.inCall"),children:R1}):null;return i?Zd("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:[Yn(Xh,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),Yn("div",{className:"UserList__collaborator-name",children:r.username}),Zd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Yn("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Ar}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):Zd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[Yn(Xh,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&Yn("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as Vi}from"@excalidraw/element";import{isFrameLikeElement as sD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as lD}from"@excalidraw/element";import{KEYS as Qo,arrayToMap as cD}from"@excalidraw/common";import{alignElements as dD}from"@excalidraw/element";import{CaptureUpdateAction as Yi}from"@excalidraw/element";import{getSelectedElementsByGroup as mD}from"@excalidraw/element";import{jsx as Ki}from"react/jsx-runtime";var pt=(e,n)=>{let t=n.scene.getSelectedElements(e);return mD(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>sD(o))},Xi=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=dD(r,o,t.scene,n),a=cD(i);return lD(e.map(s=>a.get(s.id)||s),n,t)},pD=O({name:"alignTop",label:"labels.alignTop",icon:Iu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"start",axis:"y"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Qo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Qo.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Iu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Me(Vi(e),n)})}),uD=O({name:"alignBottom",label:"labels.alignBottom",icon:Tu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"end",axis:"y"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Qo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Qo.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Tu,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Me(Vi(e),n)})}),hD=O({name:"alignLeft",label:"labels.alignLeft",icon:Su,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"start",axis:"x"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Qo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Qo.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Su,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Me(Vi(e),n)})}),gD=O({name:"alignRight",label:"labels.alignRight",icon:Cu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"end",axis:"x"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Qo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Qo.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Cu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Me(Vi(e),n)})}),fD=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Pu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"center",axis:"y"}),captureUpdate:Yi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Pu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Me(Vi(e),n)})}),ED=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:ku,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"center",axis:"x"}),captureUpdate:Yi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:ku,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Me(Vi(e),n)})});import{getNonDeletedElements as fy}from"@excalidraw/element";import{isFrameLikeElement as bD}from"@excalidraw/element";import{CODES as Ey,KEYS as by,arrayToMap as xD}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as wD}from"@excalidraw/element";import{distributeElements as yD}from"@excalidraw/element";import{CaptureUpdateAction as xy}from"@excalidraw/element";import{getSelectedElementsByGroup as vD}from"@excalidraw/element";import{jsx as vy}from"react/jsx-runtime";var wy=(e,n)=>{let t=n.scene.getSelectedElements(e);return vD(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>bD(o))},yy=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=yD(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=xD(i);return wD(e.map(s=>a.get(s.id)||s),n,t)},ID=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:yy(e,n,o,{space:"between",axis:"x"}),captureUpdate:xy.IMMEDIATELY}),keyTest:e=>!e[by.CTRL_OR_CMD]&&e.altKey&&e.code===Ey.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>vy(K,{hidden:!wy(n,o),type:"button",icon:Gx,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Me(fy(e),n)})}),TD=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:yy(e,n,o,{space:"between",axis:"y"}),captureUpdate:xy.IMMEDIATELY}),keyTest:e=>!e[by.CTRL_OR_CMD]&&e.altKey&&e.code===Ey.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>vy(K,{hidden:!wy(n,o),type:"button",icon:Ux,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Me(fy(e),n)})});import{arrayToMap as Iy,KEYS as CD,matchKey as PD}from"@excalidraw/common";import{CaptureUpdateAction as kD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as MD}from"@excalidraw/element/frame";import{arrangeElements as AD}from"@excalidraw/element/arrange";var SD={fitToViewport:!0,animate:!0,duration:200,viewportZoomFactor:.8},$i=(e,n)=>({smartZoom:{...SD,...n?.smartZoom},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as RD}from"react/jsx-runtime";var LD=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Iy(e),{arrange:i}=$i(n,t.props.editorPreferences),a=AD(t.scene,o,r,i.algorithm,i.gap),s=Iy(a);return MD(e.map(l=>s.get(l.id)||l),n,t)},DD=pt,_D=O({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:Fu,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>DD(n,o),perform:(e,n,t,o)=>({appState:n,elements:LD(e,n,o),captureUpdate:kD.IMMEDIATELY}),keyTest:e=>e.shiftKey&&PD(e,CD.R),PanelComponent:({updateData:e})=>RD("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+R")}`,children:Fu})});import{arrayToMap as Ty}from"@excalidraw/common";import{CaptureUpdateAction as ND}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as BD}from"@excalidraw/element/frame";import{normaliseElements as OD}from"@excalidraw/element/normalise";import{jsx as GD}from"react/jsx-runtime";var FD=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Ty(e),{normalise:i}=$i(n,t.props.editorPreferences),a=OD(t.scene,o,r,i.mode,i.metric),s=Ty(a);return BD(e.map(l=>s.get(l.id)||l),n,t)},zD=pt,HD=O({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:zu,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>zD(n,o),perform:(e,n,t,o)=>({appState:n,elements:FD(e,n,o),captureUpdate:ND.IMMEDIATELY}),PanelComponent:({updateData:e})=>GD("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:zu})});import{getNonDeletedElements as UD}from"@excalidraw/element";import{bindOrUnbindBindingElements as WD}from"@excalidraw/element";import{getCommonBoundingBox as Sy}from"@excalidraw/element";import{newElementWith as VD}from"@excalidraw/element";import{deepCopyElement as YD}from"@excalidraw/element";import{resizeMultipleElements as XD}from"@excalidraw/element";import{isArrowElement as Cy,isElbowArrow as KD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as Py}from"@excalidraw/element";import{CODES as ky,KEYS as $D,arrayToMap as ZD}from"@excalidraw/common";import{CaptureUpdateAction as My}from"@excalidraw/element";var Kh=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:z1,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Py(Ay(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:My.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ky.H}),$h=O({name:"flipVertical",label:"labels.flipVertical",icon:F1,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Py(Ay(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:My.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ky.V&&!e[$D.CTRL_OR_CMD]}),Ay=(e,n,t,o,r)=>{let i=ie(UD(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=jD(i,n,o,r),s=ZD(a);return e.map(l=>s.get(l.id)||l)},jD=(e,n,t,o)=>{if(e.every(p=>Cy(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return VD(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=Sy(e);XD(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,YD(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),WD(e.filter(Cy),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>KD(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=Sy(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 qD}from"@excalidraw/element";import{getTextFromElements as JD}from"@excalidraw/element";import{CODES as QD,KEYS as Ly,isFirefox as e_}from"@excalidraw/common";import{CaptureUpdateAction as Xt}from"@excalidraw/element";var Zi=O({name:"copy",label:"labels.copy",icon:ds,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Fd(r,o.files,t)}catch(i){return{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:Xt.EVENTUALLY}},keyTest:void 0}),Zh=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await Jw()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),e_?{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(jw({types:r}))}catch(i){return console.error(i),{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Xt.EVENTUALLY}},keyTest:void 0}),jd=O({name:"cut",label:"labels.cut",icon:M1,trackEvent:{category:"element"},perform:(e,n,t,o)=>(Zi.perform(e,n,t,o),Es.perform(e,n,null,o)),keyTest:e=>e[Ly.CTRL_OR_CMD]&&e.key===Ly.X}),t_=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:H1,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Xt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Or(e,n,!0);try{await Fr("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:Xt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Xt.EVENTUALLY}}},predicate:e=>Od&&e.length>0,keywords:["svg","clipboard","copy"]}),n_=O({name:"copyAsPng",label:"labels.copyAsPng",icon:G1,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Xt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Or(e,n,!0);try{return await Fr("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:Xt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:Xt.EVENTUALLY}}},predicate:e=>qo&&e.length>0,keyTest:e=>e.code===QD.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),o_=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{po(JD(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Xt.EVENTUALLY}},predicate:(e,n,t,o)=>Od&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(qD),keywords:["text","clipboard","copy"]});import{CODES as r_,KEYS as i_}from"@excalidraw/common";import{CaptureUpdateAction as a_}from"@excalidraw/element";var ji=O({name:"gridMode",icon:W1,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:a_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[i_.CTRL_OR_CMD]&&e.code===r_.QUOTE});import{KEYS as jh}from"@excalidraw/common";import{CaptureUpdateAction as s_}from"@excalidraw/element/store";import{jsx as c_}from"react/jsx-runtime";var l_=O({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:Hu,viewMode:!0,perform:(e,n,t,o)=>{let r=$i(n,o.props.editorPreferences).smartZoom,i=ie(e,n);return o.viewport.setViewport({target:i.length?i:e,fit:r.fitToViewport?"contain":"none",animation:r.animate?{duration:r.duration}:!1,offsets:{ui:!0},viewportZoomFactor:r.viewportZoomFactor}),{captureUpdate:s_.NEVER}},keyTest:e=>!e[jh.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===jh.F,PanelComponent:({data:e,updateData:n})=>c_(K,{type:"button",icon:Hu,"aria-label":f("labels.smartZoom"),onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:jh.F.toLocaleUpperCase()})});import{CODES as d_,KEYS as m_}from"@excalidraw/common";import{CaptureUpdateAction as p_}from"@excalidraw/element";var kt=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Fo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:p_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[m_.CTRL_OR_CMD]&&e.altKey&&e.code===d_.S});import{CaptureUpdateAction as u_}from"@excalidraw/element";var Ys=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:u_.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as h_}from"@excalidraw/element";var Xs=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:h_.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as g_,KEYS as f_}from"@excalidraw/common";import{CaptureUpdateAction as E_}from"@excalidraw/element";var er=O({name:"stats",label:"stats.fullTitle",icon:O1,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:E_.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[f_.CTRL_OR_CMD]&&e.altKey&&e.code===g_.SLASH});import{BOUND_TEXT_PADDING as Dy,ROUNDNESS as _y,TEXT_ALIGN as By,VERTICAL_ALIGN as Oy,arrayToMap as Fy,getFontString as b_,getStrokeWidthByKey as x_}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as w_,isBoundToContainer as Ry,resetOriginalContainerCache as y_,updateOriginalContainerCache as v_}from"@excalidraw/element";import{computeBoundTextPosition as I_,computeContainerDimensionForBoundText as Ny,getBoundTextElement as zy,redrawTextBoundingBox as Hy}from"@excalidraw/element";import{hasBoundTextElement as T_,isArrowElement as S_,isTextBindableContainer as qh,isTextElement as Ks,isUsingAdaptiveRadius as C_}from"@excalidraw/element";import{measureText as P_}from"@excalidraw/element";import{syncMovedIndices as Gy}from"@excalidraw/element";import{newElement as k_}from"@excalidraw/element";import{CaptureUpdateAction as Jh}from"@excalidraw/element";var Qh=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>T_(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=zy(a,i);if(s){let{width:l,height:c}=P_(s.originalText,b_(s),s.lineHeight),d=w_(a.id);y_(a.id);let{x:m,y:p}=I_(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:Jh.IMMEDIATELY}}}),eg=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=Ks(r[0])||Ks(r[1]),a;if(qh(r[0])?a=r[0]:qh(r[1])&&(a=r[1]),i&&a&&zy(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;Ks(r[0])&&qh(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:Oy.MIDDLE,textAlign:By.CENTER,autoResize:!0,angle:S_(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return Hy(i,a,o.scene),v_(a.id,s),{elements:M_(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:Jh.IMMEDIATELY}}}),M_=(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),Gy(o,Fy([n,t])),o},A_=(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),Gy(o,Fy([n,t])),o},Uy=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>Ks(a)&&!Ry(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(Ks(s)&&!Ry(s)){let l=k_({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:x_("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:C_("rectangle")?_y.ADAPTIVE_RADIUS:_y.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-Dy,y:s.y-Dy,width:Ny(s.width,"rectangle"),height:Ny(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:Oy.MIDDLE,boundElements:null,textAlign:By.CENTER,autoResize:!0}),Hy(s,l,o.scene),i=A_([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:Jh.IMMEDIATELY}}});import{getNonDeletedElements as Jy,isEmbeddableElement as K_}from"@excalidraw/element";import{KEYS as Qy}from"@excalidraw/common";import{CaptureUpdateAction as $_}from"@excalidraw/element";import{pointFrom as Xy}from"@excalidraw/math";import L_ from"clsx";import{useCallback as Wy,useEffect as Vy,useLayoutEffect as D_,useRef as __,useState as R_}from"react";import{EVENT as tg,HYPERLINK_TOOLTIP_DELAY as N_,KEYS as qd}from"@excalidraw/common";import{getElementAbsoluteCoords as ag}from"@excalidraw/element";import{hitElementBoundingBox as B_}from"@excalidraw/element";import{isElementLink as O_}from"@excalidraw/element";import{getEmbedLink as F_,embeddableURLValidator as z_}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Ky,viewportCoordsToSceneCoords as H_,wrapEvent as G_,isLocalLink as U_,normalizeLink as ng}from"@excalidraw/common";import{isEmbeddableElement as og}from"@excalidraw/element";import{jsx as qi,jsxs as Yy}from"react/jsx-runtime";var sg=380,W_=42,rg=5,$y=85,V_=500,ig=!1,Jd=new Map,Zy=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=Ko(),l=yn(),c=ge(),d=e.link||"",[m,p]=R_(d),u=__(null),E=s.showHyperlinkPopup==="editor",g=Wy(()=>{if(!u.current)return;let v=ng(u.current.value)||null;if(!e.link&&v&&Ne("hyperlink","create"),og(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){n.mutateElement(e,{link:null}),i(e,!1);return}if(!z_(v,l.validateEmbeddable))v&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&Jd.set(e.id,e.link),n.mutateElement(e,{link:v}),i(e,!1);else{let{width:T,height:C}=e,P=F_(v);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let A=P?P.intrinsicSize.w/P.intrinsicSize.h:1,L=Jd.get(e.id)!==e.link;n.mutateElement(e,{...L?{width:P?.type==="video"?T>C?T:C*A:T,height:P?.type==="video"&&T>C?T/A:C}:{},link:v}),i(e,!0),Jd.has(e.id)&&Jd.delete(e.id)}}else n.mutateElement(e,{link:v})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);D_(()=>()=>{g()},[g]),Vy(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),Vy(()=>{let v=null,T=C=>{if(E)return;v&&clearTimeout(v),X_(e,a,s,Xy(C.clientX,C.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},V_))};return window.addEventListener(tg.POINTER_MOVE,T,!1),()=>{window.removeEventListener(tg.POINTER_MOVE,T,!1),v&&clearTimeout(v)}},[s,e,E,t,a]);let b=Wy(()=>{Ne("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),y=()=>{Ne("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:w,y:x}=jy(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:Yy("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${w}px`,width:sg,padding:rg},children:[E?qi("input",{className:L_("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:m,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[qd.CTRL_OR_CMD]&&v.key===qd.K&&v.preventDefault(),(v.key===qd.ENTER||v.key===qd.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?qi("a",{href:ng(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:U_(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&o){let T=G_(tg.EXCALIDRAW_LINK,v.nativeEvent);o({...e,link:ng(e.link)},T),T.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):qi("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),Yy("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&qi(K,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:y,className:"excalidraw-hyperlinkContainer--edit",icon:zn}),qi(K,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Oc}),d&&!og(e)&&qi(K,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Pr})]})]})},jy=(e,n,t)=>{let[o,r]=ag(e,t),{x:i,y:a}=Ky({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-sg/2,l=a-n.offsetTop-$y;return{x:s,y:l}},lg=(e,n)=>{let t=ie(e,n);return og(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},$s=null,qy=(e,n,t)=>{$s&&clearTimeout($s),$s=window.setTimeout(()=>Y_(e,n,t),N_)},Y_=(e,n,t)=>{if(!e.link)return;let o=Ri();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=O_(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=ag(e,t),[l,c,d,m]=Zb([r,i,a,s],e.angle,n),p=Ky({sceneX:l,sceneY:c},n);Sh(o,{left:p.x,top:p.y,width:d,height:m},"top"),Ne("hyperlink","tooltip","link-icon"),ig=!0},Qd=()=>{$s&&clearTimeout($s),ig&&(ig=!1,Ri().classList.remove("excalidraw-tooltip--visible"))},X_=(e,n,t,[o,r])=>{let{x:i,y:a}=H_({clientX:o,clientY:r},t),s=15/t.zoom.value;if(B_(Xy(i,a),e,n))return!1;let[l,c,d]=ag(e,n);if(i>=l&&i<=d&&a>=c-$y&&a<=c)return!1;let{x:m,y:p}=jy(e,t,n);return!(o>=m-s&&o<=m+sg+rg*2+s&&r>=p-s&&r<=p+s+rg*2+W_)};import{jsx as Z_}from"react/jsx-runtime";var cg=O({name:"hyperlink",label:(e,n)=>lg(Jy(e),n),icon:hs,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:$_.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[Qy.CTRL_OR_CMD]&&e.key===Qy.K,predicate:(e,n)=>ie(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=ie(e,n);return Z_(K,{type:"toggle",icon:hs,"aria-label":f(lg(Jy(e),n)),title:`${K_(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 mg,randomId as j_}from"@excalidraw/common";import{elementsAreInSameGroup as q_,getNonDeletedElements as tv,newElementWith as nv,selectGroupsFromGivenElements as ov}from"@excalidraw/element";import{CaptureUpdateAction as rv}from"@excalidraw/element";var dg=e=>e.every(n=>!n.locked),Zs=O({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return dg(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=ie(n,e);return dg(t)?No:io},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=dg(r),a=mg(r),s=r.length>1&&q_(r),c=r.length===1||s?null:j_(),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]),nv(y,{locked:i,groupIds:w.length!==y.groupIds.length?w:y.groupIds})}),p=mg(m),u=i?{}:Object.fromEntries(r.map(y=>[y.id,!0])),E=r.map(y=>p.get(y.id)||y),g=i?{}:ov(tv(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:rv.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}),iv=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:io,predicate:(e,n)=>ie(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 nv(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=mg(o),i=t.map(s=>r.get(s.id)||s),a=tv(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:ov(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:rv.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as c8,isLinearElement as d8,isLineElement as ia}from"@excalidraw/element";import{arrayToMap as m8,invariant as Wv}from"@excalidraw/common";import{toggleLinePolygonState as p8,CaptureUpdateAction as Vv}from"@excalidraw/element";import{getSizeFromPoints as DIe,randomInteger as s8,getUpdatedTimestamp as l8}from"@excalidraw/common";import{simplify as GR}from"points-on-curve";import{getStroke as UR,getStrokePoints as uIe}from"perfect-freehand";function Xe([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function Ji([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function Qe([e,n,t],o){return[e*o,n*o,t*o]}function Wr([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function Et([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function av(e,n,t){return Xe(e,Qe(Ji(n,e),t))}function pg(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 ug(e){return Math.atan2(Math.sin(e),Math.cos(e))}function hg([e,n]){return Math.sqrt(e**2+n**2)}function Ur([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function sv(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=Ur(e[t-1],e[t]);return n+=Ur(e[e.length-2],e[e.length-1]),n}var J_=(e,n,t)=>Math.max(n,Math.min(t,e));function lv(e,n,t){let o=Ur(n,t);if(o===0)return Ur(e,n);let r=J_(((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 Ur(i,e)}function js(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=lv(l,t,o);return d>a?[d,c]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...js([t,...e.slice(1,i),a],n).slice(0,-1),a,...js([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var tr=class tr{constructor(n){I(this,"options");I(this,"originalPoints",[]);I(this,"stablePoints",[]);I(this,"tailPoints",[]);I(this,"isFresh",!0);this.options=Object.assign({},tr.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=av(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),sv(this.tailPoints)>tr.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=js(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 L=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)L.push(Xe(P,Qe(Et([1,0,0],_),A)));return L.push(Xe(P,Qe([1,0,0],this.getSize(n,P[2],0,o,0)))),L}if(o===2){let P=t[0],A=t[1],L=this.getSize(n,P[2],0,o,0),_=this.getSize(n,A[2],0,o,0);if(L<.5||_<.5)return[];let k=[],D=pg(P,[P[0],P[1]-100,P[2]],A);for(let F=D;F<=Math.PI+D;F+=Math.PI/16)k.push(Xe(P,Qe(Et([1,0,0],F),L)));for(let F=Math.PI+D;F<=Math.PI*2+D;F+=Math.PI/16)k.push(Xe(A,Qe(Et([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 A=t[P-1],L=t[P],_=t[P+1],k=L[2],D=Ur(A,L);c+=D,a=s+(D-s)*.2;let F=this.getSize(n,k,P,o,c);if(F===0){l=P+1;continue}let Y=Wr(Ji(A,L)),z=Wr(Ji(_,L)),W=Et(Y,Math.PI/2),$=Et(Y,-Math.PI/2),H=Et(z,Math.PI/2),re=Et(z,-Math.PI/2),B=Xe(L,Qe(W,F)),U=Xe(L,Qe($,F)),ue=Xe(L,Qe(H,F)),we=Xe(L,Qe(re,F)),pe=Xe(W,re),he=Xe($,H),ye=Xe(L,Qe(hg(pe)===0?Y:Wr(pe),F)),se=Xe(L,Qe(hg(he)===0?z:Wr(he),F)),ve=ug(pg(L,A,_)),st=tr.constants.cornerDetectionMaxAngle/180*Math.PI*tr.constants.cornerDetectionVariance(a);if(Math.abs(ve)<st){let Ze=Math.abs(ug(Math.PI-ve));if(Ze===0)continue;if(ve<0){i.push(U,se);for(let Re=0;Re<=Ze;Re+=Ze/4)r.push(Xe(L,Et(Qe(W,F),Re)));for(let Re=Ze;Re>=0;Re-=Ze/4)i.push(Xe(L,Et(Qe(W,F),Re)));i.push(se,ue)}else{r.push(B,ye);for(let Re=0;Re<=Ze;Re+=Ze/4)i.push(Xe(L,Et(Qe(W,-F),-Re)));for(let Re=Ze;Re>=0;Re-=Ze/4)r.push(Xe(L,Et(Qe(W,-F),-Re)));r.push(ye,we)}}else r.push(ye),i.push(se);s=a}if(l>=o-2){if(this.options.keepHead){let P=t[o-1],A=[];for(let L=0;L<=Math.PI*2;L+=Math.PI/16)A.push(Xe(P,Qe(Et([1,0,0],L),this.options.size)));return A.push(Xe(P,Qe([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=Wr(Ji(m,d)),g=Wr(Ji(p,u)),b=Et(E,-Math.PI/2),y=Et(g,Math.PI/2),w=this.getSize(n,d[2],0,o,0),x=[],v=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(Xe(d,Et(Qe(b,w),-P)));x.unshift(Xe(d,Qe(b,-w)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push(Xe(u,Et(Qe(y,-v),-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"?js(C,this.options.simplify):C}};I(tr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),I(tr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var Qi=tr;import{pointsOnBezierCurves as Pce}from"points-on-curve";import{invariant as Mce}from"@excalidraw/common";import{curve as Lce,lineSegment as Dce,pointFrom as _ce,pointDistance as Rce,pointFromArray as Nce,pointFromVector as Bce,pointRotateRads as Oce,polygon as Fce,polygonFromPoints as zce,PRECISION as Hce,segmentsIntersectAt as Gce,vector as Uce,vectorAdd as Wce,vectorFromPoint as Vce,vectorScale as Yce}from"@excalidraw/math";import{getElementAbsoluteCoords as Kce}from"@excalidraw/element";var gg=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 WR,pointDistance as Ov,pointRotateRads as EIe}from"@excalidraw/math";import{ROUGHNESS as VR,THEME as _g,isTransparent as cl,assertNever as YR,COLOR_PALETTE as XR,LINE_POLYGON_POINT_MERGE_DISTANCE as xIe,applyDarkModeFilter as dl,DEFAULT_STROKE_STREAMLINE as KR}from"@excalidraw/common";import{RoughGenerator as $R}from"roughjs/bin/generator";import C2e from"roughjs/bin/rough";import{isRightAngleRads as k2e,lineSegment as M2e,pointFrom as A2e,pointRotateRads as L2e}from"@excalidraw/math";import{BOUND_TEXT_PADDING as _2e,DEFAULT_REDUCED_GLOBAL_ALPHA as R2e,ELEMENT_READY_TO_ERASE_OPACITY as N2e,FRAME_STYLE as B2e,DARK_THEME_FILTER as O2e,MIME_TYPES as Bv,THEME as F2e,distance as z2e,getFontString as H2e,isRTL as G2e,getVerticalOffset as U2e,invariant as W2e,applyDarkModeFilter as V2e,isSafari as Y2e}from"@excalidraw/common";import qve from"roughjs/bin/rough";import{arrayToMap as Qve,invariant as Nv,rescalePoints as e2e,sizeOf as t2e}from"@excalidraw/common";import{degreesToRadians as Mg,lineSegment as o2e,pointFrom as bt,pointFromArray as RR,pointRotateRads as ra}from"@excalidraw/math";import{pointsOnBezierCurves as a2e}from"points-on-curve";import{pointCenter as gve,pointFrom as fve,pointRotateRads as Eve,pointsEqual as bve,pointDistance as xve,vectorFromPoint as wve,curveLength as yve,curvePointAtLength as vve}from"@excalidraw/math";import{DRAGGING_THRESHOLD as Sve,KEYS as Cve,shouldRotateWithDiscreteAngle as Pve,getGridPoint as kve,invariant as Mve,isShallowEqual as Ave,getFeatureFlag as Lve}from"@excalidraw/common";import{arrayToMap as Aye,getFeatureFlag as Lye,getGridPoint as Dye,invariant as _ye,isTransparent as Rye}from"@excalidraw/common";import{PRECISION as Bye,clamp as Oye,lineSegment as Fye,pointDistance as zye,pointDistanceSq as Hye,pointFrom as Gye,pointFromArray as Uye,pointFromVector as Wye,pointRotateRads as Vye,pointsEqual as Yye,vectorFromPoint as Xye,vectorNormalize as Kye,vectorScale as $ye}from"@excalidraw/math";import{invariant as qwe,isTransparent as Jwe}from"@excalidraw/common";import{curveIntersectLineSegment as eye,isPointWithinBounds as tye,lineSegment as nye,lineSegmentIntersectionPoints as oye,pointFrom as rye,pointFromVector as iye,pointRotateRads as aye,pointsEqual as sye,vectorFromPoint as lye,vectorNormalize as cye,vectorScale as dye}from"@excalidraw/math";import{ellipse as pye,ellipseSegmentInterceptPoints as uye}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as nR,DEFAULT_PROPORTIONAL_RADIUS as bg,invariant as rde,LINE_CONFIRM_THRESHOLD as oR,ROUNDNESS as xg}from"@excalidraw/common";import{bezierEquation as ade,curve as sde,curveCatmullRomCubicApproxPoints as lde,curveOffsetPoints as cde,lineSegment as dde,lineSegmentIntersectionPoints as mde,pointDistance as rR,pointFrom as pde,pointFromArray as ude,pointFromVector as hde,pointRotateRads as gde,pointTranslate as fde,rectangle as Ede,vectorFromPoint as bde,vectorNormalize as xde,vectorScale as wde}from"@excalidraw/math";import{ROUNDNESS as qce,assertNever as Jce}from"@excalidraw/common";import{pointsEqual as ede}from"@excalidraw/math";var cv=e=>!!e&&e.type==="embeddable",fg=e=>!!e&&e.type==="iframe",Eg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),rn=e=>e!=null&&e.type==="text";var Xn=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var an=e=>e!=null&&eR(e.type);var In=e=>e!=null&&e.type==="arrow",Tn=e=>In(e)&&e.elbowed;var eR=e=>e==="arrow"||e==="line";var uo=e=>e!==null&&"containerId"in e&&e.containerId!==null&&rn(e);var ea=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return rR(t,o)<=oR/n}return!1},qs=(e,n)=>{if(n.roundness?.type===xg.PROPORTIONAL_RADIUS||n.roundness?.type===xg.LEGACY)return e*bg;if(n.roundness?.type===xg.ADAPTIVE_RADIUS){let t=n.roundness?.value??nR,o=t/bg;return e<=o?e*bg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Awe,ARROW_LABEL_WIDTH_FRACTION as Lwe,BOUND_TEXT_PADDING as Dwe,DEFAULT_FONT_SIZE as _we,TEXT_ALIGN as Rwe,VERTICAL_ALIGN as Nwe,getFontString as Bwe,isProdEnv as Owe,invariant as Fwe}from"@excalidraw/common";import{pointFrom as Hwe,pointRotateRads as Gwe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Rde,DEFAULT_FONT_SIZE as Nde,DEFAULT_FONT_FAMILY as Bde,getFontString as Ode,isTestEnv as Fde,normalizeEOL as zde}from"@excalidraw/common";var Hde="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Kde,isTestEnv as $de}from"@excalidraw/common";import{toIterable as S0e}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Qde,viewportCoordsToSceneCoords as eme}from"@excalidraw/common";import{normalizeRadians as nme,radiansBetweenAngles as ome,radiansDifference as rme}from"@excalidraw/math";import{pointsEqual as ame}from"@excalidraw/math";import{arrayToMap as Vme,isShallowEqual as lR}from"@excalidraw/common";import{arrayToMap as Tme}from"@excalidraw/common";import{isPointWithinBounds as Cme,pointFrom as Pme,segmentsIntersectAt as kme}from"@excalidraw/math";import{arrayToMap as pme}from"@excalidraw/common";import{validateOrderKey as hme,generateNKeysBetween as gme}from"@excalidraw/fractional-indexing";var wg=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var Jme=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}(),nl=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){Vr(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&&uo(i)&&Vr(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{Xn(a)&&wg(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var vg=(e,n)=>lR(n.selectedElementIds,e)?n.selectedElementIds:e;var cR=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:vg({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):nl(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:vg(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var fpe=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as pue,VERTICAL_ALIGN as uue}from"@excalidraw/common";import{pointDistance as gue,pointFromVector as fue,pointsEqual as Eue,vector as bue,vectorDot as xue,vectorFromPoint as wue,vectorNormalize as yue,vectorScale as vue}from"@excalidraw/math";import{invariant as kpe,isDevEnv as Mpe,isTestEnv as Ape}from"@excalidraw/common";import{pointFrom as Dpe,pointFromVector as _pe,pointRotateRads as Rpe,pointScaleFromOrigin as Npe,pointsEqual as Bpe,triangleIncludesPoint as Ope,vectorCross as Fpe,vectorFromPoint as pR,vectorScale as zpe}from"@excalidraw/math";var il=[1,0],rm=[0,1],al=[-1,0],im=[0,-1],am=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?il:n<=-r?al:t>o?rm:im},bv=(e,n)=>am(pR(e,n)),sm=(e,n)=>lm(bv(e,n)),rl=(e,n)=>e[0]===n[0]&&e[1]===n[1],lm=e=>rl(e,il)||rl(e,al);import{DEFAULT_ELEMENT_PROPS as Vpe,DEFAULT_FONT_FAMILY as Ype,DEFAULT_FONT_SIZE as Xpe,DEFAULT_TEXT_ALIGN as Kpe,DEFAULT_VERTICAL_ALIGN as $pe,DEFAULT_STROKE_STREAMLINE as Zpe,VERTICAL_ALIGN as jpe,randomInteger as qpe,randomId as Jpe,getFontString as Qpe,getUpdatedTimestamp as eue,getLineHeight as tue}from"@excalidraw/common";import{pointsOnBezierCurves as Yue,simplify as Xue}from"points-on-curve";import{curveToBezier as $ue}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as jue,lineSegment as que,lineSegmentIntersectionPoints as Jue,pointDistance as Que,pointFrom as ehe,pointRotateRads as the,polygonArea as nhe,polygonIncludesPoint as ohe,polygonIncludesPointNonZero as rhe,polygonSignedArea as ihe}from"@excalidraw/math";import{isOpaqueColor as she,isTransparent as lhe}from"@excalidraw/common";var vv=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as _ue,distanceToLineSegment as Rue,pointRotateRads as Nue}from"@excalidraw/math";import{ellipse as Oue,ellipseDistanceFromPoint as Fue}from"@excalidraw/math/ellipse";import{pointFrom as vhe,pointCenter as Ihe,pointRotateRads as The,vectorFromPoint as She,vectorNormalize as Che,vectorSubtract as Phe,vectorAdd as khe,vectorScale as Mhe,pointFromVector as Ahe,clamp as Lhe,isCloseTo as Dhe}from"@excalidraw/math";import{arrayToMap as sfe,arrayToObject as lfe,assertNever as cfe,isDevEnv as dfe,isShallowEqual as mfe,isTestEnv as pfe,randomInteger as ufe}from"@excalidraw/common";import{assertNever as hge,COLOR_PALETTE as gge,isDevEnv as fge,isTestEnv as Ege,randomId as bge,Emitter as xge,toIterable as wge}from"@excalidraw/common";import{ORIG_ID as Yhe,randomId as Xhe,randomInteger as Khe,arrayToMap as $he,castArray as Zhe,findLastIndex as jhe,getUpdatedTimestamp as qhe,isTestEnv as Jhe}from"@excalidraw/common";import{arrayToMap as Ohe}from"@excalidraw/common";import gR from"lodash.throttle";import{randomInteger as Nge,arrayToMap as Bge,toBrandedType as Oge,isDevEnv as Cv,isTestEnv as Pv,toArray as Fge}from"@excalidraw/common";import{isNonDeletedElement as Hge}from"@excalidraw/element";import{isFrameLikeElement as Uge}from"@excalidraw/element";import{getElementsInGroup as Vge}from"@excalidraw/element";import{syncInvalidIndices as Xge,syncMovedIndices as Kge,validateFractionalIndices as fR}from"@excalidraw/element";import{getSelectedElements as Zge}from"@excalidraw/element";import{mutateElement as qge}from"@excalidraw/element";var Jge=gR(e=>{(Cv()||Pv()||window?.DEBUG_FRACTIONAL_INDICES)&&fR(e,{shouldThrow:Cv()||Pv(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as Ffe,getGridPoint as zfe,getFontString as Hfe,DRAGGING_THRESHOLD as Gfe}from"@excalidraw/common";import{clamp as Jfe,pointDistance as Qfe,pointFrom as eEe,pointScaleFromOrigin as tEe,pointsEqual as nEe,pointTranslate as oEe,vector as rEe,vectorCross as iEe,vectorFromPoint as aEe,vectorScale as sEe}from"@excalidraw/math";import{BinaryHeap as cEe,invariant as dEe,isAnyTrue as mEe,getSizeFromPoints as pEe,isDevEnv as uEe,arrayToMap as hEe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as kEe,normalizeLink as MEe}from"@excalidraw/common";import{FONT_FAMILY as REe,VERTICAL_ALIGN as NEe,escapeDoubleQuotes as BEe,getFontString as OEe}from"@excalidraw/common";import{invariant as XEe,toBrandedType as KEe}from"@excalidraw/common";import{clamp as ZEe,pointFrom as jEe}from"@excalidraw/math";import{pointDistance as Sbe,pointFrom as Cbe}from"@excalidraw/math";import{invariant as kbe}from"@excalidraw/common";import{arrayToMap as dbe,findIndex as mbe,findLastIndex as pbe}from"@excalidraw/common";import{isFiniteNumber as hbe}from"@excalidraw/math";import{MIME_TYPES as Fbe,SVG_NS as zbe}from"@excalidraw/common";import{rgbaToThumbHash as Gbe,thumbHashToRGBA as Ube}from"thumbhash";import{pointCenter as rxe,normalizeRadians as ixe,pointFrom as axe,pointRotateRads as sxe}from"@excalidraw/math";import{MIN_FONT_SIZE as cxe,SHIFT_LOCKING_ANGLE as dxe,rescalePoints as mxe,getFontString as pxe}from"@excalidraw/common";import{pointFrom as zxe,pointOnLineSegment as Hxe,pointRotateRads as Gxe}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as Wxe}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as Cxe}from"@excalidraw/common";import{pointFrom as kxe,pointRotateRads as Mxe}from"@excalidraw/math";import{KEYS as Cn}from"@excalidraw/common";var e1e=[{icon:Cc,value:"selection",key:Cn.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:Ei,value:"rectangle",key:Cn.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:bi,value:"diamond",key:Cn.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:xi,value:"ellipse",key:Cn.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Pc,value:"arrow",key:Cn.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Bo,value:"line",key:Cn.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:zn,value:"freedraw",key:[Cn.P,Cn.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:wn,value:"text",key:Cn.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Cr,value:"image",key:[Cn.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:kc,value:"eraser",key:Cn.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as p1e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as h1e,DEFAULT_FONT_SIZE as g1e,TEXT_ALIGN as f1e,VERTICAL_ALIGN as E1e,getSizeFromPoints as b1e,randomId as x1e,arrayToMap as w1e,assertNever as y1e,cloneJSON as v1e,getFontString as I1e,isDevEnv as T1e,toBrandedType as S1e,getLineHeight as C1e}from"@excalidraw/common";import{getBoundsFromPoints as Z1e,getElementAbsoluteCoords as j1e}from"@excalidraw/element/bounds";import{newArrowElement as J1e,newElement as Q1e,newLinearElement as e0e}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as n0e,getStrokeWidthByKey as o0e,ROUNDNESS as r0e}from"@excalidraw/common";import{convexHull as a0e,distanceToLineSegment as s0e,elongation as l0e,kurtosis as c0e,lineSegment as d0e,orientPrincipalAxes as m0e,pointFrom as p0e,polygonArea as u0e,principalAxes as h0e,principalCoords as g0e,skewness as f0e}from"@excalidraw/math";var w0e=[{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 Vr=e=>!e.isDeleted;var PR=10/1.5;var em=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 NR=20,BR=15,OR=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 BR;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return NR;default:return 15}},FR=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},At=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=gg(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;Nv(s.length===6,"Op data length is not 6");let l=bt(s[4],s[5]),c=bt(s[2],s[3]),d=bt(s[0],s[1]),m=i[a-1],p=bt(0,0);if(m.op==="move"){let H=RR(m.data);Nv(H!=null,"Op data is not a point"),p=H}else m.op==="bcurveTo"&&(p=bt(m.data[4],m.data[5]));let u=(H,re)=>Math.pow(1-H,3)*l[re]+3*H*Math.pow(1-H,2)*c[re]+3*Math.pow(H,2)*(1-H)*d[re]+p[re]*Math.pow(H,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,v=(g-y)/w,T=OR(o),C=0;{let[H,re]=t==="end"?e.points[e.points.length-1]:e.points[0],[B,U]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(H-B,re-U)}let A=Math.min(T,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),L=E-x*A*r,_=g-v*A*r,k=L-x*A,D=_-v*A;if(o==="circle"||o==="circle_outline"){let H=Math.hypot(D-_,k-L)+e.strokeWidth-2;return[L,_,H]}let F=FR(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[H,re]=ra(bt(L,_),bt(k,D),Mg(-F)),[B,U]=ra(bt(L,_),bt(k,D),Mg(F));return[k,D,H,re,B,U]}let[Y,z]=ra(bt(k,D),bt(L,_),-F*Math.PI/180),[W,$]=ra(bt(k,D),bt(L,_),Mg(F));if(o==="diamond"||o==="diamond_outline"){let H,re;if(t==="start"){let[B,U]=e.points.length>1?e.points[1]:[0,0];[H,re]=ra(bt(L+A*2,_),bt(L,_),Math.atan2(U-_,B-L))}else{let[B,U]=e.points.length>1?e.points[e.points.length-2]:[0,0];[H,re]=ra(bt(L-A*2,_),bt(L,_),Math.atan2(_-U,L-B))}return[L,_,Y,z,H,re,W,$]}return[L,_,Y,z,W,$]};var zR=typeof document<"u"?document.createElement("img"):{src:""};zR.src=`data:${Bv.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 HR=typeof document<"u"?document.createElement("img"):{src:""};HR.src=`data:${Bv.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 Ag=new WeakMap;var Ft=class Ft{};I(Ft,"rg",new $R),I(Ft,"cache",new WeakMap),I(Ft,"get",(n,t)=>{let o=Ft.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),I(Ft,"delete",n=>{Ft.cache.delete(n),Ag.delete(n)}),I(Ft,"destroy",()=>{Ft.cache=new WeakMap}),I(Ft,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Ft.get(n,t?t.theme:null);if(o!==void 0)return o;Ag.delete(n);let r=qR(n,Ft.rg,t||{isExporting:!1,canvasBackgroundColor:XR.white,embedsValidationStatus:null,theme:_g.LIGHT});return t?.isExporting||Ft.cache.set(n,{shape:r,theme:t?.theme||_g.LIGHT}),r});var oa=Ft,ZR=e=>[8,8+e],Gv=e=>[1.5,6+e];function jR(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&&vv(e.type)||an(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var go=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?ZR(e.strokeWidth):e.strokeStyle==="dotted"?Gv(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:jR(e),stroke:dl(e.strokeColor,t),preserveVertices:n||e.roughness<VR.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=cl(e.backgroundColor)?void 0:dl(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return ea(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:dl(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},Fv=(e,n,t)=>Eg(e)&&(n||cv(e)&&t?.get(e.id)!==!0)&&cl(e.backgroundColor)&&cl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:fg(e)?{...e,strokeColor:cl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:cl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,ll=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},dm=(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)]},Xr=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=Gv(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Lg=(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)]},zv=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=dl(e.strokeColor,s),c=dl(a,s),d=-.25,m=.8;switch(o){case"circle":case"circle_outline":return Lg(r,i,l,At(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let p=At(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=At(e,n,t,o);if(p===null)return[];let[u,E,g,b,y,w,x,v]=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,v],[u,E]],T)]}case"cardinality_one":return ll(r,At(e,n,t,o),Xr(e,i));case"cardinality_many":return dm(r,At(e,n,t,o),Xr(e,i));case"cardinality_one_or_many":{let p=Xr(e,i);return[...dm(r,At(e,n,t,"cardinality_many"),p),...ll(r,At(e,n,t,"cardinality_one",d),p)]}case"cardinality_exactly_one":{let p=Xr(e,i);return[...ll(r,At(e,n,t,"cardinality_one",-.5),p),...ll(r,At(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=Xr(e,i);return[...Lg(r,i,l,At(e,n,t,"circle_outline",1.5),c,m),...ll(r,At(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=Xr(e,i);return[...dm(r,At(e,n,t,"cardinality_many"),p),...Lg(r,i,l,At(e,n,t,"circle_outline",1.5),c,m)]}case"bar":case"arrow":default:return dm(r,At(e,n,t,o),Xr(e,i))}};var qR=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===_g.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=qs(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`,go(Fv(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,go(Fv(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,m,p,u,E,g]=em(e);if(e.roundness){let b=qs(Math.abs(l-E),e),y=qs(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
8
  L ${E+b} ${g+y}
9
9
  C ${E} ${g}, ${E} ${g}, ${E+b} ${g-y}
10
10
  L ${l-b} ${c+y}
11
- C ${l} ${c}, ${l} ${c}, ${l+b} ${c+y}`,uo(e,!0,a))}else s=n.polygon([[l,c],[d,p],[m,u],[E,g]],uo(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,uo(e,!1,a));case"line":case"arrow":{let s,l=uo(e,!1,a),c=e.points.length?e.points:[RR(0,0)];if(yn(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path(WR(c,16),uo(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:p="arrow"}=e;if(d!==null){let m=Fv(e,s,"start",d,n,l,o,a);s.push(...m)}if(p!==null){let m=Fv(e,s,"end",p,n,l,o,a);s.push(...m)}}return s}case"freedraw":{let s=[];if(Ki(e.points)){let l=DR(e.points,.75);s.push(n.curve(l,{...uo(e,!1,a),stroke:"none"}))}return s.push(VR(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return BR(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},WR=(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=nm(s,i),c=nm(a,s),d=Math.min(n,Bv(e[r],a)/2,Bv(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 VR=e=>qR(ZR(e)),Sg={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},YR={SIZE_FACTOR:1.4},Gv=e=>e.strokeOptions?.streamline??FR,KR=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 _R(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*Sg.SIZE_FACTOR,thinning:Sg.THINNING,smoothing:Sg.SMOOTHING,streamline:Gv(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},XR=e=>new Yi({size:e.strokeWidth*YR.SIZE_FACTOR,streamline:Gv(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),$R=e=>{let n=XR(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},ZR=e=>e.strokeOptions?.variability==="constant"?$R(e):KR(e);var zv=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],jR=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,qR=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,zv(o,i[0]),"L",i[0],"Z"):t.push(o,zv(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(jR,"$1")};var Ur=(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??JR(),updated:QR()}};import{jsx as Vv}from"react/jsx-runtime";var Ji=F({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&&t8(r[0])&&!e8(r[0]))},perform(e,n,t,o){Uv(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);Uv(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:Wv.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 Vv($,{type:"button",icon:G1,title:r,"aria-label":r,onClick:()=>n(null)})}}),TTe=F({name:"togglePolygon",icon:lu,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!qi(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=>qi(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!qi(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=n8(i);return{elements:e.map(l=>!s.has(l.id)||!qi(l)?l:Ur(l,{backgroundColor:a?l.backgroundColor:"transparent",...o8(l,a)})),appState:n,captureUpdate:Wv.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!qi(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>qi(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return Vv($,{type:"toggle",icon:lu,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as Yv,CANVAS_SEARCH_TAB as Kv,CLASSES as r8,DEFAULT_SIDEBAR as Xv}from"@excalidraw/common";import{CaptureUpdateAction as i8}from"@excalidraw/element";var Pg=F({name:"searchMenu",icon:Un,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===Xv.name&&n.openSidebar.tab===Kv){let r=o.excalidrawContainerValue.container?.querySelector(`.${r8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:Xv.name,tab:Kv},openDialog:null},captureUpdate:i8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[Yv.CTRL_OR_CMD]&&e.key===Yv.F});import{isImageElement as a8}from"@excalidraw/element";import{CaptureUpdateAction as s8}from"@excalidraw/element";import{jsx as l8}from"react/jsx-runtime";var kg=F({name:"cropEditor",label:"helpDialog.cropStart",icon:Du,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:s8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&a8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return l8($,{type:"button",icon:Du,title:o,"aria-label":o,onClick:()=>n(null)})}});import{canCreateLinkFromElements as Mg,defaultGetElementLinkFromSelection as c8,getLinkIdAndTypeFromSelection as d8}from"@excalidraw/element";import{CaptureUpdateAction as tl}from"@excalidraw/element";var $v=F({name:"copyElementLink",label:"labels.copyElementLink",icon:Ic,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=ie(e,n);try{if(window.location){let i=d8(r,n);return i?(await co(o.props.generateLinkForSelection?o.props.generateLinkForSelection(i.id,i.type):c8(i.id,i.type)),{appState:{toast:{message:f("toast.elementLinkCopied"),closable:!0}},captureUpdate:tl.EVENTUALLY}):{appState:n,elements:e,app:o,captureUpdate:tl.EVENTUALLY}}}catch(i){console.error(i)}return{appState:n,elements:e,app:o,captureUpdate:tl.EVENTUALLY}},predicate:(e,n)=>Mg(ie(e,n))}),kIe=F({name:"linkToElement",label:"labels.linkToElement",icon:Pc,perform:(e,n,t,o)=>{let r=ie(e,n);return r.length!==1||!Mg(r)?{elements:e,appState:n,app:o,captureUpdate:tl.EVENTUALLY}:{appState:{...n,openDialog:{name:"elementLinkSelector",sourceElementId:ie(e,n)[0].id}},captureUpdate:tl.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=ie(e,n);return n.openDialog?.name!=="elementLinkSelector"&&r.length===1&&Mg(r)},trackEvent:!1});import{getNonDeletedElements as m8}from"@excalidraw/element";import{mutateElement as p8}from"@excalidraw/element";import{newFrameElement as u8}from"@excalidraw/element";import{isFrameLikeElement as am}from"@excalidraw/element";import{addElementsToFrame as h8,removeAllElementsFromFrame as g8}from"@excalidraw/element";import{getFrameChildren as f8}from"@excalidraw/element";import{getElementsInGroup as E8}from"@excalidraw/element";import{getCommonBounds as b8}from"@excalidraw/element";import{CaptureUpdateAction as Qi}from"@excalidraw/element";var Zv=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&am(t[0])},jv=F({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(am(r)){let i=f8(m8(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:Qi.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:Qi.EVENTUALLY}},predicate:(e,n,t,o)=>Zv(n,o)}),qv=F({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return am(r)?{elements:g8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:Qi.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:Qi.EVENTUALLY}},predicate:(e,n,t,o)=>Zv(n,o)}),UIe=F({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:Qi.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),Jv=F({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=ie(e,n);return r.length>0&&!r.some(i=>am(i))},perform:(e,n,t,o)=>{let r=ie(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=b8(r,i),d=16,p=u8({x:a-d,y:s-d,width:l-a+d*2,height:c-s+d*2});if(n.editingGroupId){let u=E8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);p8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:h8([...o.scene.getElementsIncludingDeleted(),p],r,p),appState:{selectedElementIds:{[p.id]:!0}},captureUpdate:Qi.IMMEDIATELY}}});import{KEYS as ta,matchKey as Dg,arrayToMap as Qv,MOBILE_ACTION_BUTTON_BG as e2}from"@excalidraw/common";import{CaptureUpdateAction as Lg}from"@excalidraw/element";import{orderByFractionalIndex as S8}from"@excalidraw/element";import{Emitter as x8}from"@excalidraw/common";import{CaptureUpdateAction as w8,StoreChange as y8,StoreDelta as v8}from"@excalidraw/element";var ea=class extends v8{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)}},Vr=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},nl=class e{constructor(n){this.store=n;T(this,"onHistoryChangedEmitter",new x8);T(this,"undoStack",[]);T(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 ea)return;let t=ea.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Vr(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=w8.IMMEDIATELY,s=this.store.snapshot,l=n,c=t,d=!1;for(;i;){try{[l,c,d]=i.applyTo(l,c,s);let p=s.elements,m=s.maybeClone(a,l,c),u=y8.create(s,m),E=ea.applyLatestChanges(i,p,l);E.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:E}),i=E),s=m}finally{r(i)}if(d)break;i=o()}return[l,c]}finally{this.onHistoryChangedEmitter.trigger(new Vr(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=ea.inverse(t);return n.push(o)}};import{useEffect as T8,useState as I8}from"react";var Ag=(e,n)=>{let[t,o]=I8(n);return T8(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as r2}from"react/jsx-runtime";var t2=(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:Lg.EVENTUALLY};let[r,i]=o,a=S8(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Lg.NEVER}}return{captureUpdate:Lg.EVENTUALLY}},n2=e=>({name:"undo",label:"buttons.undo",icon:pu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>t2(r,t,()=>e.undo(Qv(n),t)),keyTest:n=>n[ta.CTRL_OR_CMD]&&Dg(n,ta.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=Ag(e.onHistoryChangedEmitter,new Vr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=rt()==="mobile";return r2($,{type:"button",icon:pu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?e2:{}}})}}),o2=e=>({name:"redo",label:"buttons.redo",icon:uu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>t2(r,t,()=>e.redo(Qv(n),t)),keyTest:n=>n[ta.CTRL_OR_CMD]&&n.shiftKey&&Dg(n,ta.Z)||n[ta.CTRL_OR_CMD]&&!n.shiftKey&&Dg(n,ta.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=Ag(e.onHistoryChangedEmitter,new Vr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=rt()==="mobile";return r2($,{type:"button",icon:uu,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?e2:{}}})}});import{getFontString as C8}from"@excalidraw/common";import{getTextAnchorRatios as P8,isExcalidrawElement as k8,isNonDeletedElement as M8,newElementWith as A8,updateBoundElements as L8}from"@excalidraw/element";import{measureText as D8}from"@excalidraw/element";import{isTextElement as _g}from"@excalidraw/element";import{CaptureUpdateAction as _8}from"@excalidraw/element";var Rg=F({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=ie(e,n);return o.length===1&&_g(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=ie(e,n),i=k8(t)&&_g(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!_g(a))return!1;let s=D8(a.originalText,C8(a),a.lineHeight),l=P8(a),c=A8(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 M8(c)&&L8(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:_8.IMMEDIATELY}}});import{CODES as R8,KEYS as N8}from"@excalidraw/common";import B8 from"clsx";import{CaptureUpdateAction as O8}from"@excalidraw/element";import{jsx as F8}from"react/jsx-runtime";var Yr=F({name:"viewMode",label:"labels.viewMode",icon:Pr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:O8.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[N8.CTRL_OR_CMD]&&e.altKey&&e.code===R8.R,PanelComponent:({data:e,updateData:n,appState:t,appProps:o})=>t.viewModeOnly||o.viewModeOnly?null:F8($,{type:"button",icon:Pr,"aria-label":f("labels.viewMode"),onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:B8({enabled:t.viewModeEnabled})})});import{isPromiseLike as z8}from"@excalidraw/common";import{jsx as H8}from"react/jsx-runtime";var Ng=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Re(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},sm=class{constructor(n,t,o,r){T(this,"actions",{});T(this,"updater");T(this,"getAppState");T(this,"getElementsIncludingDeleted");T(this,"app");T(this,"isActionBlockedByViewportTransition",n=>n.navigation===!0&&this.app.viewport.isLockedTransitionPending);T(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)||(Ng(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return H8(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:a,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});T(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(z8(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 Ng(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();Ng(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var Bg=e=>{let n=Array.from(e.values());return{x:i2(n,t=>t.x)/n.length,y:i2(n,t=>t.y)/n.length}},Og=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),i2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as V,pointRotateRads as Jo,rangeInclusive as rn,rangeIntersection as lm,rangesOverlap as cm}from"@excalidraw/math";import{TOOL_TYPE as Kr,KEYS as a2}from"@excalidraw/common";import{getCommonBounds as Fg,getDraggedElementsBounds as zg,getElementAbsoluteCoords as G8}from"@excalidraw/element";import{isBoundToContainer as d2}from"@excalidraw/element";import{getMaximumGroups as m2}from"@excalidraw/element";import{getSelectedElements as U8,getVisibleAndNonSelectedElements as p2}from"@excalidraw/element";var W8=8,s2=99999,dm=e=>W8/e,At=class At{};T(At,"referenceSnapPoints",null),T(At,"visibleGaps",null),T(At,"setReferenceSnapPoints",n=>{At.referenceSnapPoints=n}),T(At,"getReferenceSnapPoints",()=>At.referenceSnapPoints),T(At,"setVisibleGaps",n=>{At.visibleGaps=n}),T(At,"getVisibleGaps",()=>At.visibleGaps),T(At,"destroy",()=>{At.referenceSnapPoints=null,At.visibleGaps=null});var an=At,Qo=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,ho=({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[a2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[a2.CTRL_OR_CMD]&&!Qo(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},V8=(e,n,t=.01)=>Math.abs(e-n)<=t,ol=(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,p,m]=G8(a,n);r&&(s+=r.x,c+=r.x,p+=r.x,l+=r.y,d+=r.y,m+=r.y);let u=(c-s)/2,E=(d-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=Jo(V(s,l+E),V(p,m),a.angle),b=Jo(V(s+u,l),V(p,m),a.angle),y=Jo(V(c,l+E),V(p,m),a.angle),w=Jo(V(s+u,d),V(p,m),a.angle),x=V(p,m);i=t?[g,b,y,w]:[g,b,y,w,x]}else{let g=Jo(V(s,l),V(p,m),a.angle),b=Jo(V(c,l),V(p,m),a.angle),y=Jo(V(s,d),V(p,m),a.angle),w=Jo(V(c,d),V(p,m),a.angle),x=V(p,m);i=t?[g,b,y,w]:[g,b,y,w,x]}}else if(e.length>1){let[a,s,l,c]=zg(e,r??{x:0,y:0}),d=l-a,p=c-s,m=V(a,s),u=V(l,s),E=V(a,c),g=V(l,c),b=V(a+d/2,s+p/2);i=t?[m,u,E,g]:[m,u,E,g,b]}return i.map(a=>V(We(a[0]),We(a[1])))},u2=(e,n,t,o)=>p2(e,n,t,o),h2=(e,n,t,o)=>{let r=u2(e,n,t,o),i=m2(r,o).filter(p=>!(p.length===1&&d2(p[0]))).map(p=>Fg(p).map(m=>We(m))),a=i.sort((p,m)=>p[0]-m[0]),s=[],l=0;e:for(let p=0;p<a.length;p++){let m=a[p];for(let u=p+1;u<a.length;u++){if(++l>s2)break e;let E=a[u],[,g,b,y]=m,[w,x,,v]=E;b<w&&cm(rn(g,y),rn(x,v))&&s.push({startBounds:m,endBounds:E,startSide:[V(b,g),V(b,y)],endSide:[V(w,x),V(w,v)],length:w-b,overlap:lm(rn(g,y),rn(x,v))})}}let c=i.sort((p,m)=>p[1]-m[1]),d=[];l=0;e:for(let p=0;p<c.length;p++){let m=c[p];for(let u=p+1;u<c.length;u++){if(++l>s2)break e;let E=c[u],[g,,b,y]=m,[w,x,v]=E;y<x&&cm(rn(g,b),rn(w,v))&&d.push({startBounds:m,endBounds:E,startSide:[V(g,y),V(b,y)],endSide:[V(w,x),V(v,x)],length:x-y,overlap:lm(rn(g,b),rn(w,v))})}}return{horizontalGaps:s,verticalGaps:d}},l2=(e,n,t,o,r,i,a)=>{if(!ho({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=an.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,p,m,u]=zg(e,n).map(b=>We(b)),E=(d+m)/2,g=(p+u)/2;for(let b of l){if(!cm(rn(p,u),b.overlap))continue;let y=b.startSide[0][0]+b.length/2,w=We(y-E);if(b.length>m-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[,,v]=b.endBounds,I=d-v,C=We(b.length-I);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-m,L=We(A-b.length);if(Math.abs(L)<=a.x){Math.abs(L)<a.x&&(r.length=0),a.x=Math.abs(L);let _={type:"gap",direction:"side_left",gap:b,offset:L};r.push(_);continue}}for(let b of c){if(!cm(rn(d,m),b.overlap))continue;let y=b.startSide[0][1]+b.length/2,w=We(y-g);if(b.length>u-p&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let _={type:"gap",direction:"center_vertical",gap:b,offset:w};i.push(_);continue}let[,v,,]=b.startBounds,I=v-u,C=We(I-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=We(p-P),L=b.length-A;if(Math.abs(L)<=a.y){Math.abs(L)<a.y&&(i.length=0),a.y=Math.abs(L);let _={type:"gap",direction:"side_bottom",gap:b,offset:L};i.push(_);continue}}}},g2=(e,n,t,o)=>{let r=u2(e,n,t,o);return m2(r,o).filter(i=>!(i.length===1&&d2(i[0]))).flatMap(i=>ol(i,o))},na=(e,n,t,o,r,i,a)=>{if(!ho({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let s=an.getReferenceSnapPoints();if(s)for(let l of n)for(let c of s){let d=c[0]-l[0],p=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(p)<=a.y&&(Math.abs(p)<a.y&&(i.length=0),i.push({type:"point",points:[l,c],offset:p}),a.y=Math.abs(p))}},f2=(e,n,t,o,r)=>{let i=t.state,a=U8(e,i);if(!ho({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=We(n.x),n.y=We(n.y);let s=[],l=[],c=dm(i.zoom.value),d={x:c,y:c},p=ol(a,r,{dragOffset:n});na(a,p,t,o,s,l,d),l2(a,n,t,o,s,l,d);let m={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:We(n.x+m.x),y:We(n.y+m.y)};na(a,ol(a,r,{dragOffset:u}),t,o,s,l,d),l2(a,u,t,o,s,l,d);let E=Hg(s,l),g=K8(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:m,snapLines:[...E,...g]}},We=e=>Math.round(e*10**6)/10**6,c2=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())},Hg=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=We(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>V(We(a[0]),We(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=We(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>V(We(a[0]),We(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:c2(i.map(a=>V(Number(r),a[1])).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:c2(i.map(a=>V(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},Y8=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[We(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},K8=(e,n,t)=>{let[o,r,i,a]=zg(e,n),s=[];for(let l of t){let[c,d,p,m]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,y=lm(rn(r,a),l.gap.overlap),w=lm(rn(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:[V(l.gap.startSide[0][0],x),V(o,x)]},{type:"gap",direction:"horizontal",points:[V(i,x),V(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:[V(x,l.gap.startSide[0][1]),V(x,r)]},{type:"gap",direction:"vertical",points:[V(x,a),V(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:[V(p,x),V(u,x)]},{type:"gap",direction:"horizontal",points:[V(g,x),V(o,x)]})}break}case"side_left":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[V(i,x),V(c,x)]},{type:"gap",direction:"horizontal",points:[V(p,x),V(u,x)]})}break}case"side_top":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,a),V(x,d)]},{type:"gap",direction:"vertical",points:[V(x,m),V(x,E)]})}break}case"side_bottom":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,m),V(x,E)]},{type:"gap",direction:"vertical",points:[V(x,b),V(x,r)]})}break}}}return Y8(s.map(l=>({...l,points:l.points.map(c=>V(We(c[0]),We(c[1])))})))},Gg=(e,n,t,o,r,i)=>{if(!ho({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!V8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=Fg(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(V(l,s),V(l,c));break}case"w":{d.push(V(a,s),V(a,c));break}case"n":{d.push(V(a,s),V(l,s));break}case"s":{d.push(V(a,c),V(l,c));break}case"ne":{d.push(V(l,s));break}case"nw":{d.push(V(a,s));break}case"se":{d.push(V(l,c));break}case"sw":{d.push(V(a,c));break}}let p=dm(t.state.zoom.value),m={x:p,y:p},u=[],E=[];na(n,d,t,o,u,E,m);let g={x:u[0]?.offset??0,y:E[0]?.offset??0};m.x=0,m.y=0,u.length=0,E.length=0;let[b,y,w,x]=Fg(e).map(C=>We(C)),v=[V(b,y),V(b,x),V(w,y),V(w,x)];na(e,v,t,o,u,E,m);let I=Hg(u,E);return{snapOffset:g,snapLines:I}},E2=(e,n,t,o,r,i)=>{if(!ho({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[V(o.x+r.x,o.y+r.y)],s=dm(n.state.zoom.value),l={x:s,y:s},c=[],d=[];na([e],a,n,t,c,d,l);let p={x:c[0]?.offset??0,y:d[0]?.offset??0};l.x=0,l.y=0,c.length=0,d.length=0;let m=ol([e],i,{boundingBoxCorners:!0,omitCenter:!0});na([e],m,n,t,c,d,l);let u=Hg(c,d);return{snapOffset:p,snapLines:u}},b2=(e,n,t,o,r)=>{if(!ho({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=p2(e,[],n.state,r),a=dm(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let p=ol([d],r);for(let m of p){let u=m[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:[m,V(m[0],t.y)],direction:"vertical"}),s.x=u);let E=m[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:[m,V(t.x,m[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]}},x2=e=>e===Kr.rectangle||e===Kr.ellipse||e===Kr.diamond||e===Kr.frame||e===Kr.magicframe||e===Kr.image||e===Kr.text;import{getCommonFrameId as X8,getFrameChildrenInsertionIndex as $8,isElementInViewport as Z8}from"@excalidraw/element";import{arrayToMap as j8,memoize as q8,toBrandedType as J8}from"@excalidraw/common";var rl=class{constructor(n){T(this,"scene");T(this,"_getRenderableElements",q8(({canvasNonce:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l,editingTextElement:c,newElement:d})=>{let p=this.scene.getNonDeletedElements(),{elementsMap:m,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:p,editingTextElement:c,newElement:d}),E=this.getVisibleCanvasElements({elementsMap:m,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l});return{elementsMap:m,visibleElements:E,newElementCanvasElement:u,canvasNonce:n}}));T(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&&X8(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())Z8(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=J8(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=j8(t),i=n.filter(s=>!r.has(s.id)),a=$8(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){Yb.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as oN,easeOut as v2}from"@excalidraw/common";import{SVG_NS as y2,getSvgPathFromStroke as tN,sceneCoordsToViewportCoords as nN}from"@excalidraw/common";import{version as Q8}from"react";import{unstable_batchedUpdates as w2}from"react-dom";import{throttleRAF as eN}from"@excalidraw/common";var Ve=e=>n=>{w2(e,n)},mm=e=>eN(n=>{w2(e,n)}),oa=(()=>{let e;try{let t=Q8.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 le=class le{static start(n,t){if(le.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};le.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw le.animations.get(n)===o&&(le.animations.delete(n),le.cancelScheduledFrameIfIdle()),i}if(le.animations.get(n)===o){if(!r){le.animations.delete(n),le.cancelScheduledFrameIfIdle();return}o.state=r,le.scheduleNextFrame()}}static scheduleNextFrame(){le.scheduledFrame||(oa()?le.scheduledFrame={id:requestAnimationFrame(le.tick),type:"raf"}:le.scheduledFrame={id:setTimeout(le.tick,0),type:"timeout"})}static cancelScheduledFrame(){le.scheduledFrame&&(le.scheduledFrame.type==="raf"?cancelAnimationFrame(le.scheduledFrame.id):clearTimeout(le.scheduledFrame.id),le.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return le.animations.size>0?!1:(le.cancelScheduledFrame(),!0)}static tick(){if(le.scheduledFrame=null,le.animations.size>0){let n=[...le.animations];for(let[t,o]of n){if(le.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(le.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(le.animations.delete(t),le.cancelScheduledFrameIfIdle())return}}if(le.cancelScheduledFrameIfIdle())return;le.scheduleNextFrame()}}static running(n){return le.animations.has(n)}static cancel(n){le.animations.delete(n),le.cancelScheduledFrameIfIdle()}static reset(){le.animations.clear(),le.cancelScheduledFrame()}};T(le,"scheduledFrame",null),T(le,"animations",new Map);var tt=le;var pm=class pm{constructor(n,t){this.app=n;this.options=t;T(this,"currentTrail");T(this,"pastTrails",[]);T(this,"container");T(this,"trailElement");T(this,"trailAnimation");T(this,"key");this.key=`animated-trail-${pm.counter++}`,this.trailElement=document.createElementNS(y2,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(y2,"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),tt.running(this.key)||tt.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){tt.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new Yi(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=nN({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return tN(r,!0)}};T(pm,"counter",0);var In=pm;var um=class{constructor(n){this.app=n;T(this,"localTrail");T(this,"collabTrails",new Map);T(this,"container");this.localTrail=new In(n,{...this.getTrailOptions(),fill:()=>oN})}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(v2(i),v2(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 In(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||Fr(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 rN}from"@excalidraw/common";import{pointFrom as il,pointRotateRads as hm}from"@excalidraw/math";var iN=12,Ug=16,aN=10,sN=Ug+2,lN=.8,Wg=e=>rN*2/e,Vg=(e,n,t)=>{let o=Wg(n);if(t!=="desktop"||Ug>(e.height+o*2)*n*lN)return null;let r=iN/n,i=Ug/n,a=il(e.x+e.width/2,e.y+e.height/2),s=hm(il(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:hm(il(s[0],s[1]-i/2),s,e.angle),end:hm(il(s[0],s[1]+i/2),s,e.angle),hitboxWidth:aN/n,hitboxHeight:sN/n}},T2=(e,n,t,o)=>{let r=Vg(n,t,o);if(!r)return!1;let i=hm(il(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 Yg,KEYS as al,CLASSES as Kg,POINTER_BUTTON as cN,THEME as dN,isWritableElement as mN,getFontString as I2,getFontFamilyString as S2,isTestEnv as C2,MIME_TYPES as Xg,applyDarkModeFilter as pN,isRTL as uN}from"@excalidraw/common";import{pointFrom as P2,pointRotateRads as hN}from"@excalidraw/math";import{getTextFromElements as gN,originalContainerCache as fN,updateBoundElements as k2,updateOriginalContainerCache as M2}from"@excalidraw/element";import{LinearElementEditor as EN}from"@excalidraw/element/linearElementEditor";import{bumpVersion as bN}from"@excalidraw/element";import{getBoundTextElementId as xN,getContainerElement as $g,getTextElementAngle as wN,redrawTextBoundingBox as yN,getBoundTextMaxHeight as vN,getBoundTextMaxWidth as A2,computeContainerDimensionForBoundText as L2,computeBoundTextPosition as TN,getBoundTextElement as IN}from"@excalidraw/element";import{getTextWidth as SN}from"@excalidraw/element";import{getLineHeightInPx as CN}from"@excalidraw/element";import{getLineWidth as PN}from"@excalidraw/element";import{normalizeText as D2}from"@excalidraw/element";import{wrapText as kN}from"@excalidraw/element";import{getWrappedTextLines as MN}from"@excalidraw/element";import{isArrowElement as gm,isBoundToContainer as AN,isTextElement as _2}from"@excalidraw/element";var LN=(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)`},DN=(e,n)=>{let t=e.lastIndexOf(`
11
+ C ${l} ${c}, ${l} ${c}, ${l+b} ${c+y}`,go(e,!0,a))}else s=n.polygon([[l,c],[d,m],[p,u],[E,g]],go(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,go(e,!1,a));case"line":case"arrow":{let s,l=go(e,!1,a),c=e.points.length?e.points:[WR(0,0)];if(Tn(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path(JR(c,16),go(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=zv(e,s,"start",d,n,l,o,a);s.push(...p)}if(m!==null){let p=zv(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(ea(e.points)){let l=GR(e.points,.75);s.push(n.curve(l,{...go(e,!1,a),stroke:"none"}))}return s.push(QR(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return YR(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},JR=(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=sm(s,i),c=sm(a,s),d=Math.min(n,Ov(e[r],a)/2,Ov(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 QR=e=>a8(r8(e)),Dg={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},e8={SIZE_FACTOR:1.4},Uv=e=>e.strokeOptions?.streamline??KR,t8=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 UR(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*Dg.SIZE_FACTOR,thinning:Dg.THINNING,smoothing:Dg.SMOOTHING,streamline:Uv(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},n8=e=>new Qi({size:e.strokeWidth*e8.SIZE_FACTOR,streamline:Uv(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),o8=e=>{let n=n8(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},r8=e=>e.strokeOptions?.variability==="constant"?o8(e):t8(e);var Hv=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],i8=/(\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,Hv(o,i[0]),"L",i[0],"Z"):t.push(o,Hv(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(i8,"$1")};var Yr=(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??s8(),updated:l8()}};import{jsx as Yv}from"react/jsx-runtime";var aa=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&&d8(r[0])&&!c8(r[0]))},perform(e,n,t,o){Wv(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);Wv(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:Vv.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 Yv(K,{type:"button",icon:V1,title:r,"aria-label":r,onClick:()=>n(null)})}}),XIe=O({name:"togglePolygon",icon:uu,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!ia(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=>ia(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!ia(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=m8(i);return{elements:e.map(l=>!s.has(l.id)||!ia(l)?l:Yr(l,{backgroundColor:a?l.backgroundColor:"transparent",...p8(l,a)})),appState:n,captureUpdate:Vv.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!ia(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>ia(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return Yv(K,{type:"toggle",icon:uu,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as Xv,CANVAS_SEARCH_TAB as Kv,CLASSES as u8,DEFAULT_SIDEBAR as $v}from"@excalidraw/common";import{CaptureUpdateAction as h8}from"@excalidraw/element";var ml=O({name:"searchMenu",icon:Wn,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===$v.name&&n.openSidebar.tab===Kv){let r=o.excalidrawContainerValue.container?.querySelector(`.${u8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:$v.name,tab:Kv},openDialog:null},captureUpdate:h8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[Xv.CTRL_OR_CMD]&&e.key===Xv.F});import{isImageElement as g8}from"@excalidraw/element";import{CaptureUpdateAction as f8}from"@excalidraw/element";import{jsx as E8}from"react/jsx-runtime";var Rg=O({name:"cropEditor",label:"helpDialog.cropStart",icon:Ou,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:f8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&g8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return E8(K,{type:"button",icon:Ou,title:o,"aria-label":o,onClick:()=>n(null)})}});import{canCreateLinkFromElements as Ng,defaultGetElementLinkFromSelection as b8,getLinkIdAndTypeFromSelection as x8}from"@excalidraw/element";import{CaptureUpdateAction as pl}from"@excalidraw/element";var Zv=O({name:"copyElementLink",label:"labels.copyElementLink",icon:Rc,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=ie(e,n);try{if(window.location){let i=x8(r,n);return i?(await po(o.props.generateLinkForSelection?o.props.generateLinkForSelection(i.id,i.type):b8(i.id,i.type)),{appState:{toast:{message:f("toast.elementLinkCopied"),closable:!0}},captureUpdate:pl.EVENTUALLY}):{appState:n,elements:e,app:o,captureUpdate:pl.EVENTUALLY}}}catch(i){console.error(i)}return{appState:n,elements:e,app:o,captureUpdate:pl.EVENTUALLY}},predicate:(e,n)=>Ng(ie(e,n))}),qTe=O({name:"linkToElement",label:"labels.linkToElement",icon:Oc,perform:(e,n,t,o)=>{let r=ie(e,n);return r.length!==1||!Ng(r)?{elements:e,appState:n,app:o,captureUpdate:pl.EVENTUALLY}:{appState:{...n,openDialog:{name:"elementLinkSelector",sourceElementId:ie(e,n)[0].id}},captureUpdate:pl.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=ie(e,n);return n.openDialog?.name!=="elementLinkSelector"&&r.length===1&&Ng(r)},trackEvent:!1});import{getNonDeletedElements as w8}from"@excalidraw/element";import{mutateElement as y8}from"@excalidraw/element";import{newFrameElement as v8}from"@excalidraw/element";import{isFrameLikeElement as mm}from"@excalidraw/element";import{addElementsToFrame as I8,removeAllElementsFromFrame as T8}from"@excalidraw/element";import{getFrameChildren as S8}from"@excalidraw/element";import{getElementsInGroup as C8}from"@excalidraw/element";import{getCommonBounds as P8}from"@excalidraw/element";import{CaptureUpdateAction as sa}from"@excalidraw/element";var jv=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&mm(t[0])},qv=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(mm(r)){let i=S8(w8(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:sa.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:sa.EVENTUALLY}},predicate:(e,n,t,o)=>jv(n,o)}),Jv=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return mm(r)?{elements:T8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:sa.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:sa.EVENTUALLY}},predicate:(e,n,t,o)=>jv(n,o)}),mSe=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:sa.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),Qv=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=ie(e,n);return r.length>0&&!r.some(i=>mm(i))},perform:(e,n,t,o)=>{let r=ie(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=P8(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=C8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);y8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:I8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:sa.IMMEDIATELY}}});import{KEYS as ca,matchKey as Fg,arrayToMap as e2,MOBILE_ACTION_BUTTON_BG as t2}from"@excalidraw/common";import{CaptureUpdateAction as Og}from"@excalidraw/element";import{orderByFractionalIndex as R8}from"@excalidraw/element";import{Emitter as k8}from"@excalidraw/common";import{CaptureUpdateAction as M8,StoreChange as A8,StoreDelta as L8}from"@excalidraw/element";var la=class extends L8{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)}},Kr=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},ul=class e{constructor(n){this.store=n;I(this,"onHistoryChangedEmitter",new k8);I(this,"undoStack",[]);I(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(n){if(n.isEmpty()||n instanceof la)return;let t=la.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Kr(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=M8.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=A8.create(s,p),E=la.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 Kr(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=la.inverse(t);return n.push(o)}};import{useEffect as D8,useState as _8}from"react";var Bg=(e,n)=>{let[t,o]=_8(n);return D8(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as i2}from"react/jsx-runtime";var n2=(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:Og.EVENTUALLY};let[r,i]=o,a=R8(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Og.NEVER}}return{captureUpdate:Og.EVENTUALLY}},o2=e=>({name:"undo",label:"buttons.undo",icon:Eu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>n2(r,t,()=>e.undo(e2(n),t)),keyTest:n=>n[ca.CTRL_OR_CMD]&&Fg(n,ca.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=Bg(e.onHistoryChangedEmitter,new Kr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=it()==="mobile";return i2(K,{type:"button",icon:Eu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?t2:{}}})}}),r2=e=>({name:"redo",label:"buttons.redo",icon:bu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>n2(r,t,()=>e.redo(e2(n),t)),keyTest:n=>n[ca.CTRL_OR_CMD]&&n.shiftKey&&Fg(n,ca.Z)||n[ca.CTRL_OR_CMD]&&!n.shiftKey&&Fg(n,ca.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=Bg(e.onHistoryChangedEmitter,new Kr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=it()==="mobile";return i2(K,{type:"button",icon:bu,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?t2:{}}})}});import{getFontString as N8}from"@excalidraw/common";import{getTextAnchorRatios as B8,isExcalidrawElement as O8,isNonDeletedElement as F8,newElementWith as z8,updateBoundElements as H8}from"@excalidraw/element";import{measureText as G8}from"@excalidraw/element";import{isTextElement as zg}from"@excalidraw/element";import{CaptureUpdateAction as U8}from"@excalidraw/element";var Hg=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=ie(e,n);return o.length===1&&zg(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=ie(e,n),i=O8(t)&&zg(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!zg(a))return!1;let s=G8(a.originalText,N8(a),a.lineHeight),l=B8(a),c=z8(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 F8(c)&&H8(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:U8.IMMEDIATELY}}});import{CODES as W8,KEYS as V8}from"@excalidraw/common";import Y8 from"clsx";import{CaptureUpdateAction as X8}from"@excalidraw/element";import{jsx as K8}from"react/jsx-runtime";var $r=O({name:"viewMode",label:"labels.viewMode",icon:Ar,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:X8.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[V8.CTRL_OR_CMD]&&e.altKey&&e.code===W8.R,PanelComponent:({data:e,updateData:n,appState:t,appProps:o})=>t.viewModeOnly||o.viewModeOnly?null:K8(K,{type:"button",icon:Ar,"aria-label":f("labels.viewMode"),onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:Y8({enabled:t.viewModeEnabled})})});import{isPromiseLike as $8}from"@excalidraw/common";import{jsx as Z8}from"react/jsx-runtime";var Gg=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Ne(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},pm=class{constructor(n,t,o,r){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"isActionBlockedByViewportTransition",n=>n.navigation===!0&&this.app.viewport.isLockedTransitionPending);I(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)||(Gg(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return Z8(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:a,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});I(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($8(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 Gg(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();Gg(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var Ug=e=>{let n=Array.from(e.values());return{x:a2(n,t=>t.x)/n.length,y:a2(n,t=>t.y)/n.length}},Wg=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),a2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as V,pointRotateRads as nr,rangeInclusive as sn,rangeIntersection as um,rangesOverlap as hm}from"@excalidraw/math";import{TOOL_TYPE as Zr,KEYS as s2}from"@excalidraw/common";import{getCommonBounds as Vg,getDraggedElementsBounds as Yg,getElementAbsoluteCoords as j8}from"@excalidraw/element";import{isBoundToContainer as m2}from"@excalidraw/element";import{getMaximumGroups as p2}from"@excalidraw/element";import{getSelectedElements as q8,getVisibleAndNonSelectedElements as u2}from"@excalidraw/element";var J8=8,l2=99999,gm=e=>J8/e,Lt=class Lt{};I(Lt,"referenceSnapPoints",null),I(Lt,"visibleGaps",null),I(Lt,"setReferenceSnapPoints",n=>{Lt.referenceSnapPoints=n}),I(Lt,"getReferenceSnapPoints",()=>Lt.referenceSnapPoints),I(Lt,"setVisibleGaps",n=>{Lt.visibleGaps=n}),I(Lt,"getVisibleGaps",()=>Lt.visibleGaps),I(Lt,"destroy",()=>{Lt.referenceSnapPoints=null,Lt.visibleGaps=null});var ln=Lt,or=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,fo=({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[s2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[s2.CTRL_OR_CMD]&&!or(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},Q8=(e,n,t=.01)=>Math.abs(e-n)<=t,hl=(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]=j8(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=nr(V(s,l+E),V(m,p),a.angle),b=nr(V(s+u,l),V(m,p),a.angle),y=nr(V(c,l+E),V(m,p),a.angle),w=nr(V(s+u,d),V(m,p),a.angle),x=V(m,p);i=t?[g,b,y,w]:[g,b,y,w,x]}else{let g=nr(V(s,l),V(m,p),a.angle),b=nr(V(c,l),V(m,p),a.angle),y=nr(V(s,d),V(m,p),a.angle),w=nr(V(c,d),V(m,p),a.angle),x=V(m,p);i=t?[g,b,y,w]:[g,b,y,w,x]}}else if(e.length>1){let[a,s,l,c]=Yg(e,r??{x:0,y:0}),d=l-a,m=c-s,p=V(a,s),u=V(l,s),E=V(a,c),g=V(l,c),b=V(a+d/2,s+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>V(Ve(a[0]),Ve(a[1])))},h2=(e,n,t,o)=>u2(e,n,t,o),g2=(e,n,t,o)=>{let r=h2(e,n,t,o),i=p2(r,o).filter(m=>!(m.length===1&&m2(m[0]))).map(m=>Vg(m).map(p=>Ve(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>l2)break e;let E=a[u],[,g,b,y]=p,[w,x,,v]=E;b<w&&hm(sn(g,y),sn(x,v))&&s.push({startBounds:p,endBounds:E,startSide:[V(b,g),V(b,y)],endSide:[V(w,x),V(w,v)],length:w-b,overlap:um(sn(g,y),sn(x,v))})}}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>l2)break e;let E=c[u],[g,,b,y]=p,[w,x,v]=E;y<x&&hm(sn(g,b),sn(w,v))&&d.push({startBounds:p,endBounds:E,startSide:[V(g,y),V(b,y)],endSide:[V(w,x),V(v,x)],length:x-y,overlap:um(sn(g,b),sn(w,v))})}}return{horizontalGaps:s,verticalGaps:d}},c2=(e,n,t,o,r,i,a)=>{if(!fo({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=ln.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=Yg(e,n).map(b=>Ve(b)),E=(d+p)/2,g=(m+u)/2;for(let b of l){if(!hm(sn(m,u),b.overlap))continue;let y=b.startSide[0][0]+b.length/2,w=Ve(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[,,v]=b.endBounds,T=d-v,C=Ve(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,L=Ve(A-b.length);if(Math.abs(L)<=a.x){Math.abs(L)<a.x&&(r.length=0),a.x=Math.abs(L);let _={type:"gap",direction:"side_left",gap:b,offset:L};r.push(_);continue}}for(let b of c){if(!hm(sn(d,p),b.overlap))continue;let y=b.startSide[0][1]+b.length/2,w=Ve(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[,v,,]=b.startBounds,T=v-u,C=Ve(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=Ve(m-P),L=b.length-A;if(Math.abs(L)<=a.y){Math.abs(L)<a.y&&(i.length=0),a.y=Math.abs(L);let _={type:"gap",direction:"side_bottom",gap:b,offset:L};i.push(_);continue}}}},f2=(e,n,t,o)=>{let r=h2(e,n,t,o);return p2(r,o).filter(i=>!(i.length===1&&m2(i[0]))).flatMap(i=>hl(i,o))},da=(e,n,t,o,r,i,a)=>{if(!fo({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let s=ln.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))}},E2=(e,n,t,o,r)=>{let i=t.state,a=q8(e,i);if(!fo({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=Ve(n.x),n.y=Ve(n.y);let s=[],l=[],c=gm(i.zoom.value),d={x:c,y:c},m=hl(a,r,{dragOffset:n});da(a,m,t,o,s,l,d),c2(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:Ve(n.x+p.x),y:Ve(n.y+p.y)};da(a,hl(a,r,{dragOffset:u}),t,o,s,l,d),c2(a,u,t,o,s,l,d);let E=Xg(s,l),g=tN(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},Ve=e=>Math.round(e*10**6)/10**6,d2=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())},Xg=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Ve(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>V(Ve(a[0]),Ve(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=Ve(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>V(Ve(a[0]),Ve(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:d2(i.map(a=>V(Number(r),a[1])).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:d2(i.map(a=>V(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},eN=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[Ve(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},tN=(e,n,t)=>{let[o,r,i,a]=Yg(e,n),s=[];for(let l of t){let[c,d,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,y=um(sn(r,a),l.gap.overlap),w=um(sn(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:[V(l.gap.startSide[0][0],x),V(o,x)]},{type:"gap",direction:"horizontal",points:[V(i,x),V(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:[V(x,l.gap.startSide[0][1]),V(x,r)]},{type:"gap",direction:"vertical",points:[V(x,a),V(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:[V(m,x),V(u,x)]},{type:"gap",direction:"horizontal",points:[V(g,x),V(o,x)]})}break}case"side_left":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[V(i,x),V(c,x)]},{type:"gap",direction:"horizontal",points:[V(m,x),V(u,x)]})}break}case"side_top":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,a),V(x,d)]},{type:"gap",direction:"vertical",points:[V(x,p),V(x,E)]})}break}case"side_bottom":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,p),V(x,E)]},{type:"gap",direction:"vertical",points:[V(x,b),V(x,r)]})}break}}}return eN(s.map(l=>({...l,points:l.points.map(c=>V(Ve(c[0]),Ve(c[1])))})))},Kg=(e,n,t,o,r,i)=>{if(!fo({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!Q8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=Vg(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(V(l,s),V(l,c));break}case"w":{d.push(V(a,s),V(a,c));break}case"n":{d.push(V(a,s),V(l,s));break}case"s":{d.push(V(a,c),V(l,c));break}case"ne":{d.push(V(l,s));break}case"nw":{d.push(V(a,s));break}case"se":{d.push(V(l,c));break}case"sw":{d.push(V(a,c));break}}let m=gm(t.state.zoom.value),p={x:m,y:m},u=[],E=[];da(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]=Vg(e).map(C=>Ve(C)),v=[V(b,y),V(b,x),V(w,y),V(w,x)];da(e,v,t,o,u,E,p);let T=Xg(u,E);return{snapOffset:g,snapLines:T}},b2=(e,n,t,o,r,i)=>{if(!fo({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[V(o.x+r.x,o.y+r.y)],s=gm(n.state.zoom.value),l={x:s,y:s},c=[],d=[];da([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=hl([e],i,{boundingBoxCorners:!0,omitCenter:!0});da([e],p,n,t,c,d,l);let u=Xg(c,d);return{snapOffset:m,snapLines:u}},x2=(e,n,t,o,r)=>{if(!fo({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=u2(e,[],n.state,r),a=gm(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=hl([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,V(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,V(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]}},w2=e=>e===Zr.rectangle||e===Zr.ellipse||e===Zr.diamond||e===Zr.frame||e===Zr.magicframe||e===Zr.image||e===Zr.text;import{getCommonFrameId as nN,getFrameChildrenInsertionIndex as oN,isElementInViewport as rN}from"@excalidraw/element";import{arrayToMap as iN,memoize as aN,toBrandedType as sN}from"@excalidraw/common";var gl=class{constructor(n){I(this,"scene");I(this,"_getRenderableElements",aN(({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}}));I(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&&nN(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())rN(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=sN(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=iN(t),i=n.filter(s=>!r.has(s.id)),a=oN(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){qb.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as pN,easeOut as I2}from"@excalidraw/common";import{SVG_NS as v2,getSvgPathFromStroke as dN,sceneCoordsToViewportCoords as mN}from"@excalidraw/common";import{version as lN}from"react";import{unstable_batchedUpdates as y2}from"react-dom";import{throttleRAF as cN}from"@excalidraw/common";var Ye=e=>n=>{y2(e,n)},fm=e=>cN(n=>{y2(e,n)}),ma=(()=>{let e;try{let t=lN.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 ce=class ce{static start(n,t){if(ce.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};ce.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw ce.animations.get(n)===o&&(ce.animations.delete(n),ce.cancelScheduledFrameIfIdle()),i}if(ce.animations.get(n)===o){if(!r){ce.animations.delete(n),ce.cancelScheduledFrameIfIdle();return}o.state=r,ce.scheduleNextFrame()}}static scheduleNextFrame(){ce.scheduledFrame||(ma()?ce.scheduledFrame={id:requestAnimationFrame(ce.tick),type:"raf"}:ce.scheduledFrame={id:setTimeout(ce.tick,0),type:"timeout"})}static cancelScheduledFrame(){ce.scheduledFrame&&(ce.scheduledFrame.type==="raf"?cancelAnimationFrame(ce.scheduledFrame.id):clearTimeout(ce.scheduledFrame.id),ce.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return ce.animations.size>0?!1:(ce.cancelScheduledFrame(),!0)}static tick(){if(ce.scheduledFrame=null,ce.animations.size>0){let n=[...ce.animations];for(let[t,o]of n){if(ce.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(ce.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(ce.animations.delete(t),ce.cancelScheduledFrameIfIdle())return}}if(ce.cancelScheduledFrameIfIdle())return;ce.scheduleNextFrame()}}static running(n){return ce.animations.has(n)}static cancel(n){ce.animations.delete(n),ce.cancelScheduledFrameIfIdle()}static reset(){ce.animations.clear(),ce.cancelScheduledFrame()}};I(ce,"scheduledFrame",null),I(ce,"animations",new Map);var ot=ce;var Em=class Em{constructor(n,t){this.app=n;this.options=t;I(this,"currentTrail");I(this,"pastTrails",[]);I(this,"container");I(this,"trailElement");I(this,"trailAnimation");I(this,"key");this.key=`animated-trail-${Em.counter++}`,this.trailElement=document.createElementNS(v2,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(v2,"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),ot.running(this.key)||ot.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){ot.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new Qi(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=mN({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return dN(r,!0)}};I(Em,"counter",0);var Pn=Em;var bm=class{constructor(n){this.app=n;I(this,"localTrail");I(this,"collabTrails",new Map);I(this,"container");this.localTrail=new Pn(n,{...this.getTrailOptions(),fill:()=>pN})}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(I2(i),I2(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 Pn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||Gr(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 uN}from"@excalidraw/common";import{pointFrom as fl,pointRotateRads as xm}from"@excalidraw/math";var hN=12,$g=16,gN=10,fN=$g+2,EN=.8,Zg=e=>uN*2/e,jg=(e,n,t)=>{let o=Zg(n);if(t!=="desktop"||$g>(e.height+o*2)*n*EN)return null;let r=hN/n,i=$g/n,a=fl(e.x+e.width/2,e.y+e.height/2),s=xm(fl(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:xm(fl(s[0],s[1]-i/2),s,e.angle),end:xm(fl(s[0],s[1]+i/2),s,e.angle),hitboxWidth:gN/n,hitboxHeight:fN/n}},T2=(e,n,t,o)=>{let r=jg(n,t,o);if(!r)return!1;let i=xm(fl(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 qg,KEYS as El,CLASSES as Jg,POINTER_BUTTON as bN,THEME as xN,isWritableElement as wN,getFontString as S2,getFontFamilyString as C2,isTestEnv as P2,MIME_TYPES as Qg,applyDarkModeFilter as yN,isRTL as vN}from"@excalidraw/common";import{pointFrom as k2,pointRotateRads as IN}from"@excalidraw/math";import{getTextFromElements as TN,originalContainerCache as SN,updateBoundElements as M2,updateOriginalContainerCache as A2}from"@excalidraw/element";import{LinearElementEditor as CN}from"@excalidraw/element/linearElementEditor";import{bumpVersion as PN}from"@excalidraw/element";import{getBoundTextElementId as kN,getContainerElement as ef,getTextElementAngle as MN,redrawTextBoundingBox as AN,getBoundTextMaxHeight as LN,getBoundTextMaxWidth as L2,computeContainerDimensionForBoundText as D2,computeBoundTextPosition as DN,getBoundTextElement as _N}from"@excalidraw/element";import{getTextWidth as RN}from"@excalidraw/element";import{getLineHeightInPx as NN}from"@excalidraw/element";import{getLineWidth as BN}from"@excalidraw/element";import{normalizeText as _2}from"@excalidraw/element";import{wrapText as ON}from"@excalidraw/element";import{getWrappedTextLines as FN}from"@excalidraw/element";import{isArrowElement as wm,isBoundToContainer as zN,isTextElement as R2}from"@excalidraw/element";var HN=(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)`},GN=(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 uN(r)?"rtl":"ltr"},_N=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},RN=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=_N(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),p=i[0],m=1/0;for(let u=0;u<i.length;u++){let E=Math.abs(c[u]-d-r);E<m&&(m=E,p=i[u])}return p},R2=({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,U)=>{if(!U.style.fontFamily||!U.style.fontSize)return!1;let me=U.style.fontFamily.replace(/"/g,"");return S2({fontFamily:B.fontFamily})!==me||`${B.fontSize}px`!==U.style.fontSize},p=a.state.theme,m=()=>{p=a.state.theme;let B=a.state,U=a.scene.getElement(o.id);if(!U)return;let{textAlign:me,verticalAlign:be}=U,de=a.scene.getNonDeletedElementsMap();if(U&&_2(U)){let pe=U.x,xe=U.y,ae=$g(U,a.scene.getNonDeletedElementsMap()),we=U.width,at=U.height,$e=U.width,_e=U.height;if(ae&&U.containerId){if(gm(ae)){let _n=EN.getBoundTextElementPosition(ae,U,de);pe=_n.x,xe=_n.y}let Jp=d(U,u),to;if(Jp?to=M2(ae.id,ae.height):(to=fN[ae.id],to||(to=M2(ae.id,ae.height))),$e=A2(ae,U),_e=vN(ae,U),!gm(ae)&&at>_e){let _n=L2(at,ae.type);a.scene.mutateElement(ae,{height:_n}),k2(ae,a.scene);return}else if(!gm(ae)&&ae.height>to.height&&at<_e){let _n=L2(at,ae.type);a.scene.mutateElement(ae,{height:_n}),k2(ae,a.scene)}else{let{x:_n,y:Ya}=TN(ae,U,de);pe=_n,xe=Ya}}let[ko,ii]=t(pe,xe);ae?we+=.5:($e=(B.width-8-ko)/B.zoom.value,we=Math.min(we,$e)),at*=1.05;let Ql=I2(U),ec=wN(U,ae),tc=(B.height-ii)/B.zoom.value;Object.assign(u.style,{font:Ql,lineHeight:U.lineHeight,width:`${we}px`,height:`${at}px`,left:`${ko}px`,top:`${ii}px`,transform:LN(we,at,ec,B,$e,tc),textAlign:me,verticalAlign:be,color:pN(U.strokeColor,B.theme===dN.DARK),opacity:U.opacity/100,maxHeight:`${tc}px`}),c={angle:ec,font:Ql,height:U.height,lineHeightPx:CN(U.fontSize,U.lineHeight),textAlign:me,width:U.width,x:pe,y:xe},u.scrollTop=0,C2()&&(u.style.fontFamily=S2(U)),a.scene.mutateElement(U,{x:pe,y:xe})}},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";(AN(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,m();let b=()=>{if(!l||!c)return null;let B=c,U=P2(B.x+B.width/2,B.y+B.height/2),[me,be]=hN(P2(l.x,l.y),U,-B.angle),de=me-B.x,pe=be-B.y,xe=MN(u.value,B.font,E==="pre-wrap"?B.width:1/0),ae=Math.max(0,Math.min(xe.length-1,Math.floor(pe/B.lineHeightPx))),we=xe[ae],at=DN(u.value,we.start),$e=PN(we.text,B.font),_e=B.textAlign==="center"?(B.width-$e)/2:B.textAlign==="right"?B.width-$e:0,ko=de-_e;if(!we.text)return we.start;let ii=RN({text:we.text,font:B.font,lineHeightPx:B.lineHeightPx,direction:at,targetX:ko});return we.start+(ii||0)},y=(()=>{let B=b();return B===null?null:{start:B,end:B}})();e&&(u.onpaste=async B=>{let U=Jw(B),me=null;if(U.has(Xg.excalidrawClipboard)||U.has(Xg.excalidraw)){B.preventDefault(),me=await _r(B);try{let ae=await Ad(me);if(ae.elements){let we=gN(ae.elements);if(we){let{selectionStart:at,selectionEnd:$e,value:_e}=u;u.value=_e.slice(0,at)+we+_e.slice($e);let ko=at+we.length;u.selectionStart=u.selectionEnd=ko,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}me=me||await _r(B);let be=me.findByType(Xg.text);if(!be)return;let de=D2(be.value);if(!de)return;let pe=$g(o,a.scene.getNonDeletedElementsMap()),xe=I2({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(pe){let ae=IN(pe,a.scene.getNonDeletedElementsMap()),we=kN(`${u.value}${de}`,xe,A2(pe,ae)),at=SN(we,xe);u.style.width=`${at}px`}},u.oninput=()=>{let B=D2(u.value);if(u.value!==B){let U=u.selectionStart;u.value=B,u.selectionStart=U,u.selectionEnd=U}e(u.value)}),u.onkeydown=B=>{if(!B.shiftKey&&dd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(dd),m();else if(!B.shiftKey&&md.keyTest(B))B.preventDefault(),a.actionManager.executeAction(md),m();else if(!B.shiftKey&&pd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(pd),m();else if(Eh.keyTest(B))a.actionManager.executeAction(Eh);else if(bh.keyTest(B))a.actionManager.executeAction(bh);else if(B.key===al.ESCAPE)B.preventDefault(),L=!0,_();else if(Br.keyTest(B))B.preventDefault(),_(),a.actionManager.executeAction(Br);else if(B.key===al.ENTER&&B[al.CTRL_OR_CMD]){if(B.preventDefault(),B.isComposing||B.keyCode===229)return;L=!0,_()}else if(B.key===al.TAB||B[al.CTRL_OR_CMD]&&(B.code===Yg.BRACKET_LEFT||B.code===Yg.BRACKET_RIGHT)){if(B.preventDefault(),B.isComposing)return;B.shiftKey||B.code===Yg.BRACKET_LEFT?C():I(),u.dispatchEvent(new Event("input"))}};let w=4,x=" ".repeat(w),v=new RegExp(`^ {1,${w}}`),I=()=>{let{selectionStart:B,selectionEnd:U}=u,me=P(),be=u.value;me.forEach(de=>{let pe=be.slice(0,de),xe=be.slice(de);be=`${pe}${x}${xe}`}),u.value=be,u.selectionStart=B+w,u.selectionEnd=U+w*me.length},C=()=>{let{selectionStart:B,selectionEnd:U}=u,me=P(),be=[],de=u.value;me.forEach(pe=>{let xe=de.slice(pe,pe+w).match(v);if(xe){let ae=de.slice(0,pe),we=de.slice(pe+xe[0].length);de=`${ae}${we}`,be.push(pe)}}),u.value=de,be.length&&(B>be[be.length-1]?u.selectionStart=Math.max(B-w,be[be.length-1]):u.selectionStart=B,u.selectionEnd=Math.max(u.selectionStart,U-w*be.length))},P=()=>{let{selectionStart:B,selectionEnd:U,value:me}=u,be=me.slice(0,B).match(/[^\n]*$/)[0].length;return B=B-be,me.slice(B,U).split(`
14
- `).reduce((pe,xe,ae,we)=>pe.concat(ae?pe[ae-1]+we[ae-1].length+1:B),[]).reverse()},A=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},L=!1,_=()=>{if(X)return;X=!0,k();let B=a.scene.getElement(o.id);if(!B)return;let U=$g(B,a.scene.getNonDeletedElementsMap());if(U){if(u.value.trim()){let me=xN(U);!me||me!==o.id?a.scene.mutateElement(U,{boundElements:(U.boundElements||[]).concat({type:"text",id:o.id})}):gm(U)&&bN(U)}else a.scene.mutateElement(U,{boundElements:U.boundElements?.filter(me=>!_2(me))});yN(B,U,a.scene)}n({viaKeyboard:L,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,oe&&oe.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",A,!0),window.removeEventListener("pointerdown",G),window.removeEventListener("pointerup",D),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),W(),z(),j(),u.remove()},D=B=>{window.removeEventListener("pointerup",D);let U=B?.target,me=U instanceof HTMLElement&&U.classList.contains("properties-trigger"),be=(U instanceof HTMLElement||U instanceof SVGElement)&&!!U.closest(".properties-content"),de=(U instanceof HTMLElement||U instanceof SVGElement)&&(!!U.closest(`.${Kg.SHAPE_ACTIONS_MENU}`)||!!U.closest(".compact-shape-actions-island"));setTimeout(()=>{de||me||be||(u.onblur=_,u.focus(),y&&(u.setSelectionRange(y.start,y.end),y=null))})},O=()=>{u.onblur=null,window.addEventListener("pointerup",D),window.addEventListener("blur",_)},G=B=>{let U=B?.target;if(B.button===cN.WHEEL){U instanceof HTMLTextAreaElement&&(B.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(B)),O();return}let me=U instanceof HTMLElement&&U.classList.contains("properties-trigger"),be=(U instanceof HTMLElement||U instanceof SVGElement)&&!!U.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${Kg.SHAPE_ACTIONS_MENU}, .${Kg.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!mN(B.target)||me||be?O():B.target instanceof HTMLCanvasElement&&!C2()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(B=>{a.state.theme!==p&&m()}),W=a.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||u.focus()}),j=a.onScrollChangeEmitter.on(()=>{m()}),X=!1;s&&!y&&u.select(),D();let oe=null;return r&&"ResizeObserver"in window?(oe=new window.ResizeObserver(()=>{m()}),oe.observe(r)):window.addEventListener("resize",m),u.onpointerdown=B=>B.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",G,{capture:!0})}),window.addEventListener("beforeunload",_),i?.querySelector(".excalidraw-textEditorContainer").appendChild(u),_};import{getGlobalCSSVariable as fm}from"@excalidraw/common";import{getCommonBounds as NN}from"@excalidraw/element";var go=4,sn=6,N2="rgba(0,0,0,0.3)",B2=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=NN(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(fm("sat"))||0,bottom:parseInt(fm("sab"))||0,left:parseInt(fm("sal"))||0,right:parseInt(fm("sar"))||0},p=Bn().rtl,m=-o.scrollX+d.left,u=-o.scrollY+d.top,E=m+l-d.right,g=u+c-d.bottom,b=Math.min(r,m),y=Math.min(i,u),w=Math.max(a,E),x=Math.max(s,g),v=a-r,I=s-i,C=w-b,P=x-y,A=Math.max(go*2,d.left+d.right)+sn*2,L=n*(l/C)-A,_=Math.max(go*2,d.top+d.bottom)+sn*2,k=t*(c/P)-_,D=C>v?C*o.zoom.value/(L+A):n/(L+A),O=P>I?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:m===b&&E===w?null:{x:Math.max(d.left,go)+sn+(m-b)/C*n,y:t-sn-Math.max(go,d.bottom),width:L,height:sn,deltaMultiplier:D},vertical:u===y&&g===x?null:{x:p?Math.max(d.left,go):n-sn-Math.max(d.right,go),y:Math.max(d.top,go)+sn+(u-y)/P*t,width:sn,height:k,deltaMultiplier:O}}},Zg=(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 e7}from"@excalidraw/math";import{getElementLineSegments as t7}from"@excalidraw/element";import{LinearElementEditor as n7}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as o7,isLinearElement as r7}from"@excalidraw/element";import{getFrameChildren as i7}from"@excalidraw/element";import{selectGroupsForSelectedElements as a7}from"@excalidraw/element";import{arrayToMap as s7,easeOut as W2,isShallowEqual as l7}from"@excalidraw/common";import{simplify as BN}from"points-on-curve";import{polygonFromPoints as ON,lineSegment as bm,pointFrom as ra,pointOnLineSegment as FN,polygonIncludesPointNonZero as zN,PRECISION as Em}from"@excalidraw/math";import{boundsContainBounds as F2,computeBoundTextPosition as HN,doBoundsIntersect as GN,elementOverlapsWithFrame as UN,getBoundTextElement as z2,getContainingFrame as WN,getElementBounds as H2,intersectElementWithLineSegment as VN,isBoundToContainer as G2,pointInsideBoundsInclusive as YN}from"@excalidraw/element";var U2=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=BN(n,s));let d=t.filter(g=>!g.locked&&!G2(g));a.clear(),i.clear();let p=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]),m=ON(c),u=[p[0]-Em,p[1]-Em,p[2]+Em,p[3]+Em];for(let g of d){let b=H2(g,o),y=KN(g,b,o),w=XN(b,y);if(GN(p,w)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!F2(u,w))continue;let x=$N(g,o,r,y),v=qN(m,x,w,l);l==="contain"?v&&!O2(c,g,o,y)&&a.add(g.id):v?a.add(g.id):O2(c,g,o,y)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?jN([...a],o):[...i,...a]}},KN=(e,n,t)=>{let o=WN(e,t);if(!o)return null;let r=H2(o,t);return F2(r,n)?null:UN(e,o,t)?r:null},XN=(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,$N=(e,n,t,o)=>{let r=t.get(e.id)??[],i=z2(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?ZN(s,o):s},ZN=(e,n)=>{let[t,o,r,i]=n,a=[];for(let[[s,l],[c,d]]of e){let p=c-s,m=d-l,u=0,E=1,g=!0;for(let[b,y]of[[-p,s-t],[p,r-s],[-m,l-o],[m,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(bm(ra(s+u*p,l+u*m),ra(s+E*p,l+E*m)))}return a},jN=(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||G2(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))})},qN=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>zN(a,e)||o==="contain"&&QN(a,e);return n.length===0?JN(t)[r](i):n[r](a=>a[r](i))},JN=([e,n,t,o])=>[ra(e,n),ra(t,n),ra(t,o),ra(e,o)],QN=(e,n)=>n.some((t,o)=>o>0&&FN(e,bm(n[o-1],t))),O2=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>bm(e[l],s)).concat([bm(e[e.length-1],e[0])]),i=z2(n,t),a=(s,l)=>{let c=VN(s,t,l,0,!o);return o?c.some(d=>YN(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...HN(n,i,t)},s))};var xm=class extends In{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(W2(s),W2(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});T(this,"intersectedElements",new Set);T(this,"enclosedElements",new Set);T(this,"elementsSegments",null);T(this,"canvasTranslate",null);T(this,"keepPreviousSelection",!1);T(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&&o7(c)){let d=i7(this.app.scene.getNonDeletedElementsMap(),c.id);for(let p of d)delete r[p.id]}}let i=a7({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&&r7(this.app.scene.getNonDeletedElement(a[0]))?new n7(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});T(this,"addPointToPath",(t,o,r=!1)=>{super.addPointToPath(t,o),this.keepPreviousSelection=r,this.updateSelection()});T(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>e7(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!l7(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=s7(this.app.visibleElements);for(let i of this.app.visibleElements){let a=t7(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=U2({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 c7,easeOut as V2,THEME as d7}from"@excalidraw/common";import{computeBoundTextPosition as m7,doBoundsIntersect as p7,getBoundTextElement as u7,getElementBounds as h7,getElementLineSegments as g7,getFreedrawOutlineAsSegments as f7,getFreedrawOutlinePoints as E7,intersectElementWithLineSegment as Y2,isArrowElement as b7,isFreeDrawElement as K2,isLineElement as x7,isPointInElement as w7}from"@excalidraw/element";import{lineSegment as y7,lineSegmentsDistance as X2,pointFrom as Q2,polygon as v7,polygonIncludesPointNonZero as T7}from"@excalidraw/math";import{getElementsInGroup as $2}from"@excalidraw/element";import{shouldTestInside as I7}from"@excalidraw/element";import{hasBoundTextElement as Z2,isBoundToContainer as j2}from"@excalidraw/element";import{getBoundTextElementId as q2}from"@excalidraw/element";var wm=class extends In{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(V2(s),V2(a))},fill:()=>t.state.theme===d7.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});T(this,"elementsToErase",new Set);T(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=>Q2(s[0],s[1]))||[];if(o.length<2)return[];let r=y7(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=c7(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(J2(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=$2(this.app.scene.getNonDeletedElementsMap(),c);for(let p of d)this.elementsToErase.delete(p.id);this.groupsToErase.delete(c)}if(j2(s)&&this.elementsToErase.delete(s.containerId),Z2(s)){let d=q2(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&J2(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=$2(this.app.scene.getNonDeletedElementsMap(),c);for(let p of d)this.elementsToErase.add(p.id);this.groupsToErase.add(c)}if(Z2(s)){let d=q2(s);d&&this.elementsToErase.add(d)}j2(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()}},J2=(e,n,t,o)=>{let r=e[1],i=K2(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=h7(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!p7(a,l))return!1;if(I7(n)&&w7(r,n,t))return!0;if(K2(n)){let d=E7(n),p=f7(n,d,t),m=Math.max(2.25,5/o);for(let E of p)if(X2(E,e)<=m)return!0;let u=v7(...d.map(([E,g])=>Q2(n.x+E,n.y+g)));return!!T7(e[0],u)}let c=u7(n,t);if(b7(n)||x7(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),p=g7(n,t);for(let m of p)if(X2(m,e)<=d)return!0;return!1}return Y2(n,t,e,0,!0).length>0||!!c&&Y2({...c,...m7(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as H7}from"@excalidraw/common";import{newElement as G7}from"@excalidraw/element";import{COLOR_PALETTE as S7,DEFAULT_FONT_FAMILY as C7,DEFAULT_FONT_SIZE as P7,VERTICAL_ALIGN as k7}from"@excalidraw/common";var eT=44,tT=22,nT=66,oT=48,sl=14,rT=304,iT=320,jg=5.87,aT=28,sT=4,lT=2,qg=10,cT=10,dT=8,Xn=12,ia=256,Xr=10,Jg=4,aa=Xn*2,Qg=Xn*2,mT=100,pT=140,ll=.35,uT=Xn/2,er=20,ym=Xn*2,ef=Xn,Le={fillStyle:"hachure",fontFamily:C7,fontSize:P7,opacity:100,roughness:1,strokeColor:S7.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:k7.MIDDLE,locked:!1};import{pointFrom as sa}from"@excalidraw/math";import{COLOR_PALETTE as bT,DEFAULT_CHART_COLOR_INDEX as M7,FONT_FAMILY as of,FONT_SIZES as vm,ROUNDNESS as hT,DEFAULT_FONT_SIZE as A7,getAllColorsSpecificShade as L7,getFontString as rf,getLineHeight as af,ROUGHNESS as gT}from"@excalidraw/common";import{getApproxMinLineWidth as sf,measureText as tr,newElement as nf,newLinearElement as tf,newTextElement as la,wrapText as xT}from"@excalidraw/element";var $r=L7(M7),D7=e=>e.labels?.length??e.series[0]?.values.length??0,ca=(e,n)=>{if(!e)return!1;let t=D7(e);return t<2?!1:n==="radar"?t>=3:!0},fT=(e,n)=>{let t=n<=1?0:Math.min(nT,(n-1)*tT);return e+t},Tm=(e,n)=>{if(e==="line"){let o=fT(oT,n);return{slotWidth:o,gap:sl,chartHeight:iT,xLabelMaxWidth:o+sl*3+qg}}let t=fT(eT,n);return{slotWidth:t,gap:sl,chartHeight:rT,xLabelMaxWidth:t+sl*3+qg}},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}},wT=()=>{let e=ia+Qg*2,n=ia+Qg*2;return{chartWidth:e,chartHeight:n}},_7=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},ma=(e,n)=>{if(e<=0||$r.length===0)return[];let t=$r.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 p=r.map(E=>_7(d,E,t)),m=Math.min(...p),u=p.reduce((E,g)=>E+g,0)/p.length;(m>l||m===l&&u>c)&&(s=d,l=m,c=u)}r.push(s),a.delete(s)}return Array.from({length:e},(s,l)=>$r[r[l%r.length]])},pa=e=>{if($r.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*$r.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)%$r.length},ua=e=>$r[e],yT=(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>=mT;return{renderSteps:!1,normalize:(s,l)=>{let c=Math.max(0,s);return a?Math.log10(c+1)/Math.log10(r+1):c/r}}},R7=e=>/\s/.test(e.trim()),Im=(e,n,t)=>R7(e)?xT(e,n,t):e,vT=(e,n,t,o,r,i)=>{let a=of.Excalifont,s=vm.sm,l=af(a),c=rf({fontFamily:a,fontSize:s}),d=Math.min(pT,r*(e.length>8?.56:.72)),p=sf(c,l),m=e.map((g,b)=>{let y=n[b],w=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>tr(z,c,l).width)),x=Math.max(p,d,w),v=Im(g,c,x),I=tr(v,c,l),C=Math.cos(y),P=Math.sin(y),A=C>ll?"left":C<-ll?"right":"center",L=A==="center"?I.width/2:0,_=Math.abs(C)*L+Math.abs(P)*(I.height/2),k=aa+_+uT,D=t+C*(r+k),O=o+P*(r+k),G=P>ll?Xn/3:P<-ll?-Xn/3:0;return la({backgroundColor:i,...Le,text:v,originalText:g,x:D,y:O+G,fontFamily:a,fontSize:s,lineHeight:l,textAlign:A,verticalAlign:"middle"})}),u=Math.min(...m.map(g=>g.y)),E=Math.max(...m.map(g=>g.y+g.height));return{axisLabels:m,axisLabelTopY:u,axisLabelBottomY:E}},ha=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=of["Lilita One"],s=vm.lg,l=af(a),c=rf({fontFamily:a,fontSize:s}),d=e.map((v,I)=>{let C=v.title?.trim()||`Series ${I+1}`,P=Im(C,c,ia),A=tr(P,c,l),L=er+ef+A.width;return{label:C,displayLabel:P,color:n[I],width:L,height:A.height}}),p=Math.max(er/2,...d.map(v=>v.height/2)),m=Math.max(r,o+p+aa),u=ym,E=er*.6,g=d.reduce((v,I)=>v+I.width,0)+ym*Math.max(0,d.length-1),b=g+u*2,y=p*2+E*2,w=[];w.push(nf({...Le,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:bT.black,x:t-b/2,y:m-y/2,width:b,height:y,roughness:gT.architect,roundness:{type:hT.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(v=>{w.push(nf({...Le,backgroundColor:v.color,type:"rectangle",x,y:m-er/2,width:er,height:er,fillStyle:"solid",strokeColor:v.color,roughness:gT.architect,roundness:{type:hT.PROPORTIONAL_RADIUS}})),w.push(la({...Le,text:v.displayLabel,originalText:v.label,autoResize:!1,x:x+er+ef,y:m,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=v.width+ym}),w},N7=(e,n,t,o)=>{if(tr(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(tr(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},B7=(e,n,t,o)=>{if(tr(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=>tr(a,t,o).width>n)&&n>=sf(t,o)?{wrapped:!0,text:xT(e,t,n)}:{wrapped:!1,text:N7(e,n,t,o)}},TT=(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}},ET=e=>e.includes("..."),O7=(e,n,t,o,r)=>{let i=Math.max(aT,Math.ceil(sf(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=ET(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,p=null,m=null;for(let u of s){let{wrapped:E,text:g}=B7(e,u,o,r),b=tr(g,o,r),y=TT(b.width,b.height,jg),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}(!p||x<p.overflow||x===p.overflow&&c(w,p.spec))&&(p={overflow:x,spec:w}),!ET(w.text)&&(!m||x<m.overflow||x===m.overflow&&c(w,m.spec))&&(m={overflow:x,spec:w})}return d||(m&&p&&m.overflow<=p.overflow+dT?m.spec:p.spec)},Sm=e=>{if(e.type!=="text")return e.y+e.height;let n=TT(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},cl=(e,n,t,o,r)=>{let i=Le.fontFamily,a=vm.sm,s=af(i),l=rf({fontFamily:i,fontSize:a}),c=Math.max(1,r.slotWidth+r.gap-sT*2+cT),d=t;return e.labels?.map((p,m)=>{let u=O7(p,r.xLabelMaxWidth,c,l,s),E=n+m*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=d+lT+(u.rotatedHeight-u.metrics.height)/2;return la({backgroundColor:o,...Le,text:u.text,originalText:u.wrapped?p:u.text,autoResize:!u.wrapped,x:E,y:g,angle:jg,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},F7=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=la({backgroundColor:o,...Le,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=la({backgroundColor:o,...Le,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},z7=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=da(e,r),s=tf({backgroundColor:o,...Le,type:"line",x:n,y:t,width:i,points:[sa(0,0),sa(i,0)]}),l=tf({backgroundColor:o,...Le,type:"line",x:n,y:t,height:a,points:[sa(0,0),sa(0,-a)]}),c=tf({backgroundColor:o,...Le,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:Xr,points:[sa(0,0),sa(i,0)]});return[s,l,c]},Cm=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=da(e,r),c=e.title?la({backgroundColor:o,...Le,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-A7,roundness:null,textAlign:"center",fontSize:vm.xl,fontFamily:of["Lilita One"]}):null,d=a?nf({backgroundColor:o,...Le,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:bT.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...cl(e,n,t,o,r),...F7(e,n,t,o,r,i),...z7(e,n,t,o,r)]};var IT=(e,n,t,o)=>{let r=e.series,i=Tm("bar",r.length),a=Math.max(1,...r.flatMap(v=>v.values.map(I=>Math.max(0,I)))),s=pa(o),l=ua(s),c=ma(r.length,s),d=r.length>1?Math.max(1,Math.floor(i.gap/(r.length+1))):0,p=r.length>1?Math.max(2,(i.slotWidth-d*(r.length-1))/r.length):i.slotWidth,m=r.length*p+d*(r.length-1),u=(i.slotWidth-m)/2,E=r[0].values.flatMap((v,I)=>r.map((C,P)=>{let L=Math.max(0,C.values[I]??0)/a*i.chartHeight,_=r.length>1?c[P]:l;return G7({backgroundColor:_,...Le,type:"rectangle",fillStyle:r.length>1?"solid":Le.fillStyle,strokeColor:r.length>1?_:Le.strokeColor,x:n+I*(i.slotWidth+i.gap)+i.gap+u+P*(p+d),y:t-L-i.gap,width:p,height:L})})),g=Cm(e,n,t,l,i,a,H7()),b=cl(e,n,t,l,i),y=Math.max(t+i.gap/2,...b.map(v=>Sm(v))),{chartWidth:w}=da(e,i),x=ha(r,c,n+w/2,y,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as lf}from"@excalidraw/math";import{isDevEnv as U7}from"@excalidraw/common";import{newElement as W7,newLinearElement as ST}from"@excalidraw/element";var CT=(e,n,t,o)=>{let r=e.series,i=Tm("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=pa(o),l=ua(s),c=ma(r.length,s),d=r.map((x,v)=>{let I=x.values.map((_,k)=>lf(k*(i.slotWidth+i.gap),-(_/a)*i.chartHeight)),C=Math.max(...I.map(_=>_[0])),P=Math.max(...I.map(_=>_[1])),A=Math.min(...I.map(_=>_[0])),L=Math.min(...I.map(_=>_[1]));return ST({backgroundColor:"transparent",...Le,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:P-L,width:C-A,strokeColor:c[v],strokeWidth:2,points:I})}),p=r.flatMap((x,v)=>x.values.map((I,C)=>{let P=C*(i.slotWidth+i.gap)+i.gap/2,A=-(I/a)*i.chartHeight+i.gap/2;return W7({backgroundColor:c[v],...Le,fillStyle:"solid",strokeColor:c[v],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,v)=>Math.max(0,...r.map(I=>I.values[v]??0))).map((x,v)=>{let I=v*(i.slotWidth+i.gap)+i.gap/2,C=x/a*i.chartHeight+i.gap/2+i.gap;return ST({backgroundColor:l,...Le,type:"line",x:n+I+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:Xr,points:[lf(0,0),lf(0,C)]})}),E=Cm(e,n,t,l,i,a,U7()),g=cl(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>Sm(x))),{chartWidth:y}=da(e,i),w=ha(r,c,n+y/2,b,t+i.gap*5,l);return[...E,...d,...u,...p,...w]};var Sn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},V7=(e,n)=>e.slice(1).every(t=>Sn(t[n])!==null),PT=e=>{let n=e[0].length;if(n>2){let a=e[0].every(p=>Sn(p)===null),s=a?e.slice(1):e;if(s.length<1)return{ok:!1,reason:"No data rows"};if(s.some(p=>p.slice(1).some(m=>Sn(m)===null)))return{ok:!1,reason:"Value is not numeric"};if(n-1>s.length){let p=a?e[0].slice(1).map(E=>E.trim()):null,m=s.map(E=>({title:E[0]?.trim()||null,values:E.slice(1).map(g=>Sn(g))}));return{ok:!0,data:{title:m.length===1?m[0].title:a&&e[0][0].trim()||null,labels:p,series:m}}}let d=e[0].slice(1).map((p,m)=>{let u=m+1,E=`Series ${u}`;return{title:a&&p.trim()||E,values:s.map(g=>Sn(g[u]))}});return{ok:!0,data:{title:a&&e[0][0].trim()||null,labels:s.map(p=>p[0]),series:d}}}if(n===1){if(!V7(e,0))return{ok:!1,reason:"Value is not numeric"};let a=Sn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(c=>Sn(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=Sn(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=>Sn(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=>Sn(a[1]))}]}}},Pm=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"},UN=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},WN=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=UN(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},N2=({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,U)=>{if(!U.style.fontFamily||!U.style.fontSize)return!1;let ue=U.style.fontFamily.replace(/"/g,"");return C2({fontFamily:B.fontFamily})!==ue||`${B.fontSize}px`!==U.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let B=a.state,U=a.scene.getElement(o.id);if(!U)return;let{textAlign:ue,verticalAlign:we}=U,pe=a.scene.getNonDeletedElementsMap();if(U&&R2(U)){let he=U.x,ye=U.y,se=ef(U,a.scene.getNonDeletedElementsMap()),ve=U.width,st=U.height,Ze=U.width,Re=U.height;if(se&&U.containerId){if(wm(se)){let Rn=CN.getBoundTextElementPosition(se,U,pe);he=Rn.x,ye=Rn.y}let ou=d(U,u),no;if(ou?no=A2(se.id,se.height):(no=SN[se.id],no||(no=A2(se.id,se.height))),Ze=L2(se,U),Re=LN(se,U),!wm(se)&&st>Re){let Rn=D2(st,se.type);a.scene.mutateElement(se,{height:Rn}),M2(se,a.scene);return}else if(!wm(se)&&se.height>no.height&&st<Re){let Rn=D2(st,se.type);a.scene.mutateElement(se,{height:Rn}),M2(se,a.scene)}else{let{x:Rn,y:ts}=DN(se,U,pe);he=Rn,ye=ts}}let[Do,li]=t(he,ye);se?ve+=.5:(Ze=(B.width-8-Do)/B.zoom.value,ve=Math.min(ve,Ze)),st*=1.05;let dc=S2(U),mc=MN(U,se),pc=(B.height-li)/B.zoom.value;Object.assign(u.style,{font:dc,lineHeight:U.lineHeight,width:`${ve}px`,height:`${st}px`,left:`${Do}px`,top:`${li}px`,transform:HN(ve,st,mc,B,Ze,pc),textAlign:ue,verticalAlign:we,color:yN(U.strokeColor,B.theme===xN.DARK),opacity:U.opacity/100,maxHeight:`${pc}px`}),c={angle:mc,font:dc,height:U.height,lineHeightPx:NN(U.fontSize,U.lineHeight),textAlign:ue,width:U.width,x:he,y:ye},u.scrollTop=0,P2()&&(u.style.fontFamily=C2(U)),a.scene.mutateElement(U,{x:he,y:ye})}},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";(zN(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,U=k2(B.x+B.width/2,B.y+B.height/2),[ue,we]=IN(k2(l.x,l.y),U,-B.angle),pe=ue-B.x,he=we-B.y,ye=FN(u.value,B.font,E==="pre-wrap"?B.width:1/0),se=Math.max(0,Math.min(ye.length-1,Math.floor(he/B.lineHeightPx))),ve=ye[se],st=GN(u.value,ve.start),Ze=BN(ve.text,B.font),Re=B.textAlign==="center"?(B.width-Ze)/2:B.textAlign==="right"?B.width-Ze:0,Do=pe-Re;if(!ve.text)return ve.start;let li=WN({text:ve.text,font:B.font,lineHeightPx:B.lineHeightPx,direction:st,targetX:Do});return ve.start+(li||0)},y=(()=>{let B=b();return B===null?null:{start:B,end:B}})();e&&(u.onpaste=async B=>{let U=Qw(B),ue=null;if(U.has(Qg.excalidrawClipboard)||U.has(Qg.excalidraw)){B.preventDefault(),ue=await Br(B);try{let se=await zd(ue);if(se.elements){let ve=TN(se.elements);if(ve){let{selectionStart:st,selectionEnd:Ze,value:Re}=u;u.value=Re.slice(0,st)+ve+Re.slice(Ze);let Do=st+ve.length;u.selectionStart=u.selectionEnd=Do,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}ue=ue||await Br(B);let we=ue.findByType(Qg.text);if(!we)return;let pe=_2(we.value);if(!pe)return;let he=ef(o,a.scene.getNonDeletedElementsMap()),ye=S2({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(he){let se=_N(he,a.scene.getNonDeletedElementsMap()),ve=ON(`${u.value}${pe}`,ye,L2(he,se)),st=RN(ve,ye);u.style.width=`${st}px`}},u.oninput=()=>{let B=_2(u.value);if(u.value!==B){let U=u.selectionStart;u.value=B,u.selectionStart=U,u.selectionEnd=U}e(u.value)}),u.onkeydown=B=>{if(!B.shiftKey&&yd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(yd),p();else if(!B.shiftKey&&vd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(vd),p();else if(!B.shiftKey&&Id.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Id),p();else if(Ih.keyTest(B))a.actionManager.executeAction(Ih);else if(Th.keyTest(B))a.actionManager.executeAction(Th);else if(B.key===El.ESCAPE)B.preventDefault(),L=!0,_();else if(zr.keyTest(B))B.preventDefault(),_(),a.actionManager.executeAction(zr);else if(B.key===El.ENTER&&B[El.CTRL_OR_CMD]){if(B.preventDefault(),B.isComposing||B.keyCode===229)return;L=!0,_()}else if(B.key===El.TAB||B[El.CTRL_OR_CMD]&&(B.code===qg.BRACKET_LEFT||B.code===qg.BRACKET_RIGHT)){if(B.preventDefault(),B.isComposing)return;B.shiftKey||B.code===qg.BRACKET_LEFT?C():T(),u.dispatchEvent(new Event("input"))}};let w=4,x=" ".repeat(w),v=new RegExp(`^ {1,${w}}`),T=()=>{let{selectionStart:B,selectionEnd:U}=u,ue=P(),we=u.value;ue.forEach(pe=>{let he=we.slice(0,pe),ye=we.slice(pe);we=`${he}${x}${ye}`}),u.value=we,u.selectionStart=B+w,u.selectionEnd=U+w*ue.length},C=()=>{let{selectionStart:B,selectionEnd:U}=u,ue=P(),we=[],pe=u.value;ue.forEach(he=>{let ye=pe.slice(he,he+w).match(v);if(ye){let se=pe.slice(0,he),ve=pe.slice(he+ye[0].length);pe=`${se}${ve}`,we.push(he)}}),u.value=pe,we.length&&(B>we[we.length-1]?u.selectionStart=Math.max(B-w,we[we.length-1]):u.selectionStart=B,u.selectionEnd=Math.max(u.selectionStart,U-w*we.length))},P=()=>{let{selectionStart:B,selectionEnd:U,value:ue}=u,we=ue.slice(0,B).match(/[^\n]*$/)[0].length;return B=B-we,ue.slice(B,U).split(`
14
+ `).reduce((he,ye,se,ve)=>he.concat(se?he[se-1]+ve[se-1].length+1:B),[]).reverse()},A=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},L=!1,_=()=>{if(H)return;H=!0,k();let B=a.scene.getElement(o.id);if(!B)return;let U=ef(B,a.scene.getNonDeletedElementsMap());if(U){if(u.value.trim()){let ue=kN(U);!ue||ue!==o.id?a.scene.mutateElement(U,{boundElements:(U.boundElements||[]).concat({type:"text",id:o.id})}):wm(U)&&PN(U)}else a.scene.mutateElement(U,{boundElements:U.boundElements?.filter(ue=>!R2(ue))});AN(B,U,a.scene)}n({viaKeyboard:L,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,re&&re.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",A,!0),window.removeEventListener("pointerdown",Y),window.removeEventListener("pointerup",D),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),W(),z(),$(),u.remove()},D=B=>{window.removeEventListener("pointerup",D);let U=B?.target,ue=U instanceof HTMLElement&&U.classList.contains("properties-trigger"),we=(U instanceof HTMLElement||U instanceof SVGElement)&&!!U.closest(".properties-content"),pe=(U instanceof HTMLElement||U instanceof SVGElement)&&(!!U.closest(`.${Jg.SHAPE_ACTIONS_MENU}`)||!!U.closest(".compact-shape-actions-island"));setTimeout(()=>{pe||ue||we||(u.onblur=_,u.focus(),y&&(u.setSelectionRange(y.start,y.end),y=null))})},F=()=>{u.onblur=null,window.addEventListener("pointerup",D),window.addEventListener("blur",_)},Y=B=>{let U=B?.target;if(B.button===bN.WHEEL){U instanceof HTMLTextAreaElement&&(B.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(B)),F();return}let ue=U instanceof HTMLElement&&U.classList.contains("properties-trigger"),we=(U instanceof HTMLElement||U instanceof SVGElement)&&!!U.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${Jg.SHAPE_ACTIONS_MENU}, .${Jg.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!wN(B.target)||ue||we?F():B.target instanceof HTMLCanvasElement&&!P2()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(B=>{a.state.theme!==m&&p()}),W=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),$=a.onScrollChangeEmitter.on(()=>{p()}),H=!1;s&&!y&&u.select(),D();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 ym}from"@excalidraw/common";import{getCommonBounds as VN}from"@excalidraw/element";var Eo=4,cn=6,B2="rgba(0,0,0,0.3)",O2=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=VN(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(ym("sat"))||0,bottom:parseInt(ym("sab"))||0,left:parseInt(ym("sal"))||0,right:parseInt(ym("sar"))||0},m=Fn().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),v=a-r,T=s-i,C=w-b,P=x-y,A=Math.max(Eo*2,d.left+d.right)+cn*2,L=n*(l/C)-A,_=Math.max(Eo*2,d.top+d.bottom)+cn*2,k=t*(c/P)-_,D=C>v?C*o.zoom.value/(L+A):n/(L+A),F=P>T?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:p===b&&E===w?null:{x:Math.max(d.left,Eo)+cn+(p-b)/C*n,y:t-cn-Math.max(Eo,d.bottom),width:L,height:cn,deltaMultiplier:D},vertical:u===y&&g===x?null:{x:m?Math.max(d.left,Eo):n-cn-Math.max(d.right,Eo),y:Math.max(d.top,Eo)+cn+(u-y)/P*t,width:cn,height:k,deltaMultiplier:F}}},tf=(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 c7}from"@excalidraw/math";import{getElementLineSegments as d7}from"@excalidraw/element";import{LinearElementEditor as m7}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as p7,isLinearElement as u7}from"@excalidraw/element";import{getFrameChildren as h7}from"@excalidraw/element";import{selectGroupsForSelectedElements as g7}from"@excalidraw/element";import{arrayToMap as f7,easeOut as V2,isShallowEqual as E7}from"@excalidraw/common";import{simplify as YN}from"points-on-curve";import{polygonFromPoints as XN,lineSegment as Im,pointFrom as pa,pointOnLineSegment as KN,polygonIncludesPointNonZero as $N,PRECISION as vm}from"@excalidraw/math";import{boundsContainBounds as z2,computeBoundTextPosition as ZN,doBoundsIntersect as jN,elementOverlapsWithFrame as qN,getBoundTextElement as H2,getContainingFrame as JN,getElementBounds as G2,intersectElementWithLineSegment as QN,isBoundToContainer as U2,pointInsideBoundsInclusive as e7}from"@excalidraw/element";var W2=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=YN(n,s));let d=t.filter(g=>!g.locked&&!U2(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=XN(c),u=[m[0]-vm,m[1]-vm,m[2]+vm,m[3]+vm];for(let g of d){let b=G2(g,o),y=t7(g,b,o),w=n7(b,y);if(jN(m,w)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!z2(u,w))continue;let x=o7(g,o,r,y),v=a7(p,x,w,l);l==="contain"?v&&!F2(c,g,o,y)&&a.add(g.id):v?a.add(g.id):F2(c,g,o,y)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?i7([...a],o):[...i,...a]}},t7=(e,n,t)=>{let o=JN(e,t);if(!o)return null;let r=G2(o,t);return z2(r,n)?null:qN(e,o,t)?r:null},n7=(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,o7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=H2(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?r7(s,o):s},r7=(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(Im(pa(s+u*m,l+u*p),pa(s+E*m,l+E*p)))}return a},i7=(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||U2(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))})},a7=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>$N(a,e)||o==="contain"&&l7(a,e);return n.length===0?s7(t)[r](i):n[r](a=>a[r](i))},s7=([e,n,t,o])=>[pa(e,n),pa(t,n),pa(t,o),pa(e,o)],l7=(e,n)=>n.some((t,o)=>o>0&&KN(e,Im(n[o-1],t))),F2=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>Im(e[l],s)).concat([Im(e[e.length-1],e[0])]),i=H2(n,t),a=(s,l)=>{let c=QN(s,t,l,0,!o);return o?c.some(d=>e7(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...ZN(n,i,t)},s))};var Tm=class extends Pn{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(V2(s),V2(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"canvasTranslate",null);I(this,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(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&&p7(c)){let d=h7(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=g7({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&&u7(this.app.scene.getNonDeletedElement(a[0]))?new m7(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,o,r=!1)=>{super.addPointToPath(t,o),this.keepPreviousSelection=r,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>c7(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!E7(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=f7(this.app.visibleElements);for(let i of this.app.visibleElements){let a=d7(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=W2({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 b7,easeOut as Y2,THEME as x7}from"@excalidraw/common";import{computeBoundTextPosition as w7,doBoundsIntersect as y7,getBoundTextElement as v7,getElementBounds as I7,getElementLineSegments as T7,getFreedrawOutlineAsSegments as S7,getFreedrawOutlinePoints as C7,intersectElementWithLineSegment as X2,isArrowElement as P7,isFreeDrawElement as K2,isLineElement as k7,isPointInElement as M7}from"@excalidraw/element";import{lineSegment as A7,lineSegmentsDistance as $2,pointFrom as eI,polygon as L7,polygonIncludesPointNonZero as D7}from"@excalidraw/math";import{getElementsInGroup as Z2}from"@excalidraw/element";import{shouldTestInside as _7}from"@excalidraw/element";import{hasBoundTextElement as j2,isBoundToContainer as q2}from"@excalidraw/element";import{getBoundTextElementId as J2}from"@excalidraw/element";var Sm=class extends Pn{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(Y2(s),Y2(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===x7.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")});I(this,"elementsToErase",new Set);I(this,"groupsToErase",new Set)}startPath(t,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=>eI(s[0],s[1]))||[];if(o.length<2)return[];let r=A7(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=b7(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(Q2(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=Z2(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(q2(s)&&this.elementsToErase.delete(s.containerId),j2(s)){let d=J2(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&Q2(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=Z2(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(j2(s)){let d=J2(s);d&&this.elementsToErase.add(d)}q2(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()}},Q2=(e,n,t,o)=>{let r=e[1],i=K2(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=I7(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!y7(a,l))return!1;if(_7(n)&&M7(r,n,t))return!0;if(K2(n)){let d=C7(n),m=S7(n,d,t),p=Math.max(2.25,5/o);for(let E of m)if($2(E,e)<=p)return!0;let u=L7(...d.map(([E,g])=>eI(n.x+E,n.y+g)));return!!D7(e[0],u)}let c=v7(n,t);if(P7(n)||k7(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=T7(n,t);for(let p of m)if($2(p,e)<=d)return!0;return!1}return X2(n,t,e,0,!0).length>0||!!c&&X2({...c,...w7(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as Z7}from"@excalidraw/common";import{newElement as j7}from"@excalidraw/element";import{COLOR_PALETTE as R7,DEFAULT_FONT_FAMILY as N7,DEFAULT_FONT_SIZE as B7,VERTICAL_ALIGN as O7}from"@excalidraw/common";var tI=44,nI=22,oI=66,rI=48,bl=14,iI=304,aI=320,nf=5.87,sI=28,lI=4,cI=2,of=10,dI=10,mI=8,Kn=12,ua=256,jr=10,rf=4,ha=Kn*2,af=Kn*2,pI=100,uI=140,xl=.35,hI=Kn/2,rr=20,Cm=Kn*2,sf=Kn,_e={fillStyle:"hachure",fontFamily:N7,fontSize:B7,opacity:100,roughness:1,strokeColor:R7.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:O7.MIDDLE,locked:!1};import{pointFrom as ga}from"@excalidraw/math";import{COLOR_PALETTE as xI,DEFAULT_CHART_COLOR_INDEX as F7,FONT_FAMILY as df,FONT_SIZES as Pm,ROUNDNESS as gI,DEFAULT_FONT_SIZE as z7,getAllColorsSpecificShade as H7,getFontString as mf,getLineHeight as pf,ROUGHNESS as fI}from"@excalidraw/common";import{getApproxMinLineWidth as uf,measureText as ir,newElement as cf,newLinearElement as lf,newTextElement as fa,wrapText as wI}from"@excalidraw/element";var qr=H7(F7),G7=e=>e.labels?.length??e.series[0]?.values.length??0,Ea=(e,n)=>{if(!e)return!1;let t=G7(e);return t<2?!1:n==="radar"?t>=3:!0},EI=(e,n)=>{let t=n<=1?0:Math.min(oI,(n-1)*nI);return e+t},km=(e,n)=>{if(e==="line"){let o=EI(rI,n);return{slotWidth:o,gap:bl,chartHeight:aI,xLabelMaxWidth:o+bl*3+of}}let t=EI(tI,n);return{slotWidth:t,gap:bl,chartHeight:iI,xLabelMaxWidth:t+bl*3+of}},ba=(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}},yI=()=>{let e=ua+af*2,n=ua+af*2;return{chartWidth:e,chartHeight:n}},U7=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},xa=(e,n)=>{if(e<=0||qr.length===0)return[];let t=qr.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=>U7(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)=>qr[r[l%r.length]])},wa=e=>{if(qr.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*qr.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)%qr.length},ya=e=>qr[e],vI=(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}}},W7=e=>/\s/.test(e.trim()),Mm=(e,n,t)=>W7(e)?wI(e,n,t):e,II=(e,n,t,o,r,i)=>{let a=df.Excalifont,s=Pm.sm,l=pf(a),c=mf({fontFamily:a,fontSize:s}),d=Math.min(uI,r*(e.length>8?.56:.72)),m=uf(c,l),p=e.map((g,b)=>{let y=n[b],w=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>ir(z,c,l).width)),x=Math.max(m,d,w),v=Mm(g,c,x),T=ir(v,c,l),C=Math.cos(y),P=Math.sin(y),A=C>xl?"left":C<-xl?"right":"center",L=A==="center"?T.width/2:0,_=Math.abs(C)*L+Math.abs(P)*(T.height/2),k=ha+_+hI,D=t+C*(r+k),F=o+P*(r+k),Y=P>xl?Kn/3:P<-xl?-Kn/3:0;return fa({backgroundColor:i,..._e,text:v,originalText:g,x:D,y:F+Y,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}},va=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=df["Lilita One"],s=Pm.lg,l=pf(a),c=mf({fontFamily:a,fontSize:s}),d=e.map((v,T)=>{let C=v.title?.trim()||`Series ${T+1}`,P=Mm(C,c,ua),A=ir(P,c,l),L=rr+sf+A.width;return{label:C,displayLabel:P,color:n[T],width:L,height:A.height}}),m=Math.max(rr/2,...d.map(v=>v.height/2)),p=Math.max(r,o+m+ha),u=Cm,E=rr*.6,g=d.reduce((v,T)=>v+T.width,0)+Cm*Math.max(0,d.length-1),b=g+u*2,y=m*2+E*2,w=[];w.push(cf({..._e,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:xI.black,x:t-b/2,y:p-y/2,width:b,height:y,roughness:fI.architect,roundness:{type:gI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(v=>{w.push(cf({..._e,backgroundColor:v.color,type:"rectangle",x,y:p-rr/2,width:rr,height:rr,fillStyle:"solid",strokeColor:v.color,roughness:fI.architect,roundness:{type:gI.PROPORTIONAL_RADIUS}})),w.push(fa({..._e,text:v.displayLabel,originalText:v.label,autoResize:!1,x:x+rr+sf,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=v.width+Cm}),w},V7=(e,n,t,o)=>{if(ir(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(ir(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},Y7=(e,n,t,o)=>{if(ir(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=>ir(a,t,o).width>n)&&n>=uf(t,o)?{wrapped:!0,text:wI(e,t,n)}:{wrapped:!1,text:V7(e,n,t,o)}},TI=(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}},bI=e=>e.includes("..."),X7=(e,n,t,o,r)=>{let i=Math.max(sI,Math.ceil(uf(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=bI(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}=Y7(e,u,o,r),b=ir(g,o,r),y=TI(b.width,b.height,nf),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}),!bI(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+mI?p.spec:m.spec)},Am=e=>{if(e.type!=="text")return e.y+e.height;let n=TI(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},wl=(e,n,t,o,r)=>{let i=_e.fontFamily,a=Pm.sm,s=pf(i),l=mf({fontFamily:i,fontSize:a}),c=Math.max(1,r.slotWidth+r.gap-lI*2+dI),d=t;return e.labels?.map((m,p)=>{let u=X7(m,r.xLabelMaxWidth,c,l,s),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=d+cI+(u.rotatedHeight-u.metrics.height)/2;return fa({backgroundColor:o,..._e,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:nf,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},K7=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=fa({backgroundColor:o,..._e,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=fa({backgroundColor:o,..._e,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},$7=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=ba(e,r),s=lf({backgroundColor:o,..._e,type:"line",x:n,y:t,width:i,points:[ga(0,0),ga(i,0)]}),l=lf({backgroundColor:o,..._e,type:"line",x:n,y:t,height:a,points:[ga(0,0),ga(0,-a)]}),c=lf({backgroundColor:o,..._e,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:jr,points:[ga(0,0),ga(i,0)]});return[s,l,c]},Lm=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=ba(e,r),c=e.title?fa({backgroundColor:o,..._e,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-z7,roundness:null,textAlign:"center",fontSize:Pm.xl,fontFamily:df["Lilita One"]}):null,d=a?cf({backgroundColor:o,..._e,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:xI.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...wl(e,n,t,o,r),...K7(e,n,t,o,r,i),...$7(e,n,t,o,r)]};var SI=(e,n,t,o)=>{let r=e.series,i=km("bar",r.length),a=Math.max(1,...r.flatMap(v=>v.values.map(T=>Math.max(0,T)))),s=wa(o),l=ya(s),c=xa(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((v,T)=>r.map((C,P)=>{let L=Math.max(0,C.values[T]??0)/a*i.chartHeight,_=r.length>1?c[P]:l;return j7({backgroundColor:_,..._e,type:"rectangle",fillStyle:r.length>1?"solid":_e.fillStyle,strokeColor:r.length>1?_:_e.strokeColor,x:n+T*(i.slotWidth+i.gap)+i.gap+u+P*(m+d),y:t-L-i.gap,width:m,height:L})})),g=Lm(e,n,t,l,i,a,Z7()),b=wl(e,n,t,l,i),y=Math.max(t+i.gap/2,...b.map(v=>Am(v))),{chartWidth:w}=ba(e,i),x=va(r,c,n+w/2,y,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as hf}from"@excalidraw/math";import{isDevEnv as q7}from"@excalidraw/common";import{newElement as J7,newLinearElement as CI}from"@excalidraw/element";var PI=(e,n,t,o)=>{let r=e.series,i=km("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=wa(o),l=ya(s),c=xa(r.length,s),d=r.map((x,v)=>{let T=x.values.map((_,k)=>hf(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])),L=Math.min(...T.map(_=>_[1]));return CI({backgroundColor:"transparent",..._e,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:P-L,width:C-A,strokeColor:c[v],strokeWidth:2,points:T})}),m=r.flatMap((x,v)=>x.values.map((T,C)=>{let P=C*(i.slotWidth+i.gap)+i.gap/2,A=-(T/a)*i.chartHeight+i.gap/2;return J7({backgroundColor:c[v],..._e,fillStyle:"solid",strokeColor:c[v],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,v)=>Math.max(0,...r.map(T=>T.values[v]??0))).map((x,v)=>{let T=v*(i.slotWidth+i.gap)+i.gap/2,C=x/a*i.chartHeight+i.gap/2+i.gap;return CI({backgroundColor:l,..._e,type:"line",x:n+T+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:jr,points:[hf(0,0),hf(0,C)]})}),E=Lm(e,n,t,l,i,a,q7()),g=wl(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>Am(x))),{chartWidth:y}=ba(e,i),w=va(r,c,n+y/2,b,t+i.gap*5,l);return[...E,...d,...u,...m,...w]};var kn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},Q7=(e,n)=>e.slice(1).every(t=>kn(t[n])!==null),kI=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>kn(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=>kn(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=>kn(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=>kn(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(!Q7(e,0))return{ok:!1,reason:"Value is not numeric"};let a=kn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(c=>kn(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=kn(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=>kn(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=>kn(a[1]))}]}}},Dm=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(p=>p.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)?PT(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as ga}from"@excalidraw/math";import{FONT_FAMILY as Y7,FONT_SIZES as K7,getFontString as X7,getLineHeight as $7,ROUGHNESS as kT}from"@excalidraw/common";import{measureText as Z7,newLinearElement as cf,newTextElement as j7}from"@excalidraw/element";var MT=(e,n,t,o)=>{if(!ca(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,W)=>`Value ${W+1}`),i=e.series,{normalize:a,renderSteps:s}=yT(i,r.length),l=pa(o),c=ua(l),d=ma(i.length,l),{chartWidth:p,chartHeight:m}=wT(),u=n+p/2,E=t-m/2,g=ia/2,b=r.map((z,W)=>-Math.PI/2+Math.PI*2*W/r.length),{axisLabels:y,axisLabelTopY:w,axisLabelBottomY:x}=vT(r,b,u,E,g,c),v=Y7["Lilita One"],I=K7.xl,C=$7(v),P=X7({fontFamily:v,fontSize:I}),A=e.title?Im(e.title,P,p+aa*2):null,L=A?Z7(A,P,C):null,_=A?j7({backgroundColor:c,...Le,text:A,originalText:e.title??A,x:n+p/2,y:w-aa-L.height/2,fontFamily:v,fontSize:I,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:Jg},(z,W)=>{let j=(W+1)/Jg,X=g*j,oe=b.map(B=>ga(Math.cos(B)*X,Math.sin(B)*X));return oe.push(ga(oe[0][0],oe[0][1])),cf({backgroundColor:"transparent",...Le,type:"line",x:u,y:E,width:X*2,height:X*2,strokeStyle:"solid",roughness:kT.architect,opacity:Xr,polygon:!0,points:oe})}):[],D=b.map(z=>{let W=Math.cos(z)*g,j=Math.sin(z)*g;return cf({backgroundColor:"transparent",...Le,type:"line",x:u,y:E,width:Math.abs(W),height:Math.abs(j),strokeStyle:"solid",roughness:kT.architect,opacity:Xr,points:[ga(0,0),ga(W,j)]})}),O=i.map((z,W)=>{let j=b.map((X,oe)=>{let B=z.values[oe]??0,U=a(B,oe)*g;return ga(Math.cos(X)*U,Math.sin(X)*U)});return j.push(ga(j[0][0],j[0][1])),cf({backgroundColor:"transparent",...Le,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[W],strokeWidth:2,polygon:!0,points:j})}),G=ha(i,d,u,x,t+Xn*5,c);return[..._?[_]:[],...y,...k,...D,...O,...G]};var df=(e,n,t,o,r)=>e==="line"?CT(n,t,o,r):e==="radar"?MT(n,t,o,r):IT(n,t,o,r);import{useEffect as ul,useMemo as AT,useRef as gf,useState as q7}from"react";import{bumpVersion as dl,getLinearElementSubType as Ea,mutateElement as ff,updateElbowArrowPoints as J7}from"@excalidraw/element";import{pointFrom as Mm,pointRotateRads as Q7}from"@excalidraw/math";import{hasBoundTextElement as eB,isArrowBoundToElement as tB,isArrowElement as nB,isElbowArrow as oB,isLinearElement as wf,isUsingAdaptiveRadius as rB}from"@excalidraw/element";import{getCommonBoundingBox as iB,getElementAbsoluteCoords as aB}from"@excalidraw/element";import{getBoundTextElement as NT,getBoundTextMaxHeight as sB,getBoundTextMaxWidth as lB,redrawTextBoundingBox as cB}from"@excalidraw/element";import{wrapText as dB}from"@excalidraw/element";import{assertNever as mB,CLASSES as pB,getFontString as mf,isProdEnv as uB,mapFind as hB,reduceToCommonValue as gB,ROUNDNESS as pf,sceneCoordsToViewportCoords as fB,updateActiveTool as LT}from"@excalidraw/common";import{measureText as DT}from"@excalidraw/element";import{LinearElementEditor as EB}from"@excalidraw/element/linearElementEditor";import{newArrowElement as uf,newElement as bB,newLinearElement as xB}from"@excalidraw/element";import{ShapeCache as wB}from"@excalidraw/element";import{updateBindings as yB}from"@excalidraw/element";import{jsx as xf}from"react/jsx-runtime";var vB=8,TB=10,ml=["rectangle","diamond","ellipse"],pl=["line","sharpArrow","curvedArrow","elbowArrow"],IB=new Set(ml),SB=new Set(pl),ba=e=>IB.has(e),Am=e=>e==="arrow"||SB.has(e),$n=Ze(null),hl=new Map,gl=new Map,CB=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=gf(null);return ul(()=>{if(n.length===0){e.updateEditorAtom($n,null);return}let o=Lm(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom($n,null),t.current=null)},[n,e]),ul(()=>()=>{hl.clear(),gl.clear()},[]),xf(PB,{app:e,elements:n})},PB=({app:e,elements:n})=>{let t=Lm(n),o=AT(()=>t==="generic"?OT(n):[],[t,n]),r=AT(()=>t==="linear"?bf(n):[],[t,n]),i=t==="generic"?o.every(p=>p.type===o[0].type):t==="linear"?r.every(p=>Ea(p)===Ea(r[0])):!1,[a,s]=q7({x:0,y:0}),l=gf(""),c=gf(null);ul(()=>{let p=[...o,...r].sort((b,y)=>b.id.localeCompare(y.id)),m=`
18
- ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${p.map(b=>b.id).join(",")}`;if(m===l.current)return;l.current=m;let u;if(p.length===1){let[b,,,y,w,x]=aB(p[0],e.scene.getNonDeletedElementsMap());u=Q7(Mm(b,y),Mm(w,x),p[0].angle)}else{let{minX:b,maxY:y}=iB(p);u=Mm(b,y)}let{x:E,y:g}=fB({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),ul(()=>{for(let p of r){let m=Ef(p.id,DB(p));gl.has(m)||gl.set(m,p)}},[r]),ul(()=>{for(let p of o)if(!hl.has(p.id)){let m=NT(p,e.scene.getNonDeletedElementsMap());m&&hl.set(p.id,{fontSize:m.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",Do],["sharpArrow",Ro],["curvedArrow",Bo],["elbowArrow",No]]:t==="generic"?[["rectangle",ui],["diamond",hi],["ellipse",gi]]:[];return xf("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(TB+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-vB}px`,zIndex:2},className:pB.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([p,m])=>{let u=i&&(t==="generic"&&o[0].type===p||t==="linear"&&Ea(r[0])===p);return xf($,{type:"toggle",icon:m,checked:u,title:p,"aria-label":p,"data-testid":`toolbar-${p}`,onSelect:()=>{u||(e.state.activeTool.type!==p&&Re("convertElementType",p,"ui"),yf(e,{conversionType:t,nextType:p}),c.current?.focus())}},`${n[0].id}${n[0].version}_${p}`)})})},kB=(e,n,t)=>{let o=lB(e,n),r=sB(e,n),i=dB(n.text,mf(n),o),a=DT(i,mf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=DT(n.text,mf(l),n.lineHeight)}ff(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),cB(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=OT(r),c=s.every(d=>d.type===s[0].type)?ml.indexOf(s[0].type):-1;if(t=t??ml[(c+ml.length+a)%ml.length],t&&ba(t)){let d={};for(let m of s){let u=RT(m,t,e);d[u.id]=u}let p=[];for(let m of e.scene.getElementsIncludingDeleted())d[m.id]?p.push(d[m.id]):p.push(m);e.scene.replaceAllElements(p);for(let m of Object.values(d)){let u=NT(m,e.scene.getNonDeletedElementsMap());u&&(hl.get(m.id)&&ff(u,e.scene.getNonDeletedElementsMap(),{fontSize:hl.get(m.id)?.fontSize??u.fontSize}),kB(m,u,e.scene))}e.setState(m=>({selectedElementIds:i,activeTool:LT(m,{type:"selection"})}))}}if(n==="linear"){let s=bf(r);if(!t){let c=gB(s,Ea),d=c?pl.indexOf(c):-1;t=pl[(d+pl.length+a)%pl.length]}if(Am(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let p of s){let m=gl.get(Ef(p.id,t));if(m&&Ea(m)===t)d.set(m.id,m),c.push(m);else{let u=RT(p,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let p of c)if(wf(p))if(oB(p)){let m=MB(p);if(m.length<2)continue;let u=[];for(let g=1;g<m.length-2;g++)u.push({start:m[g],end:m[g+1],index:g+1});let E=J7(p,e.scene.getNonDeletedElementsMap(),{points:m,fixedSegments:u});ff(p,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let m=hB(["line","sharpArrow","curvedArrow"],u=>gl.get(Ef(p.id,u)));if(m){let u=m.points;e.scene.mutateElement(p,{points:u})}}}let l=bf(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new EB(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:LT(c,{type:"selection"})}))}return!0},Lm=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(ba(t.type))return"generic";BT(t)&&(n=!0)}return n?"linear":null},BT=e=>wf(e)&&(!nB(e)||!tB(e)&&!eB(e)),Ef=(e,n)=>`${e}:${n}`,OT=e=>e.filter(n=>ba(n.type)),bf=e=>e.filter(n=>BT(n)),km=20,fa=(e,n)=>e[0]===n[0],hf=(e,n)=>e[1]===n[1],_T=(e,n)=>fa(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),MB=e=>{let n=[e.points[0]],t=AB(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])<km?s[0]=a[0]:Math.abs(s[1]-a[1])<km&&(s[1]=a[1]),fa(a,s)||hf(a,s)||n.push(Mm(a[0],s[1])),n.push(s)}let o=[n[0]];for(let i=1;i<n.length-1;++i)fa(n[i-1],n[i])&&fa(n[i],n[i+1])||hf(n[i-1],n[i])&&hf(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=fa(a,s),d=fa(s,l);if(c!==d){let p=_T(a,s),m=_T(s,l);if(p<km||m<km){if(m<p)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},AB=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},RT=(e,n,t)=>{if(!LB(e.type,n)){if(!uB())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(wB.delete(e),ba(n)){let o=dl(bB({...e,type:n,roundness:e.roundness?{type:rB(n)?pf.ADAPTIVE_RADIUS:pf.PROPORTIONAL_RADIUS}:e.roundness}));return yB(o,t.scene,t.state),o}if(Am(n))switch(n){case"line":return dl(xB({...e,type:"line"}));case"sharpArrow":return dl(uf({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return dl(uf({...e,type:"arrow",elbowed:!1,roundness:{type:pf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return dl(uf({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return mB(n,`unhandled conversion type: ${n}`),e},LB=(e,n)=>!!(ba(e)&&ba(n)||Am(e)&&Am(n)),DB=e=>wf(e)?Ea(e):e.type,FT=CB;import{bindBindingElementToFixedPoint as _B,dragNewTextElement as RB,getBoundTextElement as NB,getEndpointBoundTextDragAnchor as BB,getTextBindingForArrowEndpoint as OB,getUnboundArrowEndpointAtPoint as FB,isArrowElement as zB,isBindingEnabled as HB,isEndpointBoundText as GB,isTextElement as UB}from"@excalidraw/element";import{pointFrom as WB}from"@excalidraw/math";var Dm=class{constructor(n){this.app=n;T(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});T(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(n,t){if(!HB(this.app.state))return null;let o=FB(WB(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!zB(r)||NB(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 OB(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){_B(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!UB(n)||!GB(n,this.app.scene.getNonDeletedElementsMap())?!1:(RB({newElement:n,...BB(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as VB,BUCKET_FILL_BACKGROUND_PICKS as YB,COLOR_PALETTE as HT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as KB,getSizeFromPoints as XB,isTransparent as $B,THEME as ZB}from"@excalidraw/common";import{pointFrom as zT}from"@excalidraw/math";import{computeBucketFillPolygon as jB,isBucketFillCompatible as qB,isFrameLikeElement as JB,isRestylableFill as QB,newLinearElement as eO,ShapeCache as tO}from"@excalidraw/element";var vf=YB.filter(e=>e!==HT.white),_m=class{constructor(n){this.app=n;T(this,"temporaryEyeDropper",null);T(this,"pending",null);T(this,"handlePointerDown",n=>{this.pending=n});T(this,"handlePointerUp",()=>{let n=this.pending;this.pending=null,n&&this.fill(n)});T(this,"cancel",()=>{this.pending=null});T(this,"cycleBackgroundColor",()=>{let n=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=vf.indexOf(n),o=vf[(t+1)%vf.length];this.app.actionManager.executeAction(sd,"keyboard",{currentItemBackgroundColor:o})});T(this,"openTemporaryEyeDropper",()=>{if(gt.get(Nt))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(sd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Nt,n)});T(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&gt.get(Nt)===n&&this.app.updateEditorAtom(Nt,null)});T(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}),tO.delete(n),this.app.scheduleCapture())});T(this,"fill",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),o=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=zT(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=jB({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&qB(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&&QB({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=XB(s.scenePoints),[d,p]=s.scenePoints[0],m=s.scenePoints.map(w=>zT(w[0]-d,w[1]-p)),u=s.ownerId?r.get(s.ownerId):null,E=u?JB(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(v=>x.includes(v)),null)??[],b=eO({type:"line",x:d,y:p,width:l,height:c,points:m,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()});T(this,"getBucketFillBackgroundColor",(n,t)=>$B(n)?HT.green[KB]:VB(n,t===ZB.DARK))}};import{CURSOR_TYPE as fl,MIME_TYPES as Nm,THEME as GT}from"@excalidraw/common";var UT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',nO='<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"/>',WT='<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"/>',oO=`data:${Nm.svg},${encodeURIComponent(`${UT}${WT}</svg>`)}`,rO=`data:${Nm.svg},${encodeURIComponent(`${UT}${nO}${WT}</svg>`)}`,iO=e=>{let n=mu.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${Nm.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>`)}`},Rm=class{constructor(n){this.app=n;T(this,"toolCursorMemo",null);T(this,"eraserCanvasCache",null);T(this,"eraserPreviewDataURL",null);T(this,"set",n=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=n)});T(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(fl.GRAB):this.clear():this.applyForTool()});T(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(Xa({activeTool:n}))this.set(fl.GRAB);else if(qt({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(fl.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${iO(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===GT.LIGHT?oO:rO;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(fl.AUTO):this.set(fl.CROSSHAIR);this.toolCursorMemo={canvas:t,type:n.type,bucketFillColor:r,theme:o}}});T(this,"clear",()=>{this.set("")});T(this,"applyEraser",()=>{let t=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==t){let o=t===GT.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(Nm.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as dO}from"@excalidraw/common";import{bindBindingElement as mO,convertToShape as pO,convertToShapeHandlePointerMoveFromPointerDown as uO,getHoveredElementForBinding as VT,isBindingElement as hO,isLineElement as gO,LinearElementEditor as Tf,maxBindingDistance_simple as YT,newArrowElement as fO,updateBoundPoint as EO}from"@excalidraw/element";import{getStrokeWidthByKey as aO,THEME as sO}from"@excalidraw/common";import{clamp as lO,pointFrom as cO}from"@excalidraw/math";var Bm=class{constructor(n){this.app=n;T(this,"trail");this.trail=new In(this.app,{...this.getTrailOptions(),fill:()=>n.state.theme===sO.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>lO(aO("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])=>cO(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var Om=class{constructor(n){this.app=n;T(this,"trail");T(this,"gestureInProgress",!1);T(this,"stop",()=>{this.trail.stop()});T(this,"hasPendingGesture",()=>this.gestureInProgress);T(this,"handlePointerDown",n=>{this.gestureInProgress&&this.app.actionManager.executeAction(ct),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});T(this,"handlePointerMove",n=>uO(this.app,n));T(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=YT(t.state.zoom),a=["start","end"].map(d=>{let p=Tf.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:p,target:VT(p,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:p,target:m}of a)m&&mO(n,m,s?"inside":"orbit",d,t.scene,p,t.state.isBindingEnabled,l);if(s)return;let c=new Map;for(let{startOrEnd:d,target:p}of a){if(!p)continue;let m=EO(n,d==="start"?"startBinding":"endBinding",d==="start"?n.startBinding:n.endBinding,p,o);m&&c.set(d==="start"?0:n.points.length-1,{point:m})}c.size&&Tf.movePoints(n,t.scene,c)});T(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=YT(t.state.zoom),[a,s]=[0,-1].map(l=>VT(Tf.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:fO({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})});T(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||pO(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:dO(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&gO(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&hO(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new Bm(n)}};import{isArrowKey as bO,KEYS as Zr}from"@excalidraw/common";import{makeNextSelectedElementIds as xO,CaptureUpdateAction as wO,FlowChartCreator as yO,FlowChartNavigator as vO,getSelectedElements as KT,isFlowchartNodeElement as TO}from"@excalidraw/element";var Fm=class e{constructor(n){this.app=n;T(this,"creator",new yO);T(this,"navigator",new vO);T(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});T(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===Zr.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!bO(n.key))return{type:"none"};if(n[Zr.CTRL_OR_CMD]&&!n.shiftKey){let a=KT(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&TO(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=KT(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[Zr.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:xO({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:wO.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case Zr.ARROW_UP:return"up";case Zr.ARROW_DOWN:return"down";case Zr.ARROW_RIGHT:return"right";case Zr.ARROW_LEFT:return"left";default:return"right"}}};import{debounce as IO,easeOut as JT,isBounds as SO}from"@excalidraw/common";import{clamp as QT}from"@excalidraw/math";import{getCommonBounds as XT,getElementsInGroup as CO,isElementLink as PO,isExcalidrawElement as kO,parseElementLinkFromURL as MO}from"@excalidraw/element";var zm="animateScrollToContent",xa="animateScrollConstraintsSnapBack",$T=500,AO=250,LO=200,If=302,ZT={full:216,compact:64},DO=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")},_O=(e,n)=>{let t=n.get(e);return t?[t]:CO(n,e)},jT=(e,n,t)=>{if(typeof e=="string"){let a=PO(e),s=a?"link":"element",l=a?MO(e):e,c=l?_O(l,n):[];return c.length?{bounds:XT(c,n),type:s}:{bounds:null,type:s}}if(SO(e))return{bounds:e,type:"area"};if(DO(e)&&!kO(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:XT(r,n),type:"element"}},RO=e=>e===!1?0:e===!0||e==null?nu:Math.max(e,0),NO=(e,n,t="scale-down",o)=>{let{appState:r}=wr({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1});return{scrollX:r.scrollX,scrollY:r.scrollY,zoom:r.zoom}},qT=(e,n,{fit:t,offsets:o,lock:r})=>{let i=NO(e,n,t,o);if(!r?.scroll&&!r?.zoom)return{...i,scrollConstraints:null};let[a,s,l,c]=n,d={x:a,y:s,width:l-a,height:c-s,lockScroll:!!r.scroll,lockZoom:!!r.zoom,zoom:i.zoom.value,overscroll:RO(r.overscroll),offsets:o};return{...Rn({...e,...i,scrollConstraints:d}),scrollConstraints:d}},BO=({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}}},OO=e=>e===!1?null:e===!0||e==null?$T:e.duration??$T,FO=(e,n,t,o,r)=>{tt.start(zm,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=JT(QT(l,0,1));return l<1?(o({...BO({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},zO=(e,n,t=AO)=>{let o=Rn(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||tt.running(zm))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;tt.start(xa,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-JT(QT(c,0,1));return n(p=>{if(!p.scrollConstraints)return null;let m=Rn(p),u=m.zoom.value;return{scrollX:m.scrollX+r*d/u,scrollY:m.scrollY+i*d/u,zoom:m.zoom}}),c<1?{elapsed:l}:null})},Hm=class{constructor(n,t){this.app=n;this.dependencies=t;T(this,"lastPosition",{x:0,y:0});T(this,"activeTransition",null);T(this,"uiLastMeasured",new Map);T(this,"invalidateUIOffset",n=>{this.uiLastMeasured.delete(n)});T(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}});T(this,"getOffsets",n=>{let t=this.dependencies.getContainer(),o=t?.getBoundingClientRect(),r=Bn().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"?ZT.compact:ZT.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:If})}let s=n?.padding??24,l=n?.paddingTop??s,c=(r?n?.paddingLeft:n?.paddingRight)??s,d=n?.paddingBottom??s,p=(r?n?.paddingRight:n?.paddingLeft)??s,m={top:i.top+l,right:i.right+c,bottom:i.bottom+d,left:i.left+p};return{top:n?.top??m.top,right:(r?n?.left:n?.right)??m.right,bottom:n?.bottom??m.bottom,left:(r?n?.right:n?.left)??m.left}});T(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=jT(n.target,t,o);return r?qT(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});T(this,"setViewport",n=>{if(n===null){this.cancelTransition(),tt.cancel(xa),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:o,lock:r,animation:i}=n,a=this.resolveOffsets(n.offsets),{bounds:s,type:l}=jT(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!s){l==="link"&&this.app.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}});return}let c=qT(this.app.state,s,{fit:o,offsets:a,lock:r}),d=OO(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),tt.cancel(xa),this.snapBackDebounced.cancel(),d===null){this.app.setState({...c,shouldCacheIgnoreZoom:!1});return}let m={target:c};this.activeTransition=m,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),FO(p,c,d,u=>{this.activeTransition===m&&this.app.setState(u)},()=>{this.activeTransition===m&&(this.activeTransition=null,this.app.setState({...m.target,shouldCacheIgnoreZoom:!1}))})});T(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||tt.cancel(xa),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(),Rn(r,a)}),!0});T(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?Rn(t,n):null)});T(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});T(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||zO(this.app.state,n=>this.app.setState(t=>n(t)))});T(this,"snapBackDebounced",IO(this.snapBack,LO));T(this,"cancelTransition",()=>{this.activeTransition=null,tt.cancel(zm)});T(this,"destroy",()=>{this.cancelTransition(),tt.cancel(xa),this.snapBackDebounced.cancel()})}get isAnimating(){return tt.running(zm)||tt.running(xa)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import Gm from"react";var HO=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,GO=/{{([\w-]+)}}/,UO=/<([\w-]+)>/,WO=/<\/([\w-]+)>/,VO=(e,n)=>{let t=[{name:"",children:[]}];return e.split(HO).filter(Boolean).forEach(o=>{let r=o.match(UO),i=o.match(WO),a=o.match(GO);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=Gm.createElement(Gm.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},YO=({i18nKey:e,children:n,...t})=>{let{t:o}=Ce();return Gm.createElement(Gm.Fragment,{},...VO(o(e),t))},jr=YO;import{jsx as ln,jsxs as eI}from"react/jsx-runtime";var KO=()=>eI("div",{"data-testid":"brave-measure-text-error",children:[ln("p",{children:ln(jr,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>ln("span",{style:{fontWeight:600},children:e})})}),ln("p",{children:ln(jr,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>ln("span",{style:{fontWeight:600},children:e})})}),ln("p",{children:ln(jr,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>ln("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),ln("p",{children:ln(jr,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>ln("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>eI("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),tI=KO;import eF from"clsx";import tF from"react";import{isDarwin as nI}from"@excalidraw/common";var XO={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:[nI?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[nI?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")],copyAsPng:[N("Shift+Alt+C")],group:[N("CtrlOrCmd+G")],ungroup:[N("CtrlOrCmd+Shift+G")],gridMode:[N("CtrlOrCmd+'")],zenMode:[N("Alt+Z")],objectsSnapMode:[N("Alt+S")],stats:[N("Alt+/")],flipHorizontal:[N("Shift+H")],flipVertical:[N("Shift+V")],viewMode:[N("Alt+R")],hyperlink:[N("CtrlOrCmd+K")],toggleElementLock:[N("CtrlOrCmd+Shift+L")],resetZoom:[N("CtrlOrCmd+0")],zoomOut:[N("CtrlOrCmd+-")],zoomIn:[N("CtrlOrCmd++")],zoomToFitSelection:[N("Shift+3")],zoomToFit:[N("Shift+1")],zoomToFitSelectionInViewport:[N("Shift+2")],saveFileToDisk:[N("CtrlOrCmd+S")],saveToActiveFile:[N("CtrlOrCmd+S")],toggleShortcuts:[N("?")],searchMenu:[N("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[N("Shift+R")],toolLock:[N("Q")]},pt=(e,n=0)=>{let t=XO[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as $O,useRef as oI,useEffect as rI}from"react";import{unstable_batchedUpdates as ZO}from"react-dom";import{KEYS as jO,queryFocusableElements as qO}from"@excalidraw/common";import{clamp as iI}from"@excalidraw/math";import JO from"clsx";import{jsx as QO}from"react/jsx-runtime";var nr=10,aI=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=oI(null);rI(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let p=m=>{if(m.key===jO.TAB){let u=qO(d),{activeElement:E}=document,g=u.findIndex(b=>b===E);E===d?(m.shiftKey?u[u.length-1]?.focus():u[0].focus(),m.preventDefault(),m.stopImmediatePropagation()):g===0&&m.shiftKey?(u[u.length-1]?.focus(),m.preventDefault(),m.stopImmediatePropagation()):g===u.length-1&&!m.shiftKey&&(u[0]?.focus(),m.preventDefault(),m.stopImmediatePropagation())}};return d.addEventListener("keydown",p),()=>d.removeEventListener("keydown",p)},[]);let c=oI(null);return $O(()=>{if(r&&l.current&&t!=null&&n!=null){let d=l.current,{width:p,height:m}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===n)return;c.current={top:t,left:n};let u=Math.max(0,i-nr*2);p>=u?(d.style.width=`${u}px`,d.style.left=`${nr}px`,d.style.overflowX="scroll"):d.style.left=`${iI(n,nr,i-nr-p)}px`;let E=Math.max(0,a-nr*2);m>=E?(d.style.height=`${E}px`,d.style.top=`${nr}px`,d.style.overflowY="scroll"):d.style.top=`${iI(t,nr,a-nr-m)}px`}},[t,n,r,i,a]),rI(()=>{if(o){let d=p=>{l.current?.contains(p.target)||ZO(()=>o(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),QO("div",{className:JO("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as fo,jsxs as lI}from"react/jsx-runtime";var nt="separator",sI=e=>"onSelect"in e,cI=tF.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=Uo(),a=yi(),s=n.reduce((l,c)=>c?c===nt||sI(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return fo(aI,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:fo("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===nt)return!s[c-1]||s[c-1]===nt?null:fo("hr",{className:"context-menu-item-separator"},c);if(sI(l))return fo("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:lI("button",{type:"button",className:"context-menu-item",children:[fo("div",{className:"context-menu-item__label",children:l.label}),fo("kbd",{className:"context-menu-item__shortcut"})]})},l.key);let d=l.name,p="";return l.label&&(typeof l.label=="function"?p=f(l.label(a,i,e.app)):p=f(l.label)),fo("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:lI("button",{type:"button",className:eF("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[fo("div",{className:"context-menu-item__label",children:p}),fo("kbd",{className:"context-menu-item__shortcut",children:d?pt(d):""})]})},c)})})})});import{useId as nF}from"react";import oF from"clsx";import{Fragment as rF,jsx as El,jsxs as dI}from"react/jsx-runtime";var Um=({border:e,style:n})=>El("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),Wm=({label:e,border:n})=>{let t=nF(),o=dI(rF,{children:[e.icon&&El("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return dI("div",{className:oF("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&&El("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),El("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&El("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:zn})]})};import Aa from"clsx";import CG from"react";import{CLASSES as PG,TOOL_TYPE as mP,arrayToMap as kG,isShallowEqual as yp}from"@excalidraw/common";import{mutateElement as MG}from"@excalidraw/element";import{showSelectedShapeActions as AG}from"@excalidraw/element";import{ShapeCache as LG}from"@excalidraw/element";import{createIsolation as iF}from"jotai-scope";import Sf from"react";import Eo from"tunnel-rat";var Cf=Sf.createContext(null),Ke=()=>Sf.useContext(Cf),aF=iF(),mI=()=>Sf.useMemo(()=>({MainMenuTunnel:Eo(),WelcomeScreenMenuHintTunnel:Eo(),WelcomeScreenToolbarHintTunnel:Eo(),WelcomeScreenHelpHintTunnel:Eo(),WelcomeScreenCenterTunnel:Eo(),FooterCenterTunnel:Eo(),DefaultSidebarTriggerTunnel:Eo(),DefaultSidebarTabTriggersTunnel:Eo(),OverwriteConfirmDialogTunnel:Eo(),tunnelsJotai:aF}),[]);import rr from"clsx";import{useRef as fF}from"react";import{Popover as or}from"radix-ui";import{CLASSES as yI}from"@excalidraw/common";import{isArrowElement as wI}from"@excalidraw/element";import{forwardRef as pI}from"react";import uI from"clsx";import{jsx as hI}from"react/jsx-runtime";var sF=pI(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>hI("div",{className:uI("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),lF=pI(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>hI("div",{className:uI("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Lt={Row:sF,Col:lF};import{isTransparent as gI}from"@excalidraw/common";import{shouldAllowVerticalAlign as cF,suppportsHorizontalAlign as dF,hasBoundTextElement as fI,isElbowArrow as mF,isImageElement as pF,isLinearElement as uF,isTextElement as hF,hasStrokeColor as EI,toolIsArrow as gF}from"@excalidraw/element";var bI=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return EI(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>EI(o.type))},xI=(e,n)=>Ao(e.activeTool.type)||n.some(t=>Ao(t.type)),Vm=(e,n,t,o)=>{let r=e.activeTool.type,i=d=>d(r)||n.some(p=>d(p.type)),a=n.length===1,s=n.length===2&&(fI(n[0])||fI(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:bI(e,n),backgroundColor:xI(e,n),fill:r==="bucketfill"||Ao(r)&&!gI(e.currentItemBackgroundColor)||n.some(d=>Ao(d.type)&&!gI(d.backgroundColor)),strokeWidth:i(Fb),freedrawMode:i(zb),strokeStyle:i(ou),sloppiness:i(ou),roundness:i(Hb),arrowType:i(gF),arrowheads:i(Ka),text:r==="text"||n.some(hF),textAlign:r==="text"||dF(n,t),verticalAlign:cF(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||ie(t,e).some(d=>d.type==="freedraw"),align:!s&&mt(e,o),distribute:n.length>2,link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&pF(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&uF(n[0])&&!mF(n[0])}};import{Fragment as cn,jsx as Z,jsxs as Ie}from"react/jsx-runtime";var Pf=rr([yI.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),vI=({renderAction:e})=>Ie("fieldset",{children:[Z("legend",{children:f("labels.layers")}),Ie("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),TI=({renderAction:e,showDistribute:n})=>{let t=document.documentElement.getAttribute("dir")==="rtl";return Ie("fieldset",{children:[Z("legend",{children:f("labels.align")}),Ie("div",{className:"buttonList",children:[t?Ie(cn,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Ie(cn,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),Z("div",{style:{flexBasis:"100%",height:0}}),Ie("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]})]})]})},II=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=si(n,e),i=Vm(e,r,n,o);return e.activeTool.type==="bucketfill"?Ie("div",{className:"selected-shape-actions",children:[Z("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Ie("div",{className:"selected-shape-actions",children:[Z("div",{children:i.strokeColor&&t("changeStrokeColor")}),i.backgroundColor&&Z("div",{children:t("changeBackgroundColor")}),i.fill&&t("changeFillStyle"),i.strokeWidth&&t("changeStrokeWidth"),i.strokeStyle&&Z(cn,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&Z(cn,{children:t("changeSloppiness")}),i.roundness&&Z(cn,{children:t("changeRoundness")}),i.arrowType&&Z(cn,{children:t("changeArrowType")}),i.text&&Ie(cn,{children:[Z("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&Z(cn,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&Z(vI,{renderAction:t}),i.align&&Z(TI,{renderAction:t,showDistribute:i.distribute}),i.showExtraActions&&Ie("fieldset",{children:[Z("legend",{children:f("labels.actions")}),Ie("div",{className:"buttonList",children:[t("duplicateSelection"),t("deleteSelectedElements"),t("group"),t("ungroup"),i.link&&t("hyperlink"),i.cropEditor&&t("cropEditor"),i.lineEditor&&t("toggleLinearEditor")]})]})]})},SI=({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?Z("div",{className:"compact-action-item",children:Ie(or.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[Z(or.Trigger,{asChild:!0,children:Z("button",{type:"button",className:rr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:V1})}),a&&Z(io,{className:Pf,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Ie("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&Z(cn,{children:n("changeStrokeStyle")}),o.sloppiness&&Z(cn,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},CI=({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 Z("div",{className:"compact-action-item",children:Ie(or.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[Z(or.Trigger,{asChild:!0,children:Z("button",{type:"button",className:rr("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=st(o,a,c=>wI(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>wI(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?No:l==="round"?Bo:Ro})()})}),s&&Z(io,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},PI=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=h0(),s=e.openPopup==="compactTextProperties";return Z("div",{className:"compact-action-item",children:Ie(or.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[Z(or.Trigger,{asChild:!0,children:Z("button",{type:"button",className:rr("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:bx})}),e.openPopup==="compactTextProperties"&&Z(io,{className:Pf,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Ie("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},kI=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let s=e.openPopup==="compactOtherProperties";return t.showExtraActions?Z("div",{className:"compact-action-item",children:Ie(or.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[Z(or.Trigger,{asChild:!0,children:Z("button",{type:"button",className:rr("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:mx})}),s&&Z(io,{className:Pf,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Ie("div",{className:"selected-shape-actions",children:[t.layers&&Z(vI,{renderAction:n}),t.align&&Z(TI,{renderAction:n,showDistribute:t.distribute}),Ie("fieldset",{children:[Z("legend",{children:f("labels.actions")}),Ie("div",{className:"buttonList",children:[n("group"),n("ungroup"),t.linkSingleOnly&&n("hyperlink"),t.cropEditor&&n("cropEditor"),i&&n("duplicateSelection"),a&&n("deleteSelectedElements")]})]})]})})]})}):null},EF=({renderAction:e,predicates:n})=>n.lineEditor?Z("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,MI=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=si(n,e),a=Vm(e,i,n,o),{container:s}=Ae();return Ie("div",{className:"compact-shape-actions",children:[a.strokeColor&&Z("div",{className:rr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&Z("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),a.freedrawMode&&Z("div",{className:"compact-action-item",children:t("changeFreedrawMode",{cycle:!0})}),Z(SI,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),Z(CI,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),a.lineEditor&&Z("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Ie(cn,{children:[Z("div",{className:"compact-action-item",children:t("changeFontFamily")}),Z(PI,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),a.showExtraActions&&Z("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&Z("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),Z(kI,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},AI=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=si(n,e),a=Vm(e,i,n,o),{container:s}=Ae(),l=fF(null),c=l.current?.getBoundingClientRect()?.width??0,d=9,p=6,m=32,u=d*m+(d-1)*p,E=m+p,g=c>=u+E,b=c>=u+2*E;return Ie(Ue,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:m*1.35,marginBottom:4,alignItems:"center",gap:p,pointerEvents:"none"},ref:l,children:[Ie("div",{style:{display:"flex",flexDirection:"row",gap:p,flex:1},children:[a.strokeColor&&Z("div",{className:rr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&Z("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),Z(SI,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),Z(CI,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),Z(EF,{renderAction:t,predicates:a}),a.text&&Ie(cn,{children:[Z("div",{className:"compact-action-item",children:t("changeFontFamily")}),Z(PI,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),Z(kI,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Ie("div",{style:{display:"flex",flexDirection:"row",gap:p},children:[Z("div",{className:"compact-action-item",children:t("undo")}),Z("div",{className:"compact-action-item",children:t("redo")}),b&&Z("div",{className:"compact-action-item",children:t("duplicateSelection")}),g&&Z("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},LI=({renderAction:e})=>Z(Lt.Col,{gap:1,className:yI.ZOOM_ACTIONS,children:Ie(Lt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),DI=({renderAction:e,className:n})=>Ie("div",{className:`undo-redo-buttons ${n}`,children:[Z("div",{className:"undo-button-container",children:Z(lt,{label:f("buttons.undo"),children:e("undo")})}),Z("div",{className:"redo-button-container",children:Ie(lt,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),_I=({actionManager:e,showExitZenModeBtn:n})=>Z("button",{type:"button",className:rr("disable-zen-mode",{"disable-zen-mode--visible":n}),onClick:()=>e.executeAction(Zo),children:f("buttons.exitZenMode")}),RI=({actionManager:e})=>Z("button",{type:"button",className:"disable-view-mode",onClick:()=>e.executeAction(Yr),children:K1});import bF from"clsx";import{useState as xF,useEffect as wF}from"react";import{THEME as yF}from"@excalidraw/common";import{jsx as kf,jsxs as vF}from"react/jsx-runtime";var Ym=({delay:e,theme:n})=>{let[t,o]=xF(!!e);return wF(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:vF("div",{className:bF("LoadingMessage",{"LoadingMessage--dark":n===yF.DARK}),children:[kf("div",{children:kf(ro,{})}),kf("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as Zm,useEffect as nS}from"react";import qF from"clsx";import{KEYS as jm,capitalizeString as oS}from"@excalidraw/common";import tS from"react";import{DropdownMenu as XF}from"radix-ui";import{CLASSES as $F}from"@excalidraw/common";import TF from"clsx";import{useCallback as IF,useEffect as SF,useRef as CF}from"react";import{CLASSES as PF,EVENT as NI,KEYS as kF}from"@excalidraw/common";import{DropdownMenu as MF}from"radix-ui";import{jsx as Km}from"react/jsx-runtime";var BI=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=ue(),l=CF(null),c=wi({onClickOutside:n});xi(l,IF(p=>{l.current?.closest(`.${PF.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(p.target)||c.onClickOutside?.()},[c])),SF(()=>{if(!r)return;let p=u=>{u.key===kF.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},m={capture:!0};return document.addEventListener(NI.KEYDOWN,p,m),()=>{document.removeEventListener(NI.KEYDOWN,p,m)}},[c,r]);let d=TF(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return Km(rh.Provider,{value:{onSelect:o},children:Km(MF.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:p=>p.preventDefault(),children:s.formFactor==="phone"?Km(Lt.Col,{className:"dropdown-menu-container",children:e}):Km(Ue,{className:"dropdown-menu-container",padding:2,children:e})})})};BI.displayName="DropdownMenuContent";var OI=BI;import{jsx as LF}from"react/jsx-runtime";var AF=({children:e,className:n="",selected:t,...o})=>LF("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),FI=AF;import{DropdownMenu as DF}from"radix-ui";import{jsx as Mf}from"react/jsx-runtime";var zI=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=jc(r);return Mf(DF.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Mf("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:Ho(i,a),title:l.title??l["aria-label"],children:Mf(Go,{icon:e,shortcut:n,children:o})})})},wa=zI;zI.displayName="DropdownMenuItemLink";import{jsx as _F}from"react/jsx-runtime";var HI=()=>_F("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),GI=HI;HI.displayName="DropdownMenuSeparator";import{DropdownMenu as HF}from"radix-ui";import RF from"clsx";import{DropdownMenu as NF}from"radix-ui";import{useCallback as BF,useState as UI}from"react";import{jsx as Lf}from"react/jsx-runtime";var Af=-4,OF=4,WI=({children:e,className:n})=>{let t=ue(),o=RF(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=BF(c=>{if(c){let p=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(p){let m=c.getBoundingClientRect().width,E=window.innerWidth-p.right;E<m+20&&(a(E-m+Af),l(Af+8))}}},[]),[i,a]=UI(OF),[s,l]=UI(Af);return Lf(NF.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?Lf(Lt.Col,{className:"dropdown-menu-container",children:e}):Lf(Ue,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},VI=WI;WI.displayName="DropdownMenuSubContent";import{DropdownMenu as FF}from"radix-ui";import{jsx as YI,jsxs as zF}from"react/jsx-runtime";var KI=({children:e,icon:n,shortcut:t,className:o})=>zF(FF.SubTrigger,{className:`${Ho(o)} dropdown-menu__submenu-trigger`,children:[YI(Go,{icon:n,shortcut:t,children:e}),YI("div",{className:"dropdown-menu__submenu-trigger-icon",children:$1})]}),XI=KI;KI.displayName="DropdownMenuSubTrigger";import $I from"react";var Xm=e=>n=>{let t=$I.Children.toArray(n).find(o=>$I.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},ZI=Xm("DropdownMenuTrigger"),jI=Xm("DropdownMenuContent"),qI=Xm("DropdownMenuSubTrigger"),JI=Xm("DropdownMenuSubContent");import{jsxs as GF}from"react/jsx-runtime";var $m=({children:e})=>{let n=qI(e),t=JI(e);return GF(HF.Sub,{children:[n,t]})};$m.Trigger=XI;$m.Content=VI;$m.displayName="DropdownMenuSub";var ir=$m;import UF from"clsx";import{DropdownMenu as WF}from"radix-ui";import{jsx as VF}from"react/jsx-runtime";var QI=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=ue(),a=UF(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return VF(WF.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},eS=QI;QI.displayName="DropdownMenuTrigger";import{jsx as KF}from"react/jsx-runtime";var YF=e=>KF(Vt,{...e,icon:e.checked?xc:kc}),Cn=YF;import{jsx as jF,jsxs as ZF}from"react/jsx-runtime";var Pn=({children:e,open:n})=>{let t=ZI(e),o=jI(e),r=o&&tS.isValidElement(o)?tS.cloneElement(o,{open:n}):o;return jF(XF.Root,{open:n,modal:!1,children:ZF("div",{className:$F.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Pn.Trigger=eS;Pn.Content=OI;Pn.Item=Vt;Pn.ItemCheckbox=Cn;Pn.ItemLink=wa;Pn.ItemCustom=FI;Pn.Group=Es;Pn.Separator=GI;Pn.Sub=ir;var ye=Pn;Pn.displayName="DropdownMenu";import{jsx as xt,jsxs as Df}from"react/jsx-runtime";var rS=({app:e,setAppState:n})=>{let t=e.state.activeTool,[o,r]=Zm(!1),[i,a]=Zm("rectangle"),[s,l]=Zm("arrow");nS(()=>{(t.type==="rectangle"||t.type==="diamond"||t.type==="ellipse")&&a(t.type)},[t.type]),nS(()=>{(t.type==="arrow"||t.type==="line")&&l(t.type)},[t.type]);let c=t.type==="frame",d=t.type==="autoshape",p=t.type==="laser",m=t.type==="embeddable",u=t.type==="bucketfill",E=["rectangle","diamond","ellipse"].map(G=>({type:G,icon:Je[G].icon,title:oS(f(`toolBar.${G}`)),fillable:Je[G].fillable})),g=["arrow","line"].map(G=>({type:G,icon:Je[G].icon,title:oS(f(`toolBar.${G}`)),fillable:Je[G].fillable})),[b,y]=Zm(0),w=36,x=4,v=7,I=v*w+(v-1)*x,C=w+x,P=b>=I+1*C,A=b>=I+2*C,L=b>=I+3*C,k=["text","frame","embeddable","laser","bucketfill"].filter(G=>!(P&&G==="text"||L&&G==="frame")).includes(t.type),D=k?t.type==="text"?En:t.type==="image"?Tr:t.type==="frame"?Hn:t.type==="embeddable"?_o:t.type==="laser"?Gn:t.type==="bucketfill"?Fn:Qa:Qa,O={app:e,activeTool:t};return Df("div",{className:"mobile-toolbar",ref:G=>{G&&y(G.getBoundingClientRect().width)},children:[xt(Ed,{...O,hideKeyBinding:!0}),xt(yd,{...O,setAppState:n}),xt(vd,{...O}),xt(wd,{...O,hideShortcut:!0}),xt(Di,{app:e,options:E,activeTool:t,defaultOption:i,"data-testid":"toolbar-rectangle",onToolChange:G=>{(G==="rectangle"||G==="diamond"||G==="ellipse")&&(a(G),e.setActiveTool({type:G}))},displayedOption:E.find(G=>G.type===i)||E[0]}),xt(Di,{app:e,options:g,activeTool:t,defaultOption:s,"data-testid":"toolbar-arrow",onToolChange:G=>{(G==="arrow"||G==="line")&&(l(G),e.setActiveTool({type:G}))},displayedOption:g.find(G=>G.type===s)||g[0]}),P&&xt(bd,{...O,hideShortcut:!0}),A&&xt(xd,{...O,hideShortcut:!0}),L&&xt(Lw,{...O,hideShortcut:!0}),Df(ye,{open:o,children:[xt(ye.Trigger,{className:qF("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":k||o}),onToggle:()=>{r(!o),n({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),style:{width:w,height:w,display:"flex",alignItems:"center",justifyContent:"center"},children:D}),Df(ye.Content,{onClickOutside:()=>r(!1),onSelect:()=>r(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[!P&&xt(ye.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:En,shortcut:jm.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:t.type==="text",disabled:it(e,"text"),children:f("toolBar.text")}),!A&&xt(ye.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Tr,"data-testid":"toolbar-image",selected:t.type==="image",disabled:it(e,"image"),children:f("toolBar.image")}),!L&&xt(ye.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Hn,shortcut:jm.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:it(e,"frame"),children:f("toolBar.frame")}),xt(ye.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:_o,"data-testid":"toolbar-embeddable",selected:m,disabled:it(e,"embeddable"),children:f("toolBar.embeddable")}),xt(ye.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Cr,shortcut:Cs("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:it(e,"autoshape"),children:f("toolBar.autoshape")}),xt(ye.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Gn,"data-testid":"toolbar-laser",selected:p,shortcut:jm.K.toLocaleUpperCase(),disabled:it(e,"laser"),children:f("toolBar.laser")}),xt(ye.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Fn,"data-testid":"toolbar-bucketfill",selected:u,shortcut:jm.B.toLocaleUpperCase(),disabled:it(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]})};import JF from"clsx";import{jsx as QF}from"react/jsx-runtime";var qm=({children:e,side:n,className:t})=>QF("div",{className:JF("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import e9 from"clsx";import{jsx as t9}from"react/jsx-runtime";var ya=e=>e.penDetected?t9($,{className:e9("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Ex,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as iS,jsx as Dt,jsxs as va}from"react/jsx-runtime";var aS=({appState:e,elements:n,actionManager:t,setAppState:o,renderTopLeftUI:r,renderTopRightUI:i,renderSidebars:a,renderWelcomeScreen:s,defaultUIEnabled:l,scrollBackToContentUIEnabled:c,app:d,onPenModeToggle:p})=>{let{WelcomeScreenCenterTunnel:m,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:E}=Ke(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let C=va("div",{className:"excalidraw-ui-top-right",children:[i?.(!0,e)??(!e.viewModeEnabled&&va(iS,{children:[l&&Dt(ya,{checked:e.penMode,onChange:()=>p(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),Dt(E.Out,{})]})),l&&e.viewModeEnabled&&d.isInteractionEnabled()&&Dt(RI,{actionManager:t})]}),P=va("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),Dt(u.Out,{})]});return va("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[P,C]})},b=()=>Dt(rS,{app:d,setAppState:o}),y=c&&e.scrolledOutside,w=l&&!e.viewModeEnabled,x=y&&!e.openMenu&&!e.openSidebar?Dt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(C=>({...ai(n,C)}))},children:f("buttons.scrollBackToContent")}):null,v=d.props.viewportStatusFrame?.label,I=v?Dt(Wm,{label:v,border:d.props.viewportStatusFrame?.border}):null;return va(iS,{children:[a(),Dt("div",{className:"App-welcome-screen",children:s&&Dt(m.Out,{})}),w&&va("div",{className:"App-bottom-bar",style:{marginBottom:sn+go},"data-viewport-ui":"bottom",children:[x&&Dt("div",{className:"floating-status-stack",children:x}),Dt(AI,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o}),Dt(Ue,{className:"App-toolbar",children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!w&&x&&Dt("div",{className:"floating-status-stack",children:x}),I&&Dt("div",{className:"viewport-status-frame__badge-row",children:I}),Dt(qm,{side:"top",className:"App-top-bar",children:g()})]})};import uS,{useLayoutEffect as hS,useRef as gS,useState as fS}from"react";import{newTextElement as ES}from"@excalidraw/element";import l9 from"clsx";import{useEffect as c9,useState as d9}from"react";import{KEYS as m9,queryFocusableElements as mS}from"@excalidraw/common";import{useCallback as n9,useState as o9}from"react";var sS=()=>{let[e,n]=o9(null),t=n9(o=>n(o),[]);return[e,t]};import lS from"clsx";import{useRef as r9}from"react";import{createPortal as i9}from"react-dom";import{KEYS as a9}from"@excalidraw/common";import{jsx as cS,jsxs as s9}from"react/jsx-runtime";var dS=e=>{let{closeOnClickOutside:n=!0}=e,t=zc({className:lS("excalidraw-modal-container",e.portalContainerClassName)}),o=r9(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===a9.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return i9(s9("div",{className:lS("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[cS("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),cS("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Jm,jsxs as pS}from"react/jsx-runtime";function p9(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var dn=e=>{let[n,t]=sS(),[o]=d9(document.activeElement),{id:r}=Ae(),i=ue().formFactor==="phone";c9(()=>{if(!n)return;let l=mS(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===m9.TAB){let p=mS(n),{activeElement:m}=document,u=p.findIndex(E=>E===m);u===0&&d.shiftKey?(p[p.length-1].focus(),d.preventDefault()):u===p.length-1&&!d.shiftKey&&(p[0].focus(),d.preventDefault())}};return n.addEventListener("keydown",c),()=>n.removeEventListener("keydown",c)},[n,e.autofocus]);let a=Ne(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return Jm(dS,{className:l9("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:p9(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:pS(Ue,{ref:t,children:[e.title&&pS("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[Jm("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&Jm("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:zn}),Jm("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as bo,jsxs as Qm}from"react/jsx-runtime";var u9=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}},h9=e=>{let n=gS(null),[t,o]=fS(null),{theme:r}=he();hS(()=>{if(!e.spreadsheet){o(null);return}let a=df(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 yr(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=u9(e.chartType);return Qm("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[bo("div",{className:"ChartPreview__canvas",ref:n}),bo("div",{className:"ChartPreview__label",children:i})]})},g9=e=>{let n=gS(null),{theme:t}=he();return hS(()=>{if(!e.rawText)return;let o=ES({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await yr([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]),Qm("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[bo("div",{className:"ChartPreview__canvas",ref:n}),bo("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},bS=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=Tt(),[i,a]=fS(Math.random()),s=uS.useCallback(()=>{a(Math.random())},[]),l=uS.useCallback(()=>{t&&t()},[t]),c=(p,m)=>{o(m),Re("paste","chart",p),t(),r()},d=p=>{let m=ES({text:p,x:0,y:0});o([m]),Re("paste","chart","plaintext"),t(),r()};return bo(dn,{size:"regular",onCloseRequest:l,title:Qm("div",{className:"PasteChartDialog__title",children:[bo("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),bo("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),s())},children:Fn})]}),className:"PasteChartDialog",autofocus:!1,children:Qm("div",{className:"container",children:[["bar","line","radar"].map(p=>ca(e,p)?bo(h9,{chartType:p,spreadsheet:e,colorSeed:i,onClick:c},p):null),n&&bo(g9,{rawText:n,onClick:d})]})})};import{Fragment as f9,jsx as xS,jsxs as E9}from"react/jsx-runtime";var bl=({heading:e,children:n,...t})=>{let{id:o}=Ae(),r=xS("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return xS("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):E9(f9,{children:[r,n]})})};import{Popover as xl}from"radix-ui";import wS from"clsx";import ep,{useLayoutEffect as b9}from"react";import{supportsResizeObserver as x9,isShallowEqual as w9}from"@excalidraw/common";import{Fragment as Nf,jsx as wt,jsxs as Ta}from"react/jsx-runtime";var y9=4,v9=8,_f=38,yS=21,T9=({shouldWrap:e,children:n,username:t})=>e?wt(lt,{label:t||"Unknown user",children:n}):wt(Nf,{children:n}),Rf=({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 wt(T9,{username:n.username,shouldWrap:r,children:s},t)},I9=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],tp=ep.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=Xe(),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,p]=ep.useState(""),m=s.filter(C=>C.username?.toLowerCase().includes(d)),u=ep.useRef(null);b9(()=>{if(u.current){let C=A=>{g(A)};if(C(u.current.clientWidth),!x9)return;let P=new ResizeObserver(A=>{for(let L of A){let{width:_}=L.contentRect;C(_)}});return P.observe(u.current),()=>{P.disconnect()}}},[]);let[E,g]=ep.useState(y9*_f),b=l?E-yS:E,y=Math.max(1,Math.min(8,Math.floor(b/_f))),w=l?Math.max(0,y-1):y,x=c.slice(0,w),v=l?[...x,l]:x,I=v.map(C=>{let P=Rf({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?Ta(xl.Root,{children:[wt(xl.Trigger,{asChild:!0,children:Ta("div",{className:"UserList__pill",children:[P,wt("div",{className:"UserList__pill-chevron",children:X1})]})}),wt(xl.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Ta(Ue,{padding:2,children:[s.length>=v9&&wt($c,{placeholder:f("quickSearch.placeholder"),onChange:p}),wt(Zc,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:m.length>0?[wt("div",{className:"hint",children:f("userList.hint.text")},"hint"),m.map(A=>Rf({actionManager:i,collaborator:A,socketId:A.socketId,withName:!0,isBeingFollowed:A.socketId===o}))]:[]}),a&&Ta(Nf,{children:[wt("div",{className:"UserList__menu-divider"}),wt(xl.Close,{asChild:!0,children:wt("div",{className:"dropdown-menu",children:a})})]}),wt(xl.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?Ta("div",{className:wS("UserList UserList_mobile",e),children:[wt("div",{className:"UserList_mobile__avatars",children:s.map(C=>Rf({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&Ta(Nf,{children:[wt("div",{className:"UserList__menu-divider"}),a]})]}):wt("div",{className:"UserList__wrapper",ref:u,children:wt("div",{className:wS("UserList",e),style:{"--max-avatars":v.length+(l?yS/_f:0)},children:I})})},(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||!w9(r,i,I9))return!1}return!0});import wl from"clsx";import{jsx as vS}from"react/jsx-runtime";var TS=e=>vS(lt,{label:`${f("helpDialog.title")} \u2014 ?`,children:vS("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:fi})});import{jsx as Xt,jsxs as Bf}from"react/jsx-runtime";var IS=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=Ke(),l=Tt();return Bf("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&Xt("div",{className:wl("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Xt(Lt.Col,{gap:2,children:Bf(bl,{heading:"canvasActions",children:[!e.viewModeOnly&&Xt(lt,{label:f("labels.viewMode"),children:Xt("div",{className:wl("view-mode-button"),children:n.renderAction("viewMode")})}),Xt(lt,{label:f("buttons.smartZoom"),children:Xt("div",{className:wl("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&Xt(LI,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&Xt(DI,{renderAction:n.renderAction,className:wl("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Xt(a.Out,{}),(r||o)&&Xt("div",{className:wl("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Bf("div",{style:{position:"relative"},children:[o&&Xt(s.Out,{}),r&&Xt(TS,{onClick:()=>n.executeAction(Or)})]})}),r&&Xt(_I,{actionManager:n,showExitZenModeBtn:t})]})},SS=IS;IS.displayName="Footer";import{composeEventHandlers as D9}from"@excalidraw/common";import{useLayoutEffect as S9,useRef as C9}from"react";import{jsx as P9}from"react/jsx-runtime";var qr=(e,n)=>{let t=Ze(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=Ke(),[,a]=i(t),s=C9({preferHost:!1,counter:0});return S9(()=>{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:P9(n,{...r})};return o.displayName=e,o};var Hf={};YM(Hf,{ChangeCanvasBackground:()=>BS,Export:()=>OS,Help:()=>RS,LiveCollaborationTrigger:()=>zS,LoadScene:()=>AS,Preferences:()=>kn,PreferencesToggleGridModeItem:()=>zf,PreferencesToggleZenModeItem:()=>YS,SaveAsImage:()=>DS,SaveToActiveFile:()=>LS,SearchMenu:()=>_S,Socials:()=>FS,ToggleTheme:()=>NS});import L9 from"clsx";import{THEME as vl}from"@excalidraw/common";var Of=Ze({active:!1});async function CS({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{gt.set(Of,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import k9 from"clsx";import{jsx as PS,jsxs as M9}from"react/jsx-runtime";var np=function({onChange:e,value:n,choices:t,name:o}){return PS("div",{className:"RadioGroup",children:t.map(r=>M9("div",{className:k9("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[PS("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 A9,jsx as yl,jsxs as kS}from"react/jsx-runtime";var MS=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=ue();return kS(A9,{children:[kS("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&yl("div",{className:"dropdown-menu-item__icon",children:a}),yl("label",{className:"dropdown-menu-item__text",children:yl(bs,{children:r})}),yl(np,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&yl("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};MS.displayName="DropdownMenuItemContentRadio";var Ff=MS;import{Fragment as $S,jsx as ge,jsxs as Tl}from"react/jsx-runtime";var AS=()=>{let{t:e}=Ce(),n=Xe(),t=yi();return n.isActionEnabled(Ni)?ge(Vt,{icon:wc,onSelect:async()=>{(!t.length||await CS({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:ge(jr,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>ge("strong",{children:r}),br:()=>ge("br",{})})}))&&n.executeAction(Ni)},"data-testid":"load-button",shortcut:pt("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};AS.displayName="LoadScene";var LS=()=>{let{t:e}=Ce(),n=Xe();return n.isActionEnabled(Br)?ge(Vt,{shortcut:pt("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(Br),icon:Sx,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};LS.displayName="SaveToActiveFile";var DS=()=>{let e=Ne(),{t:n}=Ce();return ge(Vt,{icon:kx,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:pt("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};DS.displayName="SaveAsImage";var _S=e=>{let{t:n}=Ce(),t=Xe();return ge(Vt,{icon:Un,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Pg)},shortcut:pt("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};_S.displayName="SearchMenu";var RS=()=>{let{t:e}=Ce(),n=Xe();return ge(Vt,{"data-testid":"help-menu-item",icon:fi,onSelect:()=>n.executeAction(Or),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};RS.displayName="Help";var NS=e=>{let{t:n}=Ce(),t=he(),o=Xe(),r=pt("toggleTheme"),i=bn();return o.isActionEnabled(ud)?e?.allowSystemTheme?ge(Ff,{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:vl.LIGHT,label:rs,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:vl.DARK,label:os,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:z1,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):ge(Vt,{onSelect:a=>{a.preventDefault(),o.executeAction(ud)},icon:t.theme===vl.DARK?rs:os,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===vl.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===vl.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};NS.displayName="ToggleTheme";var BS=()=>{let{t:e}=Ce(),n=he(),t=Xe(),o=bn();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:Tl("div",{style:{marginTop:"0.75rem"},children:[ge("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),ge("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};BS.displayName="ChangeCanvasBackground";var OS=()=>{let{t:e}=Ce(),n=Ne();return ge(Vt,{icon:is,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};OS.displayName="Export";var FS=()=>{let{t:e}=Ce();return Tl($S,{children:[ge(wa,{icon:vx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),ge(wa,{icon:Ix,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),ge(wa,{icon:Tx,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};FS.displayName="Socials";var zS=({onSelect:e,isCollaborating:n})=>{let{t}=Ce();return ge(Vt,{"data-testid":"collab-button",icon:yc,className:L9({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};zS.displayName="LiveCollaborationTrigger";var HS=()=>{let{t:e}=Ce(),n=Tt(),t=he();return ge(Cn,{checked:t.activeTool.locked,shortcut:pt("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},GS=()=>{let{t:e}=Ce(),n=he(),t=Ne();return ge(Ff,{name:"boxSelectionMode",icon:kc,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")})},US=()=>{let{t:e}=Ce(),n=Xe(),t=he();return ge(Cn,{checked:t.objectsSnapModeEnabled,shortcut:pt("objectsSnapMode"),onSelect:o=>{n.executeAction(Rs),o.preventDefault()},children:e("buttons.objectsSnapMode")})},WS=()=>{let{t:e}=Ce(),n=Xe(),t=he();return ge(Cn,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(Ns),o.preventDefault()},children:e("labels.arrowBinding")})},VS=()=>{let{t:e}=Ce(),n=Xe(),t=he();return ge(Cn,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(Bs),o.preventDefault()},children:e("labels.midpointSnapping")})},zf=()=>{let{t:e}=Ce(),n=Xe(),t=he();return ge(Cn,{checked:t.gridModeEnabled,shortcut:pt("gridMode"),onSelect:o=>{n.executeAction(Ui),o.preventDefault()},children:e("labels.toggleGrid")})},YS=()=>{let{t:e}=Ce(),n=Xe(),t=he();return ge(Cn,{checked:t.zenModeEnabled,shortcut:pt("zenMode"),onSelect:o=>{n.executeAction(Zo),o.preventDefault()},children:e("buttons.zenMode")})},KS=()=>{let{t:e}=Ce(),n=Xe(),t=he();return t.viewModeOnly?null:ge(Cn,{checked:t.viewModeEnabled,shortcut:pt("viewMode"),onSelect:o=>{n.executeAction(Yr),o.preventDefault()},children:e("labels.viewMode")})},XS=()=>{let{t:e}=Ce(),n=Xe(),t=he();return ge(Cn,{checked:t.stats.open,shortcut:pt("stats"),onSelect:o=>{n.executeAction(jo),o.preventDefault()},children:e("stats.fullTitle")})},kn=({children:e,additionalItems:n})=>{let{t}=Ce();return Tl(ir,{children:[ge(ir.Trigger,{icon:Z1,children:t("labels.preferences")}),Tl(ir.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||Tl($S,{children:[ge(GS,{}),ge(HS,{}),ge(US,{}),ge(zf,{}),ge(KS,{}),ge(XS,{}),ge(WS,{}),ge(VS,{})]}),n]})]})};kn.ToggleToolLock=HS;kn.BoxSelectionMode=GS;kn.ToggleSnapMode=US;kn.ToggleArrowBinding=WS;kn.ToggleMidpointSnapping=VS;kn.ToggleGridMode=zf;kn.ToggleZenMode=YS;kn.ToggleViewMode=KS;kn.ToggleElementProperties=XS;kn.displayName="Preferences";import{jsx as op,jsxs as Gf}from"react/jsx-runtime";var _9=Object.assign(qr("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=Ke(),o=ue(),r=he(),i=bn(),a=Ne();return op(t.In,{children:Gf(ye,{open:r.openMenu==="canvas",children:[op(ye.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:wx}),Gf(ye.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:D9(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&Gf("fieldset",{className:"UserList-Wrapper",children:[op("legend",{children:f("labels.collaborators")}),op(tp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:ye.Trigger,Item:ye.Item,ItemLink:ye.ItemLink,ItemCustom:ye.ItemCustom,Group:ye.Group,Separator:ye.Separator,Sub:ir,DefaultItems:Hf}),_t=_9;import R9 from"clsx";import{forwardRef as N9,useState as B9}from"react";import{isPromiseLike as O9}from"@excalidraw/common";import{jsx as rp,jsxs as F9}from"react/jsx-runtime";var ar=N9(({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},p)=>{let[m,u]=B9(!1),E=async b=>{let y=t?.(b);if(O9(y)){let w=window.setTimeout(()=>{u(!0)},50);try{await y}catch(x){if(x instanceof oc)console.warn(x);else throw x}finally{clearTimeout(w),u(!1)}}},g=m?"loading":c;return i=g==="success"?"success":i,rp("button",{className:R9("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:p,disabled:d||g==="loading"||g==="success",children:F9("div",{className:"ExcButton__contents",children:[g==="loading"?rp(ro,{className:"ExcButton__statusIcon"}):g==="success"&&rp("div",{className:"ExcButton__statusIcon",children:S1}),n&&rp("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as Ia,jsxs as G9}from"react/jsx-runtime";var ip=({title:e,children:n,actionLabel:t,onClick:o})=>G9("div",{className:"OverwriteConfirm__Actions__Action",children:[Ia("h4",{children:e}),Ia("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),Ia(ar,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),z9=()=>{let{t:e}=Ce(),n=Xe(),t=Ne();return Ia(ip,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(_d,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},H9=()=>{let{t:e}=Ce(),n=Xe();return Ia(ip,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(Ds,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Uf=Object.assign(({children:e})=>Ia("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:z9,SaveToDisk:H9});import{jsx as sr,jsxs as ZS}from"react/jsx-runtime";var ap=Object.assign(qr("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=Ke(),[t,o]=Fe(Of);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return sr(n.In,{children:sr(dn,{onCloseRequest:r,title:!1,size:916,children:ZS("div",{className:"OverwriteConfirm",children:[sr("h3",{children:t.title}),ZS("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[sr("div",{className:"OverwriteConfirm__Description__icon",children:C1}),sr("div",{children:t.description}),sr("div",{className:"OverwriteConfirm__Description__spacer"}),sr(ar,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),sr(Uf,{children:e})]})})})}),{Actions:Uf,Action:ip});import{round as zC}from"@excalidraw/math";import iH from"clsx";import aH from"lodash.throttle";import{useEffect as HC,useMemo as nE,useState as sH,memo as lH}from"react";import{STATS_PANELS as gp}from"@excalidraw/common";import{getCommonBounds as cH}from"@excalidraw/element";import{getUncroppedWidthAndHeight as dH}from"@excalidraw/element";import{isImageElement as oE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as mH}from"@excalidraw/element";import{elementsAreInSameGroup as pH}from"@excalidraw/element";import{degreesToRadians as oC,radiansToDegrees as sC}from"@excalidraw/math";import{getBoundTextElement as rC}from"@excalidraw/element";import{isArrowElement as iC,isElbowArrow as tz}from"@excalidraw/element";import{updateBindings as aC}from"@excalidraw/element";import Z9 from"clsx";import{useEffect as tC,useRef as lp,useState as j9}from"react";import{EVENT as Pa,KEYS as q9,cloneJSON as Wf}from"@excalidraw/common";import{deepCopyElement as J9}from"@excalidraw/element";import{CaptureUpdateAction as nC}from"@excalidraw/element";import{pointFrom as lr,pointRotateRads as sp}from"@excalidraw/math";import{getBoundTextElement as U9,getNonDeletedElements as W9,isBindingElement as V9,unbindBindingElement as jS}from"@excalidraw/element";import{isFrameLikeElement as QS}from"@excalidraw/element";import{getSelectedGroupIds as Y9,getElementsInGroup as K9,isInGroup as X9}from"@excalidraw/element";import{getFrameChildren as $9}from"@excalidraw/element";import{updateBindings as qS}from"@excalidraw/element";import{DRAGGING_THRESHOLD as JS}from"@excalidraw/common";var eC=.01,Il=10,Ft=(e,n)=>!(n==="angle"&&QS(e)),He=(e,n)=>{let t=e+n/2;return t-t%n},Sa=(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 Jr=(e,n,t,o,r,i,a=!0)=>{if(V9(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<JS&&Math.abs(n-t.y)<JS)return;jS(t,"start",o),jS(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],[p,m]=sp(lr(t.x,t.y),lr(c,d),t.angle),u=e-p,E=n-m,[g,b]=sp(lr(e,n),lr(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),qS(l,o,r);let y=U9(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(QS(t)){let w=$9(i,t.id);w.forEach(x=>{let v=s.get(x.id);if(!v)return;let[I,C]=[x.x+x.width/2,x.y+x.height/2],[P,A]=sp(lr(x.x,x.y),lr(I,C),x.angle),L=Math.round(P+u),_=Math.round(A+E),[k,D]=sp(lr(L,_),lr(I+u,C+E),-x.angle);o.mutateElement(v,{x:k,y:D},{informMutation:a,isDragging:!1}),qS(v,o,r,{simultaneouslyUpdated:W9(w)})})}},Ca=(e,n)=>{let o=Y9(n).map(r=>K9(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!X9(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as Vf,jsxs as ez}from"react/jsx-runtime";var Q9=({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:p})=>{let m=Tt(),u=Ne(),E=lp(null),g=lp(null),[b,y]=j9(o.toString()),w=lp(null);w.current||(w.current={originalAppState:Wf(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),tC(()=>{let I=o.toString();y(I),w.current.lastUpdatedValue=I},[o]);let x=(I,C,P)=>{if(!w.current.updatePending)return!1;w.current.updatePending=!1;let A=Number(I);if(isNaN(A)){y(o.toString());return}let L=Number(A.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(L-_)>=eC)&&(w.current.lastUpdatedValue=I,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:m.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:L,property:s,originalAppState:P,setInputValue:k=>y(String(k)),app:m,setAppState:u}),m.syncActionResult({captureUpdate:nC.IMMEDIATELY}))},v=lp({});return v.current.handleInputValue=x,tC(()=>{let I=E.current,C=v.current;return()=>{let P=I?.value;P&&C.handleInputValue?.(P,w.current.originalElements,w.current.originalAppState),window.removeEventListener(Pa.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(Pa.POINTER_UP,C.onPointerUp,!1)}},[i]),i?ez("div",{className:Z9("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Vf("div",{className:"drag-input-label",ref:g,onPointerDown:I=>{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=m.scene.getNonDeletedElements().reduce((z,W)=>(z.set(W.id,J9(W)),z),new Map),L=r.map(z=>A.get(z.id)),_=Wf(c),k=0,D=0,O=z=>{if(P&&A!==null&&L!==null){let W=z.clientX-P.x;W!==0&&(D+=W,Math.abs(D)>=d&&(D=Math.sign(D)*Math.floor(Math.abs(D)/d),k+=D,t({accumulatedChange:k,instantChange:D,originalElements:L,originalElementsMap:A,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:j=>y(String(j)),app:m,setAppState:u}),D=0))}P={x:z.clientX,y:z.clientY}},G=()=>{window.removeEventListener(Pa.POINTER_MOVE,O,!1),m.syncActionResult({captureUpdate:nC.IMMEDIATELY}),p?.({app:m,setAppState:u,originalElements:L,originalAppState:_}),P=null,k=0,D=0,L=null,A=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(Pa.POINTER_UP,G,!1)};v.current.onPointerMove=O,v.current.onPointerUp=G,window.addEventListener(Pa.POINTER_MOVE,O,!1),window.addEventListener(Pa.POINTER_UP,G,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?Vf(Qc,{icon:n}):e}),Vf("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:I=>{if(i){let C=I.target;C instanceof HTMLInputElement&&I.key===q9.ENTER&&(x(C.value,r,c),m.focusContainer())}},ref:E,value:b,onChange:I=>{w.current.updatePending=!0,y(I.target.value)},onFocus:I=>{I.target.select(),w.current.originalElements=r,w.current.originalAppState=Wf(c)},onBlur:I=>{b?i&&x(I.target.value,w.current.originalElements,w.current.originalAppState):y(o.toString())},disabled:!i})]}):null},ut=Q9;import{jsx as iz}from"react/jsx-runtime";var nz=15,oz=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!tz(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=oC(o);r.mutateElement(l,{angle:E}),aC(l,r,i.state);let g=rC(l,a);g&&!iC(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(sC(s.angle)*100)/100,d=Math.round(e),p=(c+d)%360;t&&(p=He(p,nz)),p=p<0?p+360:p;let m=oC(p);r.mutateElement(l,{angle:m}),aC(l,r,i.state);let u=rC(l,a);u&&!iC(l)&&r.mutateElement(u,{angle:m})}},rz=({element:e,scene:n,appState:t,property:o})=>iz(ut,{label:"A",icon:Tc,value:Math.round(sC(e.angle)%360*100)/100,elements:[e],dragInputCallback:oz,editable:Ft(e,"angle"),scene:n,appState:t,property:o}),lC=rz;import{jsx as sz}from"react/jsx-runtime";var cC=5,az=({property:e,scene:n,appState:t,setAppState:o})=>sz(ut,{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?He(l.gridStep+cC*Math.sign(i),cC):l.gridStep+i),c?(c=Bb(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),dC=az;import{clamp as cp,round as Yf}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as dp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as mC,getNonDeletedElements as lz,getUncroppedWidthAndHeight as hC}from"@excalidraw/element";import{resizeSingleElement as pC}from"@excalidraw/element";import{isImageElement as gC}from"@excalidraw/element";import{isFrameLikeElement as Kf}from"@excalidraw/element";import{getElementsInResizingFrame as Xf}from"@excalidraw/element";import{replaceAllElementsInFrame as fC}from"@excalidraw/element";import{jsx as uz}from"react/jsx-runtime";var uC=10,cz=e=>e.type==="image",dz=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldKeepAspectRatio:o,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:s,instantChange:l,scene:c,app:d,setAppState:p})=>{let m=c.getNonDeletedElementsMap(),u=n[0],E=m.get(u.id);if(u&&E){let g=o||cz(u),b=u.width/u.height;if(s.croppingElementId===u.id){let y=m.get(u.id);if(!y||!gC(y)||!y.crop)return;let w=y.crop,x={...w},v=y.scale[0]===-1,I=y.scale[1]===-1,{width:C,height:P}=hC(y),A=w.naturalWidth/C,L=w.naturalHeight/P,_=v?w.width+w.x:w.naturalWidth-w.x,k=I?w.height+w.y:w.naturalHeight-w.y,D=mC*A,O=mC*L;if(i!==void 0){if(a==="width"){let X=i*A,oe=cp(X,D,_);x={...x,width:oe,x:v?w.x+w.width-oe:w.x}}else if(a==="height"){let X=i*L,oe=cp(X,O,k);x={...x,height:oe,y:I?w.y+w.height-oe:w.y}}c.mutateElement(y,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}let G=a==="width"?l:0,z=a==="height"?l:0,W=cp(w.width+G,D,_),j=cp(w.height+z,D,k);x={...w,x:v?w.x+w.width-W:w.x,y:I?w.y+w.height-j:w.y,width:W,height:j},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,dp),w=Math.max(a==="height"?i:g?i/b:u.height,dp);if(pC(y,w,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),Kf(E)){let x=Xf(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),v=fC(c.getElementsIncludingDeleted(),x,E);c.replaceAllElements(v)}return}{let y=a==="width"?e:0,w=a==="height"?e:0,x=Math.max(0,u.width+y);a==="width"&&(r?x=He(x,uC):x=Math.round(x));let v=Math.max(0,u.height+w);if(a==="height"&&(r?v=He(v,uC):v=Math.round(v)),g&&(a==="width"?v=Math.round(x/b*100)/100:x=Math.round(v*b*100)/100),v=Math.max(dp,v),x=Math.max(dp,x),pC(x,v,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),Kf(E)){let I=lz(Xf(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));p({elementsToHighlight:I})}}}},mz=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Kf(a)){let s=Xf(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=fC(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},pz=({property:e,element:n,scene:t,appState:o})=>{let r=Yf(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&gC(n)&&n.crop){let{width:i,height:a}=hC(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=Yf(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=Yf(n.crop.height*s,2)}}return uz(ut,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:dz,value:r,editable:Ft(n,e),scene:t,appState:o,property:e,dragFinishedCallback:mz})},$f=pz;import{getBoundTextElement as hz,redrawTextBoundingBox as gz}from"@excalidraw/element";import{hasBoundTextElement as fz,isTextElement as bC}from"@excalidraw/element";import{jsx as wz}from"react/jsx-runtime";var EC=4,Ez=4,bz=({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||!bC(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),EC);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,EC),t&&(l=He(l,Ez))}l&&(r.mutateElement(s,{fontSize:l}),gz(s,r.getContainerElement(s),r))}},xz=({element:e,scene:n,appState:t,property:o})=>{let r=bC(e)?e:fz(e)?hz(e,n.getNonDeletedElementsMap()):null;return r?wz(ut,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:bz,icon:Sr,appState:t,scene:n,property:o}):null},xC=xz;import{degreesToRadians as wC,radiansToDegrees as TC}from"@excalidraw/math";import{getBoundTextElement as yC}from"@excalidraw/element";import{isArrowElement as vC}from"@excalidraw/element";import{isInGroup as Zf}from"@excalidraw/element";import{jsx as Iz}from"react/jsx-runtime";var yz=15,vz=({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&&!Zf(c)&&Ft(c,r)),l=n.filter(c=>!Zf(c)&&Ft(c,r));if(o!==void 0){let c=wC(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let p=yC(d,a);p&&!vC(d)&&i.mutateElement(p,{angle:c})}i.triggerUpdate();return}for(let c=0;c<s.length;c++){let d=s[c];if(!d)continue;let p=l[c],m=Math.round(TC(p.angle)*100)/100,u=Math.round(e),E=(m+u)%360;t&&(E=He(E,yz)),E=E<0?E+360:E;let g=wC(E);i.mutateElement(d,{angle:g});let b=yC(d,a);b&&!vC(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},Tz=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!Zf(l)&&Ft(l,"angle")),i=r.map(l=>Math.round(TC(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>Ft(l,"angle"));return Iz(ut,{label:"A",icon:Tc,value:a,elements:e,dragInputCallback:vz,editable:s,appState:t,scene:n,property:o})},IC=Tz;import{pointFrom as kC}from"@excalidraw/math";import{useMemo as Cz}from"react";import{MIN_WIDTH_OR_HEIGHT as cr}from"@excalidraw/common";import{getElementsInResizingFrame as jf,getNonDeletedElements as Pz,isFrameLikeElement as qf,replaceAllElementsInFrame as LC,updateBoundElements as kz}from"@excalidraw/element";import{rescalePointsInElement as Mz,resizeSingleElement as MC}from"@excalidraw/element";import{getBoundTextElement as Az,handleBindTextResize as Lz}from"@excalidraw/element";import{isTextElement as DC}from"@excalidraw/element";import{MIME_TYPES as Qr}from"@excalidraw/common";import{getNonDeletedElements as SC}from"@excalidraw/element";var mp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=SC(vr(e,null,{deleteInvisibleElements:!0})),l=ci(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},(p,m)=>{let u=document.createElement("canvas");if(o){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(p,m),b=o<g?o/g:n?.exportScale??1;return u.width=p*b,u.height=m*b,{canvas:u,scale:b}}let E=r?.(p,m)||{width:p,height:m};return u.width=E.width,u.height=E.height,{canvas:u,scale:E.scale??1}})},CC=async e=>{let{mimeType:n=Qr.png,quality:t}=e;n===Qr.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${Qr.png}" mimeType`),n==="image/jpg"&&(n=Qr.jpg),n===Qr.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${Qr.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await mp(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===Qr.png&&e.appState?.exportEmbedScene&&(a=await Xb({blob:a,metadata:$a(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},PC=async({elements:e,appState:n=Lo(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=SC(vr(e,null,{deleteInvisibleElements:!0})),d={...ci(n,null),exportPadding:o};return yr(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},Sz=async e=>{if(e.type==="svg"){let n=await PC(e);await co(n.outerHTML)}else if(e.type==="png")await Ld(CC(e));else if(e.type==="json")await Md(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as SRe}from"@excalidraw/element";import{getCommonBounds as pp}from"@excalidraw/element";import{jsx as Oz}from"react/jsx-runtime";var ka=10,Dz=(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,...Mz(o,a,s,!1),...DC(o)?{fontSize:o.fontSize*t}:{}}},_z=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=Dz(e,n,o,i);s.mutateElement(r,c);let d=Az(i,a);if(d){let p=d.fontSize*o;kz(r,s);let m=l.get(d.id);m&&DC(m)&&(s.mutateElement(m,{fontSize:p}),Lz(r,s,t==="width"?"e":"s",!0))}},AC=(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 p=0;p<s.length;p++){let m=s[p],u=a[p];_z(r[0],r[1],i,d,u,m,l,c)}},Rz=({accumulatedChange:e,originalElements:n,originalElementsMap:t,originalAppState:o,shouldChangeByStepSize:r,nextValue:i,scene:a,property:s,setAppState:l,app:c})=>{let d=a.getNonDeletedElementsMap(),p=Ca(n,o);if(i!==void 0){for(let g of p){let b=Sa(g,d,t);if(b.length>1){let y=b.map(D=>D.latest),w=b.map(D=>D.original),[x,v,I,C]=pp(w),P=I-x,A=C-v,L=P/A,_=Math.max(cr,s==="width"?Math.max(0,i):P),k=Math.max(cr,s==="height"?Math.max(0,i):A);AC(_,k,A,L,kC(x,v),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&Ft(w,s)){let v=s==="width"?Math.max(0,i):w.width;s==="width"&&(r?v=He(v,ka):v=Math.round(v));let I=s==="height"?Math.max(0,i):w.height;if(s==="height"&&(r?I=He(I,ka):I=Math.round(I)),v=Math.max(cr,v),I=Math.max(cr,I),MC(v,I,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),qf(w)){let C=jf(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()),P=LC(a.getElementsIncludingDeleted(),C,w);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let m=s==="width"?e:0,u=s==="height"?e:0,E=[];for(let g of p){let b=Sa(g,d,t);if(b.length>1){let y=b.map(D=>D.latest),w=b.map(D=>D.original),[x,v,I,C]=pp(w),P=I-x,A=C-v,L=P/A,_=Math.max(0,P+m);s==="width"&&(r?_=He(_,ka):_=Math.round(_));let k=Math.max(0,A+u);s==="height"&&(r?k=He(k,ka):k=Math.round(k)),_=Math.max(cr,_),k=Math.max(cr,k),AC(_,k,A,L,kC(x,v),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&Ft(w,s)){let v=Math.max(0,x.width+m);s==="width"&&(r?v=He(v,ka):v=Math.round(v));let I=Math.max(0,x.height+u);if(s==="height"&&(r?I=He(I,ka):I=Math.round(I)),v=Math.max(cr,v),I=Math.max(cr,I),MC(v,I,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),qf(w)){let C=Pz(jf(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}l({elementsToHighlight:E}),a.triggerUpdate()},Nz=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&qf(a)){let s=jf(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=LC(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},Bz=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=Cz(()=>o.map(c=>{let d=Sa(c,t);if(d.length>1){let[m,u,E,g]=pp(d.map(b=>b.latest));return Math.round((e==="width"?E-m:g-u)*100)/100}let[p]=d;return Math.round((e==="width"?p.latest.width:p.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 Oz(ut,{label:e==="width"?"W":"H",elements:n,dragInputCallback:Rz,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:Nz})},Jf=Bz;import{getBoundTextElement as Fz,redrawTextBoundingBox as _C}from"@excalidraw/element";import{hasBoundTextElement as zz,isTextElement as Hz}from"@excalidraw/element";import{isInGroup as Gz}from"@excalidraw/element";import{jsx as Kz}from"react/jsx-runtime";var RC=4,Uz=4,Wz=(e,n)=>e.reduce((t,o)=>{if(!o||Gz(o))return t;if(Hz(o))return t.push(o),t;if(zz(o)){let r=Fz(o,n);if(r)return t.push(r),t}return t},[]),Vz=({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),RC);for(let l of a)r.mutateElement(l,{fontSize:s}),_C(l,r.getContainerElement(l),r);r.triggerUpdate()}else{let l=n;for(let c=0;c<a.length;c++){let d=a[c],p=l[c],m=Math.round(p.fontSize),u=Math.round(e),E=Math.max(m+u,RC);t&&(E=He(E,Uz)),r.mutateElement(d,{fontSize:E}),_C(d,r.getContainerElement(d),r)}r.triggerUpdate()}},Yz=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=Wz(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 Kz(ut,{label:"F",icon:Sr,elements:i,dragInputCallback:Vz,value:s,editable:l,scene:n,property:o,appState:t})},NC=Yz;import{pointFrom as dr,pointRotateRads as up}from"@excalidraw/math";import{useMemo as Xz}from"react";import{isTextElement as $z}from"@excalidraw/element";import{getCommonBounds as Qf}from"@excalidraw/element";import{jsx as Qz}from"react/jsx-runtime";var Zz=(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],[p,m]=up(dr(l.x,l.y),dr(c,d),l.angle),u=e==="x"?Math.round(p+n):p,E=e==="y"?Math.round(m+t):m;Jr(u,E,l,i,a,r,!1)}},jz=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=Qf(t),c=e-s,d=n-l;for(let p=0;p<t.length;p++){let m=t[p],u=a.get(m.id);if(u&&(!$z(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,y]=up(dr(u.x,u.y),dr(E,g),u.angle);Jr(b+c,y+d,m,r,i,o,!1)}}},qz=({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 Ca(n,s)){let E=Sa(u,c,t);if(E.length>1){let[g,b,,]=Qf(E.map(x=>x.latest));jz(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&&Ft(b,i)){let[y,w]=[g.x+g.width/2,g.y+g.height/2],[x,v]=up(dr(g.x,g.y),dr(y,w),g.angle);Jr(i==="x"?r:x,i==="y"?r:v,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?He(e,Il):e;Zz(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},Jz=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=Xz(()=>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]=Qf(c);return Math.round((e==="x"?g:b)*100)/100}let[d]=c,[p,m]=[d.x+d.width/2,d.y+d.height/2],[u,E]=up(dr(d.x,d.y),dr(p,m),d.angle);return Math.round((e==="x"?u:E)*100)/100}),[o,t,e]),s=new Set(a).size===1?a[0]:"Mixed";return Qz(ut,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:qz,value:s,property:e,scene:r,appState:i})},eE=Jz;import{clamp as Sl,pointFrom as hp,pointRotateRads as OC,round as BC}from"@excalidraw/math";import{getFlipAdjustedCropPosition as eH,getUncroppedWidthAndHeight as tH}from"@excalidraw/element";import{isImageElement as FC}from"@excalidraw/element";import{jsx as rH}from"react/jsx-runtime";var nH=({accumulatedChange:e,instantChange:n,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:i,property:a,scene:s,originalAppState:l,app:c})=>{let d=s.getNonDeletedElementsMap(),p=t[0],[m,u]=[p.x+p.width/2,p.y+p.height/2],[E,g]=OC(hp(p.x,p.y),hp(m,u),p.angle);if(l.croppingElementId===p.id){let v=d.get(p.id);if(!v||!FC(v)||!v.crop)return;let I=v.crop,C=I,P=v.scale[0]===-1,A=v.scale[1]===-1,{width:L,height:_}=tH(v);if(i!==void 0){if(a==="x"){let O=i*(I.naturalWidth/L);P?C={...I,x:Sl(I.naturalWidth-O-I.width,0,I.naturalWidth-I.width)}:C={...I,x:Sl(i*(I.naturalWidth/L),0,I.naturalWidth-I.width)}}a==="y"&&(C={...I,y:Sl(i*(I.naturalHeight/_),0,I.naturalHeight-I.height)}),s.mutateElement(v,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),D=(a==="y"?n:0)*(A?-1:1);C={...I,x:Sl(I.x+k,0,I.naturalWidth-I.width),y:Sl(I.y+D,0,I.naturalHeight-I.height)},s.mutateElement(v,{crop:C});return}if(i!==void 0){Jr(a==="x"?i:E,a==="y"?i:g,p,s,c.state,o);return}let b=a==="x"?e:0,y=a==="y"?e:0,w=a==="x"?Math.round(r?He(p.x+b,Il):E+b):E,x=a==="y"?Math.round(r?He(p.y+y,Il):g+y):g;Jr(w,x,p,s,c.state,o)},oH=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=OC(hp(n.x,n.y),hp(n.x+n.width/2,n.y+n.height/2),n.angle),a=BC(e==="x"?r:i,2);if(o.croppingElementId===n.id&&FC(n)&&n.crop){let s=eH(n);s&&(a=BC(e==="x"?s.x:s.y,2))}return rH(ut,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:nH,scene:t,value:a,property:e,appState:o})},tE=oH;import{Fragment as rE,jsx as te,jsxs as zt}from"react/jsx-runtime";var uH=50,Cl=e=>{let n=Uo(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=Qo(e.app);return te(hH,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},Be=({children:e,columns:n=1,heading:t,style:o,...r})=>te("div",{className:iH("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});Be.displayName="StatsRow";var fp=({children:e,order:n,style:t,...o})=>te("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});fp.displayName="StatsRows";Cl.StatsRow=Be;Cl.StatsRows=fp;var hH=lH(({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=Ne(),p=o.length===1?o[0]:null,m=o.length>1?o:null,u=r.croppingElementId&&oE(p),E=u?dH(p):null,[g,b]=sH({width:0,height:0}),y=nE(()=>aH(v=>{let I=cH(v);b({width:Math.round(I[2])-Math.round(I[0]),height:Math.round(I[3])-Math.round(I[1])})},uH),[]);HC(()=>{y(l)},[i,l,y]),HC(()=>()=>y.cancel(),[y]);let w=nE(()=>Ca(o,r),[o,r]),x=nE(()=>mH(o),[o]);return te("div",{className:"exc-stats",children:zt(Ue,{padding:3,children:[zt("div",{className:"title",children:[te("h2",{children:f("stats.title")}),te("div",{className:"close",onClick:n,children:zn})]}),zt(ys,{label:te("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&gp.generalStats),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^gp.generalStats}})),children:[zt(fp,{children:[te(Be,{heading:!0,children:f("stats.scene")}),zt(Be,{columns:2,children:[te("div",{children:f("stats.shapes")}),te("div",{children:l.length})]}),zt(Be,{columns:2,children:[te("div",{children:f("stats.width")}),te("div",{children:g.width})]}),zt(Be,{columns:2,children:[te("div",{children:f("stats.height")}),te("div",{children:g.height})]}),a&&zt(rE,{children:[te(Be,{heading:!0,children:"Canvas"}),te(Be,{children:te(dC,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&te("div",{id:"elementStats",style:{marginTop:12},children:te(ys,{label:te("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&gp.elementProperties),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^gp.elementProperties}})),children:zt(fp,{children:[p&&zt(rE,{children:[u&&te(Be,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&oE(p)&&E&&zt(Be,{columns:2,children:[te("div",{children:f("stats.width")}),te("div",{children:zC(E.width,2)})]}),r.croppingElementId&&oE(p)&&E&&zt(Be,{columns:2,children:[te("div",{children:f("stats.height")}),te("div",{children:zC(E.height,2)})]}),te(Be,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?f("labels.imageCropping"):p.type==="magicframe"?f("element.frame"):f(`element.${p.type}`)}),te(Be,{children:te(tE,{element:p,property:"x",elementsMap:c,scene:s,appState:r})}),te(Be,{children:te(tE,{element:p,property:"y",elementsMap:c,scene:s,appState:r})}),te(Be,{children:te($f,{property:"width",element:p,scene:s,appState:r})}),te(Be,{children:te($f,{property:"height",element:p,scene:s,appState:r})}),te(Be,{children:te(lC,{property:"angle",element:p,scene:s,appState:r})}),te(Be,{children:te(xC,{property:"fontSize",element:p,scene:s,appState:r})})]}),m&&zt(rE,{children:[pH(m)&&te(Be,{heading:!0,children:f("element.group")}),zt(Be,{columns:2,style:{margin:"0.3125rem 0"},children:[te("div",{children:f("stats.shapes")}),te("div",{children:o.length})]}),te(Be,{children:te(eE,{property:"x",elements:m,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(eE,{property:"y",elements:m,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(Jf,{property:"width",elements:m,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(Jf,{property:"height",elements:m,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(IC,{property:"angle",elements:m,scene:s,appState:r})}),te(Be,{children:te(NC,{property:"fontSize",elements:m,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 CH,useEffect as UC,useState as WC}from"react";import{normalizeLink as PH,KEYS as lE}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as kH,getLinkIdAndTypeFromSelection as MH}from"@excalidraw/element";import gH from"clsx";import{jsx as Ep,jsxs as EH}from"react/jsx-runtime";var fH=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return EH("button",{className:gH("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Ep("div",{style:a?{visibility:"hidden"}:{},children:o}),Ep("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Ep("div",{style:{position:"absolute",inset:0},children:Ep(ro,{})})]})},iE=fH;import aE from"clsx";import{forwardRef as yH,useRef as vH,useImperativeHandle as TH,useLayoutEffect as IH,useState as SH}from"react";import bH from"clsx";import{composeEventHandlers as xH}from"@excalidraw/common";import{jsx as wH}from"react/jsx-runtime";var Mn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>wH("button",{onClick:xH(i.onClick,a=>{n()}),type:e,className:bH("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as sE,jsxs as GC}from"react/jsx-runtime";var bp=yH(({onChange:e,label:n,fullWidth:t,placeholder:o,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,icon:l,className:c,type:d,...p},m)=>{let u=vH(null);TH(m,()=>u.current),IH(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=SH(!1);return GC("div",{className:aE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&sE("div",{className:"ExcTextField__label",children:n}),GC("div",{className:aE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[sE("input",{className:aE({"is-redacted":"value"in p&&p.value&&s&&!E}),readOnly:r,value:"value"in p?p.value:void 0,defaultValue:"defaultValue"in p?p.defaultValue:void 0,placeholder:o,ref:u,onChange:b=>e?.(b.target.value),onKeyDown:a,type:d}),s&&sE(Mn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?k1:Pr})]})]})});import{jsx as Ma,jsxs as xp}from"react/jsx-runtime";var AH=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=kH})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=WC(a),[c,d]=WC(!1);UC(()=>{let m=ie(i,t),u=a;if(m.length>0&&r){let E=MH(m,t);E&&(u=PH(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let p=CH(()=>{if(s&&s!==i.get(e)?.link){let m=i.get(e);m&&o.mutateElement(m,{link:s})}if(!s&&c&&e){let m=i.get(e);m&&o.mutateElement(m,{link:null})}n?.()},[e,s,i,c,o,n]);return UC(()=>{let m=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===lE.ENTER&&p(),t.openDialog?.name==="elementLinkSelector"&&u.key===lE.ESCAPE&&n?.()};return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m)}},[t,n,p]),xp("div",{className:"ElementLinkDialog",children:[xp("div",{className:"ElementLinkDialog__header",children:[Ma("h2",{children:f("elementLink.title")}),Ma("p",{children:f("elementLink.desc")})]}),xp("div",{className:"ElementLinkDialog__input",children:[Ma(bp,{value:s??"",onChange:m=>{c||d(!0),l(m)},onKeyDown:m=>{m.key===lE.ENTER&&p()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&Ma($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:Ir})]}),xp("div",{className:"ElementLinkDialog__actions",children:[Ma(iE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),Ma(iE,{label:f("buttons.confirm"),onClick:p,actionType:"primary"})]})]})},VC=AH;import LH,{useState as DH}from"react";import{Fragment as _H,jsx as cE}from"react/jsx-runtime";var YC=({children:e,onClose:n})=>{let[t,o]=DH(!!e),{container:r}=Ae(),i=LH.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return cE(_H,{children:t&&cE(dn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:cE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import KC,{useMemo as GH}from"react";import XC from"clsx";import{isDarwin as $C,isFirefox as UH,isWindows as WH}from"@excalidraw/common";import{KEYS as ti}from"@excalidraw/common";import{SHAPES as VH}from"@excalidraw/element/shapes";import{isFirefox as RH,KEYS as dE}from"@excalidraw/common";import{SHAPES as NH}from"@excalidraw/element/shapes";import{Fragment as HH,jsx as Ge,jsxs as ei}from"react/jsx-runtime";var BH=e=>ei(HH,{children:[Ge("h3",{children:e.title}),Ge("div",{className:"HelpDialog__islands-container",children:e.children})]}),mE=e=>ei("div",{className:`HelpDialog__island ${e.className}`,children:[Ge("h4",{className:"HelpDialog__island-title",children:e.caption}),Ge("div",{className:"HelpDialog__island-content",children:e.children})]});function*OH(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var FH=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),yt=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ge(zH,{children:FH(a)},a)));return ei("div",{className:"HelpDialog__shortcut",children:[Ge("div",{children:e}),Ge("div",{className:"HelpDialog__key-container",children:[...OH(o,t?f("helpDialog.or"):null)]})]})},zH=e=>Ge("kbd",{className:"HelpDialog__key",...e});function pE(){return ei(BH,{title:f("helpDialog.shortcuts"),children:[ei(mE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ge(yt,{label:f("toolBar.hand"),shortcuts:[dE.H]}),NH.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ge(yt,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ge(yt,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ge(yt,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),ei(mE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ge(yt,{label:f("helpDialog.smartZoom"),shortcuts:[dE.F]}),Ge(yt,{label:f("helpDialog.dragToZoom"),shortcuts:[`${dE.Z}+${f("helpDialog.drag")}`]}),Ge(yt,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),ei(mE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ge(yt,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ge(yt,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ge(yt,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ge(yt,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(Ko||RH)&&Ge(yt,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ge(yt,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ge(yt,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ge(yt,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ge(yt,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ge(yt,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as jC,jsx as Y,jsxs as ni}from"react/jsx-runtime";var YH=e=>ni(jC,{children:[Y("h3",{children:e.title}),Y("div",{className:"HelpDialog__islands-container",children:e.children})]}),uE=e=>ni("div",{className:`HelpDialog__island ${e.className}`,children:[Y("h4",{className:"HelpDialog__island-title",children:e.caption}),Y("div",{className:"HelpDialog__island-content",children:e.children})]});function*KH(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var XH=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=>Y($H,{children:XH(a)},a)));return ni("div",{className:"HelpDialog__shortcut",children:[Y("div",{children:e}),Y("div",{className:"HelpDialog__key-container",children:[...KH(o,t?f("helpDialog.or"):null)]})]})},$H=e=>Y("kbd",{className:"HelpDialog__key",...e}),ZC=({onClose:e})=>{let[n,t]=KC.useState(!1),o=KC.useCallback(()=>{e&&e()},[e]),r=GH(()=>n?Y("button",{className:XC("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):Y("button",{className:XC("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return Y(jC,{children:Y(dn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?ni(YH,{title:f("helpDialog.shortcuts"),children:[ni(uE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Y(q,{label:f("toolBar.hand"),shortcuts:[ti.H]}),VH.map(({value:i,key:a})=>Y(q,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),Y(q,{label:f("toolBar.frame"),shortcuts:[ti.F]}),Y(q,{label:f("toolBar.laser"),shortcuts:[ti.K]}),Y(q,{label:f("labels.eyeDropper"),shortcuts:[ti.I,"Shift+S","Shift+G"]}),Y(q,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),Y(q,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),Y(q,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),Y(q,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),Y(q,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),Y(q,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),Y(q,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Y(q,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),Y(q,{label:f("toolBar.lock"),shortcuts:[ti.Q]}),Y(q,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),Y(q,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),Y(q,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),ni(uE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Y(q,{label:f("helpDialog.smartZoom"),shortcuts:[ti.F]}),Y(q,{label:f("helpDialog.dragToZoom"),shortcuts:[`${ti.Z}+${f("helpDialog.drag")}`]}),Y(q,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),Y(q,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),Y(q,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),Y(q,{label:f("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),Y(q,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),Y(q,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),Y(q,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),Y(q,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),Y(q,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),Y(q,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),Y(q,{label:f("search.title"),shortcuts:[pt("searchMenu")]})]}),ni(uE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Y(q,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),Y(q,{label:f("labels.delete"),shortcuts:[N("Delete")]}),Y(q,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),Y(q,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),Y(q,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),Y(q,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Y(q,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),Y(q,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Y(q,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Y(q,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(Ko||UH)&&Y(q,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Y(q,{label:f("labels.sendToBack"),shortcuts:[$C?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),Y(q,{label:f("labels.bringToFront"),shortcuts:[$C?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),Y(q,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),Y(q,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),Y(q,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),Y(q,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),Y(q,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),Y(q,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),Y(q,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+R")]}),Y(q,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),Y(q,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Y(q,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),Y(q,{label:f("buttons.redo"),shortcuts:WH?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),Y(q,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Y(q,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Y(q,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Y(q,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),Y(q,{label:f("labels.showStroke"),shortcuts:[N("S")]}),Y(q,{label:f("labels.showBackground"),shortcuts:[N("G")]}),Y(q,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),Y(q,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),Y(q,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):Y(pE,{})})})};import{useEffect as QC,useRef as eP,useState as oi}from"react";import{DEFAULT_EXPORT_PADDING as eG,EXPORT_IMAGE_TYPES as hE,isFirefox as tG,EXPORT_SCALES as nG,cloneJSON as tP}from"@excalidraw/common";import{useCallback as ZH,useRef as jH,useState as qH}from"react";var JH=2e3,qC=()=>{let[e,n]=qH(null),t=jH(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},JH)},r=ZH(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import QH from"clsx";import{jsx as JC}from"react/jsx-runtime";var Pl=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>JC("div",{className:QH("Switch",{toggled:t,disabled:r}),children:JC("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 Oe,jsxs as mr}from"react/jsx-runtime";var oG=()=>mr("div",{children:[Oe("h3",{children:f("canvasError.cannotShowPreview")}),Oe("p",{children:Oe("span",{children:f("canvasError.canvasTooBig")})}),mr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),rG=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=Me(n,e),[l,c]=oi(i),[d,p]=oi(s),[m,u]=oi(e.exportBackground),[E,g]=oi(e.exportEmbedScene),[b,y]=oi(e.exportScale),w=eP(null),x=eP(0),[v,I]=oi(null),{onCopy:C,copyStatus:P,resetCopyStatus:A}=qC();QC(()=>{A()},[l,m,a,b,E,A]);let{exportedElements:L,exportingFrame:_}=Rr(n,e,d);return QC(()=>{let k=w.current;if(!k)return;let D=k.offsetWidth,O=k.offsetHeight;if(!D)return;let G=++x.current,z=()=>G!==x.current;return mp({elements:L,appState:{...e,name:l,exportBackground:m,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:eG,maxWidthOrHeight:Math.max(D,O),exportingFrame:_}).then(async W=>{if(!z()){try{await Ja(W)}catch(j){throw j.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):j}z()||(I(null),k.replaceChildren(W))}}).catch(W=>{z()||(console.error(W),I(W))}),()=>{x.current+=1}},[e,t,L,_,l,m,a,b,E]),mr("div",{className:"ImageExportModal",children:[Oe("h3",{children:f("imageExportDialog.header")}),mr("div",{className:"ImageExportModal__preview",children:[Oe("div",{className:"ImageExportModal__preview__canvas",ref:w,children:v&&Oe(oG,{})}),Oe("div",{className:"ImageExportModal__preview__filename",children:!li&&Oe("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction(Lh,"ui",k.target.value)}})})]}),mr("div",{className:"ImageExportModal__settings",children:[Oe("h3",{children:f("imageExportDialog.header")}),s&&Oe(kl,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Oe(Pl,{name:"exportOnlySelected",checked:d,onChange:k=>{p(k)}})}),Oe(kl,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Oe(Pl,{name:"exportBackgroundSwitch",checked:m,onChange:k=>{u(k),o.executeAction(Dh,"ui",k)}})}),Oe(kl,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Oe(Pl,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(oy,"ui",k)}})}),Oe(kl,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Oe(Pl,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(_d,"ui",k)}})}),Oe(kl,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Oe(np,{name:"exportScale",value:b,onChange:k=>{y(k),o.executeAction(ty,"ui",k)},choices:nG.map(k=>({value:k,label:`${k}\xD7`}))})}),mr("div",{className:"ImageExportModal__settings__buttons",children:[Oe(ar,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(hE.png,L,{exportingFrame:_}),icon:Mu,children:f("imageExportDialog.button.exportToPng")}),Oe(ar,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(hE.svg,L,{exportingFrame:_}),icon:Mu,children:f("imageExportDialog.button.exportToSvg")}),(Ko||tG)&&Oe(ar,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(hE.clipboard,L,{exportingFrame:_}),C()},icon:Ic,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},kl=({label:e,children:n,tooltip:t,name:o})=>mr("div",{className:"ImageExportModal__settings__setting",title:e,children:[mr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Oe(lt,{label:t,long:!0,children:I1})]}),Oe("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),nP=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=oi(()=>({appStateSnapshot:tP(n),elementsSnapshot:tP(e)}));return Oe(dn,{onCloseRequest:i,size:"wide",title:!1,children:Oe(rG,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import aG from"react";import{getFrame as sG}from"@excalidraw/common";import{jsx as iG}from"react/jsx-runtime";var gE={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"}},fE=({children:e,color:n})=>iG("div",{className:"Card",style:{"--card-color":gE[n].base,"--card-color-darker":gE[n].darker,"--card-color-darkest":gE[n].darkest},children:e});import{Fragment as cG,jsx as An,jsxs as wp}from"react/jsx-runtime";var lG=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return An("div",{className:"ExportDialog ExportDialog--json",children:wp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&wp(fE,{color:"lime",children:[An("div",{className:"Card-icon",children:Mx}),An("h2",{children:f("exportDialog.disk_title")}),wp("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!li&&r.renderAction("changeProjectName")]}),An($,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Ds,"ui")}})]}),l&&wp(fE,{color:"pink",children:[An("div",{className:"Card-icon",children:as}),An("h2",{children:f("exportDialog.link_title")}),An("div",{className:"Card-details",children:f("exportDialog.link_details")}),An($,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Re("export","link",`ui (${sG()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},oP=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=aG.useCallback(()=>{a({openDialog:null})},[a]);return An(cG,{children:n.openDialog?.name==="jsonExport"&&An(dn,{onCloseRequest:s,title:f("buttons.export"),children:An(lG,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import dG from"clsx";import{jsx as mG}from"react/jsx-runtime";var rP=e=>mG($,{className:dG("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:Gn,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import cP from"clsx";import{useState as TG}from"react";import{KEYS as bE}from"@excalidraw/common";import{CANVAS_SEARCH_TAB as pG,DEFAULT_SIDEBAR as uG}from"@excalidraw/common";import{isArrowElement as hG,isFlowchartNodeElement as gG,isImageElement as iP,isLinearElement as aP,isLineElement as fG,isTextBindableContainer as EG,isTextElement as bG}from"@excalidraw/element";import{isNodeInFlowchart as xG}from"@excalidraw/element";import{jsx as EE}from"react/jsx-runtime";var Ee=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,wG=({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===uG.name&&e.openSidebar.tab===pG&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:Ee("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(qt(e))return f("hints.eraserRevert",{shortcut:Ee("Alt")});let c=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:Ee("Ctrl"),shortcut_2:Ee("Alt")});if(r.type==="arrow"||r.type==="line")return l?f("hints.linearElementMulti",{shortcut_1:Ee("Escape"),shortcut_2:Ee("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:Ee("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 aP(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:Ee("Shift")}):iP(d)?f("hints.resizeImage",{shortcut_1:Ee("Shift"),shortcut_2:Ee("Alt")}):f("hints.resize",{shortcut_1:Ee("Shift"),shortcut_2:Ee("Alt")})}if(a&&s==="mouse")return f("hints.rotate",{shortcut:Ee("Shift")});if(c.length===1&&bG(c[0]))return f("hints.text_selected",{shortcut:Ee("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:Ee("Escape"),shortcut_2:Ee(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:Ee("Enter"),shortcut_2:Ee("Escape")});if(c.length===1&&iP(c[0]))return f("hints.enterCropEditor",{shortcut:Ee("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:Ee("CtrlOrCmd")});if(Qo(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:Ee("CtrlOrCmd")});if(!c.length&&!n)return f("hints.canvasPanning",{shortcut_1:Ee(f("keys.mmb")),shortcut_2:Ee("Space")});if(c.length===1){if(aP(c[0]))return hG(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:Ee("Delete"),shortcut_2:Ee(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:Ee("Shift"),shortcut_2:Ee("Alt")}):fG(c[0])?f("hints.lineEditor_line_info",{shortcut:Ee("Enter")}):f("hints.lineEditor_info",{shortcut_1:Ee("CtrlOrCmd"),shortcut_2:Ee(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&EG(c[0])){let d=f("hints.bindTextToElement",{shortcut:Ee("Enter")}),p=f("hints.createFlowchart",{shortcut:Ee(["CtrlOrCmd","\u2191\u2193"])});return gG(c[0])?xG(c[0],o.scene.getNonDeletedElementsMap())?[d,p]:[d,p]:d}}}return null},sP=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let r=wG({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 EE("kbd",{children:c?c[1]:s},l)}return s});return EE("div",{className:"HintViewer",children:EE("span",{children:a})})};import yG from"clsx";import{jsx as vG}from"react/jsx-runtime";var lP=e=>vG($,{className:yG("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?gc:es,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 SG,jsx as De,jsxs as Ml}from"react/jsx-runtime";var IG=({app:e,activeTool:n,setAppState:t})=>{let[o,r]=TG(!1),i=rt()==="full",a=n.type==="frame",s=n.type==="autoshape",l=n.type==="laser",c=n.type==="bucketfill",d=i&&n.type==="lasso"&&e.state.preferredSelectionTool.type!=="lasso",p=n.type==="embeddable";return Ml(ye,{open:o,children:[De(ye.Trigger,{className:cP("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||p||i&&s||d||c||l&&!e.props.isCollaborating}),onToggle:()=>{r(!o),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:a?Hn:p?_o:i&&s?Cr:l&&!e.props.isCollaborating?Gn:d?ts:c?Fn:Qa}),Ml(ye.Content,{onClickOutside:()=>r(!1),onSelect:()=>r(!1),className:"App-toolbar__extra-tools-dropdown",children:[De(ye.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Hn,shortcut:bE.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,disabled:it(e,"frame"),children:f("toolBar.frame")}),De(ye.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:_o,"data-testid":"toolbar-embeddable",selected:p,disabled:it(e,"embeddable"),children:f("toolBar.embeddable")}),De(ye.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Cr,shortcut:Cs("autoshape"),"data-testid":"toolbar-autoshape",selected:s,disabled:it(e,"autoshape"),children:f("toolBar.autoshape")}),De(ye.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Gn,"data-testid":"toolbar-laser",selected:l,shortcut:bE.K.toLocaleUpperCase(),disabled:it(e,"laser"),children:f("toolBar.laser")}),De(ye.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Fn,"data-testid":"toolbar-bucketfill",selected:c,shortcut:bE.B.toLocaleUpperCase(),disabled:it(e,"bucketfill"),children:f("toolBar.bucketfill")}),i&&De(ye.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:ts,"data-testid":"toolbar-lasso",selected:d,disabled:it(e,"lasso"),children:f("toolBar.lasso")})]})]})},dP=({app:e,appState:n,setAppState:t,UIOptions:o,onPenModeToggle:r,onLockToggle:i,heading:a})=>{let s=ue(),l=rt()==="compact",c=n.activeTool,d={app:e,activeTool:c};return Ml(Ue,{padding:1,className:cP("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":l}),"data-viewport-ui":"top",children:[De(sP,{appState:n,isMobile:s.formFactor==="phone",editorInterface:s,app:e}),a,Ml(Lt.Row,{gap:l?.5:1,children:[!l&&De(ya,{checked:n.penMode,onChange:()=>r(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&Ml(SG,{children:[De(lP,{checked:n.activeTool.locked,onChange:i,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),De("div",{className:"App-toolbar__divider",style:{marginRight:"0.25rem"}})]}),De(Ed,{...d,hideKeyBinding:!0}),l?De(yd,{...d,setAppState:t}):n.preferredSelectionTool.type==="lasso"?De(_w,{...d}):De(Dw,{...d}),De(Sw,{...d}),De(Cw,{...d}),De(Pw,{...d}),De(kw,{...d}),De(Mw,{...d}),l?De(vd,{...d}):De(Aw,{...d}),De(bd,{...d}),o.tools?.image!==!1&&De(xd,{...d}),De(wd,{...d}),De("div",{className:"App-toolbar__divider",style:{marginLeft:"0.25rem"}}),De(IG,{app:e,activeTool:c,setAppState:t})]})]})};import{Fragment as xE,jsx as ee,jsxs as $t}from"react/jsx-runtime";var DG=({UIOptions:e})=>$t(_t,{__fallback:!0,children:[ee(_t.DefaultItems.LoadScene,{}),ee(_t.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ee(_t.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ee(_t.DefaultItems.SaveAsImage,{}),ee(_t.DefaultItems.SearchMenu,{}),ee(_t.DefaultItems.Help,{}),ee(_t.Separator,{}),ee(_t.Group,{title:"Excalidraw links",children:ee(_t.DefaultItems.Socials,{})}),ee(_t.Separator,{}),ee(_t.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),ee(_t.DefaultItems.ChangeCanvasBackground,{})]}),_G=()=>$t(ap,{__fallback:!0,children:[ee(ap.Actions.SaveToDisk,{}),ee(ap.Actions.ExportToImage,{})]}),RG=({actionManager:e,appState:n,files:t,setAppState:o,elements:r,canvas:i,onLockToggle:a,onPenModeToggle:s,showExitZenModeBtn:l,renderTopLeftUI:c,renderTopRightUI:d,renderCustomStats:p,UIOptions:m,onExportImage:u,renderWelcomeScreen:E,children:g,app:b,defaultUIEnabled:y,zoomUIEnabled:w,scrollBackToContentUIEnabled:x,isCollaborating:v,generateLinkForSelection:I,currentUserControls:C})=>{let P=ue(),A=bn(),_=rt()==="compact",k=mI(),D=_?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},O=k.tunnelsJotai.Provider,[G,z]=Fe(Nt),W=()=>m.canvasActions.export?ee(oP,{elements:r,appState:n,files:t,actionManager:e,exportOpts:m.canvasActions.export,canvas:i,setAppState:o}):null,j=()=>!m.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:ee(nP,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),X=()=>$t("div",{style:{position:"relative"},children:[$t("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),ee(k.MainMenuTunnel.Out,{})]}),E&&ee(k.WelcomeScreenMenuHintTunnel.Out,{})]}),oe=()=>ee(bl,{heading:"selectedShapeActions",className:Aa("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?ee(Ue,{className:Aa("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:ee(MI,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):ee(Ue,{className:PG.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:ee(II,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),B=()=>{let de=y&&AG(n,r),pe=y&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return ee(qm,{side:"top",children:$t("div",{className:"App-menu App-menu_top",children:[$t(Lt.Col,{gap:D.menuTopGap,className:Aa("App-menu_top__left"),children:[X(),y&&ee("div",{className:Aa("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:de&&oe()}),y&&_&&!n.viewModeEnabled&&de&&ee(ya,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),y&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&ee(bl,{heading:"shapes",className:"shapes-section",children:xe=>$t("div",{style:{position:"relative"},children:[E&&ee(k.WelcomeScreenToolbarHintTunnel.Out,{}),ee(Lt.Col,{gap:D.toolbarColGap,align:"start",children:$t(Lt.Row,{gap:D.toolbarRowGap,className:Aa("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[ee(dP,{app:b,appState:n,setAppState:o,UIOptions:m,onPenModeToggle:s,onLockToggle:a,heading:xe}),v&&ee(Ue,{style:{marginLeft:D.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:ee(rP,{title:f("toolBar.laser"),checked:n.activeTool.type===mP.laser,onChange:()=>b.setActiveTool({type:mP.laser}),isMobile:!0})})]})})]})}),$t("div",{className:Aa("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(tp,{collaborators:n.collaborators,userToFollow:A.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),pe&&ee(Cl,{app:b,onClose:()=>{e.executeAction(jo)},renderCustomStats:p})]})]})})},U=()=>null,me=!1,be=$t(xE,{children:[g,y&&ee(xE,{children:ee(DG,{UIOptions:m})}),ee(_G,{}),y&&n.isLoading&&ee(Ym,{delay:250}),y&&n.errorMessage&&ee(YC,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),y&&G&&P.formFactor!=="phone"&&ee(u0,{colorPickerType:G.colorPickerType,onCancel:()=>{z(null)},onChange:(de,pe,xe,{altKey:ae})=>{if(!(de!=="elementBackground"&&de!=="elementStroke"))if(xe.length){for(let we of xe)MG(we,kG(r),{[ae&&G.swapPreviewOnAlt?de==="elementBackground"?"strokeColor":"backgroundColor":de==="elementBackground"?"backgroundColor":"strokeColor"]:pe}),LG.delete(we);b.scene.triggerUpdate()}else o(de==="elementBackground"?{currentItemBackgroundColor:pe}:{currentItemStrokeColor:pe})},onSelect:(de,pe)=>{z(xe=>xe?.keepOpenOnAlt&&pe.altKey?xe:null),G?.onSelect?.(de,pe)}}),n.openDialog?.name==="help"&&ee(ZC,{onClose:()=>{o({openDialog:null})}}),y&&n.openDialog?.name==="elementLinkSelector"&&ee(VC,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:I}),ee(k.OverwriteConfirmDialogTunnel.Out,{}),j(),W(),y&&n.openDialog?.name==="charts"&&ee(bS,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),P.formFactor==="phone"&&ee(aS,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:W,renderImageExportDialog:j,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:U,renderWelcomeScreen:E,defaultUIEnabled:y,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&$t(xE,{children:[A.viewportStatusFrame?.border&&ee(Um,{border:A.viewportStatusFrame.border,style:me?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),$t("div",{className:"layer-ui__wrapper",style:me?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&ee(k.WelcomeScreenCenterTunnel.Out,{}),B(),ee(SS,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:y,zoomUIEnabled:w}),(n.toast||x&&n.scrolledOutside||A.viewportStatusFrame?.label)&&$t("div",{className:"floating-status-stack",children:[n.toast&&ee(Cd,{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=>({...ai(r,de)}))},children:f("buttons.scrollBackToContent")}),A.viewportStatusFrame?.label&&ee(Wm,{label:A.viewportStatusFrame.label,border:A.viewportStatusFrame.border})]})]}),U()]})]});return ee(Ku.Provider,{value:n,children:ee(O,{children:ee(Cf.Provider,{value:k,children:be})})})},pP=e=>{let{cursorButton:n,scrollX:t,scrollY:o,zoom:r,shouldCacheIgnoreZoom:i,snapLines:a,originSnapOffset:s,suggestedBinding:l,frameToHighlight:c,elementsToHighlight:d,...p}=e;return p},NG=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return yp(pP(o),pP(a),{selectedElementIds:yp,selectedGroupIds:yp})&&yp(r,s)},uP=CG.memo(RG,NG);import{useEffect as BG,useRef as OG}from"react";import{jsx as hP}from"react/jsx-runtime";var gP=({trails:e})=>{let n=OG(null);return BG(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),hP("div",{className:"SVGLayer",children:hP("svg",{ref:n})})};import FG from"clsx";import zG from"lodash.debounce";import{Fragment as HG,memo as GG,useEffect as Al,useMemo as fP,useRef as wE,useState as EP}from"react";import{CLASSES as UG,EVENT as WG,FONT_FAMILY as yE,FRAME_STYLE as vE,getLineHeight as VG}from"@excalidraw/common";import{getCommonBounds as YG,isElementCompletelyInViewport as KG}from"@excalidraw/element";import{measureText as Ll}from"@excalidraw/element";import{KEYS as La,randomInteger as bP,addEventListener as XG,getFontString as vp}from"@excalidraw/common";import{newTextElement as $G}from"@excalidraw/element";import{isTextElement as vP,isFrameLikeElement as Tp}from"@excalidraw/element";import{getDefaultFrameName as TP}from"@excalidraw/element/frame";import{Fragment as rU,jsx as ht,jsxs as Zn}from"react/jsx-runtime";var ZG=Ze(""),TE=Ze(null),jG=350,IP=()=>{let e=Tt(),n=Ne(),t=wE(null),[o,r]=Fe(ZG),i=o.trim(),[a,s]=EP(!1),[l,c]=EP({nonce:null,items:[]}),d=wE(null),p=wE(void 0),[m,u]=Fe(TE),E=e.scene.getNonDeletedElementsMap();Al(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==p.current)&&(d.current=null,yP(i,e,(x,v)=>{c({nonce:bP(),items:x}),d.current=i,p.current=e.scene.getSceneNonce(),n({searchMatches:x.length?{focusedId:null,matches:x.map(I=>({id:I.element.id,focus:!1,matchedLines:I.matchedLines}))}:null})}))},[a,i,E,e,n,u,p]);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)};Al(()=>{n(x=>x.searchMatches?{searchMatches:{focusedId:m!==null&&x.searchMatches?.matches[m]?.id||null,matches:x.searchMatches.matches.map((I,C)=>C===m?{...I,focus:!0}:{...I,focus:!1})}}:null)},[m,n]),Al(()=>{if(l.items.length>0&&m!==null){let x=l.items[m];if(x){let v=e.state.zoom.value,I=$G({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:Tp(x.element)?vE.nameFontSize:x.element.fontSize,fontFamily:Tp(x.element)?yE.Assistant:x.element.fontFamily}),C=14,P=I.fontSize,A=P*v<C;if(!KG([I],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.viewport.getOffsets())||A){let L=A&&P<C?"contain":"scale-down";e.viewport.setViewport({target:YG([I]),fit:L,animation:{duration:300},offsets:{ui:!0}})}}}},[m,l,e]),Al(()=>()=>{u(null),d.current=null,p.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let y=wi({goToNextItem:g,goToPreviousItem:b,searchMatches:l});Al(()=>{let x=v=>{if(v.key===La.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),n({openSidebar:null});return}if(v[La.CTRL_OR_CMD]&&v.key===La.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&n({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&y.searchMatches.items.length&&(v.key===La.ENTER&&(v.stopPropagation(),y.goToNextItem()),v.key===La.ARROW_UP?(v.stopPropagation(),y.goToPreviousItem()):v.key===La.ARROW_DOWN&&(v.stopPropagation(),y.goToNextItem()))};return XG(window,WG.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 Zn("div",{className:"layer-ui__search",children:[ht("div",{className:"layer-ui__search-header",children:ht(bp,{className:UG.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:Un,onChange:x=>{r(x),s(!0);let v=x.trim();yP(v,e,(I,C)=>{c({nonce:bP(),items:I}),u(C),d.current=v,p.current=e.scene.getSceneNonce(),n({searchMatches:I.length?{focusedId:null,matches:I.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),s(!1)})},selectOnRender:!0})}),Zn("div",{className:"layer-ui__search-count",children:[l.items.length>0&&Zn(rU,{children:[m!==null&&m>-1?Zn("div",{children:[m+1," / ",w]}):ht("div",{children:w}),Zn("div",{className:"result-nav",children:[ht(Mn,{onSelect:()=>{g()},className:"result-nav-btn",children:Cc}),ht(Mn,{onSelect:()=>{b()},className:"result-nav-btn",children:W1})]})]}),l.items.length===0&&i&&d.current&&ht("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),ht(QG,{matches:l,onItemClick:u,focusIndex:m,searchQuery:i})]})},xP=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 ht("div",{tabIndex:-1,className:FG("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ht("div",{className:"preview-text",children:n.flatMap((t,o)=>ht(HG,{children:o===2?ht("b",{children:t}):t},o))})})},qG=e=>{let n=fP(()=>e.matches.items.filter(o=>Tp(o.element)),[e.matches]),t=fP(()=>e.matches.items.filter(o=>vP(o.element)),[e.matches]);return Zn("div",{children:[n.length>0&&Zn("div",{className:"layer-ui__search-result-container",children:[Zn("div",{className:"layer-ui__search-result-title",children:[ht("div",{className:"title-icon",children:Hn}),ht("div",{children:f("search.frames")})]}),n.map((o,r)=>ht(xP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&ht("div",{className:"layer-ui__divider"})]}),t.length>0&&Zn("div",{className:"layer-ui__search-result-container",children:[Zn("div",{className:"layer-ui__search-result-title",children:[ht("div",{className:"title-icon",children:En}),ht("div",{children:f("search.texts")})]}),t.map((o,r)=>ht(xP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},JG=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,QG=GG(qG,JG),wP=(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 p=e.slice(n+t.length),m=p.split(/\s+/),u=!p.startsWith(" "),E=u?6:5,g=(u?"":" ")+m.slice(0,E).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+g,moreBefore:l>0,moreAfter:m.length>E}},eU=(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 Ia}from"@excalidraw/math";import{FONT_FAMILY as eB,FONT_SIZES as tB,getFontString as nB,getLineHeight as oB,ROUGHNESS as MI}from"@excalidraw/common";import{measureText as rB,newLinearElement as gf,newTextElement as iB}from"@excalidraw/element";var AI=(e,n,t,o)=>{if(!Ea(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,W)=>`Value ${W+1}`),i=e.series,{normalize:a,renderSteps:s}=vI(i,r.length),l=wa(o),c=ya(l),d=xa(i.length,l),{chartWidth:m,chartHeight:p}=yI(),u=n+m/2,E=t-p/2,g=ua/2,b=r.map((z,W)=>-Math.PI/2+Math.PI*2*W/r.length),{axisLabels:y,axisLabelTopY:w,axisLabelBottomY:x}=II(r,b,u,E,g,c),v=eB["Lilita One"],T=tB.xl,C=oB(v),P=nB({fontFamily:v,fontSize:T}),A=e.title?Mm(e.title,P,m+ha*2):null,L=A?rB(A,P,C):null,_=A?iB({backgroundColor:c,..._e,text:A,originalText:e.title??A,x:n+m/2,y:w-ha-L.height/2,fontFamily:v,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:rf},(z,W)=>{let $=(W+1)/rf,H=g*$,re=b.map(B=>Ia(Math.cos(B)*H,Math.sin(B)*H));return re.push(Ia(re[0][0],re[0][1])),gf({backgroundColor:"transparent",..._e,type:"line",x:u,y:E,width:H*2,height:H*2,strokeStyle:"solid",roughness:MI.architect,opacity:jr,polygon:!0,points:re})}):[],D=b.map(z=>{let W=Math.cos(z)*g,$=Math.sin(z)*g;return gf({backgroundColor:"transparent",..._e,type:"line",x:u,y:E,width:Math.abs(W),height:Math.abs($),strokeStyle:"solid",roughness:MI.architect,opacity:jr,points:[Ia(0,0),Ia(W,$)]})}),F=i.map((z,W)=>{let $=b.map((H,re)=>{let B=z.values[re]??0,U=a(B,re)*g;return Ia(Math.cos(H)*U,Math.sin(H)*U)});return $.push(Ia($[0][0],$[0][1])),gf({backgroundColor:"transparent",..._e,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[W],strokeWidth:2,polygon:!0,points:$})}),Y=va(i,d,u,x,t+Kn*5,c);return[..._?[_]:[],...y,...k,...D,...F,...Y]};var ff=(e,n,t,o,r)=>e==="line"?PI(n,t,o,r):e==="radar"?AI(n,t,o,r):SI(n,t,o,r);import{clamp as _m,pointFrom as Ta,pointsEqual as pB,bezierEquation as HI,pointRotateRads as Rm,pointDistance as uB}from"@excalidraw/math";import{arrayToMap as hB,BIND_MODE_TIMEOUT as yl,DEFAULT_TRANSFORM_HANDLE_SPACING as GI,FRAME_STYLE as mn,getFeatureFlag as gB,invariant as NI,shouldRotateWithDiscreteAngle as UI,THEME as bo}from"@excalidraw/common";import{deconstructDiamondElement as yf,deconstructRectanguloidElement as WI,elementCenterPoint as Sa,getDiamondBaseCorners as fB,FOCUS_POINT_SIZE as EB,getOmitSidesForEditorInterface as Ef,getTransformHandles as bB,getTransformHandlesFromCoords as xB,hasBoundingBox as wB,hitElementItself as yB,isArrowElement as VI,isBindableElement as YI,isElbowArrow as Ca,isFrameLikeElement as Pa,isImageElement as Nm,isLinearElement as vB,isLineElement as IB,maxBindingDistance_simple as TB,isTextElement as SB,LinearElementEditor as pn,getActiveTextElement as CB,getElementsInGroup as vf,getSelectedGroupIds as PB,isSelectedViaGroup as kB,selectGroupsFromGivenElements as MB}from"@excalidraw/element";import{renderSelectionElement as AB}from"@excalidraw/element";import{getCommonBounds as If,getElementAbsoluteCoords as Il}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as BI,isFocusPointVisible as LB}from"@excalidraw/element";import{pointFrom as St}from"@excalidraw/math";import{THEME as aB}from"@excalidraw/common";var sB="#ff6b6b",lB="#ff0000",LI=1,DI=2,_I=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===aB.LIGHT||n.zenModeEnabled?sB:lB,o=(n.zenModeEnabled?LI*1.5:LI)/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,dB(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,mB(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,cB(r,e,n));e.restore()},cB=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];dn(o,r,n)}for(let o of e.points)RI(o,t,n)},dB=(e,n,t)=>{RI(e.points[0],t,n),t.zenModeEnabled||dn(e.points[0],e.points[1],n)},RI=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?DI*1.5:DI)/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()},dn=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},mB=(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||dn(St(e[0],e[1]-i),St(e[0],e[1]+i),r),dn(St(l[0]-s,l[1]-a),St(l[0]-s,l[1]+a),r),dn(St(l[0]+s,l[1]-a),St(l[0]+s,l[1]+a),r),o.zenModeEnabled||(dn(St(n[0],n[1]-i),St(n[0],n[1]+i),r),dn(e,n,r))}else{let l=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||dn(St(e[0]-i,e[1]),St(e[0]+i,e[1]),r),dn(St(l[0]-a,l[1]-s),St(l[0]+a,l[1]-s),r),dn(St(l[0]-a,l[1]+s),St(l[0]+a,l[1]+s),r),o.zenModeEnabled||(dn(St(n[0]-i,n[1]),St(n[0]+i,n[1]),r),dn(e,n,r))}};var DB=(e,n)=>{NI(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;NI(t,"midPointCoords is null"),Bm(t,e,n)},_B=(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=pn.getElement(o,t);if(!i)return;let a=pn.getPointAtIndexGlobalCoordinates(i,r,t);Bm(a,e,n)},Bm=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",is(n,e[0],e[1],pn.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},RB=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!VI(i)||i.isDeleted)return;let a=r==="label"?pn.getBoundTextElementCenter(i,t):pn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);Bm(a,e,n)},bf=(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)"),is(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},NB=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&Pa(a)&&(e.translate(a.x,a.y),e.beginPath(),mn.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,mn.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=mn.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===bo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",mn.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,mn.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=Sa(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=_m(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===bo.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]=yf(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]=WI(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&&(Pa(n.element)||YI(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&pn.getElement(s?.elementId,t),c=r&&yB({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&Ca(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let m=Sa(n.element,t),p;if(n.element.type==="diamond"){let b=Sa(n.element,t);p=fB(n.element).map(y=>{let w=HI(y,.5),x=Rm(w,b,n.element.angle);return Ta(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=Ta(y.x+n.element.x,y.y+n.element.y),x=Rm(w,m,n.element.angle);return Ta(x[0],x[1])});let u=r&&p.reduce((b,y,w)=>{let x=uB(y,r);return w===-1||x<b.distance?{idx:w,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=TB(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===bo.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===bo.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()}}},BB=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=yl-(a?.runtime??(s?0:yl)),c=_m(1/yl*l,1e-4,1),d=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&Pa(m)&&(n.translate(m.x,m.y),n.beginPath(),mn.radius&&n.roundRect?n.roundRect(-1,-1,m.width+1,m.height+1,mn.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=mn.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===bo.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,mn.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,mn.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=Sa(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=_m(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===bo.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]=yf(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,v,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(v[0]-t.x+d,v[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]=WI(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,v,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(v[0]-t.x+d,v[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)>yl)return;let p=.5*(Math.min(t.width,t.height)/2);if(!Pa(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/yl*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||!UI(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]=yf(t),x=Sa(t,o);y=w.map(v=>{let T=HI(v,.5),C=Rm(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let w=Sa(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(v=>{let T=Ta(v.x+t.x,v.y+t.y),C=Rm(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===bo.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}},OB=(e,n,t,o,r,i,a)=>{if(t===null)return;if(gB("COMPLEX_BINDINGS"))return BB(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Ta(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&UI(e.lastPointerMoveEvent);NB(n,t,o,r,s,l),n.restore()},XI=(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??GI*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 v=0;v<x;++v)e.strokeStyle=l[v],m&&e.setLineDash([y,w+(y+w)*(x-1)]),e.lineDashOffset=(y+w)*v,as(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},FB=(e,n,t,o)=>{let[r,i,a,s]=Il(t,o),l=a-r,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=mn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),as(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,mn.radius/n.zoom.value),e.restore()},OI=(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]=If(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=vf(t,d);return l(m)};Object.entries(MB(s,n)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>XI(e,n,d))},xf=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=pn.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=pn,a=n.selectedLinearElement?.isEditing?i:i/2,s=Ca(t),l=IB(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)&&pB(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),bf(e,n,c,a,p,!1,m)}),Ca(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,m)=>{pn.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||bf(e,n,Ta((d[0]+r[m+1][0])/2,(d[1]+r[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else pn.getEditorMidPoints(t,o,n).filter((d,m,p)=>d!==null&&!(Ca(t)&&(m===0||m===p.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&bf(e,n,d,i/2,!1,!0,!1)});e.restore()},zB=(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()},HB=(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)",is(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},FI=({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||!YI(a)||a.isDeleted)return;let s=BI(i.fixedPoint,a,r);if(!LB(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&&Bm(s,o,n),!(m&&c)){let p=BI(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=pn.getPointAtIndexGlobalCoordinates(e,d,r);zB(o,n,E,p),HB(o,n,p,EB/1.5,u)}},zI=(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"?is(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()):as(e,s,l,c,d,s+c/2,l+d/2,r,!0),e.restore()}})},GB=(e,n,t,o,r)=>{let[i,a,,,s,l]=Il(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,v],[T,C],[P,A],[L,_],[k,D]]=w;e.save(),e.translate(s,l),e.rotate(o.angle),e.beginPath(),e.moveTo(x+T,v+C),e.lineTo(x+P,v+A),e.stroke(),e.beginPath(),e.moveTo(x+L,v+_),e.lineTo(x+k,v+D),e.stroke(),e.restore()}),e.restore()},UB=(e,n,t,o)=>{n.save();let r=Zg(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()},WB=(e,n,t,o,r)=>{let i=jg(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())},VB=(e,n,t,o,r,i)=>{for(let a of n){if(!Nm(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(s?.downloadError===null?!1:a.status==="error"||!!s?.downloadError){let d=vl(a,t,r,"center");d&&$I(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=vl(a,t,r,"center");m&&KI(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=vl(a,t,r,"top-right");d&&XB(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},vl=(e,n,t,o)=>{if(!Nm(e))return null;let[r,i,a,s]=Il(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}},KI=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===bo.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*_m(i,0,1)),e.stroke()),e.restore()},wf=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,YB=(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()},XB=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",c=i.color??wf("--color-primary",s),d=i.color??wf("--color-warning-darkest","#ec8b14");if(l==="failed"){$I(e,n,t,o,a,{color:i.color??wf("--color-danger","#e03131")});return}if(l==="uploading"&&KI(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),YB(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())},$I=(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()},KB=({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]=Ec(n,a),E=d,g=bc({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&&xf(g,s,b,t),s.selectionElement&&!s.isCropping)try{AB(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let y=CB(r,s);if(y&&!y.autoResize&&WB(y,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&UB(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:OB(e,g,s.suggestedBinding,i,s,m,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&RB(g,s,i),s.frameToHighlight&&FB(g,s,s.frameToHighlight,t),s.elementsToHighlight&&OI(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:vf(i,s.activeLockedId);OI(g,s,P,{colors:["#ced4da"],dashed:!0})}let w=r.some(C=>Pa(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&xf(g,s,r[0],t);let x=s.selectedLinearElement,v=x&&pn.getElement(x.elementId,i);if(v&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?DB(g,s):(Ca(v)?x.hoverPointIndex===0||x.hoverPointIndex===v.points.length-1:x.hoverPointIndex>=0)&&_B(g,s,t)),VI(v)&&(FI({arrow:v,elementsMap:i,appState:s,context:g,type:"start"}),FI({arrow:v,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=wB(r,s,c),P=r.length===1&&vB(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&xf(g,s,r[0],t);let A=l.selectionColor||"#000";if(C){let L=hB(r),_=[];for(let D of t.values()){let F=[],Y=l.remoteSelectedElementIds.get(D.id);if(P&&Ca(D)&&(D.startBinding||D.endBinding)||(L.has(D.id)&&!kB(s,D)&&F.push(A),Y&&F.push(...Y.map(z=>Gr(z,s.collaborators.get(z))))),F.length){let[z,W,$,H,re,B]=Il(D,t,!0);_.push({angle:D.angle,x1:z,y1:W,x2:$,y2:H,selectionColors:D.locked?["#ced4da"]:F,dashed:!!Y||D.locked,cx:re,cy:B,activeEmbeddable:s.activeEmbeddable?.element===D&&s.activeEmbeddable.state==="active",padding:D.id===s.croppingElementId||Nm(D)?0:void 0})}}let k=D=>{let F=vf(t,D),[Y,z,W,$]=If(F);_.push({angle:0,x1:Y,x2:W,y1:z,y2:$,selectionColors:F.some(H=>H.locked)?["#ced4da"]:["#000"],dashed:!0,cx:Y+(W-Y)/2,cy:z+($-z)/2,activeEmbeddable:!1})};for(let D of PB(s))k(D);s.editingGroupId&&k(s.editingGroupId),_.forEach(D=>XI(g,s,D))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let L=bB(r[0],s.zoom,t,"mouse",Ef(c));if(!s.viewModeEnabled&&C&&!SB(s.editingTextElement)&&!s.croppingElementId&&zI(g,l,s,L,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&Nm(_)&&GB(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(L=>L.locked)){let L=GI*2/s.zoom.value;g.fillStyle="#fff";let[_,k,D,F]=If(r,t),Y=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=A,as(g,_-L,k-L,D-_+L*2,F-k+L*2,(_+D)/2,(k+F)/2,0),g.lineWidth=z,g.setLineDash(Y);let W=xB([_,k,D,F,(_+D)/2,(k+F)/2],0,s.zoom,"mouse",w?{...Ef(c),rotation:!0}:Ef(c));r.some($=>!$.locked)&&zI(g,l,s,W,0)}g.restore()}s.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:A})=>{let L=t.get(C);if(L){let[_,k,,,D,F]=Il(L,t,!0);g.save(),s.theme===bo.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=Pa(L)?s.zoom.value:1;g.translate(s.scrollX,s.scrollY),g.translate(D,F),g.rotate(L.angle),A.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/Y-D,k+z.offsetY/Y-F,z.width/Y,z.height/Y)}),g.restore()}}),_I(g,s),VB(g,o,t,e,s,l.selectionColor),g.restore(),uy({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let T;return l.renderScrollbars&&(T=O2(t,p,u,s),g.save(),g.fillStyle=B2,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&Kd(g,C.x,C.y,C.width,C.height,cn/2)}),g.restore()),{scrollBars:T,animationState:E}},Tf=e=>{let n=KB(e);return e.callback(n),n};import{useEffect as Pl,useMemo as ZI,useRef as Mf,useState as $B}from"react";import{bumpVersion as Tl,getLinearElementSubType as Ma,mutateElement as Af,updateElbowArrowPoints as ZB}from"@excalidraw/element";import{pointFrom as Fm,pointRotateRads as jB}from"@excalidraw/math";import{hasBoundTextElement as qB,isArrowBoundToElement as JB,isArrowElement as QB,isElbowArrow as eO,isLinearElement as Rf,isUsingAdaptiveRadius as tO}from"@excalidraw/element";import{getCommonBoundingBox as nO,getElementAbsoluteCoords as oO}from"@excalidraw/element";import{getBoundTextElement as eT,getBoundTextMaxHeight as rO,getBoundTextMaxWidth as iO,redrawTextBoundingBox as aO}from"@excalidraw/element";import{wrapText as sO}from"@excalidraw/element";import{assertNever as lO,CLASSES as cO,getFontString as Sf,isProdEnv as dO,mapFind as mO,reduceToCommonValue as pO,ROUNDNESS as Cf,sceneCoordsToViewportCoords as uO,updateActiveTool as jI}from"@excalidraw/common";import{measureText as qI}from"@excalidraw/element";import{LinearElementEditor as hO}from"@excalidraw/element/linearElementEditor";import{newArrowElement as Pf,newElement as gO,newLinearElement as fO}from"@excalidraw/element";import{ShapeCache as EO}from"@excalidraw/element";import{updateBindings as bO}from"@excalidraw/element";import{jsx as _f}from"react/jsx-runtime";var xO=8,wO=10,Sl=["rectangle","diamond","ellipse"],Cl=["line","sharpArrow","curvedArrow","elbowArrow"],yO=new Set(Sl),vO=new Set(Cl),Aa=e=>yO.has(e),zm=e=>e==="arrow"||vO.has(e),$n=je(null),kl=new Map,Ml=new Map,IO=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=Mf(null);return Pl(()=>{if(n.length===0){e.updateEditorAtom($n,null);return}let o=Hm(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom($n,null),t.current=null)},[n,e]),Pl(()=>()=>{kl.clear(),Ml.clear()},[]),_f(TO,{app:e,elements:n})},TO=({app:e,elements:n})=>{let t=Hm(n),o=ZI(()=>t==="generic"?nT(n):[],[t,n]),r=ZI(()=>t==="linear"?Df(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>Ma(m)===Ma(r[0])):!1,[a,s]=$B({x:0,y:0}),l=Mf(""),c=Mf(null);Pl(()=>{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]=oO(m[0],e.scene.getNonDeletedElementsMap());u=jB(Fm(b,y),Fm(w,x),m[0].angle)}else{let{minX:b,maxY:y}=nO(m);u=Fm(b,y)}let{x:E,y:g}=uO({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),Pl(()=>{for(let m of r){let p=Lf(m.id,MO(m));Ml.has(p)||Ml.set(p,m)}},[r]),Pl(()=>{for(let m of o)if(!kl.has(m.id)){let p=eT(m,e.scene.getNonDeletedElementsMap());p&&kl.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",Bo],["sharpArrow",zo],["curvedArrow",Go],["elbowArrow",Ho]]:t==="generic"?[["rectangle",Ei],["diamond",bi],["ellipse",xi]]:[];return _f("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(wO+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-xO}px`,zIndex:2},className:cO.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&Ma(r[0])===m);return _f(K,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&Ne("convertElementType",m,"ui"),Nf(e,{conversionType:t,nextType:m}),c.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},SO=(e,n,t)=>{let o=iO(e,n),r=rO(e,n),i=sO(n.text,Sf(n),o),a=qI(i,Sf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=qI(n.text,Sf(l),n.lineHeight)}Af(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),aO(n,e,t)},Nf=(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=nT(r),c=s.every(d=>d.type===s[0].type)?Sl.indexOf(s[0].type):-1;if(t=t??Sl[(c+Sl.length+a)%Sl.length],t&&Aa(t)){let d={};for(let p of s){let u=QI(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=eT(p,e.scene.getNonDeletedElementsMap());u&&(kl.get(p.id)&&Af(u,e.scene.getNonDeletedElementsMap(),{fontSize:kl.get(p.id)?.fontSize??u.fontSize}),SO(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:jI(p,{type:"selection"})}))}}if(n==="linear"){let s=Df(r);if(!t){let c=pO(s,Ma),d=c?Cl.indexOf(c):-1;t=Cl[(d+Cl.length+a)%Cl.length]}if(zm(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=Ml.get(Lf(m.id,t));if(p&&Ma(p)===t)d.set(p.id,p),c.push(p);else{let u=QI(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(Rf(m))if(eO(m)){let p=CO(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=ZB(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Af(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=mO(["line","sharpArrow","curvedArrow"],u=>Ml.get(Lf(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let l=Df(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new hO(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:jI(c,{type:"selection"})}))}return!0},Hm=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(Aa(t.type))return"generic";tT(t)&&(n=!0)}return n?"linear":null},tT=e=>Rf(e)&&(!QB(e)||!JB(e)&&!qB(e)),Lf=(e,n)=>`${e}:${n}`,nT=e=>e.filter(n=>Aa(n.type)),Df=e=>e.filter(n=>tT(n)),Om=20,ka=(e,n)=>e[0]===n[0],kf=(e,n)=>e[1]===n[1],JI=(e,n)=>ka(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),CO=e=>{let n=[e.points[0]],t=PO(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])<Om?s[0]=a[0]:Math.abs(s[1]-a[1])<Om&&(s[1]=a[1]),ka(a,s)||kf(a,s)||n.push(Fm(a[0],s[1])),n.push(s)}let o=[n[0]];for(let i=1;i<n.length-1;++i)ka(n[i-1],n[i])&&ka(n[i],n[i+1])||kf(n[i-1],n[i])&&kf(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=ka(a,s),d=ka(s,l);if(c!==d){let m=JI(a,s),p=JI(s,l);if(m<Om||p<Om){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},PO=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},QI=(e,n,t)=>{if(!kO(e.type,n)){if(!dO())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(EO.delete(e),Aa(n)){let o=Tl(gO({...e,type:n,roundness:e.roundness?{type:tO(n)?Cf.ADAPTIVE_RADIUS:Cf.PROPORTIONAL_RADIUS}:e.roundness}));return bO(o,t.scene,t.state),o}if(zm(n))switch(n){case"line":return Tl(fO({...e,type:"line"}));case"sharpArrow":return Tl(Pf({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Tl(Pf({...e,type:"arrow",elbowed:!1,roundness:{type:Cf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Tl(Pf({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return lO(n,`unhandled conversion type: ${n}`),e},kO=(e,n)=>!!(Aa(e)&&Aa(n)||zm(e)&&zm(n)),MO=e=>Rf(e)?Ma(e):e.type,oT=IO;import{bindBindingElementToFixedPoint as AO,dragNewTextElement as LO,getBoundTextElement as DO,getEndpointBoundTextDragAnchor as _O,getTextBindingForArrowEndpoint as RO,getUnboundArrowEndpointAtPoint as NO,isArrowElement as BO,isBindingEnabled as OO,isEndpointBoundText as FO,isTextElement as zO}from"@excalidraw/element";import{pointFrom as HO}from"@excalidraw/math";var Gm=class{constructor(n){this.app=n;I(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});I(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(n,t){if(!OO(this.app.state))return null;let o=NO(HO(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!BO(r)||DO(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 RO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){AO(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!zO(n)||!FO(n,this.app.scene.getNonDeletedElementsMap())?!1:(LO({newElement:n,..._O(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as GO,BUCKET_FILL_BACKGROUND_PICKS as UO,COLOR_PALETTE as iT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as WO,getSizeFromPoints as VO,isTransparent as YO,THEME as XO}from"@excalidraw/common";import{pointFrom as rT}from"@excalidraw/math";import{computeBucketFillPolygon as KO,isBucketFillCompatible as $O,isFrameLikeElement as ZO,isRestylableFill as jO,newLinearElement as qO,ShapeCache as JO}from"@excalidraw/element";var Bf=UO.filter(e=>e!==iT.white),Um=class{constructor(n){this.app=n;I(this,"temporaryEyeDropper",null);I(this,"pending",null);I(this,"handlePointerDown",n=>{this.pending=n});I(this,"handlePointerUp",()=>{let n=this.pending;this.pending=null,n&&this.fill(n)});I(this,"cancel",()=>{this.pending=null});I(this,"cycleBackgroundColor",()=>{let n=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=Bf.indexOf(n),o=Bf[(t+1)%Bf.length];this.app.actionManager.executeAction(Ed,"keyboard",{currentItemBackgroundColor:o})});I(this,"openTemporaryEyeDropper",()=>{if(gt.get(Nt))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(Ed,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Nt,n)});I(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&gt.get(Nt)===n&&this.app.updateEditorAtom(Nt,null)});I(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}),JO.delete(n),this.app.scheduleCapture())});I(this,"fill",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),o=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=rT(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=KO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&$O(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&&jO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=VO(s.scenePoints),[d,m]=s.scenePoints[0],p=s.scenePoints.map(w=>rT(w[0]-d,w[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?ZO(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(v=>x.includes(v)),null)??[],b=qO({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()});I(this,"getBucketFillBackgroundColor",(n,t)=>YO(n)?iT.green[WO]:GO(n,t===XO.DARK))}};import{CURSOR_TYPE as Al,MIME_TYPES as Vm,THEME as aT}from"@excalidraw/common";var sT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',QO='<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"/>',lT='<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"/>',eF=`data:${Vm.svg},${encodeURIComponent(`${sT}${lT}</svg>`)}`,tF=`data:${Vm.svg},${encodeURIComponent(`${sT}${QO}${lT}</svg>`)}`,nF=e=>{let n=fu.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${Vm.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>`)}`},Wm=class{constructor(n){this.app=n;I(this,"toolCursorMemo",null);I(this,"eraserCanvasCache",null);I(this,"eraserPreviewDataURL",null);I(this,"set",n=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=n)});I(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(Al.GRAB):this.clear():this.applyForTool()});I(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(os({activeTool:n}))this.set(Al.GRAB);else if(qt({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(Al.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${nF(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===aT.LIGHT?eF:tF;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(Al.AUTO):this.set(Al.CROSSHAIR);this.toolCursorMemo={canvas:t,type:n.type,bucketFillColor:r,theme:o}}});I(this,"clear",()=>{this.set("")});I(this,"applyEraser",()=>{let t=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==t){let o=t===aT.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(Vm.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as sF}from"@excalidraw/common";import{bindBindingElement as lF,convertToShape as cF,convertToShapeHandlePointerMoveFromPointerDown as dF,getHoveredElementForBinding as cT,isBindingElement as mF,isLineElement as pF,LinearElementEditor as Of,maxBindingDistance_simple as dT,newArrowElement as uF,updateBoundPoint as hF}from"@excalidraw/element";import{getStrokeWidthByKey as oF,THEME as rF}from"@excalidraw/common";import{clamp as iF,pointFrom as aF}from"@excalidraw/math";var Ym=class{constructor(n){this.app=n;I(this,"trail");this.trail=new Pn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===rF.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>iF(oF("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])=>aF(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var Xm=class{constructor(n){this.app=n;I(this,"trail");I(this,"gestureInProgress",!1);I(this,"stop",()=>{this.trail.stop()});I(this,"hasPendingGesture",()=>this.gestureInProgress);I(this,"handlePointerDown",n=>{this.gestureInProgress&&this.app.actionManager.executeAction(dt),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});I(this,"handlePointerMove",n=>dF(this.app,n));I(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=dT(t.state.zoom),a=["start","end"].map(d=>{let m=Of.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:m,target:cT(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&&lF(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=hF(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&&Of.movePoints(n,t.scene,c)});I(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=dT(t.state.zoom),[a,s]=[0,-1].map(l=>cT(Of.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:uF({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})});I(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||cF(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:sF(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&pF(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&mF(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new Ym(n)}};import{isArrowKey as gF,KEYS as Jr}from"@excalidraw/common";import{makeNextSelectedElementIds as fF,CaptureUpdateAction as EF,FlowChartCreator as bF,FlowChartNavigator as xF,getSelectedElements as mT,isFlowchartNodeElement as wF}from"@excalidraw/element";var Km=class e{constructor(n){this.app=n;I(this,"creator",new bF);I(this,"navigator",new xF);I(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});I(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===Jr.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!gF(n.key))return{type:"none"};if(n[Jr.CTRL_OR_CMD]&&!n.shiftKey){let a=mT(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&wF(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=mT(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[Jr.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:fF({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:EF.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case Jr.ARROW_UP:return"up";case Jr.ARROW_DOWN:return"down";case Jr.ARROW_RIGHT:return"right";case Jr.ARROW_LEFT:return"left";default:return"right"}}};import{debounce as yF,easeOut as ET,isBounds as vF}from"@excalidraw/common";import{clamp as bT}from"@excalidraw/math";import{getCommonBounds as pT,getElementsInGroup as IF,isElementLink as TF,isExcalidrawElement as SF,parseElementLinkFromURL as CF}from"@excalidraw/element";var $m="animateScrollToContent",La="animateScrollConstraintsSnapBack",uT=500,PF=250,kF=200,Ff=302,hT={full:216,compact:64},MF=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")},AF=(e,n)=>{let t=n.get(e);return t?[t]:IF(n,e)},gT=(e,n,t)=>{if(typeof e=="string"){let a=TF(e),s=a?"link":"element",l=a?CF(e):e,c=l?AF(l,n):[];return c.length?{bounds:pT(c,n),type:s}:{bounds:null,type:s}}if(vF(e))return{bounds:e,type:"area"};if(MF(e)&&!SF(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:pT(r,n),type:"element"}},LF=e=>e===!1?0:e===!0||e==null?su:Math.max(e,0),DF=(e,n,t="scale-down",o,r)=>{let{appState:i}=Ir({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},fT=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=DF(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:LF(r.overscroll),offsets:o};return{...Nn({...e,...a,scrollConstraints:m}),scrollConstraints:m}},_F=({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}}},RF=e=>e===!1?null:e===!0||e==null?uT:e.duration??uT,NF=(e,n,t,o,r)=>{ot.start($m,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=ET(bT(l,0,1));return l<1?(o({..._F({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},BF=(e,n,t=PF)=>{let o=Nn(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||ot.running($m))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;ot.start(La,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-ET(bT(c,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=Nn(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})},Zm=class{constructor(n,t){this.app=n;this.dependencies=t;I(this,"lastPosition",{x:0,y:0});I(this,"activeTransition",null);I(this,"uiLastMeasured",new Map);I(this,"invalidateUIOffset",n=>{this.uiLastMeasured.delete(n)});I(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}});I(this,"getOffsets",n=>{let t=this.dependencies.getContainer(),o=t?.getBoundingClientRect(),r=Fn().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"?hT.compact:hT.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:Ff})}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}});I(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=gT(n.target,t,o);return r?fT(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});I(this,"setViewport",n=>{if(n===null){this.cancelTransition(),ot.cancel(La),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}=gT(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=fT(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=RF(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),ot.cancel(La),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}),NF(p,d,m,E=>{this.activeTransition===u&&this.app.setState(E)},()=>{this.activeTransition===u&&(this.activeTransition=null,this.app.setState({...u.target,shouldCacheIgnoreZoom:!1}))})});I(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||ot.cancel(La),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(),Nn(r,a)}),!0});I(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?Nn(t,n):null)});I(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});I(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||BF(this.app.state,n=>this.app.setState(t=>n(t)))});I(this,"snapBackDebounced",yF(this.snapBack,kF));I(this,"cancelTransition",()=>{this.activeTransition=null,ot.cancel($m)});I(this,"destroy",()=>{this.cancelTransition(),ot.cancel(La),this.snapBackDebounced.cancel()})}get isAnimating(){return ot.running($m)||ot.running(La)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import jm from"react";var OF=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,FF=/{{([\w-]+)}}/,zF=/<([\w-]+)>/,HF=/<\/([\w-]+)>/,GF=(e,n)=>{let t=[{name:"",children:[]}];return e.split(OF).filter(Boolean).forEach(o=>{let r=o.match(zF),i=o.match(HF),a=o.match(FF);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=jm.createElement(jm.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},UF=({i18nKey:e,children:n,...t})=>{let{t:o}=Ae();return jm.createElement(jm.Fragment,{},...GF(o(e),t))},Qr=UF;import{jsx as un,jsxs as xT}from"react/jsx-runtime";var WF=()=>xT("div",{"data-testid":"brave-measure-text-error",children:[un("p",{children:un(Qr,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>un("span",{style:{fontWeight:600},children:e})})}),un("p",{children:un(Qr,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>un("span",{style:{fontWeight:600},children:e})})}),un("p",{children:un(Qr,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>un("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),un("p",{children:un(Qr,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>un("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>xT("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),wT=WF;import qF from"clsx";import JF from"react";import{isDarwin as yT}from"@excalidraw/common";var VF={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:[yT?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[yT?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:[],saveFileToDisk:[N("CtrlOrCmd+S")],saveToActiveFile:[N("CtrlOrCmd+S")],toggleShortcuts:[N("?")],searchMenu:[N("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[N("Shift+R")],toolLock:[N("Q")]},Ke=(e,n=0)=>{let t=VF[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as YF,useRef as vT,useEffect as IT}from"react";import{unstable_batchedUpdates as XF}from"react-dom";import{KEYS as KF,queryFocusableElements as $F}from"@excalidraw/common";import{clamp as TT}from"@excalidraw/math";import ZF from"clsx";import{jsx as jF}from"react/jsx-runtime";var ar=10,ST=({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);IT(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===KF.TAB){let u=$F(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 YF(()=>{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-ar*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${ar}px`,d.style.overflowX="scroll"):d.style.left=`${TT(n,ar,i-ar-m)}px`;let E=Math.max(0,a-ar*2);p>=E?(d.style.height=`${E}px`,d.style.top=`${ar}px`,d.style.overflowY="scroll"):d.style.top=`${TT(t,ar,a-ar-p)}px`}},[t,n,r,i,a]),IT(()=>{if(o){let d=m=>{l.current?.contains(m.target)||XF(()=>o(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),jF("div",{className:ZF("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as xo,jsxs as PT}from"react/jsx-runtime";var at="separator",CT=e=>"onSelect"in e,kT=JF.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=Ko(),a=Ci(),s=n.reduce((l,c)=>c?c===at||CT(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return xo(ST,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:xo("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===at)return!s[c-1]||s[c-1]===at?null:xo("hr",{className:"context-menu-item-separator"},c);if(CT(l))return xo("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:PT("button",{type:"button",className:"context-menu-item",children:[xo("div",{className:"context-menu-item__label",children:l.label}),xo("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)),xo("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:PT("button",{type:"button",className:qF("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[xo("div",{className:"context-menu-item__label",children:m}),xo("kbd",{className:"context-menu-item__shortcut",children:d?Ke(d):""})]})},c)})})})});import{useId as QF}from"react";import e9 from"clsx";import{Fragment as t9,jsx as Ll,jsxs as MT}from"react/jsx-runtime";var qm=({border:e,style:n})=>Ll("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),Jm=({label:e,border:n})=>{let t=QF(),o=MT(t9,{children:[e.icon&&Ll("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return MT("div",{className:e9("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&&Ll("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),Ll("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&Ll("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:Jt})]})};import Ya from"clsx";import vW from"react";import{CLASSES as IW,TOOL_TYPE as JP,arrayToMap as TW,isShallowEqual as Dp}from"@excalidraw/common";import{mutateElement as SW}from"@excalidraw/element";import{showSelectedShapeActions as CW}from"@excalidraw/element";import{ShapeCache as PW}from"@excalidraw/element";import{createIsolation as n9}from"jotai-scope";import zf from"react";import wo from"tunnel-rat";var Hf=zf.createContext(null),et=()=>zf.useContext(Hf),o9=n9(),AT=()=>zf.useMemo(()=>({MainMenuTunnel:wo(),WelcomeScreenMenuHintTunnel:wo(),WelcomeScreenToolbarHintTunnel:wo(),WelcomeScreenHelpHintTunnel:wo(),WelcomeScreenCenterTunnel:wo(),FooterCenterTunnel:wo(),DefaultSidebarTriggerTunnel:wo(),DefaultSidebarTabTriggersTunnel:wo(),OverwriteConfirmDialogTunnel:wo(),tunnelsJotai:o9}),[]);import lr from"clsx";import{useRef as u9}from"react";import{Popover as sr}from"radix-ui";import{CLASSES as HT}from"@excalidraw/common";import{isArrowElement as zT}from"@excalidraw/element";import{forwardRef as LT}from"react";import DT from"clsx";import{jsx as _T}from"react/jsx-runtime";var r9=LT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>_T("div",{className:DT("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),i9=LT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>_T("div",{className:DT("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Dt={Row:r9,Col:i9};import{isTransparent as RT}from"@excalidraw/common";import{shouldAllowVerticalAlign as a9,suppportsHorizontalAlign as s9,hasBoundTextElement as NT,isElbowArrow as l9,isImageElement as c9,isLinearElement as d9,isTextElement as m9,hasStrokeColor as BT,toolIsArrow as p9}from"@excalidraw/element";var OT=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return BT(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>BT(o.type))},FT=(e,n)=>_o(e.activeTool.type)||n.some(t=>_o(t.type)),Qm=(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&&(NT(n[0])||NT(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:OT(e,n),backgroundColor:FT(e,n),fill:r==="bucketfill"||_o(r)&&!RT(e.currentItemBackgroundColor)||n.some(d=>_o(d.type)&&!RT(d.backgroundColor)),strokeWidth:i(Vb),freedrawMode:i(Yb),strokeStyle:i(lu),sloppiness:i(lu),roundness:i(Xb),arrowType:i(p9),arrowheads:i(ns),text:r==="text"||n.some(m9),textAlign:r==="text"||s9(n,t),verticalAlign:a9(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||ie(t,e).some(d=>d.type==="freedraw"),align:!s&&pt(e,o),distribute:n.length>2,link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&c9(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&d9(n[0])&&!l9(n[0])}};import{Fragment as hn,jsx as j,jsxs as Se}from"react/jsx-runtime";var Gf=lr([HT.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),GT=({renderAction:e})=>Se("fieldset",{children:[j("legend",{children:f("labels.layers")}),Se("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),UT=({renderAction:e,showDistribute:n})=>{let t=document.documentElement.getAttribute("dir")==="rtl";return Se("fieldset",{children:[j("legend",{children:f("labels.align")}),Se("div",{className:"buttonList",children:[t?Se(hn,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Se(hn,{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")]})]})]})},WT=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=di(n,e),i=Qm(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(hn,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&j(hn,{children:t("changeSloppiness")}),i.roundness&&j(hn,{children:t("changeRoundness")}),i.arrowType&&j(hn,{children:t("changeArrowType")}),i.text&&Se(hn,{children:[j("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&j(hn,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&j(GT,{renderAction:t}),i.align&&j(UT,{renderAction:t,showDistribute:i.distribute}),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")]})]})]})},VT=({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(sr.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[j(sr.Trigger,{asChild:!0,children:j("button",{type:"button",className:lr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:K1})}),a&&j(so,{className:Gf,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(hn,{children:n("changeStrokeStyle")}),o.sloppiness&&j(hn,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},YT=({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(sr.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[j(sr.Trigger,{asChild:!0,children:j("button",{type:"button",className:lr("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=lt(o,a,c=>zT(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>zT(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?Ho:l==="round"?Go:zo})()})}),s&&j(so,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},XT=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=E0(),s=e.openPopup==="compactTextProperties";return j("div",{className:"compact-action-item",children:Se(sr.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[j(sr.Trigger,{asChild:!0,children:j("button",{type:"button",className:lr("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:Tx})}),e.openPopup==="compactTextProperties"&&j(so,{className:Gf,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")]})})]})})},KT=({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(sr.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[j(sr.Trigger,{asChild:!0,children:j("button",{type:"button",className:lr("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:Ex})}),s&&j(so,{className:Gf,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Se("div",{className:"selected-shape-actions",children:[t.layers&&j(GT,{renderAction:n}),t.align&&j(UT,{renderAction:n,showDistribute:t.distribute}),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"),i&&n("duplicateSelection"),a&&n("deleteSelectedElements")]})]})]})})]})}):null},h9=({renderAction:e,predicates:n})=>n.lineEditor?j("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,$T=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=di(n,e),a=Qm(e,i,n,o),{container:s}=De();return Se("div",{className:"compact-shape-actions",children:[a.strokeColor&&j("div",{className:lr("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(VT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),j(YT,{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(hn,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(XT,{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(KT,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},ZT=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=di(n,e),a=Qm(e,i,n,o),{container:s}=De(),l=u9(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(ze,{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:lr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&j("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),j(VT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),j(YT,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),j(h9,{renderAction:t,predicates:a}),a.text&&Se(hn,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(XT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),j(KT,{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")})]})]})},jT=({renderAction:e})=>j(Dt.Col,{gap:1,className:HT.ZOOM_ACTIONS,children:Se(Dt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),qT=({renderAction:e,className:n})=>Se("div",{className:`undo-redo-buttons ${n}`,children:[j("div",{className:"undo-button-container",children:j(ct,{label:f("buttons.undo"),children:e("undo")})}),j("div",{className:"redo-button-container",children:Se(ct,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),JT=({showExitZenModeBtn:e})=>j("button",{type:"button",className:lr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")}),QT=({actionManager:e})=>j("button",{type:"button",className:"disable-view-mode",onClick:()=>e.executeAction($r),children:Z1});import g9 from"clsx";import{useState as f9,useEffect as E9}from"react";import{THEME as b9}from"@excalidraw/common";import{jsx as Uf,jsxs as x9}from"react/jsx-runtime";var ep=({delay:e,theme:n})=>{let[t,o]=f9(!!e);return E9(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:x9("div",{className:g9("LoadingMessage",{"LoadingMessage--dark":n===b9.DARK}),children:[Uf("div",{children:Uf(ao,{})}),Uf("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as rp,useEffect as yS}from"react";import $9 from"clsx";import{KEYS as Xf,capitalizeString as vS}from"@excalidraw/common";import wS from"react";import{DropdownMenu as V9}from"radix-ui";import{CLASSES as Y9}from"@excalidraw/common";import w9 from"clsx";import{useCallback as y9,useEffect as v9,useRef as I9}from"react";import{CLASSES as T9,EVENT as eS,KEYS as S9}from"@excalidraw/common";import{DropdownMenu as C9}from"radix-ui";import{jsx as tp}from"react/jsx-runtime";var tS=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=ge(),l=I9(null),c=Si({onClickOutside:n});Ti(l,y9(m=>{l.current?.closest(`.${T9.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),v9(()=>{if(!r)return;let m=u=>{u.key===S9.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener(eS.KEYDOWN,m,p),()=>{document.removeEventListener(eS.KEYDOWN,m,p)}},[c,r]);let d=w9(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return tp(dh.Provider,{value:{onSelect:o},children:tp(C9.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?tp(Dt.Col,{className:"dropdown-menu-container",children:e}):tp(ze,{className:"dropdown-menu-container",padding:2,children:e})})})};tS.displayName="DropdownMenuContent";var nS=tS;import{jsx as k9}from"react/jsx-runtime";var P9=({children:e,className:n="",selected:t,...o})=>k9("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),oS=P9;import{DropdownMenu as M9}from"radix-ui";import{jsx as Wf}from"react/jsx-runtime";var rS=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=ad(r);return Wf(M9.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Wf("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:Yo(i,a),title:l.title??l["aria-label"],children:Wf(Xo,{icon:e,shortcut:n,children:o})})})},Da=rS;rS.displayName="DropdownMenuItemLink";import{jsx as A9}from"react/jsx-runtime";var iS=()=>A9("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),aS=iS;iS.displayName="DropdownMenuSeparator";import{DropdownMenu as O9}from"radix-ui";import L9 from"clsx";import{DropdownMenu as D9}from"radix-ui";import{useCallback as _9,useState as sS}from"react";import{jsx as Yf}from"react/jsx-runtime";var Vf=-4,R9=4,lS=({children:e,className:n})=>{let t=ge(),o=L9(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=_9(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+Vf),l(Vf+8))}}},[]),[i,a]=sS(R9),[s,l]=sS(Vf);return Yf(D9.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?Yf(Dt.Col,{className:"dropdown-menu-container",children:e}):Yf(ze,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},cS=lS;lS.displayName="DropdownMenuSubContent";import{DropdownMenu as N9}from"radix-ui";import{jsx as dS,jsxs as B9}from"react/jsx-runtime";var mS=({children:e,icon:n,shortcut:t,className:o})=>B9(N9.SubTrigger,{className:`${Yo(o)} dropdown-menu__submenu-trigger`,children:[dS(Xo,{icon:n,shortcut:t,children:e}),dS("div",{className:"dropdown-menu__submenu-trigger-icon",children:q1})]}),pS=mS;mS.displayName="DropdownMenuSubTrigger";import uS from"react";var np=e=>n=>{let t=uS.Children.toArray(n).find(o=>uS.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},hS=np("DropdownMenuTrigger"),gS=np("DropdownMenuContent"),fS=np("DropdownMenuSubTrigger"),ES=np("DropdownMenuSubContent");import{jsxs as F9}from"react/jsx-runtime";var op=({children:e})=>{let n=fS(e),t=ES(e);return F9(O9.Sub,{children:[n,t]})};op.Trigger=pS;op.Content=cS;op.displayName="DropdownMenuSub";var cr=op;import z9 from"clsx";import{DropdownMenu as H9}from"radix-ui";import{jsx as G9}from"react/jsx-runtime";var bS=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=ge(),a=z9(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return G9(H9.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},xS=bS;bS.displayName="DropdownMenuTrigger";import{jsx as W9}from"react/jsx-runtime";var U9=e=>W9(Yt,{...e,icon:e.checked?Mc:Fc}),Zn=U9;import{jsx as K9,jsxs as X9}from"react/jsx-runtime";var Mn=({children:e,open:n})=>{let t=hS(e),o=gS(e),r=o&&wS.isValidElement(o)?wS.cloneElement(o,{open:n}):o;return K9(V9.Root,{open:n,modal:!1,children:X9("div",{className:Y9.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Mn.Trigger=xS;Mn.Content=nS;Mn.Item=Yt;Mn.ItemCheckbox=Zn;Mn.ItemLink=Da;Mn.ItemCustom=oS;Mn.Group=Ss;Mn.Separator=aS;Mn.Sub=cr;var de=Mn;Mn.displayName="DropdownMenu";import{Fragment as Kf,jsx as Le,jsxs as _a}from"react/jsx-runtime";var Z9=({actionManager:e,app:n})=>{if(!e.isActionEnabled(kt))return null;let t=f("buttons.objectsSnapMode");return Le(K,{type:"toggle",icon:Fo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(kt,"ui")})},j9=({app:e})=>Le(K,{type:"button",icon:yi,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),IS=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=rp(!1),[l,c]=rp("rectangle"),[d,m]=rp("arrow");yS(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&c(o.type)},[o.type]),yS(()=>{(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(H=>({type:H,icon:We[H].icon,title:vS(f(`toolBar.${H}`)),fillable:We[H].fillable})),w=["arrow","line"].map(H=>({type:H,icon:We[H].icon,title:vS(f(`toolBar.${H}`)),fillable:We[H].fillable})),[x,v]=rp(0),T=36,C=4,P=7,A=P*T+(P-1)*C,L=T+C,_=x>=A+1*L,k=i&&x>=A+2*L,D=x>=A+3*L,F=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(H=>!(_&&H==="text"||(!i||k)&&H==="image"||D&&H==="frame")),Y=r&&Fi.includes(o.type),z=Y||F.includes(o.type),W=z?Y?We[o.type].icon:o.type==="text"?wn:o.type==="image"?Cr:o.type==="frame"?Gn:o.type==="embeddable"?Oo:o.type==="laser"?Un:o.type==="bucketfill"?Hn:cs:cs,$={app:e,activeTool:o,hideShortcut:!0};return _a("div",{className:"mobile-toolbar",ref:H=>{H&&v(H.getBoundingClientRect().width)},children:[Le(Md,{...$}),Le(Ad,{...$,setAppState:t}),r?Le(Rs,{...$}):Le(Ld,{...$}),Le(Os,{...$}),!r&&Le(Oi,{app:e,options:y,activeTool:o,defaultOption:l,"data-testid":"toolbar-rectangle",onToolChange:H=>{(H==="rectangle"||H==="diamond"||H==="ellipse")&&(c(H),e.setActiveTool({type:H}))},displayedOption:y.find(H=>H.type===l)||y[0]}),!r&&Le(Oi,{app:e,options:w,activeTool:o,defaultOption:d,"data-testid":"toolbar-arrow",onToolChange:H=>{(H==="arrow"||H==="line")&&(m(H),e.setActiveTool({type:H}))},displayedOption:w.find(H=>H.type===d)||w[0]}),_&&Le(Ns,{...$}),r&&k&&Le(j9,{app:e}),k&&Le(Bs,{...$}),!r&&D&&Le(Dw,{...$,hideShortcut:!0}),_a(de,{open:a,children:[Le(de.Trigger,{className:$9("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:W}),_a(de.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&Fi.map(H=>Le(de.Item,{onSelect:()=>e.setActiveTool({type:H}),icon:We[H].icon,"data-testid":`toolbar-${H}`,selected:o.type===H,shortcut:kd(H),disabled:$e(e,H),children:f(`toolBar.${H}`)},H)),!r&&Le("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(kt)&&Le(de.Item,{onSelect:()=>n.executeAction(kt,"ui"),icon:Fo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:Ke("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&_a(Kf,{children:[r&&Le("div",{className:"App-toolbar__dropdown-divider"}),Le(de.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?No:io,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:Xf.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Le(de.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:wn,shortcut:Xf.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:$e(e,"text"),children:f("toolBar.text")}),i&&!k&&Le(de.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Cr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:$e(e,"image"),children:f("toolBar.image")}),!r&&!D&&Le(de.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Gn,shortcut:Xf.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:$e(e,"frame"),children:f("toolBar.frame")}),!r&&_a(Kf,{children:[Le(de.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Oo,"data-testid":"toolbar-embeddable",selected:g,disabled:$e(e,"embeddable"),children:f("toolBar.embeddable")}),Le(de.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Mr,shortcut:Hi("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:$e(e,"autoshape"),children:f("toolBar.autoshape")}),Le(de.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Un,"data-testid":"toolbar-laser",selected:E,disabled:$e(e,"laser"),children:f("toolBar.laser")}),Le(de.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Hn,"data-testid":"toolbar-bucketfill",selected:b,disabled:$e(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&_a(Kf,{children:[Le("div",{className:"App-toolbar__divider"}),Le(Z9,{actionManager:n,app:e})]})]})};import q9 from"clsx";import{jsx as J9}from"react/jsx-runtime";var ip=({children:e,side:n,className:t})=>J9("div",{className:q9("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import Q9 from"clsx";import{jsx as ez}from"react/jsx-runtime";var Ra=e=>e.penDetected?ez(K,{className:Q9("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Ix,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as TS,jsx as xt,jsxs as dr}from"react/jsx-runtime";var SS=({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}=et(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=dr("div",{className:"excalidraw-ui-top-right",children:[i?.(!0,e)??(!e.viewModeEnabled&&dr(TS,{children:[l&&xt(Ra,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),xt(E.Out,{})]})),l&&e.viewModeEnabled&&d.isInteractionEnabled()&&xt(QT,{actionManager:t})]}),A=dr("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),xt(u.Out,{})]});return dr("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[A,P]})},b=()=>xt(IS,{app:d,actionManager:t,setAppState:o}),y=c&&e.scrolledOutside,w=l,x=l&&(!e.viewModeEnabled||w),v=y&&!e.openMenu&&!e.openSidebar?xt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({...ci(n,P)}))},children:f("buttons.scrollBackToContent")}):null,T=d.props.viewportStatusFrame?.label,C=T?xt(Jm,{label:T,border:d.props.viewportStatusFrame?.border}):null;return dr(TS,{children:[a(),xt("div",{className:"App-welcome-screen",children:s&&xt(p.Out,{})}),x&&dr("div",{className:"App-bottom-bar",style:{marginBottom:cn+Eo},"data-viewport-ui":"bottom",children:[v&&xt("div",{className:"floating-status-stack",children:v}),dr("div",{className:"App-bottom-bar__actions-row",children:[w&&dr(ze,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&xt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),xt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&xt(ZT,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o})]}),!e.viewModeEnabled&&xt(ze,{className:"App-toolbar",children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&v&&xt("div",{className:"floating-status-stack",children:v}),C&&xt("div",{className:"viewport-status-frame__badge-row",children:C}),xt(ip,{side:"top",className:"App-top-bar",children:g()})]})};import DS,{useLayoutEffect as _S,useRef as RS,useState as NS}from"react";import{newTextElement as BS}from"@excalidraw/element";import sz from"clsx";import{useEffect as lz,useState as cz}from"react";import{KEYS as dz,queryFocusableElements as AS}from"@excalidraw/common";import{useCallback as tz,useState as nz}from"react";var CS=()=>{let[e,n]=nz(null),t=tz(o=>n(o),[]);return[e,t]};import PS from"clsx";import{useRef as oz}from"react";import{createPortal as rz}from"react-dom";import{KEYS as iz}from"@excalidraw/common";import{jsx as kS,jsxs as az}from"react/jsx-runtime";var MS=e=>{let{closeOnClickOutside:n=!0}=e,t=Zc({className:PS("excalidraw-modal-container",e.portalContainerClassName)}),o=oz(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===iz.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return rz(az("div",{className:PS("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[kS("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),kS("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as ap,jsxs as LS}from"react/jsx-runtime";function mz(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var gn=e=>{let[n,t]=CS(),[o]=cz(document.activeElement),{id:r}=De(),i=ge().formFactor==="phone";lz(()=>{if(!n)return;let l=AS(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===dz.TAB){let m=AS(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=Ue(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return ap(MS,{className:sz("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:mz(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:LS(ze,{ref:t,children:[e.title&&LS("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[ap("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&ap("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:Jt}),ap("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as yo,jsxs as sp}from"react/jsx-runtime";var pz=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}},uz=e=>{let n=RS(null),[t,o]=NS(null),{theme:r}=fe();_S(()=>{if(!e.spreadsheet){o(null);return}let a=ff(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 Tr(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=pz(e.chartType);return sp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[yo("div",{className:"ChartPreview__canvas",ref:n}),yo("div",{className:"ChartPreview__label",children:i})]})},hz=e=>{let n=RS(null),{theme:t}=fe();return _S(()=>{if(!e.rawText)return;let o=BS({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Tr([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]),sp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[yo("div",{className:"ChartPreview__canvas",ref:n}),yo("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},OS=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=It(),[i,a]=NS(Math.random()),s=DS.useCallback(()=>{a(Math.random())},[]),l=DS.useCallback(()=>{t&&t()},[t]),c=(m,p)=>{o(p),Ne("paste","chart",m),t(),r()},d=m=>{let p=BS({text:m,x:0,y:0});o([p]),Ne("paste","chart","plaintext"),t(),r()};return yo(gn,{size:"regular",onCloseRequest:l,title:sp("div",{className:"PasteChartDialog__title",children:[yo("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),yo("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:Hn})]}),className:"PasteChartDialog",autofocus:!1,children:sp("div",{className:"container",children:[["bar","line","radar"].map(m=>Ea(e,m)?yo(uz,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),n&&yo(hz,{rawText:n,onClick:d})]})})};import{Fragment as gz,jsx as FS,jsxs as fz}from"react/jsx-runtime";var Dl=({heading:e,children:n,...t})=>{let{id:o}=De(),r=FS("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return FS("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):fz(gz,{children:[r,n]})})};import{Popover as _l}from"radix-ui";import zS from"clsx";import lp,{useLayoutEffect as Ez}from"react";import{supportsResizeObserver as bz,isShallowEqual as xz}from"@excalidraw/common";import{Fragment as jf,jsx as wt,jsxs as Na}from"react/jsx-runtime";var wz=4,yz=8,$f=38,HS=21,vz=({shouldWrap:e,children:n,username:t})=>e?wt(ct,{label:t||"Unknown user",children:n}):wt(jf,{children:n}),Zf=({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 wt(vz,{username:n.username,shouldWrap:r,children:s},t)},Iz=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],cp=lp.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=tt(),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]=lp.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(d)),u=lp.useRef(null);Ez(()=>{if(u.current){let C=A=>{g(A)};if(C(u.current.clientWidth),!bz)return;let P=new ResizeObserver(A=>{for(let L of A){let{width:_}=L.contentRect;C(_)}});return P.observe(u.current),()=>{P.disconnect()}}},[]);let[E,g]=lp.useState(wz*$f),b=l?E-HS:E,y=Math.max(1,Math.min(8,Math.floor(b/$f))),w=l?Math.max(0,y-1):y,x=c.slice(0,w),v=l?[...x,l]:x,T=v.map(C=>{let P=Zf({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?Na(_l.Root,{children:[wt(_l.Trigger,{asChild:!0,children:Na("div",{className:"UserList__pill",children:[P,wt("div",{className:"UserList__pill-chevron",children:j1})]})}),wt(_l.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Na(ze,{padding:2,children:[s.length>=yz&&wt(rd,{placeholder:f("quickSearch.placeholder"),onChange:m}),wt(id,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[wt("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(A=>Zf({actionManager:i,collaborator:A,socketId:A.socketId,withName:!0,isBeingFollowed:A.socketId===o}))]:[]}),a&&Na(jf,{children:[wt("div",{className:"UserList__menu-divider"}),wt(_l.Close,{asChild:!0,children:wt("div",{className:"dropdown-menu",children:a})})]}),wt(_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?Na("div",{className:zS("UserList UserList_mobile",e),children:[wt("div",{className:"UserList_mobile__avatars",children:s.map(C=>Zf({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&Na(jf,{children:[wt("div",{className:"UserList__menu-divider"}),a]})]}):wt("div",{className:"UserList__wrapper",ref:u,children:wt("div",{className:zS("UserList",e),style:{"--max-avatars":v.length+(l?HS/$f: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||!xz(r,i,Iz))return!1}return!0});import Rl from"clsx";import{jsx as GS}from"react/jsx-runtime";var US=e=>GS(ct,{label:`${f("helpDialog.title")} \u2014 ?`,children:GS("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:wi})});import{jsx as Kt,jsxs as qf}from"react/jsx-runtime";var WS=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=et(),l=It();return qf("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&Kt("div",{className:Rl("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Kt(Dt.Col,{gap:2,children:qf(Dl,{heading:"canvasActions",children:[!e.viewModeOnly&&Kt(ct,{label:f("labels.viewMode"),children:Kt("div",{className:Rl("view-mode-button"),children:n.renderAction("viewMode")})}),Kt(ct,{label:f("buttons.smartZoom"),children:Kt("div",{className:Rl("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&Kt(jT,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&Kt(qT,{renderAction:n.renderAction,className:Rl("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Kt(a.Out,{}),(r||o)&&Kt("div",{className:Rl("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:qf("div",{style:{position:"relative"},children:[o&&Kt(s.Out,{}),r&&Kt(US,{onClick:()=>n.executeAction(Hr)})]})}),r&&Kt(JT,{showExitZenModeBtn:t})]})},VS=WS;WS.displayName="Footer";import{composeEventHandlers as Lz}from"@excalidraw/common";import{useLayoutEffect as Tz,useRef as Sz}from"react";import{jsx as Cz}from"react/jsx-runtime";var ei=(e,n)=>{let t=je(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=et(),[,a]=i(t),s=Sz({preferHost:!1,counter:0});return Tz(()=>{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:Cz(n,{...r})};return o.displayName=e,o};var tE={};$M(tE,{ChangeCanvasBackground:()=>tC,Export:()=>nC,Help:()=>QS,LiveCollaborationTrigger:()=>rC,LoadScene:()=>ZS,Preferences:()=>jn,PreferencesToggleGridModeItem:()=>eE,SaveAsImage:()=>qS,SaveToActiveFile:()=>jS,SearchMenu:()=>JS,Socials:()=>oC,ToggleTheme:()=>eC});import Az from"clsx";import{THEME as Bl}from"@excalidraw/common";var Jf=je({active:!1});async function YS({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{gt.set(Jf,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import Pz from"clsx";import{jsx as XS,jsxs as kz}from"react/jsx-runtime";var dp=function({onChange:e,value:n,choices:t,name:o}){return XS("div",{className:"RadioGroup",children:t.map(r=>kz("div",{className:Pz("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[XS("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 Mz,jsx as Nl,jsxs as KS}from"react/jsx-runtime";var $S=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=ge();return KS(Mz,{children:[KS("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&Nl("div",{className:"dropdown-menu-item__icon",children:a}),Nl("label",{className:"dropdown-menu-item__text",children:Nl(Cs,{children:r})}),Nl(dp,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&Nl("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};$S.displayName="DropdownMenuItemContentRadio";var Qf=$S;import{Fragment as pC,jsx as Ee,jsxs as Ol}from"react/jsx-runtime";var ZS=()=>{let{t:e}=Ae(),n=tt(),t=Ci();return n.isActionEnabled(Ui)?Ee(Yt,{icon:Ac,onSelect:async()=>{(!t.length||await YS({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:Ee(Qr,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>Ee("strong",{children:r}),br:()=>Ee("br",{})})}))&&n.executeAction(Ui)},"data-testid":"load-button",shortcut:Ke("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};ZS.displayName="LoadScene";var jS=()=>{let{t:e}=Ae(),n=tt();return n.isActionEnabled(zr)?Ee(Yt,{shortcut:Ke("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(zr),icon:Lx,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};jS.displayName="SaveToActiveFile";var qS=()=>{let e=Ue(),{t:n}=Ae();return Ee(Yt,{icon:Rx,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Ke("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};qS.displayName="SaveAsImage";var JS=e=>{let{t:n}=Ae(),t=tt();return Ee(Yt,{icon:Wn,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(ml)},shortcut:Ke("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};JS.displayName="SearchMenu";var QS=()=>{let{t:e}=Ae(),n=tt();return Ee(Yt,{"data-testid":"help-menu-item",icon:wi,onSelect:()=>n.executeAction(Hr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};QS.displayName="Help";var eC=e=>{let{t:n}=Ae(),t=fe(),o=tt(),r=Ke("toggleTheme"),i=yn();return o.isActionEnabled(Td)?e?.allowSystemTheme?Ee(Qf,{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:Bl.LIGHT,label:ps,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:Bl.DARK,label:ms,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:U1,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):Ee(Yt,{onSelect:a=>{a.preventDefault(),o.executeAction(Td)},icon:t.theme===Bl.DARK?ps:ms,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===Bl.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===Bl.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};eC.displayName="ToggleTheme";var tC=()=>{let{t:e}=Ae(),n=fe(),t=tt(),o=yn();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:Ol("div",{style:{marginTop:"0.75rem"},children:[Ee("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),Ee("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};tC.displayName="ChangeCanvasBackground";var nC=()=>{let{t:e}=Ae(),n=Ue();return Ee(Yt,{icon:us,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};nC.displayName="Export";var oC=()=>{let{t:e}=Ae();return Ol(pC,{children:[Ee(Da,{icon:kx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),Ee(Da,{icon:Ax,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),Ee(Da,{icon:Mx,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};oC.displayName="Socials";var rC=({onSelect:e,isCollaborating:n})=>{let{t}=Ae();return Ee(Yt,{"data-testid":"collab-button",icon:Lc,className:Az({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};rC.displayName="LiveCollaborationTrigger";var iC=()=>{let{t:e}=Ae(),n=It(),t=fe();return Ee(Zn,{checked:t.activeTool.locked,shortcut:Ke("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},aC=()=>{let{t:e}=Ae(),n=fe(),t=Ue();return Ee(Qf,{name:"boxSelectionMode",icon:Fc,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}=Ae(),n=tt(),t=fe();return Ee(Zn,{checked:t.objectsSnapModeEnabled,shortcut:Ke("objectsSnapMode"),onSelect:o=>{n.executeAction(kt),o.preventDefault()},children:e("buttons.objectsSnapMode")})},lC=()=>{let{t:e}=Ae(),n=tt(),t=fe();return Ee(Zn,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(Ys),o.preventDefault()},children:e("labels.arrowBinding")})},cC=()=>{let{t:e}=Ae(),n=tt(),t=fe();return Ee(Zn,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(Xs),o.preventDefault()},children:e("labels.midpointSnapping")})},eE=()=>{let{t:e}=Ae(),n=tt(),t=fe();return Ee(Zn,{checked:t.gridModeEnabled,shortcut:Ke("gridMode"),onSelect:o=>{n.executeAction(ji),o.preventDefault()},children:e("labels.toggleGrid")})},dC=()=>{let{t:e}=Ae(),n=tt(),t=fe();return t.viewModeOnly?null:Ee(Zn,{checked:t.viewModeEnabled,shortcut:Ke("viewMode"),onSelect:o=>{n.executeAction($r),o.preventDefault()},children:e("labels.viewMode")})},mC=()=>{let{t:e}=Ae(),n=tt(),t=fe();return Ee(Zn,{checked:t.stats.open,shortcut:Ke("stats"),onSelect:o=>{n.executeAction(er),o.preventDefault()},children:e("stats.fullTitle")})},jn=({children:e,additionalItems:n})=>{let{t}=Ae();return Ol(cr,{children:[Ee(cr.Trigger,{icon:J1,children:t("labels.preferences")}),Ol(cr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||Ol(pC,{children:[Ee(aC,{}),Ee(iC,{}),Ee(sC,{}),Ee(eE,{}),Ee(dC,{}),Ee(mC,{}),Ee(lC,{}),Ee(cC,{})]}),n]})]})};jn.ToggleToolLock=iC;jn.BoxSelectionMode=aC;jn.ToggleSnapMode=sC;jn.ToggleArrowBinding=lC;jn.ToggleMidpointSnapping=cC;jn.ToggleGridMode=eE;jn.ToggleViewMode=dC;jn.ToggleElementProperties=mC;jn.displayName="Preferences";import{jsx as mp,jsxs as nE}from"react/jsx-runtime";var Dz=Object.assign(ei("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=et(),o=ge(),r=fe(),i=yn(),a=Ue();return mp(t.In,{children:nE(de,{open:r.openMenu==="canvas",children:[mp(de.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Cx}),nE(de.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:Lz(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&nE("fieldset",{className:"UserList-Wrapper",children:[mp("legend",{children:f("labels.collaborators")}),mp(cp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:de.Trigger,Item:de.Item,ItemLink:de.ItemLink,ItemCustom:de.ItemCustom,Group:de.Group,Separator:de.Separator,Sub:cr,DefaultItems:tE}),_t=Dz;import _z from"clsx";import{forwardRef as Rz,useState as Nz}from"react";import{isPromiseLike as Bz}from"@excalidraw/common";import{jsx as pp,jsxs as Oz}from"react/jsx-runtime";var mr=Rz(({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]=Nz(!1),E=async b=>{let y=t?.(b);if(Bz(y)){let w=window.setTimeout(()=>{u(!0)},50);try{await y}catch(x){if(x instanceof hc)console.warn(x);else throw x}finally{clearTimeout(w),u(!1)}}},g=p?"loading":c;return i=g==="success"?"success":i,pp("button",{className:_z("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:Oz("div",{className:"ExcButton__contents",children:[g==="loading"?pp(ao,{className:"ExcButton__statusIcon"}):g==="success"&&pp("div",{className:"ExcButton__statusIcon",children:L1}),n&&pp("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as Ba,jsxs as Hz}from"react/jsx-runtime";var up=({title:e,children:n,actionLabel:t,onClick:o})=>Hz("div",{className:"OverwriteConfirm__Actions__Action",children:[Ba("h4",{children:e}),Ba("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),Ba(mr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),Fz=()=>{let{t:e}=Ae(),n=tt(),t=Ue();return Ba(up,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(Ud,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},zz=()=>{let{t:e}=Ae(),n=tt();return Ba(up,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(Ws,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},oE=Object.assign(({children:e})=>Ba("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:Fz,SaveToDisk:zz});import{jsx as pr,jsxs as uC}from"react/jsx-runtime";var hp=Object.assign(ei("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=et(),[t,o]=Fe(Jf);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return pr(n.In,{children:pr(gn,{onCloseRequest:r,title:!1,size:916,children:uC("div",{className:"OverwriteConfirm",children:[pr("h3",{children:t.title}),uC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[pr("div",{className:"OverwriteConfirm__Description__icon",children:D1}),pr("div",{children:t.description}),pr("div",{className:"OverwriteConfirm__Description__spacer"}),pr(mr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),pr(oE,{children:e})]})})})}),{Actions:oE,Action:up});import{round as oP}from"@excalidraw/math";import rG from"clsx";import iG from"lodash.throttle";import{useEffect as rP,useMemo as EE,useState as aG,memo as sG}from"react";import{STATS_PANELS as Ip}from"@excalidraw/common";import{getCommonBounds as lG}from"@excalidraw/element";import{getUncroppedWidthAndHeight as cG}from"@excalidraw/element";import{isImageElement as bE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as dG}from"@excalidraw/element";import{elementsAreInSameGroup as mG}from"@excalidraw/element";import{degreesToRadians as yC,radiansToDegrees as SC}from"@excalidraw/math";import{getBoundTextElement as vC}from"@excalidraw/element";import{isArrowElement as IC,isElbowArrow as eH}from"@excalidraw/element";import{updateBindings as TC}from"@excalidraw/element";import $z from"clsx";import{useEffect as xC,useRef as fp,useState as Zz}from"react";import{EVENT as za,KEYS as jz,cloneJSON as rE}from"@excalidraw/common";import{deepCopyElement as qz}from"@excalidraw/element";import{CaptureUpdateAction as wC}from"@excalidraw/element";import{pointFrom as ur,pointRotateRads as gp}from"@excalidraw/math";import{getBoundTextElement as Gz,getNonDeletedElements as Uz,isBindingElement as Wz,unbindBindingElement as hC}from"@excalidraw/element";import{isFrameLikeElement as EC}from"@excalidraw/element";import{getSelectedGroupIds as Vz,getElementsInGroup as Yz,isInGroup as Xz}from"@excalidraw/element";import{getFrameChildren as Kz}from"@excalidraw/element";import{updateBindings as gC}from"@excalidraw/element";import{DRAGGING_THRESHOLD as fC}from"@excalidraw/common";var bC=.01,Fl=10,zt=(e,n)=>!(n==="angle"&&EC(e)),He=(e,n)=>{let t=e+n/2;return t-t%n},Oa=(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 ti=(e,n,t,o,r,i,a=!0)=>{if(Wz(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<fC&&Math.abs(n-t.y)<fC)return;hC(t,"start",o),hC(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]=gp(ur(t.x,t.y),ur(c,d),t.angle),u=e-m,E=n-p,[g,b]=gp(ur(e,n),ur(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),gC(l,o,r);let y=Gz(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(EC(t)){let w=Kz(i,t.id);w.forEach(x=>{let v=s.get(x.id);if(!v)return;let[T,C]=[x.x+x.width/2,x.y+x.height/2],[P,A]=gp(ur(x.x,x.y),ur(T,C),x.angle),L=Math.round(P+u),_=Math.round(A+E),[k,D]=gp(ur(L,_),ur(T+u,C+E),-x.angle);o.mutateElement(v,{x:k,y:D},{informMutation:a,isDragging:!1}),gC(v,o,r,{simultaneouslyUpdated:Uz(w)})})}},Fa=(e,n)=>{let o=Vz(n).map(r=>Yz(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!Xz(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as iE,jsxs as Qz}from"react/jsx-runtime";var Jz=({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=It(),u=Ue(),E=fp(null),g=fp(null),[b,y]=Zz(o.toString()),w=fp(null);w.current||(w.current={originalAppState:rE(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),xC(()=>{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 L=Number(A.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(L-_)>=bC)&&(w.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:L,property:s,originalAppState:P,setInputValue:k=>y(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:wC.IMMEDIATELY}))},v=fp({});return v.current.handleInputValue=x,xC(()=>{let T=E.current,C=v.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,w.current.originalElements,w.current.originalAppState),window.removeEventListener(za.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(za.POINTER_UP,C.onPointerUp,!1)}},[i]),i?Qz("div",{className:$z("drag-input-container",!i&&"disabled"),"data-testid":e,children:[iE("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,W)=>(z.set(W.id,qz(W)),z),new Map),L=r.map(z=>A.get(z.id)),_=rE(c),k=0,D=0,F=z=>{if(P&&A!==null&&L!==null){let W=z.clientX-P.x;W!==0&&(D+=W,Math.abs(D)>=d&&(D=Math.sign(D)*Math.floor(Math.abs(D)/d),k+=D,t({accumulatedChange:k,instantChange:D,originalElements:L,originalElementsMap:A,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:$=>y(String($)),app:p,setAppState:u}),D=0))}P={x:z.clientX,y:z.clientY}},Y=()=>{window.removeEventListener(za.POINTER_MOVE,F,!1),p.syncActionResult({captureUpdate:wC.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:L,originalAppState:_}),P=null,k=0,D=0,L=null,A=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(za.POINTER_UP,Y,!1)};v.current.onPointerMove=F,v.current.onPointerUp=Y,window.addEventListener(za.POINTER_MOVE,F,!1),window.addEventListener(za.POINTER_UP,Y,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?iE(cd,{icon:n}):e}),iE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===jz.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=rE(c)},onBlur:T=>{b?i&&x(T.target.value,w.current.originalElements,w.current.originalAppState):y(o.toString())},disabled:!i})]}):null},ut=Jz;import{jsx as rH}from"react/jsx-runtime";var tH=15,nH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!eH(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=yC(o);r.mutateElement(l,{angle:E}),TC(l,r,i.state);let g=vC(l,a);g&&!IC(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(SC(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;t&&(m=He(m,tH)),m=m<0?m+360:m;let p=yC(m);r.mutateElement(l,{angle:p}),TC(l,r,i.state);let u=vC(l,a);u&&!IC(l)&&r.mutateElement(u,{angle:p})}},oH=({element:e,scene:n,appState:t,property:o})=>rH(ut,{label:"A",icon:_c,value:Math.round(SC(e.angle)%360*100)/100,elements:[e],dragInputCallback:nH,editable:zt(e,"angle"),scene:n,appState:t,property:o}),CC=oH;import{jsx as aH}from"react/jsx-runtime";var PC=5,iH=({property:e,scene:n,appState:t,setAppState:o})=>aH(ut,{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?He(l.gridStep+PC*Math.sign(i),PC):l.gridStep+i),c?(c=Ub(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),kC=iH;import{clamp as Ep,round as aE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as bp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as MC,getNonDeletedElements as sH,getUncroppedWidthAndHeight as DC}from"@excalidraw/element";import{resizeSingleElement as AC}from"@excalidraw/element";import{isImageElement as _C}from"@excalidraw/element";import{isFrameLikeElement as sE}from"@excalidraw/element";import{getElementsInResizingFrame as lE}from"@excalidraw/element";import{replaceAllElementsInFrame as RC}from"@excalidraw/element";import{jsx as pH}from"react/jsx-runtime";var LC=10,lH=e=>e.type==="image",cH=({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||lH(u),b=u.width/u.height;if(s.croppingElementId===u.id){let y=p.get(u.id);if(!y||!_C(y)||!y.crop)return;let w=y.crop,x={...w},v=y.scale[0]===-1,T=y.scale[1]===-1,{width:C,height:P}=DC(y),A=w.naturalWidth/C,L=w.naturalHeight/P,_=v?w.width+w.x:w.naturalWidth-w.x,k=T?w.height+w.y:w.naturalHeight-w.y,D=MC*A,F=MC*L;if(i!==void 0){if(a==="width"){let H=i*A,re=Ep(H,D,_);x={...x,width:re,x:v?w.x+w.width-re:w.x}}else if(a==="height"){let H=i*L,re=Ep(H,F,k);x={...x,height:re,y:T?w.y+w.height-re:w.y}}c.mutateElement(y,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}let Y=a==="width"?l:0,z=a==="height"?l:0,W=Ep(w.width+Y,D,_),$=Ep(w.height+z,D,k);x={...w,x:v?w.x+w.width-W:w.x,y:T?w.y+w.height-$:w.y,width:W,height:$},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,bp),w=Math.max(a==="height"?i:g?i/b:u.height,bp);if(AC(y,w,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),sE(E)){let x=lE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),v=RC(c.getElementsIncludingDeleted(),x,E);c.replaceAllElements(v)}return}{let y=a==="width"?e:0,w=a==="height"?e:0,x=Math.max(0,u.width+y);a==="width"&&(r?x=He(x,LC):x=Math.round(x));let v=Math.max(0,u.height+w);if(a==="height"&&(r?v=He(v,LC):v=Math.round(v)),g&&(a==="width"?v=Math.round(x/b*100)/100:x=Math.round(v*b*100)/100),v=Math.max(bp,v),x=Math.max(bp,x),AC(x,v,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),sE(E)){let T=sH(lE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},dH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&sE(a)){let s=lE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=RC(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},mH=({property:e,element:n,scene:t,appState:o})=>{let r=aE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&_C(n)&&n.crop){let{width:i,height:a}=DC(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=aE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=aE(n.crop.height*s,2)}}return pH(ut,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:cH,value:r,editable:zt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:dH})},cE=mH;import{getBoundTextElement as uH,redrawTextBoundingBox as hH}from"@excalidraw/element";import{hasBoundTextElement as gH,isTextElement as BC}from"@excalidraw/element";import{jsx as xH}from"react/jsx-runtime";var NC=4,fH=4,EH=({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||!BC(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),NC);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,NC),t&&(l=He(l,fH))}l&&(r.mutateElement(s,{fontSize:l}),hH(s,r.getContainerElement(s),r))}},bH=({element:e,scene:n,appState:t,property:o})=>{let r=BC(e)?e:gH(e)?uH(e,n.getNonDeletedElementsMap()):null;return r?xH(ut,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:EH,icon:kr,appState:t,scene:n,property:o}):null},OC=bH;import{degreesToRadians as FC,radiansToDegrees as GC}from"@excalidraw/math";import{getBoundTextElement as zC}from"@excalidraw/element";import{isArrowElement as HC}from"@excalidraw/element";import{isInGroup as dE}from"@excalidraw/element";import{jsx as IH}from"react/jsx-runtime";var wH=15,yH=({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&&!dE(c)&&zt(c,r)),l=n.filter(c=>!dE(c)&&zt(c,r));if(o!==void 0){let c=FC(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let m=zC(d,a);m&&!HC(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(GC(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=He(E,wH)),E=E<0?E+360:E;let g=FC(E);i.mutateElement(d,{angle:g});let b=zC(d,a);b&&!HC(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},vH=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!dE(l)&&zt(l,"angle")),i=r.map(l=>Math.round(GC(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>zt(l,"angle"));return IH(ut,{label:"A",icon:_c,value:a,elements:e,dragInputCallback:yH,editable:s,appState:t,scene:n,property:o})},UC=vH;import{pointFrom as XC}from"@excalidraw/math";import{useMemo as SH}from"react";import{MIN_WIDTH_OR_HEIGHT as hr}from"@excalidraw/common";import{getElementsInResizingFrame as mE,getNonDeletedElements as CH,isFrameLikeElement as pE,replaceAllElementsInFrame as ZC,updateBoundElements as PH}from"@excalidraw/element";import{rescalePointsInElement as kH,resizeSingleElement as KC}from"@excalidraw/element";import{getBoundTextElement as MH,handleBindTextResize as AH}from"@excalidraw/element";import{isTextElement as jC}from"@excalidraw/element";import{MIME_TYPES as ni}from"@excalidraw/common";import{getNonDeletedElements as WC}from"@excalidraw/element";var xp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=WC(Sr(e,null,{deleteInvisibleElements:!0})),l=pi(n,null),{exportBackground:c,viewBackgroundColor:d}=l;return xc(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}})},VC=async e=>{let{mimeType:n=ni.png,quality:t}=e;n===ni.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ni.png}" mimeType`),n==="image/jpg"&&(n=ni.jpg),n===ni.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ni.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await xp(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===ni.png&&e.appState?.exportEmbedScene&&(a=await Qb({blob:a,metadata:rs(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},YC=async({elements:e,appState:n=Ro(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=WC(Sr(e,null,{deleteInvisibleElements:!0})),d={...pi(n,null),exportPadding:o};return Tr(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},TH=async e=>{if(e.type==="svg"){let n=await YC(e);await po(n.outerHTML)}else if(e.type==="png")await Hd(VC(e));else if(e.type==="json")await Fd(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as u8e}from"@excalidraw/element";import{getCommonBounds as wp}from"@excalidraw/element";import{jsx as BH}from"react/jsx-runtime";var Ha=10,LH=(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,...kH(o,a,s,!1),...jC(o)?{fontSize:o.fontSize*t}:{}}},DH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=LH(e,n,o,i);s.mutateElement(r,c);let d=MH(i,a);if(d){let m=d.fontSize*o;PH(r,s);let p=l.get(d.id);p&&jC(p)&&(s.mutateElement(p,{fontSize:m}),AH(r,s,t==="width"?"e":"s",!0))}},$C=(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];DH(r[0],r[1],i,d,u,p,l,c)}},_H=({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=Fa(n,o);if(i!==void 0){for(let g of m){let b=Oa(g,d,t);if(b.length>1){let y=b.map(D=>D.latest),w=b.map(D=>D.original),[x,v,T,C]=wp(w),P=T-x,A=C-v,L=P/A,_=Math.max(hr,s==="width"?Math.max(0,i):P),k=Math.max(hr,s==="height"?Math.max(0,i):A);$C(_,k,A,L,XC(x,v),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&zt(w,s)){let v=s==="width"?Math.max(0,i):w.width;s==="width"&&(r?v=He(v,Ha):v=Math.round(v));let T=s==="height"?Math.max(0,i):w.height;if(s==="height"&&(r?T=He(T,Ha):T=Math.round(T)),v=Math.max(hr,v),T=Math.max(hr,T),KC(v,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),pE(w)){let C=mE(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()),P=ZC(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=Oa(g,d,t);if(b.length>1){let y=b.map(D=>D.latest),w=b.map(D=>D.original),[x,v,T,C]=wp(w),P=T-x,A=C-v,L=P/A,_=Math.max(0,P+p);s==="width"&&(r?_=He(_,Ha):_=Math.round(_));let k=Math.max(0,A+u);s==="height"&&(r?k=He(k,Ha):k=Math.round(k)),_=Math.max(hr,_),k=Math.max(hr,k),$C(_,k,A,L,XC(x,v),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&zt(w,s)){let v=Math.max(0,x.width+p);s==="width"&&(r?v=He(v,Ha):v=Math.round(v));let T=Math.max(0,x.height+u);if(s==="height"&&(r?T=He(T,Ha):T=Math.round(T)),v=Math.max(hr,v),T=Math.max(hr,T),KC(v,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),pE(w)){let C=CH(mE(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&&pE(a)){let s=mE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=ZC(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},NH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=SH(()=>o.map(c=>{let d=Oa(c,t);if(d.length>1){let[p,u,E,g]=wp(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 BH(ut,{label:e==="width"?"W":"H",elements:n,dragInputCallback:_H,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:RH})},uE=NH;import{getBoundTextElement as OH,redrawTextBoundingBox as qC}from"@excalidraw/element";import{hasBoundTextElement as FH,isTextElement as zH}from"@excalidraw/element";import{isInGroup as HH}from"@excalidraw/element";import{jsx as YH}from"react/jsx-runtime";var JC=4,GH=4,UH=(e,n)=>e.reduce((t,o)=>{if(!o||HH(o))return t;if(zH(o))return t.push(o),t;if(FH(o)){let r=OH(o,n);if(r)return t.push(r),t}return t},[]),WH=({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),JC);for(let l of a)r.mutateElement(l,{fontSize:s}),qC(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,JC);t&&(E=He(E,GH)),r.mutateElement(d,{fontSize:E}),qC(d,r.getContainerElement(d),r)}r.triggerUpdate()}},VH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=UH(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 YH(ut,{label:"F",icon:kr,elements:i,dragInputCallback:WH,value:s,editable:l,scene:n,property:o,appState:t})},QC=VH;import{pointFrom as gr,pointRotateRads as yp}from"@excalidraw/math";import{useMemo as XH}from"react";import{isTextElement as KH}from"@excalidraw/element";import{getCommonBounds as hE}from"@excalidraw/element";import{jsx as JH}from"react/jsx-runtime";var $H=(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]=yp(gr(l.x,l.y),gr(c,d),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;ti(u,E,l,i,a,r,!1)}},ZH=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=hE(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&&(!KH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,y]=yp(gr(u.x,u.y),gr(E,g),u.angle);ti(b+c,y+d,p,r,i,o,!1)}}},jH=({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 Fa(n,s)){let E=Oa(u,c,t);if(E.length>1){let[g,b,,]=hE(E.map(x=>x.latest));ZH(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&&zt(b,i)){let[y,w]=[g.x+g.width/2,g.y+g.height/2],[x,v]=yp(gr(g.x,g.y),gr(y,w),g.angle);ti(i==="x"?r:x,i==="y"?r:v,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?He(e,Fl):e;$H(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},qH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=XH(()=>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]=hE(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]=yp(gr(d.x,d.y),gr(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 JH(ut,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:jH,value:s,property:e,scene:r,appState:i})},gE=qH;import{clamp as zl,pointFrom as vp,pointRotateRads as tP,round as eP}from"@excalidraw/math";import{getFlipAdjustedCropPosition as QH,getUncroppedWidthAndHeight as eG}from"@excalidraw/element";import{isImageElement as nP}from"@excalidraw/element";import{jsx as oG}from"react/jsx-runtime";var tG=({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]=tP(vp(m.x,m.y),vp(p,u),m.angle);if(l.croppingElementId===m.id){let v=d.get(m.id);if(!v||!nP(v)||!v.crop)return;let T=v.crop,C=T,P=v.scale[0]===-1,A=v.scale[1]===-1,{width:L,height:_}=eG(v);if(i!==void 0){if(a==="x"){let F=i*(T.naturalWidth/L);P?C={...T,x:zl(T.naturalWidth-F-T.width,0,T.naturalWidth-T.width)}:C={...T,x:zl(i*(T.naturalWidth/L),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:zl(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),s.mutateElement(v,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),D=(a==="y"?n:0)*(A?-1:1);C={...T,x:zl(T.x+k,0,T.naturalWidth-T.width),y:zl(T.y+D,0,T.naturalHeight-T.height)},s.mutateElement(v,{crop:C});return}if(i!==void 0){ti(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?He(m.x+b,Fl):E+b):E,x=a==="y"?Math.round(r?He(m.y+y,Fl):g+y):g;ti(w,x,m,s,c.state,o)},nG=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=tP(vp(n.x,n.y),vp(n.x+n.width/2,n.y+n.height/2),n.angle),a=eP(e==="x"?r:i,2);if(o.croppingElementId===n.id&&nP(n)&&n.crop){let s=QH(n);s&&(a=eP(e==="x"?s.x:s.y,2))}return oG(ut,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:tG,scene:t,value:a,property:e,appState:o})},fE=nG;import{Fragment as xE,jsx as te,jsxs as Ht}from"react/jsx-runtime";var pG=50,Hl=e=>{let n=Ko(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=or(e.app);return te(uG,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},Be=({children:e,columns:n=1,heading:t,style:o,...r})=>te("div",{className:rG("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});Be.displayName="StatsRow";var Tp=({children:e,order:n,style:t,...o})=>te("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Tp.displayName="StatsRows";Hl.StatsRow=Be;Hl.StatsRows=Tp;var uG=sG(({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=Ue(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&bE(m),E=u?cG(m):null,[g,b]=aG({width:0,height:0}),y=EE(()=>iG(v=>{let T=lG(v);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},pG),[]);rP(()=>{y(l)},[i,l,y]),rP(()=>()=>y.cancel(),[y]);let w=EE(()=>Fa(o,r),[o,r]),x=EE(()=>dG(o),[o]);return te("div",{className:"exc-stats",children:Ht(ze,{padding:3,children:[Ht("div",{className:"title",children:[te("h2",{children:f("stats.title")}),te("div",{className:"close",onClick:n,children:Jt})]}),Ht(Ms,{label:te("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&Ip.generalStats),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^Ip.generalStats}})),children:[Ht(Tp,{children:[te(Be,{heading:!0,children:f("stats.scene")}),Ht(Be,{columns:2,children:[te("div",{children:f("stats.shapes")}),te("div",{children:l.length})]}),Ht(Be,{columns:2,children:[te("div",{children:f("stats.width")}),te("div",{children:g.width})]}),Ht(Be,{columns:2,children:[te("div",{children:f("stats.height")}),te("div",{children:g.height})]}),a&&Ht(xE,{children:[te(Be,{heading:!0,children:"Canvas"}),te(Be,{children:te(kC,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&te("div",{id:"elementStats",style:{marginTop:12},children:te(Ms,{label:te("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&Ip.elementProperties),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^Ip.elementProperties}})),children:Ht(Tp,{children:[m&&Ht(xE,{children:[u&&te(Be,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&bE(m)&&E&&Ht(Be,{columns:2,children:[te("div",{children:f("stats.width")}),te("div",{children:oP(E.width,2)})]}),r.croppingElementId&&bE(m)&&E&&Ht(Be,{columns:2,children:[te("div",{children:f("stats.height")}),te("div",{children:oP(E.height,2)})]}),te(Be,{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}`)}),te(Be,{children:te(fE,{element:m,property:"x",elementsMap:c,scene:s,appState:r})}),te(Be,{children:te(fE,{element:m,property:"y",elementsMap:c,scene:s,appState:r})}),te(Be,{children:te(cE,{property:"width",element:m,scene:s,appState:r})}),te(Be,{children:te(cE,{property:"height",element:m,scene:s,appState:r})}),te(Be,{children:te(CC,{property:"angle",element:m,scene:s,appState:r})}),te(Be,{children:te(OC,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Ht(xE,{children:[mG(p)&&te(Be,{heading:!0,children:f("element.group")}),Ht(Be,{columns:2,style:{margin:"0.3125rem 0"},children:[te("div",{children:f("stats.shapes")}),te("div",{children:o.length})]}),te(Be,{children:te(gE,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(gE,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(uE,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(uE,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(UC,{property:"angle",elements:p,scene:s,appState:r})}),te(Be,{children:te(QC,{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 SG,useEffect as aP,useState as sP}from"react";import{normalizeLink as CG,KEYS as IE}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as PG,getLinkIdAndTypeFromSelection as kG}from"@excalidraw/element";import hG from"clsx";import{jsx as Sp,jsxs as fG}from"react/jsx-runtime";var gG=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return fG("button",{className:hG("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Sp("div",{style:a?{visibility:"hidden"}:{},children:o}),Sp("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Sp("div",{style:{position:"absolute",inset:0},children:Sp(ao,{})})]})},wE=gG;import yE from"clsx";import{forwardRef as wG,useRef as yG,useImperativeHandle as vG,useLayoutEffect as IG,useState as TG}from"react";import EG from"clsx";import{composeEventHandlers as bG}from"@excalidraw/common";import{jsx as xG}from"react/jsx-runtime";var fn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>xG("button",{onClick:bG(i.onClick,a=>{n()}),type:e,className:EG("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as vE,jsxs as iP}from"react/jsx-runtime";var Cp=wG(({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=yG(null);vG(p,()=>u.current),IG(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=TG(!1);return iP("div",{className:yE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&vE("div",{className:"ExcTextField__label",children:n}),iP("div",{className:yE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[vE("input",{className:yE({"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&&vE(fn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?_1:Ar})]})]})});import{jsx as Ga,jsxs as Pp}from"react/jsx-runtime";var MG=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=PG})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=sP(a),[c,d]=sP(!1);aP(()=>{let p=ie(i,t),u=a;if(p.length>0&&r){let E=kG(p,t);E&&(u=CG(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=SG(()=>{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 aP(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===IE.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===IE.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),Pp("div",{className:"ElementLinkDialog",children:[Pp("div",{className:"ElementLinkDialog__header",children:[Ga("h2",{children:f("elementLink.title")}),Ga("p",{children:f("elementLink.desc")})]}),Pp("div",{className:"ElementLinkDialog__input",children:[Ga(Cp,{value:s??"",onChange:p=>{c||d(!0),l(p)},onKeyDown:p=>{p.key===IE.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&Ga(K,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:Pr})]}),Pp("div",{className:"ElementLinkDialog__actions",children:[Ga(wE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),Ga(wE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},lP=MG;import AG,{useState as LG}from"react";import{Fragment as DG,jsx as TE}from"react/jsx-runtime";var cP=({children:e,onClose:n})=>{let[t,o]=LG(!!e),{container:r}=De(),i=AG.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return TE(DG,{children:t&&TE(gn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:TE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import dP,{useMemo as HG}from"react";import mP from"clsx";import{isDarwin as pP,isFirefox as GG,isWindows as UG}from"@excalidraw/common";import{KEYS as Ua}from"@excalidraw/common";import{SHAPES as WG}from"@excalidraw/element/shapes";import{isFirefox as _G,KEYS as SE}from"@excalidraw/common";import{SHAPES as RG}from"@excalidraw/element/shapes";import{Fragment as zG,jsx as Ge,jsxs as oi}from"react/jsx-runtime";var NG=e=>oi(zG,{children:[Ge("h3",{children:e.title}),Ge("div",{className:"HelpDialog__islands-container",children:e.children})]}),CE=e=>oi("div",{className:`HelpDialog__island ${e.className}`,children:[Ge("h4",{className:"HelpDialog__island-title",children:e.caption}),Ge("div",{className:"HelpDialog__island-content",children:e.children})]});function*BG(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var OG=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),yt=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ge(FG,{children:OG(a)},a)));return oi("div",{className:"HelpDialog__shortcut",children:[Ge("div",{children:e}),Ge("div",{className:"HelpDialog__key-container",children:[...BG(o,t?f("helpDialog.or"):null)]})]})},FG=e=>Ge("kbd",{className:"HelpDialog__key",...e});function PE(){return oi(NG,{title:f("helpDialog.shortcuts"),children:[oi(CE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ge(yt,{label:f("toolBar.hand"),shortcuts:[SE.H]}),RG.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ge(yt,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ge(yt,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ge(yt,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),oi(CE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ge(yt,{label:f("helpDialog.smartZoom"),shortcuts:[SE.F]}),Ge(yt,{label:f("helpDialog.dragToZoom"),shortcuts:[`${SE.Z}+${f("helpDialog.drag")}`]}),Ge(yt,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),oi(CE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ge(yt,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ge(yt,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ge(yt,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ge(yt,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(qo||_G)&&Ge(yt,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ge(yt,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ge(yt,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ge(yt,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ge(yt,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ge(yt,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as hP,jsx as Z,jsxs as ri}from"react/jsx-runtime";var VG=e=>ri(hP,{children:[Z("h3",{children:e.title}),Z("div",{className:"HelpDialog__islands-container",children:e.children})]}),kE=e=>ri("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*YG(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var XG=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(KG,{children:XG(a)},a)));return ri("div",{className:"HelpDialog__shortcut",children:[Z("div",{children:e}),Z("div",{className:"HelpDialog__key-container",children:[...YG(o,t?f("helpDialog.or"):null)]})]})},KG=e=>Z("kbd",{className:"HelpDialog__key",...e}),uP=({onClose:e})=>{let[n,t]=dP.useState(!1),o=dP.useCallback(()=>{e&&e()},[e]),r=HG(()=>n?Z("button",{className:mP("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):Z("button",{className:mP("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return Z(hP,{children:Z(gn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?ri(VG,{title:f("helpDialog.shortcuts"),children:[ri(kE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Z(q,{label:f("toolBar.hand"),shortcuts:[Ua.H]}),WG.map(({value:i,key:a})=>Z(q,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),Z(q,{label:f("toolBar.frame"),shortcuts:[Ua.F]}),Z(q,{label:f("labels.eyeDropper"),shortcuts:[Ua.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:[Ua.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})]}),ri(kE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Z(q,{label:f("helpDialog.smartZoom"),shortcuts:[Ua.F]}),Z(q,{label:f("helpDialog.dragToZoom"),shortcuts:[`${Ua.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:[Ke("searchMenu")]})]}),ri(kE,{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")}`)]}),(qo||GG)&&Z(q,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Z(q,{label:f("labels.sendToBack"),shortcuts:[pP?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),Z(q,{label:f("labels.bringToFront"),shortcuts:[pP?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:UG?[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(PE,{})})})};import{useEffect as EP,useRef as bP,useState as ii}from"react";import{DEFAULT_EXPORT_PADDING as QG,EXPORT_IMAGE_TYPES as ME,isFirefox as eU,EXPORT_SCALES as tU,cloneJSON as xP}from"@excalidraw/common";import{useCallback as $G,useRef as ZG,useState as jG}from"react";var qG=2e3,gP=()=>{let[e,n]=jG(null),t=ZG(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},qG)},r=$G(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import JG from"clsx";import{jsx as fP}from"react/jsx-runtime";var Gl=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>fP("div",{className:JG("Switch",{toggled:t,disabled:r}),children:fP("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 Oe,jsxs as fr}from"react/jsx-runtime";var nU=()=>fr("div",{children:[Oe("h3",{children:f("canvasError.cannotShowPreview")}),Oe("p",{children:Oe("span",{children:f("canvasError.canvasTooBig")})}),fr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),oU=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=Me(n,e),[l,c]=ii(i),[d,m]=ii(s),[p,u]=ii(e.exportBackground),[E,g]=ii(e.exportEmbedScene),[b,y]=ii(e.exportScale),w=bP(null),x=bP(0),[v,T]=ii(null),{onCopy:C,copyStatus:P,resetCopyStatus:A}=gP();EP(()=>{A()},[l,p,a,b,E,A]);let{exportedElements:L,exportingFrame:_}=Or(n,e,d);return EP(()=>{let k=w.current;if(!k)return;let D=k.offsetWidth,F=k.offsetHeight;if(!D)return;let Y=++x.current,z=()=>Y!==x.current;return xp({elements:L,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:QG,maxWidthOrHeight:Math.max(D,F),exportingFrame:_}).then(async W=>{if(!z()){try{await ls(W)}catch($){throw $.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):$}z()||(T(null),k.replaceChildren(W))}}).catch(W=>{z()||(console.error(W),T(W))}),()=>{x.current+=1}},[e,t,L,_,l,p,a,b,E]),fr("div",{className:"ImageExportModal",children:[Oe("h3",{children:f("imageExportDialog.header")}),fr("div",{className:"ImageExportModal__preview",children:[Oe("div",{className:"ImageExportModal__preview__canvas",ref:w,children:v&&Oe(nU,{})}),Oe("div",{className:"ImageExportModal__preview__filename",children:!mi&&Oe("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction(zh,"ui",k.target.value)}})})]}),fr("div",{className:"ImageExportModal__settings",children:[Oe("h3",{children:f("imageExportDialog.header")}),s&&Oe(Ul,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Oe(Gl,{name:"exportOnlySelected",checked:d,onChange:k=>{m(k)}})}),Oe(Ul,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Oe(Gl,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(Hh,"ui",k)}})}),Oe(Ul,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Oe(Gl,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(ry,"ui",k)}})}),Oe(Ul,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Oe(Gl,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(Ud,"ui",k)}})}),Oe(Ul,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Oe(dp,{name:"exportScale",value:b,onChange:k=>{y(k),o.executeAction(ny,"ui",k)},choices:tU.map(k=>({value:k,label:`${k}\xD7`}))})}),fr("div",{className:"ImageExportModal__settings__buttons",children:[Oe(mr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(ME.png,L,{exportingFrame:_}),icon:Ru,children:f("imageExportDialog.button.exportToPng")}),Oe(mr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(ME.svg,L,{exportingFrame:_}),icon:Ru,children:f("imageExportDialog.button.exportToSvg")}),(qo||eU)&&Oe(mr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(ME.clipboard,L,{exportingFrame:_}),C()},icon:Rc,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Ul=({label:e,children:n,tooltip:t,name:o})=>fr("div",{className:"ImageExportModal__settings__setting",title:e,children:[fr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Oe(ct,{label:t,long:!0,children:A1})]}),Oe("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),wP=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=ii(()=>({appStateSnapshot:xP(n),elementsSnapshot:xP(e)}));return Oe(gn,{onCloseRequest:i,size:"wide",title:!1,children:Oe(oU,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import YU from"clsx";import{CANVAS_SEARCH_TAB as zP,DEFAULT_SIDEBAR as XU}from"@excalidraw/common";import rU from"clsx";import iU from"lodash.debounce";import{Fragment as aU,memo as sU,useEffect as Wl,useMemo as yP,useRef as AE,useState as vP}from"react";import{CLASSES as lU,EVENT as cU,FONT_FAMILY as LE,FRAME_STYLE as DE,getLineHeight as dU}from"@excalidraw/common";import{getCommonBounds as mU,isElementCompletelyInViewport as pU}from"@excalidraw/element";import{measureText as Vl}from"@excalidraw/element";import{KEYS as Wa,randomInteger as IP,addEventListener as uU,getFontString as kp}from"@excalidraw/common";import{newTextElement as hU}from"@excalidraw/element";import{isTextElement as PP,isFrameLikeElement as Mp}from"@excalidraw/element";import{getDefaultFrameName as kP}from"@excalidraw/element/frame";import{Fragment as TU,jsx as ht,jsxs as An}from"react/jsx-runtime";var gU=je(""),_E=je(null),fU=350,MP=()=>{let e=It(),n=Ue(),t=AE(null),[o,r]=Fe(gU),i=o.trim(),[a,s]=vP(!1),[l,c]=vP({nonce:null,items:[]}),d=AE(null),m=AE(void 0),[p,u]=Fe(_E),E=e.scene.getNonDeletedElementsMap();Wl(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,CP(i,e,(x,v)=>{c({nonce:IP(),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)};Wl(()=>{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]),Wl(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let v=e.state.zoom.value,T=hU({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:Mp(x.element)?DE.nameFontSize:x.element.fontSize,fontFamily:Mp(x.element)?LE.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,A=P*v<C;if(!pU([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 L=A&&P<C?"contain":"scale-down";e.viewport.setViewport({target:mU([T]),fit:L,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),Wl(()=>()=>{u(null),d.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let y=Si({goToNextItem:g,goToPreviousItem:b,searchMatches:l});Wl(()=>{let x=v=>{if(v.key===Wa.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),n({openSidebar:null});return}if(v[Wa.CTRL_OR_CMD]&&v.key===Wa.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&n({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&y.searchMatches.items.length&&(v.key===Wa.ENTER&&(v.stopPropagation(),y.goToNextItem()),v.key===Wa.ARROW_UP?(v.stopPropagation(),y.goToPreviousItem()):v.key===Wa.ARROW_DOWN&&(v.stopPropagation(),y.goToNextItem()))};return uU(window,cU.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 An("div",{className:"layer-ui__search",children:[An("div",{className:"layer-ui__search-header",children:[ht(Cp,{className:lU.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:Wn,onChange:x=>{r(x),s(!0);let v=x.trim();CP(v,e,(T,C)=>{c({nonce:IP(),items:T}),u(C),d.current=v,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}),ht(fn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:Jt})]}),An("div",{className:"layer-ui__search-count",children:[l.items.length>0&&An(TU,{children:[p!==null&&p>-1?An("div",{children:[p+1," / ",w]}):ht("div",{children:w}),An("div",{className:"result-nav",children:[ht(fn,{onSelect:()=>{g()},className:"result-nav-btn",children:Bc}),ht(fn,{onSelect:()=>{b()},className:"result-nav-btn",children:X1})]})]}),l.items.length===0&&i&&d.current&&ht("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),ht(xU,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},TP=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 ht("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:ht("div",{className:"preview-text",children:n.flatMap((t,o)=>ht(aU,{children:o===2?ht("b",{children:t}):t},o))})})},EU=e=>{let n=yP(()=>e.matches.items.filter(o=>Mp(o.element)),[e.matches]),t=yP(()=>e.matches.items.filter(o=>PP(o.element)),[e.matches]);return An("div",{className:"layer-ui__search-results",children:[n.length>0&&An("div",{className:"layer-ui__search-result-container",children:[An("div",{className:"layer-ui__search-result-title",children:[ht("div",{className:"title-icon",children:Gn}),ht("div",{children:f("search.frames")})]}),n.map((o,r)=>ht(TP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&ht("div",{className:"layer-ui__divider"})]}),t.length>0&&An("div",{className:"layer-ui__search-result-container",children:[An("div",{className:"layer-ui__search-result-title",children:[ht("div",{className:"title-icon",children:wn}),ht("div",{children:f("search.texts")})]}),t.map((o,r)=>ht(TP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},bU=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,xU=sU(EU,bU),SP=(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}},wU=(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
- `)},tU=(e,n,t)=>{let r=eU(e.text,e.originalText).split(`
21
- `),i=[],a=0,s=0;for(let p of r){let m=a,u=m+p.length-1;i.push({line:p,startIndex:m,endIndex:u,lineNumber:s}),a=u+1,s++}let l=t,c=e.originalText.slice(t,t+n.length),d=[];for(let p of i){if(c==="")break;if(l>=p.startIndex&&l<=p.endIndex){let m=p.endIndex+1-l,u=p.line.slice(0,l-p.startIndex),E=c.slice(0,m);c=c.slice(m);let g=Ll(u,vp(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&p.line.length>0){let v=Ll(p.line,vp(e),e.lineHeight),I=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;g.width+=I}let{width:b,height:y}=Ll(E,vp(e),e.lineHeight),w=g.width,x=p.lineNumber*g.height;d.push({offsetX:w,offsetY:x,width:b,height:y,showOnCanvas:!0}),l+=m}}return d},nU=(e,n,t,o)=>{let r=e.name??TP(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=vp({fontSize:vE.nameFontSize,fontFamily:yE.Assistant}),l=VG(yE.Assistant),c=Ll(a,s,l);a===""&&(c.width=0);let d=Ll(i,s,l),p=c.width,m=-c.height-vE.strokeWidth,u=d.width;return[{offsetX:p,offsetY:m,width:u,height:d.height,showOnCanvas:p+u<=e.width*o}]},oU=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),yP=zG((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(m=>vP(m)),i=o.filter(m=>Tp(m));r.sort((m,u)=>m.y-u.y),i.sort((m,u)=>m.y-u.y);let a=[],s=new RegExp(oU(e),"gi");for(let m of r){let u=null,E=m.originalText;for(;(u=s.exec(E))!==null;){let g=wP(E,u.index,e),b=tU(m,e,u.index);b.length>0&&a.push({element:m,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let l=[];for(let m of i){let u=null,E=m.name??TP(m);for(;(u=s.exec(E))!==null;){let g=wP(E,u.index,e),b=nU(m,e,u.index,n.state.zoom.value);b.length>0&&l.push({element:m,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let c=new Set(n.visibleElements.map(m=>m.id)),d=[...l,...a],p=d.findIndex(m=>c.has(m.element.id))??null;t(d,p)},jG);import EU from"clsx";import{useEffect as AP,useLayoutEffect as LP,useRef as DE,useState as bU,forwardRef as DP,useImperativeHandle as xU,useCallback as PP}from"react";import{CLASSES as wU,EVENT as kP,isDevEnv as yU,KEYS as vU,updateObject as TU}from"@excalidraw/common";import aU from"clsx";import{useContext as sU}from"react";import iU from"react";var Ip=iU.createContext({});import{jsx as IE,jsxs as SP}from"react/jsx-runtime";var SE=({children:e,className:n})=>{let t=ue(),o=sU(Ip),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return SP("div",{className:aU("sidebar__header",n),"data-testid":"sidebar-header",children:[e,SP("div",{className:"sidebar__header__buttons",children:[r&&IE(lt,{label:f("labels.sidebarLock"),children:IE(Mn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:px})}),IE(Mn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:zn})]})]})};SE.displayName="SidebarHeader";import{Tabs as lU}from"radix-ui";import{jsx as CP}from"react/jsx-runtime";var CE=({children:e,tab:n,onSelect:t,...o})=>CP(lU.Trigger,{value:n,asChild:!0,onSelect:t,children:CP("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});CE.displayName="SidebarTabTrigger";import{Tabs as cU}from"radix-ui";import{jsx as dU}from"react/jsx-runtime";var PE=({children:e,...n})=>dU(cU.List,{className:"sidebar-triggers",...n,children:e});PE.displayName="SidebarTabTriggers";import mU from"clsx";import{jsx as kE,jsxs as pU}from"react/jsx-runtime";var ME=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Ne(),d=he().openSidebar?.name===e;return kE("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 p=!d;l({openSidebar:p?{name:e,tab:n}:null,openMenu:null,openPopup:null}),i?.(p)},children:pU("div",{className:mU("sidebar-trigger",a),style:s,children:[t&&kE("div",{children:t}),r&&kE("div",{className:"sidebar-trigger__label",children:r})]})})};ME.displayName="SidebarTrigger";import{Tabs as uU}from"radix-ui";import{jsx as hU}from"react/jsx-runtime";var AE=({children:e,...n})=>{let t=he(),o=Ne();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return hU(uU.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};AE.displayName="SidebarTabs";import{Tabs as gU}from"radix-ui";import{jsx as fU}from"react/jsx-runtime";var LE=({tab:e,children:n,...t})=>fU(gU.Content,{...t,value:e,"data-testid":e,children:n});LE.displayName="SidebarTab";import{jsx as MP}from"react/jsx-runtime";import{createElement as IU}from"react";var _E=Ze(!1),_P=DP(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{yU()&&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=Ne(),l=ix(_E);LP(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=DE({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=TU(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=DE(null);xU(a,()=>d.current);let p=ue(),m=PP(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return xi(d,PP(u=>{u.target.closest(".sidebar-trigger")||(!o||!p.canFitSidebar)&&m()},[m,o,p.canFitSidebar])),AP(()=>{let u=E=>{E.key===vU.ESCAPE&&(!o||!p.canFitSidebar)&&m()};return document.addEventListener(kP.KEYDOWN,u),()=>{document.removeEventListener(kP.KEYDOWN,u)}},[m,o,p.canFitSidebar]),MP(Ue,{...i,className:EU(wU.SIDEBAR,{"sidebar--docked":o},r),"data-viewport-ui":p.formFactor!=="phone"?"side":void 0,"data-viewport-ui-name":p.formFactor!=="phone"?"sidebar":void 0,ref:d,children:MP(Ip.Provider,{value:c.current,children:n})})});_P.displayName="SidebarInner";var jn=Object.assign(DP((e,n)=>{let t=he(),{onStateChange:o}=e,r=DE(t.openSidebar);AP(()=>{(!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]=bU(!1);return LP(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?IU(_P,{...e,ref:n,key:e.name}):null}),{Header:SE,TabTriggers:PE,TabTrigger:CE,Tabs:AE,Tab:LE,Trigger:ME});jn.displayName="Sidebar";import uW,{useEffect as JP,useRef as QP}from"react";import{isShallowEqual as hW,sceneCoordsToViewportCoords as gW}from"@excalidraw/common";import{clamp as Sp,pointFrom as Da,pointsEqual as LU,bezierEquation as WP,pointRotateRads as Cp,pointDistance as DU}from"@excalidraw/math";import{arrayToMap as _U,BIND_MODE_TIMEOUT as Dl,DEFAULT_TRANSFORM_HANDLE_SPACING as VP,FRAME_STYLE as pn,getFeatureFlag as RU,invariant as FP,shouldRotateWithDiscreteAngle as YP,THEME as xo}from"@excalidraw/common";import{deconstructDiamondElement as FE,deconstructRectanguloidElement as KP,elementCenterPoint as _a,getDiamondBaseCorners as NU,FOCUS_POINT_SIZE as BU,getOmitSidesForEditorInterface as RE,getTransformHandles as OU,getTransformHandlesFromCoords as FU,hasBoundingBox as zU,hitElementItself as HU,isArrowElement as XP,isBindableElement as $P,isElbowArrow as Ra,isFrameLikeElement as Na,isImageElement as Pp,isLinearElement as GU,isLineElement as UU,maxBindingDistance_simple as WU,isTextElement as VU,LinearElementEditor as un,getActiveTextElement as YU,getElementsInGroup as zE,getSelectedGroupIds as KU,isSelectedViaGroup as XU,selectGroupsFromGivenElements as $U}from"@excalidraw/element";import{renderSelectionElement as ZU}from"@excalidraw/element";import{getCommonBounds as HE,getElementAbsoluteCoords as Rl}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as zP,isFocusPointVisible as jU}from"@excalidraw/element";import{pointFrom as St}from"@excalidraw/math";import{THEME as SU}from"@excalidraw/common";var CU="#ff6b6b",PU="#ff0000",RP=1,NP=2,BP=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===SU.LIGHT||n.zenModeEnabled?CU:PU,o=(n.zenModeEnabled?RP*1.5:RP)/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,MU(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,AU(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,kU(r,e,n));e.restore()},kU=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];mn(o,r,n)}for(let o of e.points)OP(o,t,n)},MU=(e,n,t)=>{OP(e.points[0],t,n),t.zenModeEnabled||mn(e.points[0],e.points[1],n)},OP=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?NP*1.5:NP)/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()},mn=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},AU=(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||mn(St(e[0],e[1]-i),St(e[0],e[1]+i),r),mn(St(l[0]-s,l[1]-a),St(l[0]-s,l[1]+a),r),mn(St(l[0]+s,l[1]-a),St(l[0]+s,l[1]+a),r),o.zenModeEnabled||(mn(St(n[0],n[1]-i),St(n[0],n[1]+i),r),mn(e,n,r))}else{let l=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||mn(St(e[0]-i,e[1]),St(e[0]+i,e[1]),r),mn(St(l[0]-a,l[1]-s),St(l[0]+a,l[1]-s),r),mn(St(l[0]-a,l[1]+s),St(l[0]+a,l[1]+s),r),o.zenModeEnabled||(mn(St(n[0]-i,n[1]),St(n[0]+i,n[1]),r),mn(e,n,r))}};var qU=(e,n)=>{FP(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;FP(t,"midPointCoords is null"),kp(t,e,n)},JU=(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=un.getElement(o,t);if(!i)return;let a=un.getPointAtIndexGlobalCoordinates(i,r,t);kp(a,e,n)},kp=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",Za(n,e[0],e[1],un.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},QU=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!XP(i)||i.isDeleted)return;let a=r==="label"?un.getBoundTextElementCenter(i,t):un.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);kp(a,e,n)},NE=(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)"),Za(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},eW=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&Na(a)&&(e.translate(a.x,a.y),e.beginPath(),pn.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,pn.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=pn.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===xo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",pn.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,pn.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=_a(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=Sp(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===xo.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]=FE(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[p,m,u,E]=d;e.beginPath(),e.moveTo(p[0]-n.element.x,p[1]-n.element.y),e.bezierCurveTo(m[0]-n.element.x,m[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]=KP(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[p,m,u,E]=d;e.beginPath(),e.moveTo(p[0]-n.element.x,p[1]-n.element.y),e.bezierCurveTo(m[0]-n.element.x,m[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&&(Na(n.element)||$P(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&un.getElement(s?.elementId,t),c=r&&HU({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&Ra(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let p=_a(n.element,t),m;if(n.element.type==="diamond"){let b=_a(n.element,t);m=NU(n.element).map(y=>{let w=WP(y,.5),x=Cp(w,b,n.element.angle);return Da(x[0],x[1])})}else m=[{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=Da(y.x+n.element.x,y.y+n.element.y),x=Cp(w,p,n.element.angle);return Da(x[0],x[1])});let u=r&&m.reduce((b,y,w)=>{let x=DU(y,r);return w===-1||x<b.distance?{idx:w,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=WU(o.zoom)+n.element.strokeWidth/2;m.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===xo.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===xo.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()}}},tW=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=Dl-(a?.runtime??(s?0:Dl)),c=Sp(1/Dl*l,1e-4,1),d=t.strokeWidth/2,p=t.frameId&&o.get(t.frameId);switch(p&&Na(p)&&(n.translate(p.x,p.y),n.beginPath(),pn.radius&&n.roundRect?n.roundRect(-1,-1,p.width+1,p.height+1,pn.radius/r.zoom.value):n.rect(-1,-1,p.width+1,p.height+1),n.clip(),n.translate(-p.x,-p.y)),t.type){case"magicframe":case"frame":n.save(),n.translate(t.x,t.y),n.lineWidth=pn.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===xo.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,pn.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,pn.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=_a(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=Sp(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===xo.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]=FE(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,v,I,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(v[0]-t.x+d,v[1]-t.y+d,I[0]-t.x+d,I[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break;default:{let[b,y]=KP(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,v,I,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(v[0]-t.x+d,v[1]-t.y+d,I[0]-t.x+d,I[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)>Dl)return;let m=.5*(Math.min(t.width,t.height)/2);if(!Na(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/Dl*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,m,m,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,m*(1-c),m*(1-c),0,0,2*Math.PI),n.fill(),n.restore(),r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&(!e.lastPointerMoveEvent||!YP(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]=FE(t),x=_a(t,o);y=w.map(v=>{let I=WP(v,.5),C=Cp(I,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let w=_a(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(v=>{let I=Da(v.x+t.x,v.y+t.y),C=Cp(I,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===xo.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}},nW=(e,n,t,o,r,i,a)=>{if(t===null)return;if(RU("COMPLEX_BINDINGS"))return tW(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Da(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&YP(e.lastPointerMoveEvent);eW(n,t,o,r,s,l),n.restore()},ZP=(e,n,t)=>{let{angle:o,x1:r,y1:i,x2:a,y2:s,selectionColors:l,cx:c,cy:d,dashed:p,activeEmbeddable:m}=t,u=a-r,E=s-i,b=(t.padding??VP*2)/n.zoom.value,y=8/n.zoom.value,w=4/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=(m?4:1)/n.zoom.value;let x=l.length;for(let v=0;v<x;++v)e.strokeStyle=l[v],p&&e.setLineDash([y,w+(y+w)*(x-1)]),e.lineDashOffset=(y+w)*v,ja(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},oW=(e,n,t,o)=>{let[r,i,a,s]=Rl(t,o),l=a-r,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=pn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),ja(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,pn.radius/n.zoom.value),e.restore()},HP=(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[p,m,u,E]=HE(d);return{angle:0,x1:p,x2:u,y1:m,y2:E,selectionColors:r,dashed:i,cx:p+(u-p)/2,cy:m+(E-m)/2,activeEmbeddable:!1}},c=d=>{let p=zE(t,d);return l(p)};Object.entries($U(s,n)).filter(([d,p])=>p).map(([d,p])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>ZP(e,n,d))},BE=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=un.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=un,a=n.selectedLinearElement?.isEditing?i:i/2,s=Ra(t),l=UU(t);if(r.forEach((c,d)=>{if(s&&d!==0&&d!==r.length-1)return;let p=d>0&&(d!==r.length-1||!l||!t.polygon)&&LU(c,d===r.length-1?r[0]:r[d-1],2/n.zoom.value),m=!!n.selectedLinearElement?.isEditing&&!!n.selectedLinearElement?.selectedPointsIndices?.includes(d);l&&t.polygon&&!m&&d===t.points.length-1&&n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(m=!0),NE(e,n,c,a,m,!1,p)}),Ra(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,p)=>{un.isSegmentTooShort(t,r[p+1],r[p],p,n.zoom,o)||NE(e,n,Da((d[0]+r[p+1][0])/2,(d[1]+r[p+1][1])/2),i/2,!1,!c.includes(p+1),!1)})}else un.getEditorMidPoints(t,o,n).filter((d,p,m)=>d!==null&&!(Ra(t)&&(p===0||p===m.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&NE(e,n,d,i/2,!1,!0,!1)});e.restore()},rW=(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()},iW=(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)",Za(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},GP=({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||!$P(a)||a.isDeleted)return;let s=zP(i.fixedPoint,a,r);if(!jU(s,e,a,r,n,t))return;let l=n.selectedLinearElement,c=!!l?.isDragging,d=t==="start"?0:e.points.length-1,p=!!l?.selectedPointsIndices?.includes(d);if(l?.hoveredFocusPointBinding===t&&!l.draggedFocusPointBinding&&kp(s,o,n),!(p&&c)){let m=zP(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=un.getPointAtIndexGlobalCoordinates(e,d,r);rW(o,n,E,m),iW(o,n,m,BU/1.5,u)}},UP=(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"?Za(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()):ja(e,s,l,c,d,s+c/2,l+d/2,r,!0),e.restore()}})},aW=(e,n,t,o,r)=>{let[i,a,,,s,l]=Rl(o,r),c=3,d=20,p=c/t.zoom.value,m=p/2,u=s-i+p,E=l-a+p,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=p,[[[-u,-E],[0,m],[g,m],[m,0],[m,b]],[[u-m,-E],[m,m],[-g+m,m],[0,0],[0,b]],[[-u,E],[0,-m],[g,-m],[m,0],[m,-b]],[[u-m,E],[m,-m],[-g+m,-m],[0,0],[0,-b]]].forEach(w=>{let[[x,v],[I,C],[P,A],[L,_],[k,D]]=w;e.save(),e.translate(s,l),e.rotate(o.angle),e.beginPath(),e.moveTo(x+I,v+C),e.lineTo(x+P,v+A),e.stroke(),e.beginPath(),e.moveTo(x+L,v+_),e.lineTo(x+k,v+D),e.stroke(),e.restore()}),e.restore()},sW=(e,n,t,o)=>{n.save();let r=Wg(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()},lW=(e,n,t,o,r)=>{let i=Vg(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())},cW=(e,n,t,o,r,i)=>{for(let a of n){if(!Pp(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(a.status==="error"||!!s?.downloadError){let d=_l(a,t,r,"center");d&&qP(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 p=_l(a,t,r,"center");p&&jP(e,p.centerX+r.scrollX,p.centerY+r.scrollY,p.radius,p.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=_l(a,t,r,"top-right");d&&mW(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},_l=(e,n,t,o)=>{if(!Pp(e))return null;let[r,i,a,s]=Rl(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,p=Math.min((o==="center"?3:2.6)/l,d/2);if(d<=0||p<=0)return null;if(o==="top-right"){let m=6/l;return{centerX:a-m-d,centerY:i+m+d,radius:d,lineWidth:p}}return{centerX:(r+a)/2,centerY:(i+s)/2,radius:d,lineWidth:p}},jP=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===xo.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*Sp(i,0,1)),e.stroke()),e.restore()},OE=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,dW=(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()},mW=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",c=i.color??OE("--color-primary",s),d=i.color??OE("--color-warning-darkest","#ec8b14");if(l==="failed"){qP(e,n,t,o,a,{color:i.color??OE("--color-danger","#e03131")});return}l==="uploading"&&jP(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),dW(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(),e.moveTo(n+o*.42,t-o*.34),e.lineTo(n+o*.42,t+o*.14),e.stroke(),e.beginPath(),e.arc(n+o*.42,t+o*.42,o*.1,0,Math.PI*2),e.fill(),e.restore()):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())},qP=(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()},pW=({app:e,canvas:n,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:i,scale:a,appState:s,renderConfig:l,editorInterface:c,animationState:d,deltaTime:p})=>{if(n===null)return{};let[m,u]=ac(n,a),E=d,g=sc({canvas:n,scale:a,normalizedWidth:m,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&&BE(g,s,b,t),s.selectionElement&&!s.isCropping)try{ZU(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let y=YU(r,s);if(y&&!y.autoResize&&lW(y,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&sW(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:nW(e,g,s.suggestedBinding,i,s,p,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&QU(g,s,i),s.frameToHighlight&&oW(g,s,s.frameToHighlight,t),s.elementsToHighlight&&HP(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:zE(i,s.activeLockedId);HP(g,s,P,{colors:["#ced4da"],dashed:!0})}let w=r.some(C=>Na(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&BE(g,s,r[0],t);let x=s.selectedLinearElement,v=x&&un.getElement(x.elementId,i);if(v&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?qU(g,s):(Ra(v)?x.hoverPointIndex===0||x.hoverPointIndex===v.points.length-1:x.hoverPointIndex>=0)&&JU(g,s,t)),XP(v)&&(GP({arrow:v,elementsMap:i,appState:s,context:g,type:"start"}),GP({arrow:v,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=zU(r,s,c),P=r.length===1&&GU(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&BE(g,s,r[0],t);let A=l.selectionColor||"#000";if(C){let L=_U(r),_=[];for(let D of t.values()){let O=[],G=l.remoteSelectedElementIds.get(D.id);if(P&&Ra(D)&&(D.startBinding||D.endBinding)||(L.has(D.id)&&!XU(s,D)&&O.push(A),G&&O.push(...G.map(z=>Fr(z,s.collaborators.get(z))))),O.length){let[z,W,j,X,oe,B]=Rl(D,t,!0);_.push({angle:D.angle,x1:z,y1:W,x2:j,y2:X,selectionColors:D.locked?["#ced4da"]:O,dashed:!!G||D.locked,cx:oe,cy:B,activeEmbeddable:s.activeEmbeddable?.element===D&&s.activeEmbeddable.state==="active",padding:D.id===s.croppingElementId||Pp(D)?0:void 0})}}let k=D=>{let O=zE(t,D),[G,z,W,j]=HE(O);_.push({angle:0,x1:G,x2:W,y1:z,y2:j,selectionColors:O.some(X=>X.locked)?["#ced4da"]:["#000"],dashed:!0,cx:G+(W-G)/2,cy:z+(j-z)/2,activeEmbeddable:!1})};for(let D of KU(s))k(D);s.editingGroupId&&k(s.editingGroupId),_.forEach(D=>ZP(g,s,D))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let L=OU(r[0],s.zoom,t,"mouse",RE(c));if(!s.viewModeEnabled&&C&&!VU(s.editingTextElement)&&!s.croppingElementId&&UP(g,l,s,L,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&Pp(_)&&aW(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(L=>L.locked)){let L=VP*2/s.zoom.value;g.fillStyle="#fff";let[_,k,D,O]=HE(r,t),G=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=A,ja(g,_-L,k-L,D-_+L*2,O-k+L*2,(_+D)/2,(k+O)/2,0),g.lineWidth=z,g.setLineDash(G);let W=FU([_,k,D,O,(_+D)/2,(k+O)/2],0,s.zoom,"mouse",w?{...RE(c),rotation:!0}:RE(c));r.some(j=>!j.locked)&&UP(g,l,s,W,0)}g.restore()}s.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:A})=>{let L=t.get(C);if(L){let[_,k,,,D,O]=Rl(L,t,!0);g.save(),s.theme===xo.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 G=Na(L)?s.zoom.value:1;g.translate(s.scrollX,s.scrollY),g.translate(D,O),g.rotate(L.angle),A.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/G-D,k+z.offsetY/G-O,z.width/G,z.height/G)}),g.restore()}}),BP(g,s),cW(g,o,t,e,s,l.selectionColor),g.restore(),py({context:g,renderConfig:l,appState:s,normalizedWidth:m,normalizedHeight:u});let I;return l.renderScrollbars&&(I=B2(t,m,u,s),g.save(),g.fillStyle=N2,g.strokeStyle="rgba(255,255,255,0.8)",[I.horizontal,I.vertical].forEach(C=>{C&&Fd(g,C.x,C.y,C.width,C.height,sn/2)}),g.restore()),{scrollBars:I,animationState:E}},GE=e=>{let n=pW(e);return e.callback(n),n};import{jsx as bW}from"react/jsx-runtime";var ek="animateInteractiveScene",fW=e=>{let n=QP(!1),t=QP(null);return JP(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&GE({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),JP(()=>{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 p of Object.keys(c.selectedElementIds))i.has(p)||i.set(p,[]),i.get(p).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,gW({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},tt.running(ek)||tt.start(ek,({deltaTime:c,state:d})=>{let p=GE({...t.current,deltaTime:c,animationState:d}).animationState;if(p){for(let m in p)if(p[m]!==void 0)return p}})}),bW("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")})},tk=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}),EW=(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:hW(tk(e.appState),tk(n.appState)),UE=uW.memo(fW,EW);import rk,{useEffect as Mp,useRef as Nl}from"react";import{isShallowEqual as nk}from"@excalidraw/common";import{jsx as yW}from"react/jsx-runtime";var xW=e=>{let n=Nl(null),t=Nl(!1),o=Nl(e),r=Nl(()=>{}),i=Nl(null);o.current=e;let a=rk.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();Kb({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}},oa());let p=s.renderConfig.imageTransitionDuration??0;p>0&&s.visibleElements.some(u=>{if(u.type!=="image"||!u.fileId)return!1;let E=s.renderConfig.imageCache.get(u.fileId)?.transitionStart;return E!==void 0&&performance.now()-E<p})&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,Mp(()=>{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]),Mp(()=>{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()}),Mp(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),Mp(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),yW("div",{className:"excalidraw__canvas-wrapper",ref:n})},ok=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}),wW=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:nk(ok(e.appState),ok(n.appState))&&nk(e.renderConfig,n.renderConfig),WE=rk.memo(xW,wW);import{useEffect as kW,useRef as MW}from"react";import{throttleRAF as vW}from"@excalidraw/common";import{getTargetFrame as TW,isInvisiblySmallElement as IW,renderElement as SW,shouldApplyFrameClip as CW}from"@excalidraw/element";var ik=({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=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(IW(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=TW(t,o,a);u&&CW(t,u,a,o)&&Vb(u,d,s,a)}SW(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},PW=vW(e=>{ik(e)}),ak=(e,n)=>{if(n){PW(e);return}ik(e)};import{jsx as LW}from"react/jsx-runtime";var AW=e=>{let n=MW(null);return kW(()=>{n.current&&ak({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},oa())}),LW("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})},sk=AW;import DW from"clsx";import{useLayoutEffect as _W,useEffect as lk,useRef as RW,useState as NW}from"react";import{ARROW_TYPE as ck,EVENT as Ap}from"@excalidraw/common";import{jsx as zW}from"react/jsx-runtime";var dk=700,BW=100,OW=16,FW=5*60*1e3,pk=Ze(null),mk=e=>e===ck.elbow?No:e===ck.round?Bo:Ro,Lp=class{constructor(n){T(this,"app");T(this,"lastShownAt",0);T(this,"show",n=>{let{x:t,y:o}=this.app.viewport.lastPosition;t===0&&o===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(pk,{content:n,nonce:Math.random()}))});T(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<FW);T(this,"onArrowTypeCycled",n=>{this.show(mk(n))});T(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?Do:mk(this.app.state.currentItemArrowType))});this.app=n}},uk=()=>{let[e,n]=Fe(pk),t=Tt(),{container:o}=Ae(),r=RW(null),[i,a]=NW(!1),s=e?.nonce;return _W(()=>{if(s==null||!o)return;let l=(d,p)=>{let m=r.current;if(!m)return;let{left:u,top:E}=Gc({cursor:{x:d,y:p},element:{width:m.offsetWidth,height:m.offsetHeight},container:o.getBoundingClientRect(),gap:OW});m.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(Ap.POINTER_MOVE,c),()=>{window.removeEventListener(Ap.POINTER_MOVE,c)}},[s,o,t]),lk(()=>()=>{n(null)},[n]),lk(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},dk),c=window.setTimeout(()=>{n(null)},dk+BW),d=()=>{n(null)};return window.addEventListener(Ap.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(Ap.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?zW("div",{ref:r,className:DW("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var Dp=class{constructor(n){this.getState=n;T(this,"listeners",[]);T(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:p}=n;r=c,i=m=>m,a=d?(m,u)=>d(u):void 0,s=p??!1,l=c(this.getState())}else if(typeof n=="function"){let c=n;r=(d,p)=>c(d)!==c(p),i=d=>c(d)}else if(Array.isArray(n)){let c=n;r=(d,p)=>c.some(m=>d[m]!==p[m]),i=d=>d}else{let c=n;r=(d,p)=>d[c]!==p[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 HW,getElementsInGroup as GW,isNonDeletedElement as hk,selectGroupsFromGivenElements as UW}from"@excalidraw/element";import{sceneCoordsToViewportCoords as WW}from"@excalidraw/common";import{flushSync as VW}from"react-dom";import{jsx as KW}from"react/jsx-runtime";var YW=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!hk(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&hk(t)?t:null,r=o?[o]:GW(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=HW(r),{x:s,y:l}=WW({sceneX:i,sceneY:a},e.state);return KW("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{VW(()=>{let c=UW(r,e.state);e.setState({selectedElementIds:r.reduce((d,p)=>({...d,[p.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(zs)},title:f("labels.elementLock.unlock"),children:ux})},gk=YW;import{Fragment as YY,jsx as ve,jsxs as pb}from"react/jsx-runtime";var vM=hn.createContext(null),TM=hn.createContext(null),ub={formFactor:"desktop",desktopUIMode:"full",userAgent:wM(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},gb=hn.createContext(ub);gb.displayName="EditorInterfaceContext";var UY={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},fb=hn.createContext({container:null,id:null});fb.displayName="ExcalidrawContainerContext";var Eb=hn.createContext([]);Eb.displayName="ExcalidrawElementsContext";var bb=hn.createContext({...Lo(),width:0,height:0,offsetLeft:0,offsetTop:0});bb.displayName="ExcalidrawAppStateContext";var xb=hn.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});xb.displayName="ExcalidrawSetAppStateContext";var wb=hn.createContext(null);wb.displayName="ExcalidrawActionManagerContext";var Wa=hn.createContext(null);Wa.displayName="ExcalidrawAPIContext";var Xp=hn.createContext(null);Xp.displayName="ExcalidrawAPISetContext";var Tt=()=>Co(vM),bn=()=>Co(TM),ue=()=>Co(gb),rt=()=>Kp(ue()),Ae=()=>Co(fb),yi=()=>Co(Eb),Uo=()=>Co(bb),Ne=()=>Co(xb),Xe=()=>Co(wb),cd=()=>Co(Wa),Yl=!1,Kl=0,Xl=null,Io=!1,So=!1,Wp=!1,$l={horizontal:null,vertical:null},Er=0,Zl=!1,mb=new Map,WY=4,Vp=!1,Yp=0,EM=!1,Ua=null,se={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},hb=class e extends hn.Component{constructor(t){super(t);T(this,"canvas");T(this,"interactiveCanvas",null);T(this,"sessionExportThemeOverride");T(this,"rc");T(this,"unmounted",!1);T(this,"actionManager");T(this,"editorInterface",ub);T(this,"stylesPanelMode",Kp(ub));T(this,"excalidrawContainerRef",hn.createRef());T(this,"scene");T(this,"fonts");T(this,"renderer");T(this,"visibleElements");T(this,"hasRenderableElements",!1);T(this,"resizeObserver");T(this,"id");T(this,"store");T(this,"history");T(this,"excalidrawContainerValue");T(this,"files",{});T(this,"imageCache",new Map);T(this,"imageLoadingProgress",new Map);T(this,"imageLoadingProgressEmitter",new Jn);T(this,"imageStatus",new Map);T(this,"imageStatusEmitter",new Jn);T(this,"imagePlaceholderUpdateEmitter",new Jn);T(this,"iFrameRefs",new Map);T(this,"embedsValidationStatus",new Map);T(this,"initializedEmbeds",new Set);T(this,"elementsPendingErasure",new Set);T(this,"_initialized",!1);T(this,"editorLifecycleEvents",new vV(UY));T(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));T(this,"appStateObserver",new Dp(()=>this.state));T(this,"onStateChange",this.appStateObserver.onStateChange);T(this,"bucketFill",new _m(this));T(this,"flowchart",new Fm(this));T(this,"cursor",new Rm(this));T(this,"arrowText",new Dm(this));T(this,"viewport",new Hm(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>se.pointers.size>=2||So}));T(this,"bindModeHandler",null);T(this,"textWysiwygSubmitHandler",null);T(this,"hitLinkElement");T(this,"lastPointerDownEvent",null);T(this,"lastPointerUpEvent",null);T(this,"lastPointerUpIsDoubleClick",!1);T(this,"lastPointerMoveEvent",null);T(this,"lastPointerMoveCoords",null);T(this,"lastCompletedCanvasClicks",[]);T(this,"previousPointerMoveCoords",null);T(this,"drawShape",new Om(this));T(this,"laserTrails",new um(this));T(this,"eraserTrail",new wm(this));T(this,"lassoTrail",new xm(this));T(this,"cursorHints",new Lp(this));T(this,"onChangeEmitter",new Jn);T(this,"onPointerDownEmitter",new Jn);T(this,"onPointerUpEmitter",new Jn);T(this,"onUserFollowEmitter",new Jn);T(this,"onScrollChangeEmitter",new Jn);T(this,"missingPointerEventCleanupEmitter",new Jn);T(this,"onRemoveEventListenersEmitter",new Jn);T(this,"api");T(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});T(this,"updateEditorAtom",(t,...o)=>{let r=gt.set(t,...o);return this.triggerRender(),r});T(this,"previousHoveredBindableElement",null);T(this,"getEffectiveGridSize",()=>Qo(this)?this.state.gridSize:null);T(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)}});T(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:o,moveEvent:r})=>t&&Wl(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Pe.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));T(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=Ck);T(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),Ga.delete(t)});T(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(To(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=tb(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else QE(r)&&t.add(r.id);return!1}),o&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});T(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);T(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=Se({clientX:i.x,clientY:i.y},this.state),s=Se({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});T(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});T(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===Fl.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&vt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!Vk(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}=Np({sceneX:i.x,sceneY:i.y},this.state),l=6,c,d=aY(i);if(i.id===this.state.editingFrame){let p=d;c=ve("input",{autoFocus:!0,value:p,onChange:m=>{this.scene.mutateElement(i,{name:m.target.value})},onFocus:m=>m.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:m=>{(m.key===K.ESCAPE||m.key===K.ENTER)&&this.resetEditingFrame(i)},style:{background:yV(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:`${wo.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?wo.nameColorDarkTheme:wo.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-l}px`},size:p.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return ve("div",{id:this.getFrameNameDOMId(i),className:JE.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+wo.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:wo.nameFontSize,color:t?wo.nameColorDarkTheme:wo.nameColorLightTheme,lineHeight:wo.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:Pe.MOVE,pointerEvents:this.state.viewModeEnabled?Oa.disabled:Oa.enabled},onPointerDown:p=>this.handleCanvasPointerDown(p),onWheel:p=>this.handleWheel(p),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});T(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});T(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());T(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());T(this,"getSceneElements",()=>this.scene.getNonDeletedElements());T(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});T(this,"onExportImage",async(t,o,r)=>{Re("export",t,"ui");let i=await Nr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(xV).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&cc(i)&&this.setState({fileHandle:i})});T(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(Nt,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(o,r)=>{let i=t==="background"&&r.altKey||t==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:o},captureUpdate:jt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:o},captureUpdate:jt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(s=>this.state.selectedElementIds[s.id]?gr(s,{[i?"strokeColor":"backgroundColor"]:o}):s),captureUpdate:jt.IMMEDIATELY})},keepOpenOnAlt:!1})});T(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});T(this,"syncActionResult",Ve(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||!1,a=t?.appState?.zenModeEnabled||!1,s=t?.appState?.theme||this.props.theme||Fl.LIGHT,l=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),this.isInteractionEnabled()||(i=!0),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r){let d=r.id,p=t.elements.find(m=>m.id===d);r=p&&Up(p)&&Ut(p)?p:null}this.setState(d=>{let p=t.appState||{};return{...d,...p,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:a,theme:s,name:l,errorMessage:c}}),o=!0}o||this.scene.triggerUpdate()}));T(this,"scheduleCapture",()=>this.store.scheduleCapture());T(this,"onBlur",Ve(()=>{Io=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));T(this,"onUnload",()=>{this.onBlur()});T(this,"disableEvent",t=>{t.preventDefault()});T(this,"preventBrowserZoomWheel",t=>{t[K.CTRL_OR_CMD]&&t.preventDefault()});T(this,"handleNavigationModeKeyDown",t=>{if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}this.actionManager.handleKeyDown(t)});T(this,"maybeHandlePageScrollKeyDown",t=>{if(t.key!==K.PAGE_UP&&t.key!==K.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===K.PAGE_DOWN&&(o=-o),t.shiftKey?this.viewport.translate(r=>({scrollX:r.scrollX+o})):this.viewport.translate(r=>({scrollY:r.scrollY+o})),!0});T(this,"preventBrowserZoomKeyDown",t=>{t[K.CTRL_OR_CMD]&&(t.code===pr.EQUAL||t.code===pr.MINUS||t.code===pr.ZERO||t.code===pr.NUM_ADD||t.code===pr.NUM_SUBTRACT||t.code===pr.NUM_ZERO)&&t.preventDefault()});T(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Io=!1,So=!1,Wp=!1,Ua=null,se.pointers.clear(),se.lastCenter=null,se.initialDistance=null,se.initialScale=null,clearTimeout(Kl),Kl=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(Yp),Yp=0,Vp=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),gt.set(Nt,null),gt.set($n,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&vt(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())});T(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,$d(),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:Zt(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())});T(this,"isSameForcedTool",(t,o)=>t?.type===o?.type&&(t?.type==="custom"?t.customType??null:null)===(o?.type==="custom"?o.customType??null:null));T(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)});T(this,"resetHistory",()=>{this.history.clear()});T(this,"resetStore",()=>{this.store.clear()});T(this,"resetScene",Ve(t=>{this.scene.replaceAllElements([]),this.setState(o=>({...Lo(),isLoading:t?.resetLoadingState?!1:o.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));T(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=vr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=ci(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast};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(p=>!p.isDeleted),c=Gl(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,...ai(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:jt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),uY(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});T(this,"getFormFactor",(t,o)=>this.props.UIOptions.getFormFactor?.(t,o)??CV(t,o));T(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=AV(),a=wM(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:oV,l=qE(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)});T(this,"reconcileStylesPanelMode",t=>{let o=Kp(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}}))});T(this,"setDesktopUIMode",t=>{let o=LV(t);this.editorInterface=qE(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});T(this,"onResize",Ve(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Ga.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));T(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});T(this,"renderInteractiveSceneCallback",({scrollBars:t})=>{t&&($l=t),this.scheduleImageRefresh()});T(this,"onScroll",Mk(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},rV));T(this,"onCut",Ve(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||zl(t.target)||(this.actionManager.executeAction(Ud,"keyboard",t),t.preventDefault(),t.stopPropagation())}));T(this,"onCopy",Ve(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||zl(t.target)||(this.actionManager.executeAction(Gi,"keyboard",t),t.preventDefault(),t.stopPropagation())}));T(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(PV&&t.preventDefault(),!Yl){Yl=!0,t.touches.length===1&&(Xl={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Kl),Kl=window.setTimeout(e.resetTapTwice,Ck);return}if(Yl&&t.touches.length===1&&Xl){let o=t.touches[0];qn(ne(o.clientX,o.clientY),ne(Xl.x,Xl.y))<=_k&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),Yl=!1,clearTimeout(Kl)}t.touches.length===2&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null})}});T(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}):se.pointers.clear())});T(this,"pasteFromClipboard",Ve(async t=>{if(!this.isInteractionEnabled())return;let o=!!Vp,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)||zl(r)))return;let s=await _r(t),l=s.getFiles(),c=await Ad(s,o);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()}));T(this,"addElementsFromPasteOrLibrary",t=>{let o=vr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=za(o),l=Fa(r,a)/2,c=Fa(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,p=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:m,y:u}=Se({clientX:d,clientY:p},this.state),E=m-l,g=u-c,[b,y]=Ct(E,g,this.getEffectiveGridSize()),{duplicatedElements:w}=Hk({type:"everything",elements:o.map(A=>gr(A,{x:A.x+b-r,y:A.y+y-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),v=[...x,...w];v=this.props.onDuplicate?.(v,x)||v,oM(v,Gl(w));let C=this.getTopLayerFrameAtSceneCoords({x:m,y:u});if(C){let A=sY(w,C);v=ib(v,A,C)}this.scene.replaceAllElements(v),w.forEach(A=>{if(Ut(A)&&Uk(A)){let L=$k(A,this.scene.getElementsMapIncludingDeleted());QV(A,L,this.scene)}}),MV&&oo.loadElementsFonts(w).then(A=>{this.fonts.onLoaded(A)}),t.files&&this.addMissingFiles(t.files);let P=IY(w);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&gt.get(_E)?this.state.openSidebar:null,...rM(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}})});T(this,"addElementsFromPaste",t=>{this.addElementsFromPasteOrLibrary({...t,fit:t.fitToContent?"contain":void 0})});T(this,"setAppState",(t,o)=>{this.setState(t,o)});T(this,"removePointer",t=>{Er&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=se.pointers.size>=2;se.pointers.delete(t.pointerId),o&&se.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});T(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Re("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...Zt(this.state,o.activeTool.locked?{type:this.state.preferredSelectionTool.type}:o.activeTool),locked:!o.activeTool.locked}})))});T(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}}})});T(this,"togglePenMode",t=>{this.setState(o=>({penMode:t??!o.penMode,penDetected:!0,currentItemStrokeVariability:o.penDetected?o.currentItemStrokeVariability:"variable"}))});T(this,"revealIfHidden",t=>{!t.length||$V(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:za(t),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});T(this,"scrollToViewport",(t,o)=>{this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:{value:no(t.zoom)},shouldCacheIgnoreZoom:!1})});T(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}})});T(this,"emitUserFollowIntent",t=>{this.onUserFollowEmitter.trigger(t),this.props.onUserFollow?.(t)});T(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});T(this,"setToast",t=>{this.setState({toast:t})});T(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,jW,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});T(this,"addFiles",Ve(t=>{let{addedFiles:o}=this.addMissingFiles(t);this.clearImageShapeCache(o),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));T(this,"addImageElementsToScene",async(t,o,r)=>{await this.insertImages(t.map(({file:i})=>i),o,r)});T(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await di(o);if(!dc(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};this.imageCache.set(t,s),i.src=await mc(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}});T(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=Bl(o,0,1);this.imageLoadingProgress.get(t)!==r&&(this.imageLoadingProgress.set(t,r),this.imageLoadingProgressEmitter.trigger())});T(this,"setDownloadError",(t,o)=>{this.updateImageStatus(t,r=>({...r,downloadError:o===!0?{}:o||null}))});T(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:Bl(o,0,1)}:{progress:void 0}}}})});T(this,"updateImageStatus",(t,o)=>{let r=this.imageStatus.get(t),i=o(r);this.areImageStatusesEqual(r,i)||(!i.downloadError&&!i.uploadProgress?this.imageStatus.delete(t):this.imageStatus.set(t,i),this.imageStatusEmitter.trigger())});T(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);T(this,"clearImageLoadingProgress",t=>{this.imageLoadingProgress.delete(t)&&this.imageLoadingProgressEmitter.trigger()});T(this,"clearImageShapeCacheForFileId",t=>{for(let o of this.scene.getNonDeletedElements())Ha(o)&&o.fileId===t&&Ga.delete(o)});T(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===Ba.svg))try{let l=Jb(Xk(Qb(s.dataURL)),Ba.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});T(this,"updateScene",Ve(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?_V({...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}))}));T(this,"applyDeltas",(t,o)=>{let r=dM.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return dM.applyTo(r,a,i,o)});T(this,"mutateElement",(t,o,r=!0)=>this.scene.mutateElement(t,o,{informMutation:r,isDragging:!1}));T(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});T(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});T(this,"updateCurrentCursorPosition",Ve(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));T(this,"onKeyDown",Ve(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(s,l){let c=s[l];return typeof c=="function"?c.bind(s):l==="key"?t.shiftKey?s.key.toUpperCase():s.key.toLowerCase():c}})),!Ak(t.target)){if((t.key===K.ESCAPE||t.key===K.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let s=ie(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&fr(s[0])&&t.key===K.ENTER){this.startImageCropping(s[0]);return}if(t.key===K.ESCAPE)this.updateEditorAtom($n,null);else if(t.key===K.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(JE.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let l=Lm(s);gt.get($n)?.type==="panel"&&yf(this,{conversionType:l,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),l&&this.updateEditorAtom($n,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[K.CTRL_OR_CMD]&&t.key.toLowerCase()===K.V&&(Vp=t.shiftKey,clearTimeout(Yp),Yp=window.setTimeout(()=>{Vp=!1},100)),t[K.CTRL_OR_CMD]&&zl(t.target)&&(t.code===pr.MINUS||t.code===pr.EQUAL)){t.preventDefault();return}if(zl(t.target)&&t.key!==K.ESCAPE||KE(t.key)&&Ak(t.target))return;if(t.key===K.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===K.E&&t.shiftKey&&t[K.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===K.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else vo("COMPLEX_BINDINGS")?this.handleSkipBindMode():Gp({app:this,event:t});if(this.actionManager.handleKeyDown(t))return;let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===K.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let s=Iw(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!Rk(s,["laser","hand"]))return;if(s){if(this.state.activeTool.type!==s&&Re("toolbar",s,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),s==="arrow"&&this.state.activeTool.type==="arrow"){let l=this.state.currentItemArrowType===ur.sharp?ur.round:this.state.currentItemArrowType===ur.round?ur.elbow:ur.sharp;this.setState({currentItemArrowType:l}),this.cursorHints.onArrowTypeCycled(l)}else(s==="arrow"||s==="line")&&this.cursorHints.onToolShortcut(s,/^\d$/.test(t.key)?"digit":"letter");s==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():s==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:s},{toggle:!0}),t.stopPropagation();return}else if(t.key===K.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[K.CTRL_OR_CMD]&&!t.repeat&&(vo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Ht(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),Gp({app:this,event:t})),KE(t.key)){let s=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=new Set;s.filter(m=>eo(m)).filter(m=>{let u=m.startBinding&&!s.some(g=>g.id===m.startBinding?.elementId),E=m.endBinding&&!s.some(g=>g.id===m.endBinding?.elementId);return u||E}).forEach(m=>l.add(m.id)),s=s.filter(m=>!l.has(m.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?Sk:this.getEffectiveGridSize())||(t.shiftKey?eV:Sk),d=0,p=0;t.key===K.ARROW_LEFT?d=-c:t.key===K.ARROW_RIGHT?d=c:t.key===K.ARROW_UP?p=-c:t.key===K.ARROW_DOWN&&(p=c),s.forEach(m=>{this.scene.mutateElement(m,{x:m.x+d,y:m.y+p},{informMutation:!1,isDragging:!1}),Fp(m,this.scene,{simultaneouslyUpdated:s})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===K.ENTER){let s=this.scene.getSelectedElements(this.state);if(s.length===1){let l=s[0];if(t[K.CTRL_OR_CMD]||lb(l))Rt(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),Gt(l)||this.actionManager.executeAction(Ji));else if(Ut(l)||Zk(l)){let c;Ut(l)||(c=l);let d=ob(l,this.scene.getNonDeletedElementsMap()),p=d.x,m=d.y;this.startTextEditing({sceneX:p,sceneY:m,container:c}),t.preventDefault();return}else vt(l)&&this.setState({editingFrame:l.id})}}if(t.key===K.SPACE&&se.pointers.size===0&&(Io=!0,this.cursor.set(Pe.GRAB),t.preventDefault()),(t.key===K.G||t.key===K.S)&&!t.altKey&&!t[K.CTRL_OR_CMD]){let s=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!s.length)return;t.key===K.G&&(Ao(this.state.activeTool.type)||s.some(l=>Ao(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===K.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[K.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===K.F){let s=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!s.length)return;(this.state.activeTool.type==="text"||s.find(l=>Ut(l)||nb(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===K.S&&t.shiftKey&&!t[K.CTRL_OR_CMD],a=t.key===K.I||r===K.G&&t.shiftKey;(i||a)&&this.openEyeDropper({type:i?"stroke":"background"})}));T(this,"onKeyUp",Ve(t=>{if(this.isInteractionEnabled()){if(t.key===K.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Pe.GRAB):Bp(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Io=!1),t.key===K.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Gp({app:this,event:t})),(t.key===K.ALT&&this.state.bindMode==="skip"||!t[K.CTRL_OR_CMD]&&!Op(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&vo("COMPLEX_BINDINGS"))){let o=Se({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=hr(ne(o.x,o.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=ce.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());eo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[K.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Ht(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),Gp({app:this,event:t})}if(KE(t.key)){Bk(this.scene.getSelectedElements(this.state).filter(Ul),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(cb).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...pM(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...pM(r,o.get(r.endBinding.elementId),"end",o)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(t)}}));T(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(ct);let i=_i.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?Zt(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?Zt(this.state,{...t,lastActiveTool:this.state.activeTool}):Zt(this.state,t);s.type==="hand"?this.cursor.set(Pe.GRAB):Io||this.cursor.applyForTool(s),fV(document.activeElement)&&this.focusContainer(),YV(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:Bp(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:ke({},l),selectedGroupIds:ke({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:ke({},l),selectedGroupIds:ke({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});T(this,"setOpenDialog",t=>{this.setState({openDialog:t})});T(this,"isTouchScreenMultiTouchGesture",()=>se.pointers.size>=2);T(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${Lk()}`);T(this,"onGestureStart",Ve(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null}),se.initialScale=this.state.zoom.value)}));T(this,"onGestureChange",Ve(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=se.initialScale;o&&this.viewport.translate(r=>({...Mo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:no(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));T(this,"onGestureEnd",Ve(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}),se.initialScale=null)}));T(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=fM(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&T2(o,r,this.state.zoom.value,this.editorInterface.formFactor))});T(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=fM(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(Rg,"ui",r),this.cursor.reset(),!0)});T(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 p=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&p&&(nb(i,this.scene.getNonDeletedElementsMap())||(c=!0));let m=d?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=m?.fontFamily||this.state.currentItemFontFamily,E=m?.lineHeight||kk(u),g=this.state.currentItemFontSize;if(!m&&c&&i&&!Ul(i)){let C=fY(ZE({fontSize:g,fontFamily:u}),E),P=EY(g,E),A=Math.max(i.height,P),L=Math.max(i.width,C);this.scene.mutateElement(i,{height:A,width:L}),t=i.x+L/2,o=i.y+A/2,p&&(p=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),y=d?{x:t,y:o}:p?{x:p.elementCenterX,y:p.elementCenterY}:m?{x:t,y:o}:{x:b?.x??t,y:b===null?o-tM(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,v=m||Fk({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??(p?"center":this.state.currentItemTextAlign),verticalAlign:d?.verticalAlign??(p?sV.MIDDLE:Tk),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?Ul(i)?0:i.angle:0,frameId:x});if(!m&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:v.id})}),this.setState({editingTextElement:v}),!m)if(i&&c){let I=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([v],I+1)}else this.insertNewElement(v);l&&d&&this.arrowText.bindText(l,v,d.fixedPoint),a||m||i?this.handleTextWysiwyg(v,{isExistingElement:!!m,initialCaretSceneCoords:m?s:null}):this.setState({newElement:v,multiElement:null})});T(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});T(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});T(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 qn(ne(o.x,o.y),ne(r.x,r.y))<=_k});T(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}=Se(t,this.state);if(o.length===1&&Rt(o[0])){let s=o[0];if((t[K.CTRL_OR_CMD]&&cb(s)||lb(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(Ji);return}else if(this.state.selectedLinearElement&&Gt(o[0])){let l=ce.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=l?ce.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),ce.deleteFixedSegment(o[0],this.scene,c);let d=ce.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),p=d?ce.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:p,value:l,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===s.id&&lb(s))return}if(o.length===1&&fr(o[0])){this.startImageCropping(o[0]);return}if(this.cursor.reset(),vY(this.state).length>0){let s=this.getElementAtPosition(r,i),l=s&&yY(s,this.state.selectedGroupIds);if(l){this.store.scheduleCapture(),this.setState(c=>({...c,...Dn({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(Wl(s)){this.setState({activeEmbeddable:{element:s,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let l=!t[K.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(l&&(this.state.activeTool.type==="autoshape"||Gk(l)||!bV(l.backgroundColor)||Vl({point:ne(r,i),element:l,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(l)}))){let c=ob(l,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l||null})}}});T(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==yo.MAIN){this.lastCompletedCanvasClicks=[];return}let o=Se(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}]});T(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(!fr(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});T(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=_l(o,r,this.state,i);return!!a&&qn(ne(t.x,t.y),ne(a.centerX,a.centerY))<=a.radius+2/this.state.zoom.value});T(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,ne(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});T(this,"handleElementLinkClick",t=>{let o=qn(ne(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ne(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||o>Ik)return;let r=Se(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=ic(this.hitLinkElement,i,this.state,ne(r.x,r.y),this.editorInterface.formFactor==="phone"),s=Se(this.lastPointerUpEvent,this.state),l=ic(this.hitLinkElement,i,this.state,ne(s.x,s.y),this.editorInterface.formFactor==="phone");if(a&&l){$d();let c=this.hitLinkElement.link;if(c){c=$E(c);let d;if(this.props.onLinkOpen&&(d=EV(J.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let p=uV(c)?"_self":"_blank",m=window.open(void 0,p);m&&(m.opener=null,m.location=c)}}}});T(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Pe.POINTER),jy(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):($d(),!1));T(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});T(this,"handleInteractiveContentPointerMove",t=>{let o=Se(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()});T(this,"handleInteractiveContentPointerUp",t=>{if(this.lastPointerUpEvent=t,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let o=Se(t,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(t,o)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});T(this,"getTopLayerFrameAtSceneCoords",(t,o)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(l=>!l.locked&&qk(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(vt(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(p=>p.id===o.currentFrameId)??null:null;return d||(s.frameId?i.find(p=>p.id===s.frameId)??null:null)}return a});T(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});T(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,o)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!o&&HY(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});T(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?tY(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});T(this,"insertNewElement",t=>{this.insertNewElements([t]);let o=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(o&&vt(o)?o:null)});T(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())&&!So&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Se(t,this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.updateMultiTouchGesture(t),Io||So||Wp||Xa(this.state))return;let s=Zg($l,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(Pe.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Pe.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&x2(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=b2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(y=>{let w=Hl(y.snapLines,b),x=y.originSnapOffset?Hl(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:ce.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Ht(()=>{this.setState({selectedLinearElement:g})})}if(VV(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&Op(this.state)){let b=ne(r,i),y=this.scene.getNonDeletedElementsMap(),w=hr(b,this.scene.getNonDeletedElements(),y,gM(this.state.zoom));w?this.setState({suggestedBinding:{element:w,midPoint:db(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,v=x[x.length-1],{lastCommittedPoint:I}=b;if(this.cursor.applyForTool(),v===I)qn(ne(r-y,i-w),v)>=XE?(this.store.scheduleCapture(),Ht(()=>{Qn(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,ne(r-y,i-w)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Pe.POINTER);else if(x.length>2&&I&&qn(ne(r-y,i-w),I)<XE){this.cursor.set(Pe.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{Kk(x,this.state.zoom.value)&&this.cursor.set(Pe.POINTER);let C=this.scene.getNonDeletedElementsMap();if(cb(g)){let A=hr(ne(r,i),this.scene.getNonDeletedElements(),C);vo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,A)}Qn(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=ce.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=ne(r,i),b=hr(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),gM(this.state.zoom)),y=this.scene.getNonDeletedElementsMap();b&&!hM(g,b,y)&&this.setState({suggestedBinding:{element:b,midPoint:db(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(),p=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(p,o)){this.cursor.set(Pe.POINTER);return}if(p.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"&&!(p.length===1&&Gt(p[0]))&&!(Rt(p[0])&&(this.editorInterface.userAgent.isMobileDevice||p[0].points.length===2))){let g=aM(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(iM(g));return}}}else if(p.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=sM(za(p),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(iM({transformHandleType:g}));return}}if(qt(this.state))return;let m=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),u=null;m&&m.locked?u=null:u=m;let E=this.arrowText.updateHoveredAnchor(o);if(this.handleIframeLikeElementHover({hitElement:u,scenePointer:o,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(o,m)),!this.applyElementLinkHoverAffordance()){if(c)return;u&&(u.link||To(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?Pe.POINTER:Ut(u)?Pe.TEXT:Pe.CROSSHAIR):!t[K.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,p)?this.cursor.set(Pe.MOVE):this.state.viewModeEnabled?this.cursor.set(Pe.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Pe.AUTO):s?this.cursor.set(Pe.AUTO):!t[K.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,p))&&!u?.locked&&(!u||!Gt(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||p.length>0)&&this.cursor.set(Pe.MOVE):this.cursor.set(Pe.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:Hl(g.hoveredElementIds,Dn({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:Hl(g.hoveredElementIds,{})}))});T(this,"handleEraser",(t,o)=>{let r=this.eraserTrail.addPointToPath(o.x,o.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});T(this,"handleTouchMove",t=>{this.isInteractionEnabled()&&(Zl=!0)});T(this,"handleCanvasPointerDown",t=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=t),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(t),So||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=Se(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(TE,null)),gt.get($n)&&this.updateEditorAtom($n,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let g=this.state.newElement;this.updateScene({...g.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(b=>b.id!==g.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:ke(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"?jt.EVENTUALLY:jt.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=qE(this.editorInterface,{isTouchScreen:!0})),So||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===yo.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Ln.eraser){this.setState({activeTool:Zt(this.state,{type:Ln.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),y?.(),qt(this.state)&&this.setState({activeTool:Zt(this.state,{...this.state.activeTool.lastActiveTool||{type:Ln.selection},lastActiveTool:null})})},b=fe(window,J.POINTER_UP,g,{once:!0}),y;requestAnimationFrame(()=>{y=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==yo.MAIN&&t.button!==yo.TOUCH&&t.button!==yo.ERASER||se.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[K.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},v=[];Object.keys(w.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&v.push(P)});let I=c.hit.element;if(vt(I))rb(v,I.id).forEach(C=>{delete x[C.id]});else if(I.frameId)x[I.frameId]&&delete x[I.id];else{let C=I.groupIds,P=new Set(C.flatMap(A=>ri(this.scene.getNonDeletedElements(),A)).filter(A=>vt(A)).map(A=>A.id));P.size>0&&v.forEach(A=>{A.frameId&&P.has(A.frameId)&&(delete x[A.id],A.groupIds.flatMap(L=>ri(this.scene.getNonDeletedElements(),L)).forEach(L=>{delete x[L.id]}))})}return{...Dn({editingGroupId:w.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),w,this),showHyperlinkPopup:I.link||To(I)?"info":!1}}),c.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,c):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="custom"?this.cursor.applyForTool():this.state.activeTool.type===Ln.frame||this.state.activeTool.type===Ln.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===Ln.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 p=this.onPointerMoveFromPointerDownHandler(c),m=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),E=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(g=>m(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(J.POINTER_MOVE,p),window.addEventListener(J.POINTER_UP,m),window.addEventListener(J.KEYDOWN,u),window.addEventListener(J.KEYUP,E),c.eventListeners.onMove=p,c.eventListeners.onUp=m,c.eventListeners.onKeyUp=E,c.eventListeners.onKeyDown=u)});T(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(vo("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=Se({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=o;this.lastPointerMoveCoords={x:r,y:i},!this.handleIframeLikeCenterClick()&&!this.maybeHandleElementLinkClick(t,o)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});T(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(Zl=!1,Er?Zl=!0:Er=window.setTimeout(()=>{Er=0,Zl||this.handleCanvasContextMenu(t)},aV))});T(this,"resetContextMenuTimer",()=>{clearTimeout(Er),Er=0,Zl=!1});T(this,"maybeCleanupAfterMissingPointerUp",t=>{Ua?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});T(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(se.pointers.size<=1&&((t.button===yo.WHEEL||t.button===yo.MAIN&&Io||Xa(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;So=!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(Pe.GRABBING);let{clientX:i,clientY:a}=t,s=mm(c=>{let d=i-c.clientX,p=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!o&&(Math.abs(d)>1||Math.abs(p)>1)){o=!0;let m=E=>{document.body.removeEventListener(J.PASTE,m),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(J.PASTE,m),window.removeEventListener(J.POINTER_UP,u)},100)};document.body.addEventListener(J.PASTE,m),window.addEventListener(J.POINTER_UP,u)}this.viewport.translate({scrollX:this.state.scrollX-d/this.state.zoom.value,scrollY:this.state.scrollY-p/this.state.zoom.value})}),l=Ve(Ua=()=>{Ua=null,So=!1,Io||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});T(this,"updateMultiTouchGesture",t=>{se.pointers.has(t.pointerId)&&se.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=se.initialScale;if(se.pointers.size===2&&se.lastCenter&&o&&se.initialDistance){let r=Bg(se.pointers),i=r.x-se.lastCenter.x,a=r.y-se.lastCenter.y;se.lastCenter=r;let s=Og(Array.from(se.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/se.initialDistance,c=l?no(o*l):this.state.zoom.value;this.setState(d=>{let p=Mo({viewportX:r.x,viewportY:r.y,nextZoom:c},d),m=p.zoom.value;return this.viewport.translate({zoom:p.zoom,scrollX:p.scrollX+2*i/m,scrollY:p.scrollY+2*a/m,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else se.lastCenter=se.initialDistance=se.initialScale=null});T(this,"clearSelectionIfNotUsingSelection",()=>{Bp(this.state.activeTool.type)||this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});T(this,"handleSelectionOnPointerDown",(t,o)=>{if(Bp(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&&!Gt(a[0])&&!(Rt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=aM(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=sM(za(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=jE(SY(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Rt(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=CY(o.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let m=this.state.selectedLinearElement,u=ce.handlePointerDown(t,this,this.store,o.origin,m,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=ce.getElement(m.elementId,E);if(g&&eo(g)){let{hitFocusPoint:b,pointerOffset:y,arrowOtherEndpointInitialBinding:w}=OY(g,o,E,this.state);if(b)return this.setState({selectedLinearElement:{...m,hoveredFocusPointBinding:b,draggedFocusPointBinding:b,pointerOffset:y,initialState:{...m.initialState,arrowOtherEndpointInitialBinding:w}}}),!1}}let s=this.getElementsAtPosition(o.origin.x,o.origin.y,{includeLockedElements:!0}),l=s.filter(m=>!m.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(m=>this.state.selectedElementIds[m.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,p=o.hit.allHitElements.some(m=>this.isASelectedElement(m));if((d===null||!p)&&!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(m=>({selectedLinearElement:m.selectedLinearElement?{...m.selectedLinearElement,isEditing:!!d&&d.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:m.selectedLinearElement?ke({[m.selectedLinearElement.elementId]:!0},this.state):ke({},m)}));else if(d!=null){if(t[K.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(m=>({...wY(m,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!nM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!p&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(m=>{let u={...m.selectedElementIds,[d.id]:!0},E=[];if(Object.keys(m.selectedElementIds).forEach(g=>{let b=this.scene.getElement(g);b&&E.push(b)}),vt(d))rb(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=>ri(this.scene.getNonDeletedElements(),y)).filter(y=>vt(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=>ri(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete u[w.id]}))})}return m.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(g=>m.selectedGroupIds[g])||(u={[d.id]:!0})),{...Dn({editingGroupId:m.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),m,this),showHyperlinkPopup:d.link||To(d)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});T(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);Gk(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:Zt(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});T(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=Ct(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=this.state.currentItemStrokeVariability,d=BV({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"?JW:qW},locked:!1,frameId:s?s.id:null,points:[ne(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(d),this.setState(p=>{let m={...p.selectedElementIds};return delete m[d.id],{selectedElementIds:ke(m,p)}}),this.setState({newElement:d,suggestedBinding:null})});T(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,s]=Ct(t,o,this.lastPointerDownEvent?.[K.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=FV({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});T(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=Ct(t,o,this.lastPointerDownEvent?.[K.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=zp(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=Ok({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});T(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0})=>{let[i,a]=Ct(t,o,this.lastPointerDownEvent?.[K.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=r?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,l=100/this.state.zoom.value;return GV({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:s?s.id:null,x:i-l/2,y:a-l/2,width:l,height:l})});T(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Ht(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(Qn(a,"selectedLinearElement is expected to be set"),i.type==="line"&&Kk(i.points,this.state.zoom.value)){Ht(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(ct);return}if(Gt(i)&&i.points.length>1){this.actionManager.executeAction(ct,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=Se(t,this.state),{start:p,end:m}=eo(i)&&Op(this.state)?GY(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=p?.mode!=null&&m.mode!=null&&p.element.id===m.element.id&&!hM(m.focusPoint,m.element,u),g=m.mode==="orbit"&&i.startBinding?.elementId!==m.element?.id,b=c&&qn(ne(r.origin.x-s,r.origin.y-l),c)<XE;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(ct,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(y=>({selectedElementIds:ke({...y.selectedElementIds,[i.id]:!0},y)})),this.cursor.set(Pe.POINTER)}else{let[i,a]=Ct(r.origin.x,r.origin.y,t[K.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,p]=o==="arrow"?[l,c]:[null,null],m=o==="arrow"?zV({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===ur.round?{type:_p.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:p,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===ur.elbow,fixedSegments:this.state.currentItemArrowType===ur.elbow?[]:null}):UV({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:_p.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=ne(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=Op(this.state)?hr(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(m,{points:[ne(0,0),ne(0,0)]}),this.insertNewElement(m),eo(m)&&DY(m,new Map([[0,{point:ne(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:vk(t.nativeEvent)}),Ht(()=>{this.setState(b=>{let y=null,w=b.selectedElementIds;if(Rt(m)){y=new ce(m,this.scene.getNonDeletedElementsMap());let x=m.points.length-1;y={...y,selectedPointsIndices:[x],initialState:{...y.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:ne(r.origin.x,r.origin.y)}}}return w=this.isToolLocked()?b.selectedElementIds:ke({[m.id]:!0},b),{...b,bindMode:"orbit",newElement:m,suggestedBinding:g&&eo(m)?{element:g,midPoint:db(u,g,E,this.state.zoom)}:null,selectedElementIds:w,selectedLinearElement:y}})}),eo(m)&&vo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(m,g)}});T(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=Ct(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[K.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=Ok({type:"embeddable",...s}):l=HV({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.insertNewElement(l),this.setState({multiElement:null,newElement:l}))});T(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=Ct(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[K.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...wo},s=o===Ln.magicframe?OV(a):NV(a);this.insertNewElement(s),this.setState({multiElement:null,newElement:s})});T(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});T(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(eo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);Hp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);Hp(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&&Hp(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&Hp(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)||Uk(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,gr(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});T(this,"initializeImage",async(t,o)=>{if(!dc(o))throw new Error(f("errors.unsupportedFileType"));let r=o.type;if(this.cursor.set("wait"),r===Ba.svg)try{o=su(Xk(await o.text()),o.name)}catch(l){throw console.warn(l),new Error(f("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(o)||qb(o));if(!i)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[i]?.dataURL){let{maxWidthOrHeight:l,maxFileSizeBytes:c}=this.props.imageOptions;try{o=await ex(o,{maxWidthOrHeight:l})}catch(d){console.error("Error trying to resizing image file on insertion",d)}if(o.size>c)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(c/1024/1024)}MB`}))}let s=this.files[i]?.dataURL||await mc(o);return new Promise(async(l,c)=>{try{let d=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:s,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:m}=await this.updateImageCache([d]);if(m.size)throw new Error("Image cache update resulted with an error.")}let p=await this.imageCache.get(i)?.image;if(p&&this.state.newElement?.id!==d.id){d=this.getLatestInitializedImageElement(t,i);let m=this.getImageNaturalDimensions(d,p);Object.assign(d,m)}l(d)}catch(d){console.error(d),c(new Error(f("errors.imageInsertError")))}})});T(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return gr(r,{fileId:o})});T(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}=Se({clientX:t,clientY:o},this.state),a=await Ub({description:"Image",extensions:Object.keys(tV),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Zt(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(ct)})}});T(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}});T(this,"updateImageCache",async(t,o=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await JV({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:o});return i.size&&(this.store.scheduleAction(jt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Ha(a)&&i.has(a.fileId)?gr(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});T(this,"addNewImagesToImageCache",async(t=qV(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)&&Ga.delete(a);i.size&&this.scene.triggerUpdate()}});T(this,"scheduleImageRefresh",XW(()=>{this.addNewImagesToImageCache()},nV));T(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))});T(this,"insertImages",async(t,o,r)=>{let i=50/this.state.zoom.value,a=mM(t.map(()=>this.newImagePlaceholder({sceneX:o,sceneY:r})),o,r,i);this.insertNewElements(a);let s=await Promise.all(a.map(async(m,u)=>{try{return await this.initializeImage(m,await di(t[u]))}catch(E){return this.setState({errorMessage:E.message||f("errors.imageInsertError")}),gr(m,{isDeleted:!0})}})),l=Gl(s),c=mM(s.filter(m=>!m.isDeleted),o,r,i),d=Gl(c),p=this.scene.getElementsIncludingDeleted().map(m=>d.get(m.id)??l.get(m.id)??m);this.updateScene({appState:{selectedElementIds:ke(Object.fromEntries(c.map(m=>[m.id,!0])),this.state)},elements:p,captureUpdate:jt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(ct)})});T(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Se(t,this.state),i=await _r(t),a=i.getFiles();if(a.length===1){let{file:c,fileHandle:d}=a[0];if(c&&(c.type===Ba.png||c.type===Ba.svg))try{let p=await qa(c,this.state,this.scene.getElementsIncludingDeleted(),d);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:jt.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}let s=a.map(c=>c.file).filter(c=>dc(c));if(s.length>0&&this.isToolSupported("image"))return this.insertImages(s,o,r);if(a.length>0){let{file:c,fileHandle:d}=a[0];c&&await this.loadFileToCanvas(c,d)}let l=i.findByType(Ba.text);if(l){let c=l.value;if(c&&tb(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||zp(c)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:$E(c)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});T(this,"loadFileToCanvas",async(t,o)=>{t=await di(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await qa(t,this.state,r,o)}catch(a){let s=a instanceof Gb;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;yM(r.concat(i.elements)),this.store.scheduleMicroAction({action:jt.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:jt.IMMEDIATELY})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});T(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!==yo.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Se(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),s=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},a),l=i||s?"element":"canvas",c=this.excalidrawContainerRef.current,{top:d,left:p}=c.getBoundingClientRect(),m=t.clientX-p,u=t.clientY-d;Re("contextMenu","openContextMenu",l),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...Dn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Rt(i)?new ce(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:m,items:this.getContextMenuItems(l)}})})});T(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){lM({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Fa(t.origin.x,a.x),height:Fa(t.origin.y,a.y),shouldMaintainAspectRatio:Ol(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]=Ct(a.x,a.y,o[K.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=Ha(s)&&this.imageCache.get(s.fileId)?.image,p=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(o,[s]);let{snapOffset:m,snapLines:u}=E2(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+=m.x,c+=m.y,this.setState({snapLines:u}),eo(s)||lM({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:Fa(t.originInGrid.x,l),height:Fa(t.originInGrid.y,c),shouldMaintainAspectRatio:fr(s)?!Ol(o):Ol(o),shouldResizeFromCenter:yk(o),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:p,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:s}),(this.state.activeTool.type===Ln.frame||this.state.activeTool.type===Ln.magicframe)&&this.setState({elementsToHighlight:ab(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})});T(this,"maybeHandleCrop",(t,o)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,s]=Ct(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[K.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&fr(l)){let c=t.originalElements.get(l.id),d=Ha(l)&&this.imageCache.get(l.fileId)?.image;if(c&&fr(c)&&d&&!(d instanceof Promise)){let[p,m]=Ct(i.x,i.y,o[K.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:m-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:E,snapLines:g}=Gg([l],[c],this,o,u,r);this.scene.mutateElement(l,mY(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),Fp(l,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});T(this,"maybeHandleResize",(t,o)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(vt),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Gt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=Ct(s.x-t.resize.offset.x,s.y-t.resize.offset.y,o[K.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(p=>{rb(this.scene.getNonDeletedElements(),p.id).forEach(u=>{d.set(p.id+u.id,{x:u.x-p.x,y:u.y-p.y})})}),!this.state.selectedElementsAreBeingDragged){let[p,m]=Ct(s.x,s.y,o[K.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:m-t.originInGrid.y},E=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(o,r);let{snapOffset:g,snapLines:b}=Gg(r,ie(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if(PY(t.originalElements,a,r,this.scene,vk(o),yk(o),r.some(p=>fr(p))?!Ol(o):Ol(o),l,c,t.resize.center.x,t.resize.center.y)){let p=new Set;return i.forEach(m=>{ab(this.scene.getNonDeletedElements(),m,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{Up(u)?p.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...p]}),!0}return!1});T(this,"getContextMenuItems",t=>{let o=[];if(o.push(Vd,Wd),t==="canvas")return this.state.viewModeEnabled?[...o,Ui,Zo,Yr,jo]:[Wh,nt,Vd,Wd,Yd,nt,Wu,rv,nt,Ui,Rs,Ns,Bs,Zo,Yr,jo];if(o.push(Yd),this.state.viewModeEnabled)return[Gi,...o];let r=this.editorInterface.formFactor==="desktop"?[nt,zu,Hu,Gu,Uu]:[];return[nt,Ud,Gi,Wh,nt,jv,qv,Jv,nt,kg,nt,...o,nt,Rh,Nh,nt,Fh,Rg,Kh,Xh,Gy,zh,nt,...r,nt,Gh,Uh,nt,Ji,nt,ng,$v,nt,Vu,zs,nt,cs]});T(this,"handleWheel",Ve(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(JE.FRAME_NAME))){t[K.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),So)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(r),a=lV*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:cV;c=Math.max(c,d),this.viewport.translate(m=>({...Mo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:no(c)},m),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}))}));T(this,"savePointer",(t,o,r)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!t||!o)return;let{x:i,y:a}=Se({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:se.pointers})});T(this,"resetShouldCacheIgnoreZoomDebounced",Mk(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));T(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:p}=this.state;if(r===l&&i===c&&a===p&&s===d){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:s},()=>{t&&t()}),this.viewport.constrain()}});T(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});T(this,"watchState",()=>{});let o=Lo(),{viewModeEnabled:r=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${Lk()}`}=t,d=null;t.activeTool&&(t.activeTool.type==="image"?console.warn('"image" tool cannot be forced via "props.activeTool"'):this.isToolSupported(t.activeTool.type,t)?d=Zt(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===Fl.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:this.isInteractionEnabled(t)?r:!0,activeTool:d??o.activeTool,zenModeEnabled:i,objectsSnapModeEnabled:s,gridModeEnabled:a??o.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight},this.refreshEditorInterface(),this.stylesPanelMode=Kp(this.editorInterface),this.id=ZW(),this.actionManager=new sm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new cM,this.canvas=document.createElement("canvas"),this.rc=$W.canvas(this.canvas),this.renderer=new rl(this.scene),this.visibleElements=[],this.store=new AY(this),this.history=new nl(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new oo(this.scene),this.history=new nl(this.store),this.actionManager.registerAll(Ac),this.actionManager.registerAction(n2(this.history)),this.actionManager.registerAction(o2(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(Rp).includes(i)&&mb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){Qn(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=hr(ne(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=ce.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),Ht(()=>{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;Qn(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?ce.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):ce.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||Gt(t))return;let r=()=>{if(this.bindModeHandler=null,Qn(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:p,y:m}=this.lastPointerMoveCoords,u=hr(ne(p,m),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){Qn(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;Ht(()=>{Qn(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;Qn(g,"Last event must exist");let b=p-this.state.selectedLinearElement.pointerOffset.x,y=m-this.state.selectedLinearElement.pointerOffset.y,w=this.state.multiElement?ce.handlePointerMove(g,this,b,y,this.state.selectedLinearElement):ce.handlePointDragging(g,this,b,y,this.state.selectedLinearElement);w&&this.setState(w)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let p=this.scene.getNonDeletedElementsMap(),m=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),E=m?o:t.startBinding&&p.get(t.startBinding.elementId),g=u?o:t.endBinding&&p.get(t.endBinding.elementId),b=E&&uM(E,p),y=g&&uM(g,p);i=!!(b&&y&&E.id!==g.id&&_Y(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"&&Ht(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,SV)),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!==yo.MAIN||Io||!Rk(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=ne(Se({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=ne(Se({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(qn(t,o)>Ik)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&se.pointers.size<2&&Wl(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),QE(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,Rp.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case Rp.PLAYING:case Rp.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=>To(a)&&this.embedsValidationStatus.get(a.id)===!0||QE(a));return ve(YY,{children:i.map(a=>{let{x:s,y:l}=Np({sceneX:a.x,sceneY:a.y},this.state),c=Vk(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 m=zp(hV(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=m?.type==="video",b=Bl(g?t:1,.75,WY);return ve("div",{className:fk("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:xY(a,sb(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?pV:1),"--embeddable-radius":`${ZV(Math.min(a.width,a.height),a)}px`},children:pb("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?Oa.enabled:Oa.disabled},children:[E&&ve("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),ve("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:ve("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(To(a)?this.props.renderEmbeddable?.(a,this.state):null)??ve("iframe",{ref:y=>this.cacheEmbeddableRef(a,y),className:"excalidraw__embeddable",srcDoc:m?.type==="document"?m.srcdoc(this.state.theme):void 0,src:m?.type!=="document"?m?.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:`${m?.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(),p="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",m=t[0],u=gt.get($n)?.type==="panel";return ve("div",{translate:"no",className:fk("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":p?Oa.disabled:Oa.enabled,"--right-sidebar-width":`${If}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:ve(Wa.Provider,{value:this.api,children:ve(vM.Provider,{value:this,children:ve(TM.Provider,{value:this.props,children:ve(fb.Provider,{value:this.excalidrawContainerValue,children:ve(gb.Provider,{value:this.editorInterface,children:ve(xb.Provider,{value:this.setAppState,children:ve(bb.Provider,{value:this.state,children:pb(Eb.Provider,{value:this.scene.getNonDeletedElements(),children:[pb(wb.Provider,{value:this.actionManager,children:[ve(uP,{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:Bn().code,renderTopLeftUI:r,renderTopRightUI:o,renderCustomStats:i,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,currentUserControls:this.props.currentUserControls,children:this.props.children}),ve("div",{className:"excalidraw-textEditorContainer"}),ve("div",{className:"excalidraw-contextMenuContainer"}),ve("div",{className:"excalidraw-eye-dropper-container"}),ve(gP,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&ve(uk,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&ve($y,{element:m,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},m.id),this.isDefaultUIEnabled()&&this.state.contextMenu&&ve(cI,{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?.()})}}),ve(WE,{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,isExporting:!1,renderGrid:Qo(this),renderLinks:this.isLinksEnabled(),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),c&&ve(sk,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:d,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),ve(UE,{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"&&ve(Um,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&ve(gk,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&ve(FT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{Ha(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),Ga.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,bM()||xM()){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(),dV&&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),kV()&&!hY()&&this.setState({errorMessage:ve(tI,{})});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.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 cM,this.fonts=new oo(this.scene),this.renderer=new rl(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(),Ga.destroy(),an.destroy(),clearTimeout(Er),Me.clearCache(),Dn.clearCache(),Er=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(fe(window,J.MESSAGE,this.onWindowMessage,!1),fe(document,J.POINTER_UP,this.removePointer,{passive:!1}),fe(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),fe(window,J.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(fe(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),fe(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.handleNavigationModeKeyDown,!1),fe(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),fe(document,J.GESTURE_START,this.onGestureStart,!1),fe(document,J.GESTURE_CHANGE,this.onGestureChange,!1),fe(document,J.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(fe(this.excalidrawContainerRef.current,J.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),fe(this.excalidrawContainerRef.current,J.GESTURE_START,this.disableEvent,!1),fe(this.excalidrawContainerRef.current,J.GESTURE_CHANGE,this.disableEvent,!1),fe(this.excalidrawContainerRef.current,J.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(fe(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(fe(document,J.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(fe(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),fe(document,J.COPY,this.onCopy,{passive:!1}),fe(document,J.KEYUP,this.onKeyUp,{passive:!0}),fe(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),fe(document,J.GESTURE_START,this.onGestureStart,!1),fe(document,J.GESTURE_CHANGE,this.onGestureChange,!1),fe(document,J.GESTURE_END,this.onGestureEnd,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(fe(document,J.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),fe(document,J.PASTE,this.pasteFromClipboard,{passive:!1}),fe(document,J.CUT,this.onCut,{passive:!1}),fe(window,J.RESIZE,this.onResize,!1),fe(window,J.UNLOAD,this.onUnload,!1),fe(window,J.BLUR,this.onBlur,!1),fe(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),fe(this.excalidrawContainerRef.current,J.DRAG_OVER,this.disableEvent,!1),fe(this.excalidrawContainerRef.current,J.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(fe(gV(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.appStateObserver.flush(o),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===Fl.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&&qt(this.state)&&this.setState({activeTool:Zt(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(),qt(o)&&!qt(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.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===Fl.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(ct)});let s=Object.keys(this.state.selectedElementIds);if(s.length){let c=s.filter(d=>{let p=this.scene.getElement(d);return!p||p.isDeleted});c.length&&this.setState(d=>{let p={...d.selectedElementIds};for(let m of c)delete p[m];return{selectedElementIds:ke(p,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(){Yl=!1,Xl=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Se({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=Pm(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(su(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?RY(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=wV(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>jV(d)).filter(d=>tb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||zp(d)?.type==="video"));if(!r&&c.length>0&&c.length===l.length){let d=[];for(let p of c){let m=d[d.length-1],u=this.insertEmbeddableElement({sceneX:m?m.x+m.width+20:i,sceneY:a,link:$E(p)});u&&d.push(u)}d.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(d.map(p=>[p.id,!0]))}));return}this.addTextFromPaste(t.text,r)}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 tx(d)}}catch(p){let m=p.message;return p.cause==="FETCH_ERROR"?m=f("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(m=f("errors.unsupportedFileType")),{errorMessage:m}}})),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(`
20
+ `)},yU=(e,n,t)=>{let r=wU(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=Vl(u,kp(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let v=Vl(m.line,kp(e),e.lineHeight),T=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;g.width+=T}let{width:b,height:y}=Vl(E,kp(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},vU=(e,n,t,o)=>{let r=e.name??kP(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=kp({fontSize:DE.nameFontSize,fontFamily:LE.Assistant}),l=dU(LE.Assistant),c=Vl(a,s,l);a===""&&(c.width=0);let d=Vl(i,s,l),m=c.width,p=-c.height-DE.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*o}]},IU=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),CP=iU((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>PP(p)),i=o.filter(p=>Mp(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(IU(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=SP(E,u.index,e),b=yU(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??kP(p);for(;(u=s.exec(E))!==null;){let g=SP(E,u.index,e),b=vU(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)},fU);import OU from"clsx";import{useEffect as NP,useLayoutEffect as BP,useRef as UE,useState as FU,forwardRef as OP,useImperativeHandle as zU,useCallback as DP}from"react";import{CLASSES as HU,EVENT as _P,isDevEnv as GU,KEYS as UU,updateObject as WU}from"@excalidraw/common";import CU from"clsx";import{useContext as PU}from"react";import SU from"react";var Ap=SU.createContext({});import{jsx as RE,jsxs as AP}from"react/jsx-runtime";var NE=({children:e,className:n})=>{let t=ge(),o=PU(Ap),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return AP("div",{className:CU("sidebar__header",n),"data-testid":"sidebar-header",children:[e,AP("div",{className:"sidebar__header__buttons",children:[r&&RE(ct,{label:f("labels.sidebarLock"),children:RE(fn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:bx})}),RE(fn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:Jt})]})]})};NE.displayName="SidebarHeader";import{Tabs as kU}from"radix-ui";import{jsx as LP}from"react/jsx-runtime";var BE=({children:e,tab:n,onSelect:t,...o})=>LP(kU.Trigger,{value:n,asChild:!0,onSelect:t,children:LP("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});BE.displayName="SidebarTabTrigger";import{Tabs as MU}from"radix-ui";import{jsx as AU}from"react/jsx-runtime";var OE=({children:e,...n})=>AU(MU.List,{className:"sidebar-triggers",...n,children:e});OE.displayName="SidebarTabTriggers";import LU from"clsx";import{jsx as FE,jsxs as DU}from"react/jsx-runtime";var zE=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Ue(),d=fe().openSidebar?.name===e;return FE("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:DU("div",{className:LU("sidebar-trigger",a),style:s,children:[t&&FE("div",{children:t}),r&&FE("div",{className:"sidebar-trigger__label",children:r})]})})};zE.displayName="SidebarTrigger";import{Tabs as _U}from"radix-ui";import{jsx as RU}from"react/jsx-runtime";var HE=({children:e,...n})=>{let t=fe(),o=Ue();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return RU(_U.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};HE.displayName="SidebarTabs";import{Tabs as NU}from"radix-ui";import{jsx as BU}from"react/jsx-runtime";var GE=({tab:e,children:n,...t})=>BU(NU.Content,{...t,value:e,"data-testid":e,children:n});GE.displayName="SidebarTab";import{jsx as RP}from"react/jsx-runtime";import{createElement as VU}from"react";var WE=je(!1),FP=OP(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{GU()&&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=Ue(),l=mx(WE);BP(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=UE({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=WU(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=UE(null);zU(a,()=>d.current);let m=ge(),p=DP(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Ti(d,DP(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),NP(()=>{let u=E=>{E.key===UU.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(_P.KEYDOWN,u),()=>{document.removeEventListener(_P.KEYDOWN,u)}},[p,o,m.canFitSidebar]),RP(ze,{...i,className:OU(HU.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:RP(Ap.Provider,{value:c.current,children:n})})});FP.displayName="SidebarInner";var Er=Object.assign(OP((e,n)=>{let t=fe(),{onStateChange:o}=e,r=UE(t.openSidebar);NP(()=>{(!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]=FU(!1);return BP(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?VU(FP,{...e,ref:n,key:e.name}):null}),{Header:NE,TabTriggers:OE,TabTrigger:BE,Tabs:HE,Tab:GE,Trigger:zE});Er.displayName="Sidebar";import{jsx as Va,jsxs as KU}from"react/jsx-runtime";import{createElement as $U}from"react";var HP=ei("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=et();return Va(n.In,{children:Va(Er.Trigger,{...e,className:"default-sidebar-trigger",name:XU.name})})});HP.displayName="DefaultSidebarTrigger";var GP=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=et();return Va(n.In,{children:e})};GP.displayName="DefaultTabTriggers";var VE=Object.assign(ei("DefaultSidebar",({children:e,className:n,docked:t,...o})=>{let r=fe(),i=r.openSidebar?.tab===zP;return $U(Er,{...o,name:"default",key:"default",className:YU("default-sidebar",{"default-sidebar--search-only":i},n),docked:i?!1:t??r.defaultSidebarDockedPreference,onDock:void 0},KU(Er.Tabs,{children:[!i&&Va(Er.Header,{}),Va(Er.Tab,{tab:zP,children:Va(MP,{})}),!i&&e]}))}),{Trigger:HP,TabTriggers:GP});import jU from"react";import{getFrame as qU}from"@excalidraw/common";import{jsx as ZU}from"react/jsx-runtime";var YE={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"}},XE=({children:e,color:n})=>ZU("div",{className:"Card",style:{"--card-color":YE[n].base,"--card-color-darker":YE[n].darker,"--card-color-darkest":YE[n].darkest},children:e});import{Fragment as QU,jsx as Ln,jsxs as Lp}from"react/jsx-runtime";var JU=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return Ln("div",{className:"ExportDialog ExportDialog--json",children:Lp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Lp(XE,{color:"lime",children:[Ln("div",{className:"Card-icon",children:Nx}),Ln("h2",{children:f("exportDialog.disk_title")}),Lp("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!mi&&r.renderAction("changeProjectName")]}),Ln(K,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Ws,"ui")}})]}),l&&Lp(XE,{color:"pink",children:[Ln("div",{className:"Card-icon",children:hs}),Ln("h2",{children:f("exportDialog.link_title")}),Ln("div",{className:"Card-details",children:f("exportDialog.link_details")}),Ln(K,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Ne("export","link",`ui (${qU()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},UP=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=jU.useCallback(()=>{a({openDialog:null})},[a]);return Ln(QU,{children:n.openDialog?.name==="jsonExport"&&Ln(gn,{onCloseRequest:s,title:f("buttons.export"),children:Ln(JU,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import eW from"clsx";import{jsx as tW}from"react/jsx-runtime";var WP=e=>tW(K,{className:eW("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:Un,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import jP from"clsx";import{useState as uW}from"react";import{CANVAS_SEARCH_TAB as hW,DEFAULT_SIDEBAR as gW,KEYS as Yl}from"@excalidraw/common";import{CANVAS_SEARCH_TAB as nW,DEFAULT_SIDEBAR as oW}from"@excalidraw/common";import{isArrowElement as rW,isFlowchartNodeElement as iW,isImageElement as VP,isLinearElement as YP,isLineElement as aW,isTextBindableContainer as sW,isTextElement as lW}from"@excalidraw/element";import{isNodeInFlowchart as cW}from"@excalidraw/element";import{jsx as KE}from"react/jsx-runtime";var xe=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,dW=({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===oW.name&&e.openSidebar.tab===nW&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:xe("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(qt(e))return f("hints.eraserRevert",{shortcut:xe("Alt")});let c=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:xe("Ctrl"),shortcut_2:xe("Alt")});if(r.type==="arrow"||r.type==="line")return l?f("hints.linearElementMulti",{shortcut_1:xe("Escape"),shortcut_2:xe("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:xe("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 YP(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:xe("Shift")}):VP(d)?f("hints.resizeImage",{shortcut_1:xe("Shift"),shortcut_2:xe("Alt")}):f("hints.resize",{shortcut_1:xe("Shift"),shortcut_2:xe("Alt")})}if(a&&s==="mouse")return f("hints.rotate",{shortcut:xe("Shift")});if(c.length===1&&lW(c[0]))return f("hints.text_selected",{shortcut:xe("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:xe("Escape"),shortcut_2:xe(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:xe("Enter"),shortcut_2:xe("Escape")});if(c.length===1&&VP(c[0]))return f("hints.enterCropEditor",{shortcut:xe("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:xe("CtrlOrCmd")});if(or(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:xe("CtrlOrCmd")});if(!c.length&&!n)return f("hints.canvasPanning",{shortcut_1:xe(f("keys.mmb")),shortcut_2:xe("Space")});if(c.length===1){if(YP(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:xe("Delete"),shortcut_2:xe(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:xe("Shift"),shortcut_2:xe("Alt")}):aW(c[0])?f("hints.lineEditor_line_info",{shortcut:xe("Enter")}):f("hints.lineEditor_info",{shortcut_1:xe("CtrlOrCmd"),shortcut_2:xe(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&sW(c[0])){let d=f("hints.bindTextToElement",{shortcut:xe("Enter")}),m=f("hints.createFlowchart",{shortcut:xe(["CtrlOrCmd","\u2191\u2193"])});return iW(c[0])?cW(c[0],o.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},XP=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let r=dW({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 KE("kbd",{children:c?c[1]:s},l)}return s});return KE("div",{className:"HintViewer",children:KE("span",{children:a})})};import mW from"clsx";import{jsx as pW}from"react/jsx-runtime";var KP=e=>pW(K,{className:mW("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?No:io,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 ai,jsx as oe,jsxs as vo}from"react/jsx-runtime";var fW=(e,n)=>e==="image"&&n.tools?.image===!1,EW=({app:e,activeTool:n,type:t,shortcut:o})=>oe(de.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:We[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??Hi(t),disabled:$e(e,t),children:f(`toolBar.${t}`)}),$P=({app:e})=>oe(de.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?No:io,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:Yl.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),bW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(kt))return null;let t=Ke("objectsSnapMode");return oe(de.Item,{onSelect:()=>e.executeAction(kt,"ui"),icon:Fo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},xW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(kt))return null;let t=f("buttons.objectsSnapMode"),o=Ke("objectsSnapMode");return oe(K,{type:"toggle",icon:Fo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(kt,"ui")})},ZP=({actionManager:e,appState:n})=>{let t=f("search.title"),o=Ke("searchMenu");return oe(de.Item,{onSelect:()=>e.executeAction(ml,"ui"),icon:Wn,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===gW.name&&n.openSidebar.tab===hW,shortcut:o,children:t})},wW=({app:e})=>oe(K,{type:"button",icon:yi,title:`${f("labels.eyeDropper")} - ${Yl.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":Yl.I.toLocaleUpperCase(),keyBindingLabel:Yl.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),yW=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=uW(!1),l=it()==="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&&Fi.includes(n.type);return vo(de,{open:a,children:[oe(de.Trigger,{className:jP("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?We[n.type].icon:c?Gn:E?Oo:!r&&l&&d?Mr:m&&!e.props.isCollaborating?Un:u?fi:p?Hn:cs}),oe(de.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?vo(ai,{children:[l&&oe(de.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:fi,"data-testid":"toolbar-lasso",selected:u,disabled:$e(e,"lasso"),children:f("toolBar.lasso")}),Fi.filter(b=>!fW(b,o)).map(b=>oe(EW,{app:e,activeTool:n,type:b},b)),oe("div",{className:"App-toolbar__dropdown-divider"}),oe(ZP,{actionManager:i,appState:e.state}),e.props.activeTool==null&&oe(ai,{children:oe($P,{app:e})})]}):vo(ai,{children:[oe(de.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Gn,shortcut:Yl.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:$e(e,"frame"),children:f("toolBar.frame")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Oo,"data-testid":"toolbar-embeddable",selected:E,disabled:$e(e,"embeddable"),children:f("toolBar.embeddable")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Mr,shortcut:Hi("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:$e(e,"autoshape"),children:f("toolBar.autoshape")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Un,"data-testid":"toolbar-laser",selected:m,disabled:$e(e,"laser"),children:f("toolBar.laser")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Hn,"data-testid":"toolbar-bucketfill",selected:p,disabled:$e(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&oe(de.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:fi,"data-testid":"toolbar-lasso",selected:u,disabled:$e(e,"lasso"),children:f("toolBar.lasso")}),oe("div",{className:"App-toolbar__dropdown-divider"}),oe(bW,{actionManager:i,app:e}),oe(ZP,{actionManager:i,appState:e.state}),e.props.activeTool==null&&oe($P,{app:e})]})})]})},qP=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=ge(),c=it()==="compact",d=n.activeTool,m={app:e,activeTool:d},p=n.myocSimplifiedMode,u=c?oe(Ad,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?oe(Rw,{...m}):oe(_w,{...m});return vo(ze,{padding:1,className:jP("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":"top",children:[oe(XP,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,vo(Dt.Row,{gap:c?.5:1,children:[!c&&oe(Ra,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&vo(ai,{children:[oe(KP,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),oe("div",{className:"App-toolbar__divider"})]}),oe(Md,{...m}),u,p?vo(ai,{children:[oe(Rs,{...m}),oe(Ns,{...m}),oe(wW,{app:e}),o.tools?.image!==!1&&oe(Bs,{...m}),oe(Os,{...m})]}):vo(ai,{children:[oe(Pw,{...m}),oe(kw,{...m}),oe(Mw,{...m}),oe(Aw,{...m}),oe(Lw,{...m}),c?oe(Ld,{...m}):oe(Rs,{...m}),oe(Ns,{...m}),o.tools?.image!==!1&&oe(Bs,{...m}),oe(Os,{...m})]}),oe("div",{className:"App-toolbar__divider"}),oe(yW,{app:e,activeTool:d,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&vo(ai,{children:[oe("div",{className:"App-toolbar__divider"}),oe(xW,{actionManager:r,app:e})]})]})]})};import{Fragment as $E,jsx as ee,jsxs as $t}from"react/jsx-runtime";var kW=({UIOptions:e})=>$t(_t,{__fallback:!0,children:[ee(_t.DefaultItems.LoadScene,{}),ee(_t.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ee(_t.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ee(_t.DefaultItems.SaveAsImage,{}),ee(_t.DefaultItems.SearchMenu,{}),ee(_t.DefaultItems.Help,{}),ee(_t.Separator,{}),ee(_t.Group,{title:"Excalidraw links",children:ee(_t.DefaultItems.Socials,{})}),ee(_t.Separator,{}),ee(_t.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),ee(_t.DefaultItems.ChangeCanvasBackground,{})]}),MW=()=>$t(hp,{__fallback:!0,children:[ee(hp.Actions.SaveToDisk,{}),ee(hp.Actions.ExportToImage,{})]}),AW=({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:v,generateLinkForSelection:T,currentUserControls:C})=>{let P=ge(),A=yn(),_=it()==="compact",k=AT(),D=_?{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]=Fe(Nt),W=()=>p.canvasActions.export?ee(UP,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,$=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:ee(wP,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),H=()=>$t("div",{style:{position:"relative"},children:[$t("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),ee(k.MainMenuTunnel.Out,{})]}),E&&ee(k.WelcomeScreenMenuHintTunnel.Out,{})]}),re=()=>ee(Dl,{heading:"selectedShapeActions",className:Ya("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?ee(ze,{className:Ya("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:ee($T,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):ee(ze,{className:IW.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:ee(WT,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),B=()=>{let pe=y&&CW(n,r),he=y&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return ee(ip,{side:"top",children:$t("div",{className:"App-menu App-menu_top",children:[$t(Dt.Col,{gap:D.menuTopGap,className:Ya("App-menu_top__left"),children:[H(),y&&ee("div",{className:Ya("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:pe&&re()}),y&&_&&!n.viewModeEnabled&&pe&&ee(Ra,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),y&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&ee(Dl,{heading:"shapes",className:"shapes-section",children:ye=>$t("div",{style:{position:"relative"},children:[E&&ee(k.WelcomeScreenToolbarHintTunnel.Out,{}),ee(Dt.Col,{gap:D.toolbarColGap,align:"start",children:$t(Dt.Row,{gap:D.toolbarRowGap,className:Ya("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[ee(qP,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ye}),v&&ee(ze,{style:{marginLeft:D.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:ee(WP,{title:f("toolBar.laser"),checked:n.activeTool.type===JP.laser,onChange:()=>b.setActiveTool({type:JP.laser}),isMobile:!0})})]})})]})}),$t("div",{className:Ya("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(cp,{collaborators:n.collaborators,userToFollow:A.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),he&&ee(Hl,{app:b,onClose:()=>{e.executeAction(er)},renderCustomStats:m})]})]})})},U=()=>ee(VE,{}),ue=!1,we=$t($E,{children:[g,y&&ee($E,{children:ee(kW,{UIOptions:p})}),ee(MW,{}),y&&n.isLoading&&ee(ep,{delay:250}),y&&n.errorMessage&&ee(cP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),y&&Y&&P.formFactor!=="phone"&&ee(f0,{colorPickerType:Y.colorPickerType,onCancel:()=>{z(null)},onChange:(pe,he,ye,{altKey:se})=>{if(!(pe!=="elementBackground"&&pe!=="elementStroke"))if(ye.length){for(let ve of ye)SW(ve,TW(r),{[se&&Y.swapPreviewOnAlt?pe==="elementBackground"?"strokeColor":"backgroundColor":pe==="elementBackground"?"backgroundColor":"strokeColor"]:he}),PW.delete(ve);b.scene.triggerUpdate()}else o(pe==="elementBackground"?{currentItemBackgroundColor:he}:{currentItemStrokeColor:he})},onSelect:(pe,he)=>{z(ye=>ye?.keepOpenOnAlt&&he.altKey?ye:null),Y?.onSelect?.(pe,he)}}),n.openDialog?.name==="help"&&ee(uP,{onClose:()=>{o({openDialog:null})}}),y&&n.openDialog?.name==="elementLinkSelector"&&ee(lP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),ee(k.OverwriteConfirmDialogTunnel.Out,{}),$(),W(),y&&n.openDialog?.name==="charts"&&ee(OS,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),P.formFactor==="phone"&&ee(SS,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:W,renderImageExportDialog:$,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:U,renderWelcomeScreen:E,defaultUIEnabled:y,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&$t($E,{children:[A.viewportStatusFrame?.border&&ee(qm,{border:A.viewportStatusFrame.border,style:ue?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),$t("div",{className:"layer-ui__wrapper",style:ue?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&ee(k.WelcomeScreenCenterTunnel.Out,{}),B(),ee(VS,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:y,zoomUIEnabled:w}),(n.toast||x&&n.scrolledOutside||A.viewportStatusFrame?.label)&&$t("div",{className:"floating-status-stack",children:[n.toast&&ee(Nd,{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(pe=>({...ci(r,pe)}))},children:f("buttons.scrollBackToContent")}),A.viewportStatusFrame?.label&&ee(Jm,{label:A.viewportStatusFrame.label,border:A.viewportStatusFrame.border})]})]}),U()]})]});return ee(Ju.Provider,{value:n,children:ee(F,{children:ee(Hf.Provider,{value:k,children:we})})})},QP=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},LW=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return Dp(QP(o),QP(a),{selectedElementIds:Dp,selectedGroupIds:Dp})&&Dp(r,s)},ek=vW.memo(AW,LW);import{useEffect as DW,useRef as _W}from"react";import{jsx as tk}from"react/jsx-runtime";var nk=({trails:e})=>{let n=_W(null);return DW(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),tk("div",{className:"SVGLayer",children:tk("svg",{ref:n})})};import RW,{useEffect as ok,useRef as rk}from"react";import{isShallowEqual as NW,sceneCoordsToViewportCoords as BW}from"@excalidraw/common";import{jsx as zW}from"react/jsx-runtime";var ik="animateInteractiveScene",OW=e=>{let n=rk(!1),t=rk(null);return ok(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&Tf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),ok(()=>{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,BW({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},ot.running(ik)||ot.start(ik,({deltaTime:c,state:d})=>{let m=Tf({...t.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),zW("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")})},ak=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}),FW=(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:NW(ak(e.appState),ak(n.appState)),ZE=RW.memo(OW,FW);import ck,{useEffect as _p,useRef as Xl}from"react";import{isShallowEqual as sk}from"@excalidraw/common";import{jsx as UW}from"react/jsx-runtime";var HW=e=>{let n=Xl(null),t=Xl(!1),o=Xl(e),r=Xl(()=>{}),i=Xl(null);o.current=e;let a=ck.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();Jb({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}},ma());let m=s.renderConfig.imageTransitionDuration??0;m>0&&s.visibleElements.some(u=>{if(u.type!=="image"||!u.fileId)return!1;let E=s.renderConfig.imageCache.get(u.fileId)?.transitionStart;return E!==void 0&&performance.now()-E<m})&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,_p(()=>{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]),_p(()=>{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()}),_p(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),_p(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),UW("div",{className:"excalidraw__canvas-wrapper",ref:n})},lk=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}),GW=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:sk(lk(e.appState),lk(n.appState))&&sk(e.renderConfig,n.renderConfig),jE=ck.memo(HW,GW);import{useEffect as ZW,useRef as jW}from"react";import{throttleRAF as WW}from"@excalidraw/common";import{getTargetFrame as VW,isInvisiblySmallElement as YW,renderElement as XW,shouldApplyFrameClip as KW}from"@excalidraw/element";var dk=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=Ec(e,i),d=bc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(YW(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=VW(t,o,a);u&&KW(t,u,a,o)&&jb(u,d,s,a)}XW(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},$W=WW(e=>{dk(e)}),mk=(e,n)=>{if(n){$W(e);return}dk(e)};import{jsx as JW}from"react/jsx-runtime";var qW=e=>{let n=jW(null);return ZW(()=>{n.current&&mk({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},ma())}),JW("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})},pk=qW;import QW from"clsx";import{useLayoutEffect as eV,useEffect as uk,useRef as tV,useState as nV}from"react";import{ARROW_TYPE as hk,EVENT as Rp}from"@excalidraw/common";import{jsx as aV}from"react/jsx-runtime";var gk=700,oV=100,rV=16,iV=5*60*1e3,Ek=je(null),fk=e=>e===hk.elbow?Ho:e===hk.round?Go:zo,Np=class{constructor(n){I(this,"app");I(this,"lastShownAt",0);I(this,"show",n=>{let{x:t,y:o}=this.app.viewport.lastPosition;t===0&&o===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(Ek,{content:n,nonce:Math.random()}))});I(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<iV);I(this,"onArrowTypeCycled",n=>{this.show(fk(n))});I(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?Bo:fk(this.app.state.currentItemArrowType))});this.app=n}},bk=()=>{let[e,n]=Fe(Ek),t=It(),{container:o}=De(),r=tV(null),[i,a]=nV(!1),s=e?.nonce;return eV(()=>{if(s==null||!o)return;let l=(d,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=qc({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:rV});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(Rp.POINTER_MOVE,c),()=>{window.removeEventListener(Rp.POINTER_MOVE,c)}},[s,o,t]),uk(()=>()=>{n(null)},[n]),uk(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},gk),c=window.setTimeout(()=>{n(null)},gk+oV),d=()=>{n(null)};return window.addEventListener(Rp.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(Rp.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?aV("div",{ref:r,className:QW("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var Bp=class{constructor(n){this.getState=n;I(this,"listeners",[]);I(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 sV,getElementsInGroup as lV,isNonDeletedElement as xk,selectGroupsFromGivenElements as cV}from"@excalidraw/element";import{sceneCoordsToViewportCoords as dV}from"@excalidraw/common";import{flushSync as mV}from"react-dom";import{jsx as uV}from"react/jsx-runtime";var pV=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!xk(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&xk(t)?t:null,r=o?[o]:lV(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=sV(r),{x:s,y:l}=dV({sceneX:i,sceneY:a},e.state);return uV("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{mV(()=>{let c=cV(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(Zs)},title:f("labels.elementLock.unlock"),children:xx})},wk=pV;import{Fragment as pX,jsx as Ie,jsxs as xb}from"react/jsx-runtime";var kM=En.createContext(null),MM=En.createContext(null),wb={formFactor:"desktop",desktopUIMode:"full",userAgent:CM(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},vb=En.createContext(wb);vb.displayName="EditorInterfaceContext";var cX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},Ib=En.createContext({container:null,id:null});Ib.displayName="ExcalidrawContainerContext";var Tb=En.createContext([]);Tb.displayName="ExcalidrawElementsContext";var Sb=En.createContext({...Ro(),width:0,height:0,offsetLeft:0,offsetTop:0});Sb.displayName="ExcalidrawAppStateContext";var Cb=En.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Cb.displayName="ExcalidrawSetAppStateContext";var Pb=En.createContext(null);Pb.displayName="ExcalidrawActionManagerContext";var Qa=En.createContext(null);Qa.displayName="ExcalidrawAPIContext";var Jp=En.createContext(null);Jp.displayName="ExcalidrawAPISetContext";var It=()=>Ao(kM),yn=()=>Ao(MM),ge=()=>Ao(vb),it=()=>qp(ge()),De=()=>Ao(Ib),Ci=()=>Ao(Tb),Ko=()=>Ao(Sb),Ue=()=>Ao(Cb),tt=()=>Ao(Pb),xd=()=>Ao(Qa),nc=!1,oc=0,rc=null,ko=!1,Kp=!1,Mo=!1,$p=!1,ic={horizontal:null,vertical:null},yr=0,ac=!1,bb=new Map,dX=4,Zp=!1,jp=0,IM=!1,Ja=null,le={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},yb=class e extends En.Component{constructor(t){super(t);I(this,"canvas");I(this,"interactiveCanvas",null);I(this,"sessionExportThemeOverride");I(this,"rc");I(this,"unmounted",!1);I(this,"actionManager");I(this,"editorInterface",wb);I(this,"stylesPanelMode",qp(wb));I(this,"excalidrawContainerRef",En.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"hasRenderableElements",!1);I(this,"resizeObserver");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"imageLoadingProgress",new Map);I(this,"imageLoadingProgressEmitter",new Jn);I(this,"imageStatus",new Map);I(this,"imageStatusEmitter",new Jn);I(this,"imagePlaceholderUpdateEmitter",new Jn);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"elementsPendingErasure",new Set);I(this,"_initialized",!1);I(this,"editorLifecycleEvents",new WV(cX));I(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));I(this,"appStateObserver",new Bp(()=>this.state));I(this,"onStateChange",this.appStateObserver.onStateChange);I(this,"bucketFill",new Um(this));I(this,"flowchart",new Km(this));I(this,"cursor",new Wm(this));I(this,"zDragZoom",null);I(this,"arrowText",new Gm(this));I(this,"viewport",new Zm(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>le.pointers.size>=2||Mo}));I(this,"bindModeHandler",null);I(this,"textWysiwygSubmitHandler",null);I(this,"hitLinkElement");I(this,"lastPointerDownEvent",null);I(this,"lastPointerUpEvent",null);I(this,"lastPointerUpIsDoubleClick",!1);I(this,"lastPointerMoveEvent",null);I(this,"lastPointerMoveCoords",null);I(this,"lastCompletedCanvasClicks",[]);I(this,"previousPointerMoveCoords",null);I(this,"drawShape",new Xm(this));I(this,"laserTrails",new bm(this));I(this,"eraserTrail",new Sm(this));I(this,"lassoTrail",new Tm(this));I(this,"cursorHints",new Np(this));I(this,"onChangeEmitter",new Jn);I(this,"onPointerDownEmitter",new Jn);I(this,"onPointerUpEmitter",new Jn);I(this,"onUserFollowEmitter",new Jn);I(this,"onScrollChangeEmitter",new Jn);I(this,"missingPointerEventCleanupEmitter",new Jn);I(this,"onRemoveEventListenersEmitter",new Jn);I(this,"api");I(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});I(this,"updateEditorAtom",(t,...o)=>{let r=gt.set(t,...o);return this.triggerRender(),r});I(this,"previousHoveredBindableElement",null);I(this,"getEffectiveGridSize",()=>or(this)?this.state.gridSize:null);I(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)}});I(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:o,moveEvent:r})=>t&&ec(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Pe.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));I(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=Lk);I(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),qa.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Po(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=lb(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else ab(r)&&t.add(r.id);return!1}),o&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(this,"frameNameBoundsCache",{get:t=>{let 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=Ce({clientX:i.x,clientY:i.y},this.state),s=Ce({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});I(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===Zl.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&vt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!Zk(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}=zp({sceneX:i.x,sceneY:i.y},this.state),l=6,c,d=PY(i);if(i.id===this.state.editingFrame){let m=d;c=Ie("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:UV(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:`${Io.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?Io.nameColorDarkTheme:Io.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 Ie("div",{id:this.getFrameNameDOMId(i),className:ib.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+Io.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Io.nameFontSize,color:t?Io.nameColorDarkTheme:Io.nameColorLightTheme,lineHeight:Io.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:Pe.MOVE,pointerEvents:this.state.viewModeEnabled?Ka.disabled:Ka.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,o,r)=>{Ne("export",t,"ui");let i=await Fr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(HV).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&wc(i)&&this.setState({fileHandle:i})});I(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Nt,{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:jt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:jt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?Co(l,{[a?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:jt.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Ye(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||!1,a=t?.appState?.theme||this.props.theme||Zl.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&&Xp(d)&&Wt(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()}));I(this,"scheduleCapture",()=>this.store.scheduleCapture());I(this,"onBlur",Ye(()=>{ko=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));I(this,"onUnload",()=>{this.onBlur()});I(this,"disableEvent",t=>{t.preventDefault()});I(this,"preventBrowserZoomWheel",t=>{t[X.CTRL_OR_CMD]&&t.preventDefault()});I(this,"handleNavigationModeKeyDown",t=>{if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}this.actionManager.handleKeyDown(t)});I(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});I(this,"preventBrowserZoomKeyDown",t=>{t[X.CTRL_OR_CMD]&&(t.code===br.EQUAL||t.code===br.MINUS||t.code===br.ZERO||t.code===br.NUM_ADD||t.code===br.NUM_SUBTRACT||t.code===br.NUM_ZERO)&&t.preventDefault()});I(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),ko=!1,Kp=!1,Mo=!1,$p=!1,Ja=null,le.pointers.clear(),le.lastCenter=null,le.initialDistance=null,le.initialScale=null,clearTimeout(oc),oc=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(jp),jp=0,Zp=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),gt.set(Nt,null),gt.set($n,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&vt(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())});I(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,Qd(),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:Zt(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())});I(this,"isSameForcedTool",(t,o)=>t?.type===o?.type&&(t?.type==="custom"?t.customType??null:null)===(o?.type==="custom"?o.customType??null:null));I(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)});I(this,"resetHistory",()=>{this.history.clear()});I(this,"resetStore",()=>{this.store.clear()});I(this,"resetScene",Ye(t=>{this.scene.replaceAllElements([]),this.setState(o=>({...Ro(),isLoading:t?.resetLoadingState?!1:o.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(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=Sr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=pi(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=Jl(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,...ci(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:jt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),RY(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});I(this,"getFormFactor",(t,o)=>this.props.UIOptions.getFormFactor?.(t,o)??KV(t,o));I(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=qV(),a=CM(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:TV,l=rb(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)});I(this,"reconcileStylesPanelMode",t=>{let o=qp(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}}))});I(this,"setDesktopUIMode",t=>{let o=JV(t);this.editorInterface=rb(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});I(this,"onResize",Ye(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>qa.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({scrollBars:t})=>{t&&(ic=t),this.scheduleImageRefresh()});I(this,"onScroll",Rk(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},SV));I(this,"onCut",Ye(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||jl(t.target)||(this.actionManager.executeAction(jd,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Ye(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||jl(t.target)||(this.actionManager.executeAction(Zi,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if($V&&t.preventDefault(),!nc){nc=!0,t.touches.length===1&&(rc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(oc),oc=window.setTimeout(e.resetTapTwice,Lk);return}if(nc&&t.touches.length===1&&rc){let o=t.touches[0];qn(ne(o.clientX,o.clientY),ne(rc.x,rc.y))<=Fk&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),nc=!1,clearTimeout(oc)}t.touches.length===2&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null})}});I(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}):le.pointers.clear())});I(this,"pasteFromClipboard",Ye(async t=>{if(!this.isInteractionEnabled())return;let o=!!Zp,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)||jl(r)))return;let s=await Br(t),l=s.getFiles(),c=await zd(s,o);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()}));I(this,"addElementsFromPasteOrLibrary",t=>{let o=Sr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=Za(o),l=$a(r,a)/2,c=$a(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}=Ce({clientX:d,clientY:m},this.state),E=p-l,g=u-c,[b,y]=Ct(E,g,this.getEffectiveGridSize()),{duplicatedElements:w}=Yk({type:"everything",elements:o.map(A=>Co(A,{x:A.x+b-r,y:A.y+y-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),v=[...x,...w];v=this.props.onDuplicate?.(v,x)||v,cM(v,Jl(w));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let A=kY(w,C);v=pb(v,A,C)}this.scene.replaceAllElements(v),w.forEach(A=>{if(Wt(A)&&Kk(A)){let L=eM(A,this.scene.getElementsMapIncludingDeleted());wY(A,L,this.scene)}}),jV&&ro.loadElementsFonts(w).then(A=>{this.fonts.onLoaded(A)}),t.files&&this.addMissingFiles(t.files);let P=YY(w);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&gt.get(WE)?this.state.openSidebar:null,...dM(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}})});I(this,"addElementsFromPaste",t=>{this.addElementsFromPasteOrLibrary({...t,fit:t.fitToContent?"contain":void 0})});I(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)});I(this,"removePointer",t=>{yr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=le.pointers.size>=2;le.pointers.delete(t.pointerId),o&&le.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});I(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Ne("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...Zt(this.state,o.activeTool.locked?{type:this.state.preferredSelectionTool.type}:o.activeTool),locked:!o.activeTool.locked}})))});I(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}}})});I(this,"togglePenMode",t=>{this.setState(o=>({penMode:t??!o.penMode,penDetected:!0,currentItemStrokeVariability:o.penDetected?o.currentItemStrokeVariability:"variable"}))});I(this,"revealIfHidden",t=>{!t.length||gY(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:Za(t),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});I(this,"scrollToViewport",(t,o)=>{this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:{value:Bn(t.zoom)},shouldCacheIgnoreZoom:!1})});I(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}})});I(this,"emitUserFollowIntent",t=>{this.onUserFollowEmitter.trigger(t),this.props.onUserFollow?.(t)});I(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});I(this,"setToast",t=>{this.setState({toast:t})});I(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,EV,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Ye(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());Qk({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files}).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()}));I(this,"addImageElementsToScene",async(t,o,r)=>{await this.insertImages(t.map(({file:i})=>i),o,r)});I(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await ui(o);if(!yc(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};this.imageCache.set(t,s),i.src=await vc(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}});I(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=Kl(o,0,1);this.imageLoadingProgress.get(t)!==r&&(this.imageLoadingProgress.set(t,r),this.imageLoadingProgressEmitter.trigger())});I(this,"setDownloadError",(t,o)=>{this.updateImageStatus(t,r=>{let i=o===null&&r?.uploadProgress?.state==="error"?null:r?.uploadProgress;return{...r,downloadError:o===!0?{}:o||null,uploadProgress:i}})});I(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:Kl(o,0,1)}:{progress:void 0}}}})});I(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())});I(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);I(this,"clearImageLoadingProgress",t=>{this.imageLoadingProgress.delete(t)&&this.imageLoadingProgressEmitter.trigger()});I(this,"clearImageShapeCacheForFileId",t=>{for(let o of this.scene.getNonDeletedElements())ja(o)&&o.fileId===t&&qa.delete(o)});I(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===Xa.svg))try{let l=rx(Jk(ix(s.dataURL)),Xa.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});I(this,"updateScene",Ye(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?eY({...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}))}));I(this,"applyDeltas",(t,o)=>{let r=fM.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return fM.applyTo(r,a,i,o)});I(this,"mutateElement",(t,o,r=!0)=>this.scene.mutateElement(t,o,{informMutation:r,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(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});I(this,"updateCurrentCursorPosition",Ye(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));I(this,"onKeyDown",Ye(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}})),!Nk(t.target)){if((t.key===X.ESCAPE||t.key===X.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=ie(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&to(l[0])&&t.key===X.ENTER){this.startImageCropping(l[0]);return}if(t.key===X.ESCAPE)this.updateEditorAtom($n,null);else if(t.key===X.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(ib.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=Hm(l);gt.get($n)?.type==="panel"&&Nf(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom($n,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[X.CTRL_OR_CMD]&&t.key.toLowerCase()===X.V&&(Zp=t.shiftKey,clearTimeout(jp),jp=window.setTimeout(()=>{Zp=!1},100)),t[X.CTRL_OR_CMD]&&jl(t.target)&&(t.code===br.MINUS||t.code===br.EQUAL)){t.preventDefault();return}if(jl(t.target)&&t.key!==X.ESCAPE||QE(t.key)&&Nk(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 So("COMPLEX_BINDINGS")?this.handleSkipBindMode():Yp({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=Cw(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!zk(l,["laser","hand"]))return;if(l){if(this.state.activeTool.type!==l&&Ne("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"){let c=this.state.currentItemArrowType===xr.sharp?xr.round:this.state.currentItemArrowType===xr.round?xr.elbow:xr.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&&(So("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),Yp({app:this,event:t})),QE(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),c=new Set;l.filter(u=>eo(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?Ak:this.getEffectiveGridSize())||(t.shiftKey?yV:Ak),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}),Up(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]||gb(c))Rt(c)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==c.id)&&(this.store.scheduleCapture(),Ut(c)||this.actionManager.executeAction(aa));else if(Wt(c)||tM(c)){let d;Wt(c)||(d=c);let m=db(c,this.scene.getNonDeletedElementsMap()),p=m.x,u=m.y;this.startTextEditing({sceneX:p,sceneY:u,container:d}),t.preventDefault();return}else vt(c)&&this.setState({editingFrame:c.id})}}if(t.key===X.SPACE&&le.pointers.size===0&&(ko=!0,this.cursor.set(Pe.GRAB),t.preventDefault()),t.key.toLowerCase()===X.Z&&!t[X.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(Kp=!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&&(_o(this.state.activeTool.type)||l.some(c=>_o(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=>Wt(c)||cb(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})}));I(this,"onKeyUp",Ye(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(Pe.GRAB):Hp(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),ko=!1),t.key.toLowerCase()===X.Z&&(Kp=!1,this.cursor.reset()),t.key===X.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Yp({app:this,event:t})),(t.key===X.ALT&&this.state.bindMode==="skip"||!t[X.CTRL_OR_CMD]&&!Gp(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&So("COMPLEX_BINDINGS"))){let o=Ce({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=wr(ne(o.x,o.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=me.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());eo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[X.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Gt(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),Yp({app:this,event:t})}if(QE(t.key)){Gk(this.scene.getSelectedElements(this.state).filter(Ql),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(fb).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...bM(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...bM(r,o.get(r.endBinding.elementId),"end",o)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(t)}}));I(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(dt);let i=zi.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?Zt(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?Zt(this.state,{...t,lastActiveTool:this.state.activeTool}):Zt(this.state,t);s.type==="hand"?this.cursor.set(Pe.GRAB):ko||this.cursor.applyForTool(s),OV(document.activeElement)&&this.focusContainer(),pY(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:Hp(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:ke({},l),selectedGroupIds:ke({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:ke({},l),selectedGroupIds:ke({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"isTouchScreenMultiTouchGesture",()=>le.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${Bk()}`);I(this,"onGestureStart",Ye(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null}),le.initialScale=this.state.zoom.value)}));I(this,"onGestureChange",Ye(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=le.initialScale;o&&this.viewport.translate(r=>({...oo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Bn(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));I(this,"onGestureEnd",Ye(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}),le.initialScale=null)}));I(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=vM(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&T2(o,r,this.state.zoom.value,this.editorInterface.formFactor))});I(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=vM(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(Hg,"ui",r),this.cursor.reset(),!0)});I(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&&(cb(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||_k(u),g=this.state.currentItemFontSize;if(!p&&c&&i&&!Ql(i)){let C=OY(nb({fontSize:g,fontFamily:u}),E),P=FY(g,E),A=Math.max(i.height,P),L=Math.max(i.width,C);this.scene.mutateElement(i,{height:A,width:L}),t=i.x+L/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-sM(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,v=p||Wk({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?kV.MIDDLE:kk),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?Ql(i)?0:i.angle:0,frameId:x});if(!p&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:v.id})}),this.setState({editingTextElement:v}),!p)if(i&&c){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([v],T+1)}else this.insertNewElement(v);l&&d&&this.arrowText.bindText(l,v,d.fixedPoint),a||p||i?this.handleTextWysiwyg(v,{isExistingElement:!!p,initialCaretSceneCoords:p?s:null}):this.setState({newElement:v,multiElement:null})});I(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});I(this,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[o,r]=this.lastCompletedCanvasClicks;return qn(ne(o.x,o.y),ne(r.x,r.y))<=Fk});I(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}=Ce(t,this.state);if(o.length===1&&Rt(o[0])){let s=o[0];if((t[X.CTRL_OR_CMD]&&fb(s)||gb(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(aa);return}else if(this.state.selectedLinearElement&&Ut(o[0])){let l=me.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=l?me.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),me.deleteFixedSegment(o[0],this.scene,c);let d=me.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=d?me.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&&gb(s))return}if(o.length===1&&to(o[0])){this.startImageCropping(o[0]);return}if(this.cursor.reset(),WY(this.state).length>0){let s=this.getElementAtPosition(r,i),l=s&&UY(s,this.state.selectedGroupIds);if(l){this.store.scheduleCapture(),this.setState(c=>({...c,..._n({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(ec(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"||Xk(l)||!zV(l.backgroundColor)||tc({point:ne(r,i),element:l,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(l)}))){let c=db(l,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l||null})}}});I(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==To.MAIN){this.lastCompletedCanvasClicks=[];return}let o=Ce(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}]});I(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(!to(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});I(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=vl(o,r,this.state,i);return!!a&&qn(ne(t.x,t.y),ne(a.centerX,a.centerY))<=a.radius+2/this.state.zoom.value});I(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&&fc(s,this.scene.getNonDeletedElementsMap(),this.state,ne(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});I(this,"handleElementLinkClick",t=>{let o=qn(ne(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ne(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||o>Mk)return;let r=Ce(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=fc(this.hitLinkElement,i,this.state,ne(r.x,r.y),this.editorInterface.formFactor==="phone"),s=Ce(this.lastPointerUpEvent,this.state),l=fc(this.hitLinkElement,i,this.state,ne(s.x,s.y),this.editorInterface.formFactor==="phone");if(a&&l){Qd();let c=this.hitLinkElement.link;if(c){c=tb(c);let d;if(this.props.onLinkOpen&&(d=FV(J.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let m=RV(c)?"_self":"_blank",p=window.open(void 0,m);p&&(p.opener=null,p.location=c)}}}});I(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Pe.POINTER),qy(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(Qd(),!1));I(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});I(this,"handleInteractiveContentPointerMove",t=>{let o=Ce(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()});I(this,"handleInteractiveContentPointerUp",t=>{if(this.lastPointerUpEvent=t,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let o=Ce(t,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(t,o)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"getTopLayerFrameAtSceneCoords",(t,o)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(l=>!l.locked&&oM(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(vt(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});I(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});I(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,o)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!o&&sX(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});I(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?vY(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});I(this,"insertNewElement",t=>{this.insertNewElements([t]);let o=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(o&&vt(o)?o:null)});I(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=Bn(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...oo({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},s),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0}),this.resetShouldCacheIgnoreZoomDebounced()});I(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())&&!Mo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Ce(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),ko||Mo||$p||os(this.state))return;let s=tf(ic,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(Pe.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Pe.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&w2(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=x2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(y=>{let w=ql(y.snapLines,b),x=y.originSnapOffset?ql(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:me.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Gt(()=>{this.setState({selectedLinearElement:g})})}if(mY(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&Gp(this.state)){let b=ne(r,i),y=this.scene.getNonDeletedElementsMap(),w=wr(b,this.scene.getNonDeletedElements(),y,yM(this.state.zoom));w?this.setState({suggestedBinding:{element:w,midPoint:Eb(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,v=x[x.length-1],{lastCommittedPoint:T}=b;if(this.cursor.applyForTool(),v===T)qn(ne(r-y,i-w),v)>=eb?(this.store.scheduleCapture(),Gt(()=>{Qn(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,ne(r-y,i-w)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Pe.POINTER);else if(x.length>2&&T&&qn(ne(r-y,i-w),T)<eb){this.cursor.set(Pe.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{qk(x,this.state.zoom.value)&&this.cursor.set(Pe.POINTER);let C=this.scene.getNonDeletedElementsMap();if(fb(g)){let A=wr(ne(r,i),this.scene.getNonDeletedElements(),C);So("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,A)}Qn(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=me.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=ne(r,i),b=wr(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),yM(this.state.zoom)),y=this.scene.getNonDeletedElementsMap();b&&!wM(g,b,y)&&this.setState({suggestedBinding:{element:b,midPoint:Eb(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(Pe.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&&Ut(m[0]))&&!(Rt(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=pM(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(mM(g));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=uM(Za(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(mM({transformHandleType:g}));return}}if(qt(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||Po(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?Pe.POINTER:Wt(u)?Pe.TEXT:Pe.CROSSHAIR):!t[X.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Pe.MOVE):this.state.viewModeEnabled?this.cursor.set(Pe.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Pe.AUTO):s?this.cursor.set(Pe.AUTO):!t[X.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!Ut(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Pe.MOVE):this.cursor.set(Pe.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:ql(g.hoveredElementIds,_n({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:ql(g.hoveredElementIds,{})}))});I(this,"handleEraser",(t,o)=>{let r=this.eraserTrail.addPointToPath(o.x,o.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});I(this,"handleTouchMove",t=>{this.isInteractionEnabled()&&(ac=!0)});I(this,"handleCanvasPointerDown",t=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=t),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(t),Mo||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=Ce(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(_E,null)),gt.get($n)&&this.updateEditorAtom($n,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),Kp){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:ke(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"?jt.EVENTUALLY:jt.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=rb(this.editorInterface,{isTouchScreen:!0})),Mo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===To.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Dn.eraser){this.setState({activeTool:Zt(this.state,{type:Dn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),y?.(),qt(this.state)&&this.setState({activeTool:Zt(this.state,{...this.state.activeTool.lastActiveTool||{type:Dn.selection},lastActiveTool:null})})},b=be(window,J.POINTER_UP,g,{once:!0}),y;requestAnimationFrame(()=>{y=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==To.MAIN&&t.button!==To.TOUCH&&t.button!==To.ERASER||le.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},v=[];Object.keys(w.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&v.push(P)});let T=c.hit.element;if(vt(T))mb(v,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=>si(this.scene.getNonDeletedElements(),A)).filter(A=>vt(A)).map(A=>A.id));P.size>0&&v.forEach(A=>{A.frameId&&P.has(A.frameId)&&(delete x[A.id],A.groupIds.flatMap(L=>si(this.scene.getNonDeletedElements(),L)).forEach(L=>{delete x[L.id]}))})}return{..._n({editingGroupId:w.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),w,this),showHyperlinkPopup:T.link||Po(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===Dn.frame||this.state.activeTool.type===Dn.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===Dn.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)});I(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(So("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=Ce({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:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(ac=!1,yr?ac=!0:yr=window.setTimeout(()=>{yr=0,ac||this.handleCanvasContextMenu(t)},PV))});I(this,"resetContextMenuTimer",()=>{clearTimeout(yr),yr=0,ac=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{Ja?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(le.pointers.size<=1&&((t.button===To.WHEEL||t.button===To.MAIN&&ko||os(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;Mo=!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(Pe.GRABBING);let{clientX:i,clientY:a}=t,s=fm(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=Ye(Ja=()=>{Ja=null,Mo=!1,ko||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});I(this,"updateMultiTouchGesture",t=>{le.pointers.has(t.pointerId)&&le.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=le.initialScale;if(le.pointers.size===2&&le.lastCenter&&o&&le.initialDistance){let r=Ug(le.pointers),i=r.x-le.lastCenter.x,a=r.y-le.lastCenter.y;le.lastCenter=r;let s=Wg(Array.from(le.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/le.initialDistance,c=l?Bn(o*l):this.state.zoom.value;this.setState(d=>{let m=oo({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 le.lastCenter=le.initialDistance=le.initialScale=null});I(this,"clearSelectionIfNotUsingSelection",()=>{Hp(this.state.activeTool.type)||this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,o)=>{if(Hp(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&&!Ut(a[0])&&!(Rt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=pM(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(Za(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=ob(XY(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Rt(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=KY(o.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=me.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=me.getElement(p.elementId,E);if(g&&eo(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?ke({[p.selectedLinearElement.elementId]:!0},this.state):ke({},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=>({...GY(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!lM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:ke({},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)}),vt(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(y=>si(this.scene.getNonDeletedElements(),y)).filter(y=>vt(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=>si(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})),{..._n({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||Po(d)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(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);Xk(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:Zt(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});I(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=Ct(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=this.state.currentItemStrokeVariability,d=oY({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"?xV:bV},locked:!1,frameId:s?s.id:null,points:[ne(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(d),this.setState(m=>{let p={...m.selectedElementIds};return delete p[d.id],{selectedElementIds:ke(p,m)}}),this.setState({newElement:d,suggestedBinding:null})});I(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,s]=Ct(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=iY({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});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=Ct(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=Wp(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=Uk({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});I(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,s]=Ct(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 lY({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})});I(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(Qn(a,"selectedLinearElement is expected to be set"),i.type==="line"&&qk(i.points,this.state.zoom.value)){Gt(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(dt);return}if(Ut(i)&&i.points.length>1){this.actionManager.executeAction(dt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=Ce(t,this.state),{start:m,end:p}=eo(i)&&Gp(this.state)?lX(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&&!wM(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=c&&qn(ne(r.origin.x-s,r.origin.y-l),c)<eb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(dt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(y=>({selectedElementIds:ke({...y.selectedElementIds,[i.id]:!0},y)})),this.cursor.set(Pe.POINTER)}else{let[i,a]=Ct(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"?aY({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===xr.round?{type:Op.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===xr.elbow,fixedSegments:this.state.currentItemArrowType===xr.elbow?[]:null}):cY({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:Op.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=ne(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=Gp(this.state)?wr(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[ne(0,0),ne(0,0)]}),this.insertNewElement(p),eo(p)&&QY(p,new Map([[0,{point:ne(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:Pk(t.nativeEvent)}),Gt(()=>{this.setState(b=>{let y=null,w=b.selectedElementIds;if(Rt(p)){y=new me(p,this.scene.getNonDeletedElementsMap());let x=p.points.length-1;y={...y,selectedPointsIndices:[x],initialState:{...y.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:ne(r.origin.x,r.origin.y)}}}return w=this.isToolLocked()?b.selectedElementIds:ke({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&eo(p)?{element:g,midPoint:Eb(u,g,E,this.state.zoom)}:null,selectedElementIds:w,selectedLinearElement:y}})}),eo(p)&&So("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,g)}});I(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=Ct(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=Uk({type:"embeddable",...s}):l=sY({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.insertNewElement(l),this.setState({multiElement:null,newElement:l}))});I(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=Ct(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,...Io},s=o===Dn.magicframe?rY(a):nY(a);this.insertNewElement(s),this.setState({multiElement:null,newElement:s})});I(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});I(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(eo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);Vp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);Vp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else sb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&Vp(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&Vp(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)||Kk(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,Co(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});I(this,"initializeImage",async(t,o)=>{if(!yc(o))throw new Error(f("errors.unsupportedFileType"));let r=o.type;if(this.cursor.set("wait"),r===Xa.svg)try{o=pu(Jk(await o.text()),o.name)}catch(l){throw console.warn(l),new Error(f("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(o)||ox(o));if(!i)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[i]?.dataURL){let{maxWidthOrHeight:l,maxFileSizeBytes:c}=this.props.imageOptions;try{o=await(this.props.compressImageFile??ax)(o,{maxWidthOrHeight:l})}catch(d){console.error("Error trying to resize image file on insertion",d)}if(o.size>c)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(c/1024/1024)}MB`}))}let s=this.files[i]?.dataURL||await vc(o);return new Promise(async(l,c)=>{try{let d=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:s,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:u}=await this.updateImageCache([d]);if(u.size)throw new Error("Image cache update resulted with an error.")}let m=await this.imageCache.get(i)?.image,p=m?fY(m):null;if(m&&this.state.newElement?.id!==d.id){d=this.getLatestInitializedImageElement(t,i);let u=this.getImageNaturalDimensions(d,m);Object.assign(d,u)}d=Co(d,{fileName:o.name,thumbHash:p,status:"saved"}),this.files={...this.files,[i]:{...this.files[i],fileName:o.name,thumbHash:p??void 0}},l(d)}catch(d){console.error(d),c(new Error(f("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return Co(r,{fileId:o})});I(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}=Ce({clientX:t,clientY:o},this.state),a=await $b({description:"Image",extensions:Object.keys(vV),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Zt(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(dt)})}});I(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}});I(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 Qk({imageCache:this.imageCache,fileIds:t.map(s=>s.fileId),files:o});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&&(this.store.scheduleAction(jt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>ja(s)&&a.has(s.fileId)?Co(s,{status:"error"}):s))),{updatedFiles:i,erroredFiles:a}});I(this,"addNewImagesToImageCache",async(t=xY(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)&&qa.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",hV(()=>{this.addNewImagesToImageCache()},IV));I(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))});I(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,s=EM(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 ui(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),Co(u,{isDeleted:!0})}})),c=Jl(l),d=EM(l.filter(u=>!u.isDeleted),o,r,a),m=Jl(d),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??c.get(u.id)??u);this.updateScene({appState:{selectedElementIds:ke(Object.fromEntries(d.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:jt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(dt)})});I(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Ce(t,this.state),i=Nh(t),a=await Br(t),s=a.getFiles();if(s.length===1){let{file:d,fileHandle:m}=s[0];if(d&&(d.type===Xa.png||d.type===Xa.svg))try{let p=await ss(d,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:jt.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}let l=s.map(d=>d.file).filter(d=>yc(d));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,o,r,Bh(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(Xa.text);if(c){let d=c.value;if(d&&lb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||Wp(d)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:tb(d)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,o)=>{t=await ui(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await ss(t,this.state,r,o)}catch(a){let s=a instanceof Kb;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;PM(r.concat(i.elements)),this.store.scheduleMicroAction({action:jt.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:jt.IMMEDIATELY})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});I(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!==To.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Ce(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),s=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},a),l=i||s?"element":"canvas",c=this.excalidrawContainerRef.current,{top:d,left:m}=c.getBoundingClientRect(),p=t.clientX-m,u=t.clientY-d;Ne("contextMenu","openContextMenu",l),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,..._n({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Rt(i)?new me(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(l,i)}})})});I(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){hM({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:$a(t.origin.x,a.x),height:$a(t.origin.y,a.y),shouldMaintainAspectRatio:$l(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]=Ct(a.x,a.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=ja(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}=b2(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}),eo(s)||hM({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:$a(t.originInGrid.x,l),height:$a(t.originInGrid.y,c),shouldMaintainAspectRatio:to(s)?!$l(o):$l(o),shouldResizeFromCenter:Ck(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===Dn.frame||this.state.activeTool.type===Dn.magicframe)&&this.setState({elementsToHighlight:ub(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,o)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,s]=Ct(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&&to(l)){let c=t.originalElements.get(l.id),d=ja(l)&&this.imageCache.get(l.fileId)?.image;if(c&&to(c)&&d&&!(d instanceof Promise)){let[m,p]=Ct(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}=Kg([l],[c],this,o,u,r);this.scene.mutateElement(l,DY(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),Up(l,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});I(this,"maybeHandleResize",(t,o)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(vt),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Ut(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=Ct(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=>{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]=Ct(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}=Kg(r,ie(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if($Y(t.originalElements,a,r,this.scene,Pk(o),Ck(o),r.some(m=>to(m))?!$l(o):$l(o),l,c,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{ub(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{Xp(u)?m.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...m]}),!0}return!1});I(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=>to(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&to(t)?[...o([t.id])]:[]});I(this,"getContextMenuItems",(t,o)=>{let r=this.getImageContextMenuItems(o);if(t==="canvas")return this.state.viewModeEnabled?[ji,$r,er]:[Zh,at,Zu,iv,at,ji,kt,Ys,Xs,$r,er];if(this.state.viewModeEnabled)return[Zi,r.length>0&&at,...r];let i=this.editorInterface.formFactor==="desktop"?[at,Yu,Xu,Ku,$u]:[];return[at,jd,Zi,Zh,r.length>0&&at,...r,at,qv,Jv,Qv,at,Rg,at,Vh,Hg,Qh,eg,Uy,Yh,at,...i,at,Kh,$h,at,aa,at,cg,Zv,at,ju,Zs,at,Es]});I(this,"handleWheel",Ye(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(ib.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[X.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Mo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=MV*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:AV;c=Math.max(c,d),this.viewport.translate(p=>({...oo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Bn(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}))}));I(this,"savePointer",(t,o,r)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!t||!o)return;let{x:i,y:a}=Ce({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:le.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",Rk(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(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()}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});I(this,"watchState",()=>{});let o=Ro(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${Bk()}`,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=Zt(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===Zl.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=qp(this.editorInterface),this.id=fV(),this.actionManager=new pm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new gM,this.canvas=document.createElement("canvas"),this.rc=gV.canvas(this.canvas),this.renderer=new gl(this.scene),this.visibleElements=[],this.store=new qY(this),this.history=new ul(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new ro(this.scene),this.history=new ul(this.store),this.actionManager.registerAll(Hc),this.actionManager.registerAction(o2(this.history)),this.actionManager.registerAction(r2(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(Fp).includes(i)&&bb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){Qn(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=wr(ne(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=me.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),Gt(()=>{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;Qn(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?me.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):me.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||Ut(t))return;let r=()=>{if(this.bindModeHandler=null,Qn(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=wr(ne(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){Qn(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;Gt(()=>{Qn(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;Qn(g,"Last event must exist");let b=m-this.state.selectedLinearElement.pointerOffset.x,y=p-this.state.selectedLinearElement.pointerOffset.y,w=this.state.multiElement?me.handlePointerMove(g,this,b,y,this.state.selectedLinearElement):me.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&&xM(E,m),y=g&&xM(g,m);i=!!(b&&y&&E.id!==g.id&&eX(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"&&Gt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,XV)),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!==To.MAIN||ko||!zk(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=ne(Ce({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=ne(Ce({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(qn(t,o)>Mk)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&le.pointers.size<2&&ec(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),ab(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,Fp.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case Fp.PLAYING:case Fp.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=>Po(a)&&this.embedsValidationStatus.get(a.id)===!0||ab(a));return Ie(pX,{children:i.map(a=>{let{x:s,y:l}=zp({sceneX:a.x,sceneY:a.y},this.state),c=Zk(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=Wp(NV(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=Kl(g?t:1,.75,dX);return Ie("div",{className:yk("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:HY(a,hb(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?_V:1),"--embeddable-radius":`${EY(Math.min(a.width,a.height),a)}px`},children:xb("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?Ka.enabled:Ka.disabled},children:[E&&Ie("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Ie("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:Ie("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(Po(a)?this.props.renderEmbeddable?.(a,this.state):null)??Ie("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=gt.get($n)?.type==="panel";return Ie("div",{translate:"no",className:yk("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?Ka.disabled:Ka.enabled,"--right-sidebar-width":`${Ff}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:Ie(Qa.Provider,{value:this.api,children:Ie(kM.Provider,{value:this,children:Ie(MM.Provider,{value:this.props,children:Ie(Ib.Provider,{value:this.excalidrawContainerValue,children:Ie(vb.Provider,{value:this.editorInterface,children:Ie(Cb.Provider,{value:this.setAppState,children:Ie(Sb.Provider,{value:this.state,children:xb(Tb.Provider,{value:this.scene.getNonDeletedElements(),children:[xb(Pb.Provider,{value:this.actionManager,children:[Ie(ek,{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:Fn().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}),Ie("div",{className:"excalidraw-textEditorContainer"}),Ie("div",{className:"excalidraw-contextMenuContainer"}),Ie("div",{className:"excalidraw-eye-dropper-container"}),Ie(nk,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Ie(bk,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Ie(Zy,{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&&Ie(kT,{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?.()})}}),Ie(jE,{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,isExporting:!1,renderGrid:or(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&&Ie(pk,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:d,renderConfig:{imageCache:this.imageCache,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}}),Ie(ZE,{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"&&Ie(qm,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Ie(wk,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Ie(oT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{ja(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),qa.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,TM()||SM()){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(),LV&&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),ZV()&&!NY()&&this.setState({errorMessage:Ie(wT,{})});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.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 gM,this.fonts=new ro(this.scene),this.renderer=new gl(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(),qa.destroy(),ln.destroy(),clearTimeout(yr),Me.clearCache(),_n.clearCache(),yr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(be(window,J.MESSAGE,this.onWindowMessage,!1),be(document,J.POINTER_UP,this.removePointer,{passive:!1}),be(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),be(window,J.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(be(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),be(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.handleNavigationModeKeyDown,!1),be(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),be(document,J.GESTURE_START,this.onGestureStart,!1),be(document,J.GESTURE_CHANGE,this.onGestureChange,!1),be(document,J.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(be(this.excalidrawContainerRef.current,J.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),be(this.excalidrawContainerRef.current,J.GESTURE_START,this.disableEvent,!1),be(this.excalidrawContainerRef.current,J.GESTURE_CHANGE,this.disableEvent,!1),be(this.excalidrawContainerRef.current,J.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(be(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(be(document,J.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(be(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),be(document,J.COPY,this.onCopy,{passive:!1}),be(document,J.KEYUP,this.onKeyUp,{passive:!0}),be(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),be(document,J.GESTURE_START,this.onGestureStart,!1),be(document,J.GESTURE_CHANGE,this.onGestureChange,!1),be(document,J.GESTURE_END,this.onGestureEnd,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(be(document,J.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),be(document,J.PASTE,this.pasteFromClipboard,{passive:!1}),be(document,J.CUT,this.onCut,{passive:!1}),be(window,J.RESIZE,this.onResize,!1),be(window,J.UNLOAD,this.onUnload,!1),be(window,J.BLUR,this.onBlur,!1),be(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),be(this.excalidrawContainerRef.current,J.DRAG_OVER,this.disableEvent,!1),be(this.excalidrawContainerRef.current,J.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(be(BV(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.appStateObserver.flush(o),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===Zl.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&&qt(this.state)&&this.setState({activeTool:Zt(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(),qt(o)&&!qt(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===Zl.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(dt)});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:ke(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(){nc=!1,rc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Ce({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=Dm(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?tX(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=GV(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>bY(d)).filter(d=>lb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||Wp(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:tb(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)}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 sx(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}=Se({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:mV,verticalAlign:Tk,locked:!1},s=ZE({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=kk(a.fontFamily),[c,,d]=dY(this.state),p=Math.max(Math.min((d-c)*.5,800),200),m=10,u=i,E=o?[t]:t.split(`
24
- `),g=E.reduce((b,y,w)=>{let x=gY(y).trim();if(x.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),I=eM(x,s,l),C=I.width>p,P=C?pY(x,s,p):x;I=C?eM(P,s,l):I;let A=r-I.width/2,L=u-I.height/2,_=Fk({...a,x:A,y:L,text:P,originalText:x,lineHeight:l,autoResize:!C,frameId:v?v.id:null});b.push(_),u+=_.height+m}else E[w-1]?.trim()&&(u+=tM(a.fontSize,l)+m);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:ke(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&EM===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),EM=!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&&Ut(c)?gr(c,{originalText:s,isDeleted:l??c.isDeleted,...WV(c,$k(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=R2({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=Np({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Ve(s=>{a(s,!1),Up(t)&&Fp(t,this.scene)}),onSubmit:Ve(({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&&Ht(()=>{this.setState(p=>({selectedElementIds:ke({...p.selectedElementIds,[d]:!0},p)}))}),c&&RV(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Ht(()=>{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:ke({},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 Ut(r)?r:t?nb(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(Ut(i))return null;if(!Zk(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&&Ut(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 Vl({point:ne(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:vt(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||!(Ut(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=sb(l,a);return c&&!Up(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!Wl(l)?qk({x:t,y:o},c,a):!0}).filter(l=>Wl(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(Pk/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&eY([r],this.state,this.editorInterface)&&LY(ne(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||lY(ne(t,o),r,this.scene.getNonDeletedElementsMap())?!0:Vl({point:ne(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:vt(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 Wk(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,p]=Nk(r[s],this.scene.getNonDeletedElementsMap());if(Ul(r[s])&&Vl({point:ne(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<p){if(vt(r[s]))continue;a=r[s];break}}return Wk(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||Ut(this.state.newElement)}handleHoverSelectedLinearElement(t,o,r){let i=this.scene.getNonDeletedElementsMap(),a=ce.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let s=-1,l=null;Vl({point:ne(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(s=ce.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),l=ce.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Gt(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Pe.POINTER):this.hitElement(o,r,a)&&(!Gt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Pe.MOVE)):this.hitElement(o,r,a)&&(!Gt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Pe.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),ce.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}});let c=null,d=a;(d.startBinding||d.endBinding)&&(c=BY(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(Pe.POINTER)}else this.cursor.set(Pe.AUTO)}updateGestureOnPointerDown(t){se.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),se.pointers.size===2&&(se.lastCenter=Bg(se.pointers),se.initialScale=this.state.zoom.value,se.initialDistance=Og(Array.from(se.pointers.values())))}initialPointerDownState(t){let o=Se(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=za(r),c=r.findIndex(Gt)===0;return{origin:o,withCmdOrCtrl:t[K.CTRL_OR_CMD],originInGrid:jE(Ct(o.x,o.y,t[K.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:Zg($l,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,p)=>(d.set(p.id,zk(p)),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;Wp=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=mm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=Ve(()=>{Ua=null,Wp=!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 Ua=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(Pk/this.state.zoom.value,1),i=QW*2/this.state.zoom.value,[a,s,l,c]=za(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:KV(t)?_p.ADAPTIVE_RADIUS:_p.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return DV(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){ho({event:t,app:this,selectedElements:o})&&(r||!an.getReferenceSnapPoints())&&an.setReferenceSnapPoints(g2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){ho({event:t,app:this,selectedElements:o})&&(r||!an.getVisibleGaps())&&an.setVisibleGaps(h2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ve(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return Ve(o=>{o.key===K.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return mm(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Se(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[m,u]=Ct(r.x,r.y,o[K.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),E=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(E<0){let b=ce.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:m,y:u},this.state,this.scene.getNonDeletedElementsMap());E=b?ce.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let g=ce.moveFixedSegment(this.state.selectedLinearElement,E,m,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=jE(MY(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(qt(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]=Ct(r.x,r.y,o[K.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 m=this.state.selectedLinearElement;if(m.draggedFocusPointBinding){NY(m,c,r,this.scene,this.state,this.getEffectiveGridSize(),o.altKey),this.setState({selectedLinearElement:{...m,isDragging:!1,selectedPointsIndices:[],initialState:{...m.initialState,lastClickedPoint:-1}}});return}if(ce.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let u=ce.addMidpoint(this.state.selectedLinearElement,r,this,!o[K.CTRL_OR_CMD],this.scene);if(!u)return;Ht(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(m.initialState.segmentMidpoint.value!==null&&!m.initialState.segmentMidpoint.added)return;if(m.initialState.lastClickedPoint>-1){let u=ce.getElement(m.elementId,c);if(u?.isDeleted)return;if(eo(u)){let g=hr(ne(r.x,r.y),this.scene.getNonDeletedElements(),c);vo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&vo("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),m.initialState.lastClickedPoint===-1)return;let E=ce.handlePointDragging(o,this,r.x,r.y,m);if(E){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(E.suggestedBinding!==this.state.suggestedBinding||!Dk(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(m=>this.isASelectedElement(m)),p=this.state.selectedLinearElement?.isEditing&&o.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((d||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!p&&!t.drag.blockDragging){let m=this.scene.getSelectedElements(this.state);if(m.length>0&&m.every(g=>g.locked))return;let E=m.some(g=>vt(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:jk(m),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"&&m.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),m.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 v=Math.abs(g.x),I=Math.abs(g.y),C=y&&v<I,P=y&&v>I;C&&(g.x=0),P&&(g.y=0)}if(this.state.croppingElementId){let v=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(v&&fr(v)&&v.crop!==null&&t.hit.element===v){let I=v.crop,C=Ha(v)&&this.imageCache.get(v.fileId)?.image;if(C&&!(C instanceof Promise)){let P=zY(v),A=Ek(r.x-i.x,r.y-i.y);A[0]*=C.naturalWidth/P.width,A[1]*=C.naturalHeight/P.height;let[L,_,k,D,O,G]=Nk(v,c),z=YE(VE(ne(L,_),ne(O,G),v.angle)),W=YE(VE(ne(k,_),ne(O,G),v.angle)),j=YE(VE(ne(L,D),ne(O,G),v.angle)),X=wk(bk(W,z)),oe=wk(bk(j,z)),B=Ek(xk(A,X),xk(A,oe)),U={...I,x:Bl(I.x-B[0]*Math.sign(v.scale[0]),0,C.naturalWidth-I.width),y:Bl(I.y-B[1]*Math.sign(v.scale[1]),0,C.naturalHeight-I.height)};this.scene.mutateElement(v,{crop:U});return}}}this.maybeCacheVisibleGaps(o,m),this.maybeCacheReferenceSnapPoints(o,m);let{snapOffset:w,snapLines:x}=f2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||kY(t,m,g,this.scene,w,o[K.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),o.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let v=this.scene.getElementsIncludingDeleted(),I=t.hit.element,C=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});I&&t.hit.wasAddedToSelection&&!C.find(z=>z.id===I.id)&&C.push(I);let P=new Map(C.map(z=>[z.id,z])),{duplicatedElements:A,duplicateElementsMap:L,elementsWithDuplicates:_,origIdToDuplicateId:k}=Hk({type:"in-place",elements:v,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:W})=>({frameId:z.frameId??W.frameId,seed:TV()})});A.forEach(z=>{t.originalElements.set(z.id,zk(z))});let D=_.map(z=>{if(P.has(z.id)){let W=t.originalElements.get(z.id);if(W)return gr(z,{x:W.x,y:W.y})}return z}),O=this.props.onDuplicate?.(D,v),G=oM(O||D,Gl(A));Ht(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),W=z&&L.get(z);t.hit.element=W||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,W)=>{let j=k.get(W.id),X=j&&L.get(j);return X&&z.push(X),z},[]),t.drag.origin=Se(o,this.state),this.setState(z=>({...rM(A,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(G),C.forEach(z=>{eb(z)&&z.boundElements?.some(W=>W.type==="arrow")&&Fp(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 m=this.state.newElement;if(!m)return;if(m.type==="freedraw"){let u=m.points,E=r.x-m.x,g=r.y-m.y,b=u.length>0&&u[u.length-1];if(!(b&&b[0]===E&&b[1]===g)){let w=m.simulatePressure?m.pressures:[...m.pressures,o.pressure];this.scene.mutateElement(m,{points:[...u,ne(E,g)],pressures:w},{informMutation:!1,isDragging:!1}),this.setState({newElement:m})}}else if(Rt(m)&&!m.isDeleted){t.drag.hasOccurred=!0;let u=m.points;Qn(u.length>1,"Do not create linear elements with less than 2 points");let E=this.state.selectedLinearElement;(!E||E.elementId!==m.id)&&(E=new ce(m,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:m,...ce.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 m=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)ce.handleBoxSelection(o,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!o.shiftKey&&Me(m,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>Dn({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?Ob(m,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},{...Dn({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Rt(E[0])?new ce(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||To(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*($l.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*($l.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ve(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===Ln.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:a,croppingElementId:s,multiElement:l,activeTool:c,isResizing:d,isRotating:p,isCropping:m}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Hl(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,an.setReferenceSnapPoints(null),an.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=Se({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(vo("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(v=>v.type==="arrow").map(v=>r.get(v.id)).filter(v=>Gt(v)).forEach(v=>{v&&this.scene.mutateElement(v,{})})}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(ct);else{let x=ce.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(ct,"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=ce.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(FY(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(ct,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Rt(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=Se(o,this.state),v=i.points,I=x.x-i.x,C=x.y-i.y;I===v[0][0]&&C===v[0][1]&&(C+=1e-4,I+=1e-4);let P=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...v,ne(I,C)],pressures:P}),this.actionManager.executeAction(ct);return}if(Rt(i)&&this.state.activeTool.type!=="autoshape"){let x=Se(o,this.state),v=qn(ne(x.x,x.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||v<IV)&&i&&!l)if(this.editorInterface.isTouchScreen){let I=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-I/2,points:[ne(0,0),ne(I,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(ct)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),Rt(i)&&this.actionManager.executeAction(ct,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(I=>({newElement:null,activeTool:Zt(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ke({...I.selectedElementIds,[i.id]:!0},I),selectedLinearElement:new ce(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(Ut(i)){let x=bY(ZE({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&&Yk(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:jt.NEVER});return}if(vt(i)){let x=rY(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(ib(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,XV(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Se(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let v=this.scene.getElement(this.state.selectedLinearElement.elementId);if(v?.frameId){let I=sb(v,r);I&&v&&(iY(v,I,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(v,{groupIds:[]}),oY([v],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let v=this.scene.getSelectedElements(this.state),I=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:jk(v),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=A=>{if(A.length>0){for(let L of A){let _=L.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(L,{groupIds:L.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(L=>{L.groupIds.length&&ri(C,L.groupIds[L.groupIds.length-1]).length<2&&this.scene.mutateElement(L,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(I&&!this.state.selectedElementIds[I.id]){let A=v.filter(L=>Qk(L,C,this.state));this.state.editingGroupId&&P(A),C=ib(C,A,I)}else if(!I&&this.state.editingGroupId){let A=v.filter(L=>L.frameId&&!Qk(L,C,this.state));P(A)}C=Jk(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&Yk(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:jt.NEVER}),t.resize.isResizing){let x=Jk(this.scene.getElementsIncludingDeleted(),this.state,this),v=this.scene.getSelectedElements(this.state).filter(vt);for(let I of v)x=nY(x,ab(this.scene.getElementsIncludingDeleted(),I,this.state,r),I);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&Rt(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new ce(g,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!g&&!m||g&&g.id!==s))&&this.finishImageCropping();let b=this.lastPointerDownEvent,y=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(qt(this.state)&&b&&y){if(this.eraserTrail.endPath(),qn(ne(b.clientX,b.clientY),ne(y.clientX,y.clientY))===0){let v=Se({clientX:y.clientX,clientY:y.clientY},this.state);this.getElementsAtPosition(v.x,v.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]?TY(this.state,g)?this.setState(x=>{let v={...x.selectedElementIds};for(let I of g.groupIds.flatMap(C=>ri(this.scene.getNonDeletedElements(),C)))delete v[I.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(I=>({[I]:!1})).reduce((I,C)=>({...I,...C}),{})},selectedElementIds:ke(v,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let v={...x.selectedElementIds};delete v[g.id];let I=ie(this.scene.getNonDeletedElements(),{selectedElementIds:v});return{...Dn({editingGroupId:x.editingGroupId,selectedElementIds:v},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:I.length===1&&Rt(I[0])?new ce(I[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(x=>{let v={...x.selectedElementIds,[g.id]:!0};return delete v[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(I=>ri(this.scene.getNonDeletedElements(),I)).forEach(I=>{delete v[I.id]}),{...Dn({editingGroupId:x.editingGroupId,selectedElementIds:v},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||To(g)?"info":!1}}):this.setState(x=>({selectedElementIds:ke({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...Dn({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Rt(g)&&x.selectedLinearElement?.elementId!==g.id?new ce(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Gt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&cY({point:ne(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:vt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Ji):this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Pe.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[K.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&(Ut(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:ke({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:To(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||Me(this.scene.getNonDeletedElements(),this.state)||!Dk(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||p||m){let x=this.scene.getSelectedElements(this.state).filter(Ul);Bk(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(ct);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==Ln.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:Zt(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:ke({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&nM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:ke({},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=ob(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<iV){let{x:p,y:m}=Np({sceneX:a,sceneY:s},r);return{viewportX:p,viewportY:m,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)||Nn;await hc(t),this.setAppState({})}},VY=()=>{(bM()||xM())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(yM(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};VY();var IM=hb;import{useEffect as KY,useState as XY}from"react";import{jsx as $Y}from"react/jsx-runtime";var SM=e=>{let[n,t]=XY(!0);return KY(()=>{let o=async()=>{await hc(r),t(!1)},r=pi.find(i=>i.code===e.langCode)||Nn;o()},[e.langCode]),n?$Y(Ym,{theme:e.theme}):e.children};import ZY from"clsx";import{jsx as CM}from"react/jsx-runtime";var PM=({children:e})=>{let{FooterCenterTunnel:n}=Ke(),t=he();return CM(n.In,{children:CM("div",{className:ZY("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},jY=PM;PM.displayName="FooterCenter";import qY from"clsx";import{MQ_MIN_WIDTH_DESKTOP as JY}from"@excalidraw/common";import{jsx as eK,jsxs as tK}from"react/jsx-runtime";var kM=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=he(),i=t?.formFactor!=="desktop"||r.width<JY;return tK(Mn,{...o,className:qY("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?Dx:f("labels.share"),r.collaborators.size>0&&eK("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},QY=kM;kM.displayName="LiveCollaborationTrigger";import{jsx as br,jsxs as AM}from"react/jsx-runtime";var nK=()=>br("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:br("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),oK=()=>AM("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[br("path",{d:"M429.27 96.74c2.47-1.39 4.78-3.02 6.83-4.95 1.43-1.35 2.73-2.86 3.81-4.51-.66.9-1.4 1.77-2.23 2.59-2.91 2.84-5.72 5.09-8.42 6.87h.01ZM343.6 69.36c.33 3.13.58 6.27.79 9.4.09 1.37.18 2.75.25 4.12-.12-4.46-.27-8.93-.5-13.39-.11-2.08-.24-4.16-.4-6.24-.06 1.79-.11 3.85-.13 6.11h-.01ZM378.47 98.34c.01-.37.07-1.13.01-6.51-.11 1.9-.22 3.81-.31 5.71-.07 1.42-.22 2.91-.16 4.35.39.03.78.07 1.17.1-.92-.85-.76-2.01-.72-3.66l.01.01ZM344.09 86.12c-.09-2.41-.22-4.83-.39-7.24v12.21c.15-.05.32-.09.47-.14.05-1.61-.03-3.23-.09-4.83h.01ZM440.69 66.79c-.22-.34-.45-.67-.69-.99-3.71-4.87-9.91-7.14-15.65-8.55-1.05-.26-2.12-.49-3.18-.71 2.29.59 4.48 1.26 6.64 2.02 7.19 2.54 10.57 5.41 12.88 8.23ZM305.09 72.46l1.2 3.6c.84 2.53 1.67 5.06 2.46 7.61.24.78.5 1.57.73 2.36.22-.04.44-.08.67-.12a776.9 776.9 0 0 1-5.01-13.57c-.02.04-.03.09-.05.13v-.01ZM345.49 90.25v.31c1.48-.42 3.05-.83 4.66-1.2-1.56.25-3.12.52-4.66.89ZM371.02 90.22c0-.57-.04-1.14-.11-1.71-.06-.02-.12-.04-.19-.05-.21-.05-.43-.08-.65-.11.42.16.74.88.95 1.87ZM398.93 54.23c-.13 0-.27-.01-.4-.02l.03.4c.11-.15.23-.27.37-.38ZM401.57 62.28v-.15c-1.22-.24-2.86-.61-3.23-1.25-.09-.15-.18-.51-.27-.98-.09.37-.2.73-.33 1.09 1.24.56 2.52.98 3.83 1.29ZM421.73 88.68c-2.97 1.65-6.28 3.12-9.69 3.68v.18c4.72-.14 11.63-3.85 16.33-8.38-2.04 1.75-4.33 3.24-6.63 4.53l-.01-.01ZM411.28 80.92c-.05-1.2-.09-2.4-.15-3.6-.21 5.66-.46 11.38-.47 14.51.24-.02.48-.04.71-.07.15-3.61.05-7.23-.09-10.83v-.01Z",transform:"translate(-144.023 -51.76)"}),br("path",{d:"M425.38 67.41c-3.5-1.45-7.19-2.57-14.06-3.62.09 1.97.06 4.88-.03 8.12.03.04.06.09.06.15.19 1.36.28 2.73.37 4.1.25 3.77.39 7.55.41 11.33 0 1.38-.01 2.76-.07 4.13 1.4-.25 2.78-.65 4.12-1.15 4.07-1.5 7.94-3.78 11.28-6.54 2.33-1.92 5.13-4.49 5.88-7.58.63-3.53-2.45-6.68-7.97-8.96l.01.02ZM411.35 92.53v-.06l-.34.03c.11.01.22.03.34.03ZM314.26 64.06c-.23-.59-.47-1.17-.7-1.75.57 1.62 1.11 3.25 1.6 4.9l.15.54 2.35 6.05c.32.82.66 1.64.98 2.46-1.38-4.1-2.83-8.17-4.39-12.2h.01ZM156.82 103.07c-.18.13-.38.23-.58.33 1.32-.03 2.66-.2 3.93-.34.86-.09 1.72-.22 2.58-.33-2.12.1-4.12.17-5.94.34h.01ZM210.14 68.88s.03.04.05.07c.18-.31.39-.64.58-.96-.21.3-.42.6-.64.89h.01ZM201.65 82.8c-.5.77-1.02 1.56-1.49 2.37 1.11-1.55 2.21-3.1 3.2-4.59-.23.23-.49.51-.75.79-.32.47-.65.95-.96 1.43ZM194.03 98.66c-.33-.4-.65-.84-1.05-1.17-.24-.2-.07-.49.17-.56-.23-.26-.42-.5-.63-.75 1.51-2.55 3.93-5.87 6.4-9.28-.17-.08-.29-.28-.2-.49.04-.09.09-.17.13-.26-1.21 1.78-2.42 3.55-3.61 5.33-.87 1.31-1.74 2.64-2.54 4-.29.5-.63 1.04-.87 1.61.81.65 1.63 1.27 2.47 1.88-.09-.11-.18-.21-.27-.32v.01ZM307.79 82.93c-1-3.17-2.05-6.32-3.1-9.48-1.62 4.08-3.69 9.17-6.16 15.19 3.32-1.04 6.77-1.87 10.27-2.5-.32-1.08-.67-2.15-1.01-3.21ZM149.5 80.7c.05-1.71.04-3.43 0-5.14-.1 2.26-.16 4.51-.22 6.77-.02.73-.03 1.46-.04 2.19.14-1.27.2-2.55.24-3.82h.02ZM228.98 98.3c.39 1.25.91 3.03.94 3.91.06-.03.12-.07.17-.1.08-1.29-.55-2.65-1.11-3.81ZM307.72 53.36c.81.5 1.53 1.04 2.07 1.49-.38-.8-.78-1.58-1.21-2.35-.17.03-.34.06-.51.11-.43.12-.86.26-1.29.41.35-.01.53.1.94.34ZM283.69 96.14c3.91-7.25 6.89-13.35 8.88-18.15l1.1-2.66c-1.27 2.64-2.56 5.27-3.83 7.9-1.53 3.15-3.06 6.31-4.58 9.47-.87 1.81-1.76 3.62-2.54 5.47.04.02.07.04.11.07.05.05.1.09.15.14.05-.73.27-1.48.71-2.24ZM289.92 103.23s-.04.01-.05.03c0-.02.04-.03.05-.04.05-.05.11-.1.16-.15l.21-.21c-.55 0-1.5-.27-2.55-.72.4.26.8.51 1.22.74.24.13.48.26.73.37.05.02.1.03.14.05a.27.27 0 0 1 .08-.07h.01ZM269.23 68.49c-.39-.19-.82-.48-1.33-.87-3.06-1.56-6.31-2.78-9.36-2.35-3.5.49-5.7 1.11-7.74 2.44 5.71-2.6 12.82-2.07 18.44.79l-.01-.01ZM177.87 53.69l1.06.03c-.96-.22-2-.25-2.89-.3-4.95-.26-9.99.33-14.86 1.19-2.44.43-4.88.95-7.28 1.59 9.09-1.76 15.69-2.77 23.97-2.51ZM219.85 55.51c-.18.12-.36.27-.56.45-.45.53-.86 1.11-1.26 1.66-1.91 2.61-3.71 5.31-5.57 7.95l-.12.18 8.05-10.11c-.18-.05-.36-.1-.55-.13h.01ZM510.71 54.1c.12-.15.29-.3.53-.45.69-.4 3.72-.63 5.87-.74-.36-.02-.73-.04-1.09-.05-1.84-.03-3.67.09-5.49.35.05.3.12.59.18.88v.01ZM510.76 86.02c1.37-3.07 2.49-6.27 3.57-9.46.55-1.64 1.12-3.3 1.6-4.97-1.59 4.01-3.67 9.14-6.2 15.3.24-.08.5-.14.74-.22.1-.22.19-.44.29-.65ZM566.95 75.76c.11-.02.23.03.31.11-.05-.13-.09-.26-.14-.39-.05.09-.11.18-.17.28ZM511.33 86.41c3.08-.89 6.24-1.62 9.46-2.14-1.51-3.98-2.98-7.96-4.39-11.87-.05.15-.09.31-.14.46-1.02 3.32-2.15 6.61-3.39 9.85-.48 1.25-.98 2.49-1.53 3.7h-.01ZM578.24 74.45c.11-.44.23-.87.35-1.31-.31.7-.64 1.39-.97 2.08.09.21.19.4.28.61.12-.46.23-.92.35-1.38h-.01ZM520.62 53.11c-.09 0-.18-.01-.28-.02.38.34.29 1.08.93 2.53l6.65 17.15c2.2 5.68 4.69 11.36 7.41 16.87l1.06 2.17c-2.95-7.05-5.92-14.08-8.87-21.13-1.58-3.79-3.16-7.59-4.7-11.4-.78-1.92-1.73-3.89-2.25-5.91-.03-.1 0-.19.04-.26h.01ZM578.78 77.87c1.45-5.77 3.07-10.43 3.58-13.36.05-.34.16-.88.31-1.55-.67 1.79-1.37 3.56-2.08 5.33-.12.43-.23.86-.35 1.29-.65 2.43-1.29 4.86-1.9 7.3.14.33.29.65.43 1l.01-.01ZM545.3 94.66c.02-.44.03-.83.05-1.12.02-1.01.05-2.02.11-3.02.03-6.66-.46-14.33-1.46-22.8-.13-.42-.27-1.24-.56-2.89 0-.02 0-.04-.01-.06.62 6.61.95 13.25 1.32 19.87.17 3.08.33 6.16.52 9.23.02.25.03.52.04.78l-.01.01ZM580.77 102.81c.13.2.27.38.37.49.27-.11.53-.22.8-.32-.43.09-.82.05-1.17-.16v-.01ZM530.48 104.07h.33c-.36-.13-.71-.32-1.04-.56.14.24.3.47.45.7.06-.08.14-.13.26-.13v-.01ZM542.63 58.82c.06.23.11.47.15.71.14-.33.36-.62.7-.86-.28.05-.57.11-.85.15ZM583.81 57.87c.15-.7.29-1.41.42-2.11-.14.45-.28.9-.42 1.34-.46 1.44-.89 2.89-1.31 4.34.44-1.19.88-2.37 1.31-3.57ZM523.62 91.48c-4.66 1.17-9.05 2.89-14.02 5.27 4.65-1.84 9.48-3.29 14.28-4.63-.09-.22-.17-.41-.26-.64ZM460.64 78.3c-.04-2.9-.11-5.81-.28-8.71-.1-1.68-.17-3.43-.5-5.09-.07.02-.14.03-.2.05.3 6.54.45 12.17.51 17.12.17-.07.34-.14.51-.2 0-1.06-.01-2.11-.03-3.17h-.01ZM470.63 63.24c-3.38-.26-6.81.32-10.1 1.1.41 2.01.47 4.14.57 6.18.18 3.55.25 7.11.27 10.67 3.31-1.38 6.5-3.12 9.3-5.35 1.96-1.56 3.86-3.41 5.02-5.66.73-1.41 1.19-3.22.26-4.65-1.09-1.7-3.46-2.14-5.32-2.29ZM460.29 63.68c1-.24 2.01-.46 3.04-.65-1.15.16-2.37.38-3.71.69v.13c.07-.02.15-.04.22-.05.11-.13.3-.18.45-.11v-.01ZM457.24 100.96c.43-.03.86-.07 1.29-.11.14-.49.27-.99.38-1.49-.44.7-1 1.23-1.67 1.6ZM482.88 104.98c-.18.23-.36.38-.55.47.14.09.27.19.4.28a70.76 70.76 0 0 0 4.37-4.63c.76-.89 1.52-1.81 2.19-2.77-.3-.27-.61-.53-.92-.79-.07 1.94-4.62 6.32-5.49 7.45v-.01Z",transform:"translate(-144.023 -51.76)"}),br("path",{d:"M474.36 63.31c-.4-.16-.84-.27-1.29-.37 1.56.42 3.08 1.22 3.76 2.74.62 1.4.32 2.95-.28 4.32.7-1.22.94-2.34.74-3.47-.24-1.33-1.19-2.54-2.93-3.21v-.01ZM477.34 89.18c-1.2-.81-2.4-1.62-3.6-2.42-.14.1-.26.19-.4.29 1.4.67 2.73 1.39 4 2.13ZM465.88 93.85c.37.25.74.5 1.1.75.46.32.92.65 1.38.97-1.57-1.2-2.01-1.61-2.49-1.72h.01ZM574.92 90.06c-2.28-5.21-4.93-11.13-5.67-12.26-.1-.15-1.57-3.01-1.63-3.08 0 0-.01.02-.02.02.4 1.37 1.09 2.69 1.65 3.99 2.14 4.95 4.36 9.86 6.67 14.73.6 1.26 1.21 2.52 1.83 3.78-.75-2.01-1.64-4.45-2.83-7.18ZM448.73 65.29c.1.2.22.38.34.57.22-.02.43-.06.65-.08v-.08c-.14-.05-.25 0-.99-.41ZM460.16 94.81c-.02.31-.06.59-.1.89-.03 1.71-.33 3.43-.79 5.07.15-.02.3-.03.45-.05.01-.04.02-.08.03-.11.09-.34.15-.69.2-1.03.17-1.07.25-2.16.33-3.24.05-.69.08-1.39.12-2.08-.27.1-.27.26-.24.57v-.02Z",transform:"translate(-144.023 -51.76)"}),br("path",{d:"m328.67 98.12-3.22-6.58c-1.29-2.63-2.53-5.29-3.72-7.97-.25-.85-.52-1.69-.79-2.53-.81-2.57-1.67-5.12-2.55-7.67-1.92-5.53-3.9-11.08-6.32-16.41-.72-1.58-1.46-3.44-2.63-4.79-.03-.17-.16-.29-.34-.36a.282.282 0 0 0-.23-.04c-.06-.01-.12 0-.18.01-.74.06-1.5.38-2.19.61-2.22.77-4.4 1.64-6.63 2.38-.03-.08-.06-.16-.09-.25-.15-.42-.82-.24-.67.19.03.09.07.19.1.28l-.18.06c-.36.11-.28.6 0 .68.18 1.18.63 2.36.98 3.49.03.09.06.17.08.26-.08.23-.17.46-.24.64-.37.98-.79 1.94-1.21 2.9-1.27 2.89-2.62 5.75-3.98 8.6-3.18 6.67-6.44 13.31-9.64 19.97-1.08 2.25-2.2 4.5-3.15 6.81-.13.32.24.5.5.37 1.34 1.33 2.84 2.5 4.4 3.57.65.44 1.31.87 2.01 1.24.4.22.86.48 1.33.5.24.01.35-.19.33-.37.11-.1.21-.21.28-.28.41-.41.81-.84 1.2-1.26.85-.92 1.69-1.87 2.5-2.84 6.31-2.34 12.6-4.31 18.71-5.84 2.14 5.3 3.43 8.43 3.97 9.58.55 1.05 1.15 1.88 1.82 2.52 1.32.56 6.96-.03 9.23-1.96.87-1.28 1.19-2.67.93-4.15-.09-.5-.22-.95-.4-1.33l-.01-.03Zm-20.09-45.61c.43.77.83 1.56 1.21 2.35-.54-.45-1.27-.99-2.07-1.49-.42-.24-.6-.35-.94-.34.43-.15.85-.29 1.29-.41.17-.05.34-.08.51-.11Zm-25.86 45.66c.78-1.85 1.67-3.66 2.54-5.47 1.51-3.16 3.05-6.31 4.58-9.47 1.28-2.63 2.56-5.26 3.83-7.9l-1.1 2.66c-1.99 4.79-4.97 10.9-8.88 18.15-.43.76-.66 1.51-.71 2.24-.05-.05-.1-.09-.15-.14a.259.259 0 0 0-.11-.07Zm6.24 4.71c-.42-.23-.82-.48-1.22-.74 1.05.45 2 .72 2.55.72l-.21.21c-.05.05-.11.1-.16.15-.01.01-.04.03-.05.04 0-.02.03-.02.05-.03a.27.27 0 0 0-.08.07c-.05-.02-.1-.03-.14-.05-.25-.1-.49-.24-.73-.37h-.01Zm15.73-29.43c1.05 3.15 2.1 6.31 3.1 9.48.34 1.06.69 2.13 1.01 3.21-3.5.63-6.95 1.46-10.27 2.5 2.48-6.03 4.54-11.11 6.16-15.19Zm4.79 12.57c-.23-.79-.49-1.58-.73-2.36-.79-2.54-1.63-5.08-2.46-7.61l-1.2-3.6c.02-.04.04-.09.05-.13 1.6 4.45 3.28 9 5.01 13.57l-.67.12v.01Zm5.83-18.27-.15-.54c-.49-1.64-1.03-3.28-1.6-4.9.23.58.47 1.17.7 1.75 1.56 4.03 3.01 8.1 4.39 12.2-.33-.82-.67-1.64-.98-2.46l-2.35-6.05h-.01ZM390.43 79.37c-.13-10.43-.22-17.5-.24-19.97-.24-1.6.21-2.88-.65-3.65-.14-.13-.32-.23-.52-.32h.03c.45 0 .45-.69 0-.7-1.75-.03-3.5-.04-5.25-.14-1.38-.08-2.76-.21-4.15-.31-.07 0-.12.01-.17.04-.21-.07-.47.03-.45.31l.03.45c-.11.14-.19.3-.22.5-.21 1.26-.32 13.67-.36 23.59-.32 5.79-.67 11.57-.97 17.36-.09 1.73-.29 3.54-.21 5.3-.39.02-.38.64.04.69v.12c.05.44.74.45.7 0v-.06c1.1.09 2.2.21 3.3.3 1.14.19 2.44.2 3.29.17 1.73-.05 2.92-.05 3.8-.37.45-.05.9-.11 1.35-.17.44-.06.25-.73-.19-.67h-.01c.24-.32.45-.72.62-1.25.66-1.84.41-6.36.34-11.33l-.13-9.9.02.01Zm-12.26 18.17c.09-1.91.2-3.81.31-5.71.06 5.38 0 6.14-.01 6.51-.05 1.65-.21 2.81.72 3.66-.39-.04-.78-.07-1.17-.1-.06-1.44.09-2.93.16-4.35l-.01-.01ZM588.97 53.85c-2.06-.25-3.17-.51-3.76-.6a.3.3 0 0 1 .04-.08c.22-.39-.39-.75-.6-.35-.56 1.02-.9 2.19-1.26 3.29-.61 1.88-1.17 3.78-1.72 5.68-.63 2.19-1.24 4.39-1.83 6.59-.81 2.03-1.67 4.05-2.61 6.03-1.7-3.64-3.11-6.04-4.03-7.57-2.26-3.74-2.85-5.48-3.57-6.08l.31-.09c.43-.12.25-.8-.19-.67-1.06.3-2.12.6-3.17.95-.93.32-1.85.69-2.76 1.07-.13.05-.19.16-.22.27-.04.02-.08.05-.11.07-.04-.06-.07-.12-.11-.18a.354.354 0 0 0-.48-.12c-.16.09-.22.32-.13.48l.33.54c0 .09.02.18.06.28.51 1.16.78 1.38.72 1.47-2.42 3.44-5.41 7.86-6.2 9.1-1.27 1.97-2.01 3.14-2.45 3.84l-.91-6.56-.43-4.1c-.19-1.85-.37-3.23-.53-4.13-.19-1.1-.3-2.15-.45-3.16-.2-1.36-.29-2.06-.47-2.42h.04c.45.02.45-.68 0-.7-3.43-.16-6.81.94-10.17 1.48-.24-.22-.73-.04-.58.32.24.59.33 1.25.43 1.87.17 1.06.29 2.13.4 3.2.32 3.09.53 6.2.74 9.3.44 6.75.77 13.51 1.17 20.26.11 1.95.13 3.96.46 5.89.05.3.37.31.55.14.74 1.71 2.87 1.27 6.13 1.27 1.34 0 2.39.04 2.99-.11.02.32.48.53.63.18 3.61-8.26 7.41-16.46 12.05-24.2.03-.05.04-.1.05-.15.3.73.64 1.45.94 2.16.97 2.26 1.97 4.52 2.98 6.76 2.26 5.03 4.54 10.07 7.09 14.96.47.9.94 1.79 1.47 2.65.2.32.4.67.66.96-.18.25 0 .68.34.54.91-.38 1.82-.75 2.76-1.07 1.04-.35 2.11-.65 3.17-.95.39-.11.28-.66-.07-.68.62-.4.95-.96.87-1.91-.3-3.34.72-7.47.86-8.52l2.14-11.43c1.75-10.74 3.13-17.51 3.23-20.86.02-.49.08-2.84.13-3.24.17-1.25.48-1-4.96-1.65l.03-.02Zm-46.19 5.67c-.04-.24-.09-.48-.15-.71l.85-.15c-.34.24-.56.53-.7.86Zm1.95 25.12c-.36-6.63-.7-13.26-1.32-19.87 0 .02 0 .04.01.06.29 1.65.44 2.47.56 2.89 1 8.46 1.5 16.14 1.46 22.8-.06.99-.1 2-.11 3.02-.01.29-.03.68-.05 1.12-.01-.26-.03-.53-.04-.78-.19-3.08-.35-6.16-.52-9.23l.01-.01Zm36.4 18.66c-.11-.11-.24-.29-.37-.49.35.21.74.26 1.17.16-.27.11-.53.22-.8.32v.01Zm-.89-33.72c.12-.43.23-.86.35-1.29.71-1.77 1.41-3.55 2.08-5.33-.15.68-.26 1.22-.31 1.55-.5 2.94-2.13 7.59-3.58 13.36-.15-.35-.29-.66-.43-1 .61-2.44 1.25-4.87 1.9-7.3l-.01.01Zm3.56-12.48c.14-.44.28-.89.42-1.34-.13.7-.27 1.41-.42 2.11-.43 1.19-.86 2.38-1.31 3.57.42-1.45.85-2.9 1.31-4.34Zm-5.22 16.05c-.11.44-.23.87-.35 1.31-.12.46-.23.92-.35 1.38-.1-.22-.19-.4-.28-.61.34-.69.66-1.38.97-2.08h.01Zm-11.64 2.62c.06-.1.12-.19.17-.28.05.13.09.26.14.39a.398.398 0 0 0-.31-.11Zm2.3 2.98c-.56-1.3-1.25-2.63-1.65-3.99 0 0 .01-.02.02-.02.06.08 1.52 2.93 1.63 3.08.73 1.13 3.38 7.04 5.67 12.26 1.2 2.73 2.08 5.17 2.83 7.18-.62-1.25-1.23-2.51-1.83-3.78-2.31-4.87-4.53-9.78-6.67-14.73ZM275.92 87.03c-1.06-2.18-1.13-3.45-2.44-2.93-1.52.57-2.94 1.3-4.5 2.1-1.4.72-2.68 1.44-3.92 2.12.01-.25-.24-.5-.51-.34-4.8 2.93-12.41 4.7-17.28 1.31-1.98-1.77-3.32-4.15-3.97-5.78-.29-.95-.49-1.94-.63-2.93-.14-3.34 1.58-6.53 3.9-9.12.8-.79 1.68-1.51 2.66-2.12 3.7-2.3 8.22-3.07 12.51-2.51 2.71.35 5.32 1.24 7.71 2.55.39.22.75-.39.35-.6-.18-.1-.37-.18-.55-.27.56.27 1.03.33 1.51.19l-.48.39c-.15.11-.23.3-.13.48.09.15.33.24.48.13 1.3-.97 2.46-2.09 3.45-3.37.37-.29.64-.6.65-.97v-.02c.08-.33-.03-.7-.21-1.08-.31-.87-.98-2.01-2.19-3.26-2.43-2.52-3.79-3.45-5.68-4.26-1.14-.49-3.12-1.06-4.42-1.23-3.28-.42-10.64-1.21-18.18 4.11-7.74 5.46-11.94 12.3-12.23 20.61-.08 2.06.04 3.98.34 5.71.74 4.18 2.57 8 5.44 11.34 4.26 4.99 9.76 7.52 16.34 7.52 4.85 0 9.69-1.77 14.89-4.62.23-.12.45-.23.68-.35 2.19-1.1 4.37-2.23 6.46-3.5.49-.3 1.03-.61 1.5-.98 1.47-.87 1.11-1.12.49-2.95-.39-1.14-.76-2.7-2.06-5.36l.02-.01Zm-17.38-21.76c3.05-.42 6.31.79 9.36 2.35.51.39.94.68 1.33.87-5.61-2.86-12.72-3.39-18.44-.79 2.05-1.33 4.24-1.95 7.74-2.44l.01.01ZM443.67 72.67c-.4-2.2-1.15-4.33-2.37-6.22-1.49-2.32-3.58-4.19-5.91-5.64-6.17-3.81-13.75-5.11-20.83-6.01-3.23-.41-6.47-.69-9.72-.92l-1.39-.12c-.85-.07-1.52-.1-2.05-.1-1.08-.06-2.17-.12-3.25-.17-.08 0-.14.02-.19.05-.1.05-.18.14-.16.3.27 2.55-.01 5.12-.92 7.52-.15.38.4.56.62.28 1.32.59 2.68 1.05 4.08 1.37 0 2.78-.14 7.58-.33 12.91 0 0 0 .02-.01.03-.61 3.66-.79 7.42-1 11.12-.23 4.01-.43 8.03-.44 12.05 0 .64 0 1.28.03 1.93.02.31 0 .68.15.96.06.11.14.16.24.17-.2.17-.21.54.11.59 3.83.67 7.78.71 11.68.25 2.3-.19 4.87-.65 7.65-1.56 1.85-.54 3.67-1.18 5.43-1.91 7.2-3.02 14.31-8.07 17.35-15.53.76-1.86 1.17-3.8 1.31-5.75.3-1.93.28-3.82-.09-5.58l.01-.02Zm-19.32-15.42c5.74 1.41 11.94 3.68 15.65 8.55.25.32.47.65.69.99-2.3-2.82-5.68-5.69-12.88-8.23-2.16-.76-4.35-1.43-6.64-2.02 1.06.21 2.13.45 3.18.71Zm-25.82-3.04c.13 0 .27.01.4.02-.14.1-.26.23-.37.38 0-.13-.02-.26-.03-.4Zm34.82 22.17c-.75 3.09-3.55 5.66-5.88 7.58-3.35 2.76-7.21 5.03-11.28 6.54-1.33.49-2.71.9-4.12 1.15.06-1.38.08-2.76.07-4.13-.02-3.78-.16-7.56-.41-11.33-.09-1.37-.18-2.74-.37-4.1 0-.06-.03-.11-.06-.15.09-3.25.12-6.16.03-8.12 6.86 1.05 10.56 2.17 14.06 3.62 5.52 2.28 8.59 5.44 7.97 8.96l-.01-.02Zm-22 16.15c-.12 0-.23-.02-.34-.03l.34-.03v.06Zm-.69-.7c0-3.13.26-8.84.47-14.51.06 1.2.11 2.41.15 3.6.15 3.6.25 7.23.09 10.83-.24.03-.48.05-.71.07v.01Zm-12.33-30.94c.37.63 2.01 1.01 3.23 1.25v.15c-1.31-.31-2.59-.73-3.83-1.29.12-.36.23-.72.33-1.09.08.48.18.84.27.98Zm13.7 31.65v-.18c3.41-.56 6.71-2.02 9.69-3.68 2.31-1.28 4.59-2.78 6.63-4.53-4.69 4.53-11.61 8.24-16.33 8.38l.01.01Zm24.07-.75c-2.05 1.93-4.37 3.56-6.83 4.95 2.7-1.78 5.52-4.03 8.42-6.87.82-.82 1.56-1.69 2.23-2.59-1.08 1.65-2.38 3.16-3.81 4.51h-.01ZM187.16 92.14c-.79-2.47-2.1-7.12-3.1-6.87-.19-.01-2.09.77-4.08 1.54-3.06 1.18-5.91 2.13-10.09 2.82-2.74.42-5.87 1.01-10.61 1.06.04-3.34.05-6.01.05-7.99 7.97-.65 12.33-2.11 16.37-3.55 1.11-.39 2.69-1.01 2.63-1.8-.08-.35-.55-1.39-1.17-2.61-.47-1.16-.98-2.31-1.61-3.38-.42-.71-1.04-1.69-1.86-2.06-.11-.08-.22-.13-.29-.12-.02 0-.04 0-.07.01-.19-.04-.39-.05-.6-.01-.17.03-.24.15-.25.28-.04.02-.09.04-.14.05-4.33 1.48-8.85 2.33-13.24 3.61a499.1 499.1 0 0 0-.31-8.19c4.51-.99 8.88-1.38 13.11-1.82 3.68-.38 6.28.12 7.47.34.59.11.9.16 1.16.18h.1c-.1.37.44.66.62.28.02-.04.03-.08.05-.13.15.2.53.22.62-.1.17-.58.19-1.21.21-1.81v-.36c.03-.15.05-.3.07-.45.52-2.47.33-5.09-.64-7.44-.11-.27-.44-.28-.6-.14-.08-.21-.15-.42-.24-.62-.19-.41-.79-.05-.6.35.03.07.05.15.09.22-.98-.42-2.15-.54-3.17-.63-2.17-.19-4.37-.14-6.54 0-5.7.35-11.4 1.3-16.91 2.79-2.08.56-4.13 1.22-6.14 2-4.54 1.05-3.79 1.51-2.17 6.07.18.51.46 1.68.54 1.94.82 2.47 1.08 2.13 3.1 2.13s0 .05 0 .08h.52c-.48 2.66-.51 5.45-.62 8.13-.15 3.48-.22 6.96-.28 10.45 0 .41-.01.82-.02 1.23-.16.29-.33.57-.51.85-.05.38-.09.77-.14 1.18-.42 3.52-.59 6.48-.52 8.8v.34c.02.47.05.76.06.87.16 1.57-.26 3.47 1.35 3.79 1.61.32 3.5.55 4.85.55.11 0 .22-.02.33-.02 1.79.24 3.67.05 5.45-.12 2.85-.28 5.69-.7 8.51-1.19 3.03-.53 6.05-1.14 9.04-1.86 2.4-.58 4.82-1.19 7.13-2.06.51-.19 1.73-.57 2.46-1.14 1.81-.68 2.18-1 1.57-2.67-.23-.62-.48-1.49-.91-2.78l-.03-.02Zm-11.12-38.71c.89.05 1.93.08 2.89.3-.33 0-.68-.02-1.06-.03-8.28-.26-14.88.75-23.97 2.51 2.41-.64 4.85-1.16 7.28-1.59 4.87-.86 9.91-1.45 14.86-1.19Zm-26.53 22.13c.03 1.71.04 3.43 0 5.14-.04 1.27-.11 2.55-.24 3.82 0-.73.02-1.46.04-2.19.05-2.26.12-4.51.22-6.77h-.02Zm6.73 27.85c.2-.1.4-.21.58-.33 1.82-.17 3.82-.24 5.94-.34-.86.11-1.72.24-2.58.33-1.27.14-2.61.31-3.93.34h-.01ZM534.48 85.44c-3.52-8.38-7.07-16.75-10.5-25.17-.63-1.54-1.25-3.09-1.86-4.65-.31-.8-.65-1.6-.87-2.43-.04-.17-.17-.24-.31-.25.1-.2 0-.51-.29-.53-1.59-.08-3.18-.22-4.78-.25-1.96-.03-3.91.13-5.84.42-.31.05-.31.38-.13.56-.03.06-.05.14-.04.22.23 1.54.63 3.06 1.16 4.53.13.35.27.7.41 1.06l-2.68 6.18c-.11.03-.2.09-.25.22-.67 1.9-1.52 3.73-2.34 5.56a536.85 536.85 0 0 1-3.9 8.45c-2.64 5.64-5.34 11.25-7.91 16.93-.44.97-.88 1.94-1.29 2.93-.2.48-.47 1-.55 1.52v.05c-.02.12.02.26.16.34 1.19.73 2.41 1.41 3.66 2.05 1.2.62 2.45 1.25 3.76 1.61.43.12.62-.55.19-.67-1.13-.31-2.2-.83-3.24-1.36 1.09.36 2.1.69 2.75.93 2.82 1.01 2.38 1.1 4.3-3.75 2.1-1.09 4.34-1.96 6.53-2.79 4.35-1.64 8.8-3.03 13.27-4.29.82 2.01 1.77 3.97 2.72 5.92.35.83.62 1.45.79 1.82.22.42.45.8.69 1.15.17.33.33.67.5 1 .42.8.84 1.63 1.4 2.35.23.29.6 0 .55-.31 1.53-.02 3.06-.07 4.58-.27.92-.12 1.82-.32 2.71-.54 1.39-.27 3.85-1.11 3.74-1.42-.67-1.96-1.55-3.87-2.34-5.78-1.57-3.78-3.16-7.56-4.75-11.33v-.01Zm-11.65-26.16c1.54 3.81 3.12 7.6 4.7 11.4 2.94 7.05 5.91 14.09 8.87 21.13l-1.06-2.17c-2.71-5.51-5.2-11.19-7.41-16.87l-6.65-17.15c-.65-1.45-.55-2.19-.93-2.53.09 0 .18.01.28.02a.29.29 0 0 0-.04.26c.52 2.02 1.47 3.98 2.25 5.91h-.01Zm-6.58 13.58c.05-.15.09-.31.14-.46 1.41 3.92 2.88 7.9 4.39 11.87-3.22.52-6.38 1.25-9.46 2.14.55-1.22 1.05-2.46 1.53-3.7 1.24-3.24 2.37-6.53 3.39-9.85h.01Zm-.23-20c.36 0 .73.03 1.09.05-2.15.1-5.18.33-5.87.74-.24.15-.41.3-.53.45-.06-.29-.13-.58-.18-.88 1.82-.26 3.65-.39 5.49-.35v-.01Zm-.09 18.72c-.49 1.67-1.05 3.33-1.6 4.97-1.07 3.19-2.19 6.38-3.57 9.46-.09.21-.19.43-.29.65-.25.07-.5.14-.74.22 2.53-6.16 4.61-11.29 6.2-15.3Zm-6.34 25.16c4.97-2.38 9.37-4.1 14.02-5.27l.26.64c-4.8 1.35-9.63 2.8-14.28 4.63Zm20.17 6.76c.33.23.68.42 1.04.56h-.33c-.12 0-.21.06-.26.13-.15-.23-.31-.45-.45-.7v.01ZM226.57 91.75c-3.55-4.74-6.68-9.11-9.31-12.99 9.2-15.25 10.05-17.81 10.35-18.38.17-.34 1.09-2.27.64-2.53-1.13-.65-1.03-.65-2.97-1.71-1.19-.65-3.04-1.61-4.53-2.12-1.71-.59-1.24-.36-3 2.77-.06.1-.11.2-.17.3-.75 1.02-1.48 2.05-2.2 3.09-1.88 2.71-3.73 5.45-5.69 8.1-3.68-4.91-6.88-8.76-9.51-11.43-.15-.15-.3-.29-.46-.42-1.27-1.28-7.24 3.53-7.93 5.58-.09.09-.19.16-.28.25-.27.26.03.64.33.58.19.65.5 1.29.94 1.91 3.85 5.06 7.19 9.76 9.94 14-1.23 2.61-3.06 5-4.67 7.38l-2.28 3.33c-.5.66-.93 1.23-1.29 1.69-.67.93-2.09 2.61-2.3 3.87-.51.85-1.16 1.84-1.29 2.83-.06.44.61.63.67.19.01-.08.04-.15.06-.22 1.36 1.08 2.76 2.11 4.19 3.11 1.3.91 2.62 1.85 4.04 2.56.21.1.4 0 .48-.17.24.07.48.14.72.2.44.1.62-.57.19-.67-2.02-.48-3.77-1.57-5.23-3.02-.47-.46-.9-.96-1.32-1.46 1.74 1.35 4.2 2.89 5.89 4.14 1.39 1.03 2.85-2.27 4.22-4.2 1.86-2.64 3.96-5.86 5.52-8.29l10.39 14.51c.67.81 1.14 1.21 1.57 1.36-.05.24.12.51.41.4 1.53-.58 3.05-1.19 4.54-1.87 1.52-.69 3.06-1.45 4.36-2.5a.28.28 0 0 0 .12-.23c1.66-1.1.81-1.74-1.41-4.91-1.13-1.58-1.71-2.36-3.7-5.01l-.03-.02Zm2.41 6.54c.56 1.15 1.19 2.52 1.11 3.81-.06.04-.12.07-.17.1-.03-.88-.55-2.66-.94-3.91Zm-16.51-32.73c1.86-2.65 3.65-5.35 5.57-7.95.4-.55.81-1.13 1.26-1.66.19-.18.38-.33.56-.45.18.03.36.08.55.13l-8.05 10.11.12-.18h-.01ZM192.7 95.48c.79-1.37 1.66-2.69 2.54-4 1.19-1.79 2.4-3.56 3.61-5.33-.04.09-.09.17-.13.26-.1.22.03.41.2.49-2.47 3.42-4.89 6.73-6.4 9.28.21.24.4.48.63.75-.24.07-.4.36-.17.56.4.33.72.77 1.05 1.17.09.11.18.21.27.32-.84-.61-1.66-1.24-2.47-1.88.24-.57.58-1.11.87-1.61v-.01Zm7.46-10.32c.47-.81.98-1.59 1.49-2.37.31-.48.64-.95.96-1.43.26-.29.52-.56.75-.79-.99 1.48-2.09 3.03-3.2 4.59Zm10.03-16.22s-.03-.05-.05-.07c.22-.29.43-.59.64-.89-.2.32-.4.65-.58.96h-.01ZM371.54 87.96c-.01-.08-.01-.16-.03-.23-.06-.38-.58-.29-.66.03-.3-.05-.6-.08-.81-.11-1.14-.15-2.29-.19-3.44-.2 1.04-.09 2.09-.18 3.14-.23.45-.02.45-.72 0-.7-6.57.35-13.14 1.23-19.65 2.11-1.53.21-3.05.42-4.57.68-.01 0-.02.01-.04.01-.04-3.33-.13-6.66-.24-9.99-.19-5.7-.4-11.41-.88-17.1-.13-1.51-.23-3.07-.49-4.58 0-.25 0-.48-.02-.68-.06-1.19-.04-2.61-.68-2.78-.16-.07-.72-.16-1.5-.24.22-.17.16-.62-.2-.63-1.19-.04-2.39.09-3.57.23-1.2.14-2.41.32-3.59.6-.16-.1-.41-.06-.5.12-.06.02-.13.03-.19.05-.35.1-.29.55-.03.66-.26.6-.19 2.27-.21 3-.02.66-.66 33.73-.9 40.3-.03.65.06 1.12.04 1.45-.16 3.05.87 4.96 6.34 3.93 1.09-.08 2.75-.77 5.36-1.43 4.13-1.04 5.78-1.52 6.2-1.65 6.43-1.69 6.78-1.97 11.72-2.43.55-.05 4.8-.38 6.03-.3.64.04 1.19.07 1.65.1.09 0 .16-.03.24-.05.1.27.56.33.66-.02.39-1.32.61-2.71.78-4.08.2-1.61.29-3.24.15-4.86.24.03.52-.23.38-.53-.09-.2-.27-.33-.49-.43v-.02Zm-.63.56c.07.57.11 1.14.11 1.71-.21-.99-.53-1.71-.95-1.87.22.03.44.06.65.11.06.01.12.04.19.05Zm-25.41 1.73c1.54-.36 3.1-.64 4.66-.89-1.61.37-3.18.77-4.66 1.2v-.31Zm-.86-7.37c-.07-1.37-.16-2.75-.25-4.12-.21-3.13-.45-6.27-.79-9.4.02-2.25.08-4.31.13-6.11.16 2.08.29 4.16.4 6.24.23 4.46.38 8.93.5 13.39h.01Zm-.94-4c.16 2.41.29 4.83.39 7.24.06 1.6.14 3.22.09 4.83-.15.05-.32.09-.47.14V78.88h-.01ZM483.72 92.83c-3.05-2.28-6.22-4.4-9.38-6.51 8.86-6.49 13.49-12.95 13.73-19.23.04-.76 0-1.5-.13-2.2-.67-3.82-3.5-6.68-8.39-8.48.13.04.27.08.4.13 3.92 1.39 7.74 4.23 8.5 8.56.34 1.95-.05 3.96-.98 5.69-.21.4.39.75.6.35 1.86-3.46 1.46-7.55-.97-10.63-3.53-4.47-9.76-5.88-15.16-6.16-2.32-.12-4.64-.04-6.95.19-6 .32-12.71 1.68-17.63 3.21-.37.11-.67.23-.92.35-.2-.17-.62.02-.57.37v.03c-.64.68-.18 1.64.48 3.21.38.91.67 1.89 1.15 2.58.32.76.68 1.51 1.13 2.19.14.21.38.19.53.07.19-.02.38-.05.57-.08v1.57c-.06.06-.1.13-.11.23-.27 4.18-.34 8.38-.48 12.57l-.3 9.03c-.24 3.91-.44 6.77-.46 7.26-.05.88-.11 1.95.07 2.81-.01.22-.02.43-.04.65 0 .11-.02.23-.03.35 0 .05-.03.27-.01.16-.05.4.5.59.64.28.05.04.12.08.2.08 1.75.13 3.5.28 5.25.3 1.69.02 3.38-.12 5.06-.32.08.23.36.39.55.15.06-.08.11-.17.16-.26.18-.09.24-.32.18-.48.05-.2.1-.4.13-.6.16-.86.25-1.74.33-2.62.11-1.17.17-2.34.23-3.51.15-.01.32-.03.52-.04.36-.03 1.73-.15 2.06-.15.39 0 .7-.02.95-.04 1.76 1.11 3.45 2.35 5.14 3.55 2.83 2.01 5.64 4.04 8.47 6.04 1.42 1 2.85 2 4.29 2.97.1.06.19.07.27.04.08 0 .17-.02.25-.1 1.61-1.56 3.15-3.18 4.6-4.88.75-.88 1.49-1.78 2.15-2.73.01.01.03.02.04.03.34.3.83-.2.49-.49-2.16-1.9-4.34-3.76-6.64-5.48l.03-.01Zm-6.38-3.65a55.72 55.72 0 0 0-4-2.13c.14-.1.26-.19.4-.29 1.2.81 2.4 1.61 3.6 2.42Zm-20.1 11.78c.67-.37 1.23-.91 1.67-1.6-.11.5-.24 1-.38 1.49-.43.04-.86.08-1.29.11Zm2.38-37.24c1.34-.31 2.56-.52 3.71-.69-1.03.19-2.04.41-3.04.65-.14-.07-.34-.02-.45.11-.07.02-.15.04-.22.05v-.13.01Zm.04.84c.07-.02.14-.03.2-.05.34 1.66.41 3.41.5 5.09.17 2.9.24 5.81.28 8.71l.03 3.17c-.17.07-.34.14-.51.2-.06-4.96-.21-10.58-.51-17.12h.01Zm16.04 5.62c-1.16 2.25-3.06 4.1-5.02 5.66-2.8 2.23-5.99 3.97-9.3 5.35-.01-3.56-.09-7.12-.27-10.67-.1-2.04-.16-4.16-.57-6.18 3.3-.78 6.72-1.36 10.1-1.1 1.85.14 4.23.59 5.32 2.29.92 1.43.46 3.24-.26 4.65Zm.85-.18c.6-1.37.9-2.92.28-4.32-.67-1.52-2.2-2.32-3.76-2.74.46.1.89.21 1.29.37 1.74.67 2.69 1.88 2.93 3.21.2 1.13-.05 2.25-.74 3.47V70Zm-27.47-4.14c-.12-.19-.23-.38-.34-.57.74.42.85.36.99.41v.08c-.22.03-.43.06-.65.08Zm11.21 30.46c-.08 1.08-.16 2.17-.33 3.24-.05.35-.11.69-.2 1.03 0 .04-.02.07-.03.11-.15.02-.3.04-.45.05.45-1.64.76-3.36.79-5.07.03-.29.08-.57.1-.89-.03-.31-.03-.47.24-.57-.04.69-.07 1.39-.12 2.08v.02Zm5.6-2.47c.48.11.92.52 2.49 1.72-.46-.32-.92-.65-1.38-.97-.37-.25-.73-.5-1.1-.75h-.01Zm21.23 7.24a70.76 70.76 0 0 1-4.37 4.63c-.14-.09-.27-.19-.4-.28.19-.09.37-.24.55-.47.87-1.14 5.43-5.51 5.49-7.45.31.26.62.53.92.79-.67.97-1.42 1.88-2.19 2.77v.01Z",fill:"currentColor",transform:"translate(-144.023 -51.76)"})]}),MM=({style:e,size:n="small",withText:t})=>AM("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[br(nK,{}),t&&br(oK,{})]});import{Fragment as _M,jsx as ot,jsxs as yb}from"react/jsx-runtime";var vb=({icon:e,shortcut:n,children:t})=>{let o=ue();return yb(_M,{children:[ot("div",{className:"welcome-screen-menu-item__icon",children:e}),ot("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&ot("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};vb.displayName="WelcomeScreenMenuItemContent";var jl=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>ot("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:ot(vb,{icon:t,shortcut:o,children:n})});jl.displayName="WelcomeScreenMenuItem";var LM=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>ot("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:ot(vb,{icon:t,shortcut:o,children:e})});LM.displayName="WelcomeScreenMenuItemLink";var gn=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=Ke();return ot(n.In,{children:ot("div",{className:"welcome-screen-center",children:e||yb(_M,{children:[ot(Tb,{}),ot(Ib,{children:f("welcomeScreen.defaults.center_heading")}),yb(Sb,{children:[ot(Pb,{}),ot(Cb,{})]})]})})})};gn.displayName="Center";var Tb=({children:e})=>ot("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||ot(MM,{withText:!0})});Tb.displayName="Logo";var Ib=({children:e})=>ot("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Ib.displayName="Heading";var Sb=({children:e})=>ot("div",{className:"welcome-screen-menu",children:e});Sb.displayName="Menu";var Cb=()=>{let e=Xe();return ot(jl,{onSelect:()=>e.executeAction(Or),shortcut:"?",icon:fi,children:f("helpDialog.title")})};Cb.displayName="MenuItemHelp";var Pb=()=>{let e=he(),n=Xe();return e.viewModeEnabled?null:ot(jl,{onSelect:()=>n.executeAction(Ni),shortcut:pt("loadScene"),icon:wc,children:f("buttons.load")})};Pb.displayName="MenuItemLoadScene";var DM=({onSelect:e})=>{let{t:n}=Ce();return ot(jl,{shortcut:null,onSelect:e,icon:yc,children:n("labels.liveCollaboration")})};DM.displayName="MenuItemLiveCollaborationTrigger";gn.Logo=Tb;gn.Heading=Ib;gn.Menu=Sb;gn.MenuItem=jl;gn.MenuItemLink=LM;gn.MenuItemHelp=Cb;gn.MenuItemLoadScene=Pb;gn.MenuItemLiveCollaborationTrigger=DM;import{jsx as Va,jsxs as kb}from"react/jsx-runtime";var $p=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=Ke();return Va(n.In,{children:kb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[hx,Va("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};$p.displayName="MenuHint";var Zp=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=Ke();return Va(n.In,{children:kb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Va("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),fx]})})};Zp.displayName="ToolbarHint";var jp=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=Ke();return Va(n.In,{children:kb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Va("div",{children:e||f("welcomeScreen.defaults.helpHint")}),gx]})})};jp.displayName="HelpHint";import{Fragment as RM,jsx as ql,jsxs as iK}from"react/jsx-runtime";var qp=e=>ql(RM,{children:e.children||iK(RM,{children:[ql(gn,{}),ql($p,{}),ql(Zp,{}),ql(jp,{})]})});qp.displayName="WelcomeScreen";qp.Center=gn;qp.Hints={MenuHint:$p,ToolbarHint:Zp,HelpHint:jp};var rK=qp;var aK=()=>{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)})},NM=aK;import{getSceneVersion as PWe,hashElementsVersion as kWe,hashString as MWe,getNonDeletedElements as AWe}from"@excalidraw/element";import{getTextFromElements as DWe}from"@excalidraw/element";import{isInvisiblySmallElement as RWe}from"@excalidraw/element";import sK from"lodash.throttle";import{arrayToMap as lK,isDevEnv as BM,isTestEnv as OM}from"@excalidraw/common";import{orderByFractionalIndex as cK,syncInvalidIndices as FM,validateFractionalIndices as dK}from"@excalidraw/element";var mK=(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)),pK=sK((e,n,t)=>{if(BM()||OM()||window?.DEBUG_FRACTIONAL_INDICES){let o=FM(e.map(r=>({...r})));dK(o,{shouldThrow:OM()||BM(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),uK=(e,n,t)=>{let o=lK(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=mK(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=cK(r);return pK(a,e,n),FM(a),a};import{isLinearElement as WWe}from"@excalidraw/element";import{FONT_FAMILY as YWe,THEME as KWe,MIME_TYPES as XWe,ROUNDNESS as $We,DEFAULT_LASER_COLOR as ZWe,UserIdleState as jWe,normalizeLink as qWe,sceneCoordsToViewportCoords as JWe,viewportCoordsToSceneCoords as QWe,getFormFactor as eVe,throttleRAF as tVe}from"@excalidraw/common";import{mutateElement as oVe,newElementWith as rVe,bumpVersion as iVe}from"@excalidraw/element";import{CaptureUpdateAction as sVe}from"@excalidraw/element";import hK from"clsx";import{CANVAS_SEARCH_TAB as Mb,DEFAULT_SIDEBAR as gK,composeEventHandlers as fK}from"@excalidraw/common";import{jsx as xr,jsxs as zM}from"react/jsx-runtime";import{createElement as bK}from"react";var HM=qr("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=Ke();return xr(n.In,{children:xr(jn.Trigger,{...e,className:"default-sidebar-trigger",name:gK.name})})});HM.displayName="DefaultSidebarTrigger";var GM=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=Ke();return xr(n.In,{children:e})};GM.displayName="DefaultTabTriggers";var EK=Object.assign(qr("DefaultSidebar",({children:e,className:n,onDock:t,docked:o,...r})=>{let i=he(),a=Ne(),{DefaultSidebarTabTriggersTunnel:s}=Ke(),l=i.openSidebar?.tab===Mb;return bK(jn,{...r,name:"default",key:"default",className:hK("default-sidebar",n),docked:l||(o??i.defaultSidebarDockedPreference),onDock:l||t===!1||!t&&o!=null?void 0:fK(t,c=>{a({defaultSidebarDockedPreference:c})})},zM(jn.Tabs,{children:[xr(jn.Header,{children:zM(jn.TabTriggers,{children:[xr(jn.TabTrigger,{tab:Mb,children:Un}),xr(s.Out,{})]})}),xr(jn.Tab,{tab:Mb,children:xr(IP,{})}),e]}))}),{Trigger:HM,TabTriggers:GM});import{getCommonBounds as fVe,getVisibleSceneBounds as EVe,convertToExcalidrawElements as bVe}from"@excalidraw/element";import{elementsOverlappingBBox as wVe}from"@excalidraw/element";import{isElementLink as TVe}from"@excalidraw/element";import{setCustomTextMetricsProvider as CVe}from"@excalidraw/element";import{jsx as Jl}from"react/jsx-runtime";NM();var vWe=({children:e})=>{let[n,t]=IK(null);return Jl(Wa.Provider,{value:n,children:Jl(Xp.Provider,{value:t,children:e})})},CK=e=>{let{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:l,onMount:c,onUnmount:d,onInitialize:p,isCollaborating:m=!1,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b=Nn.code,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:v,activeTool:I,zenModeEnabled:C,gridModeEnabled:P,theme:A,name:L,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:D,onPaste:O,detectScroll:G=!0,handleKeyboardGlobally:z=!1,autoFocus:W=!1,compressImageFile:j,generateIdForFile:X,onLinkOpen:oe,generateLinkForSelection:B,onPointerDown:U,onPointerUp:me,onScrollChange:be,onUserFollow:de,userToFollow:pe,onDuplicate:xe,imageContextMenuItems:ae,children:we,validateEmbeddable:at,renderEmbeddable:$e,showDeprecatedFonts:_e,wheelZoomsOnDefault:ko,strokeColorTopPicks:ii,backgroundColorTopPicks:Ql,renderScrollbars:ec,viewportStatusFrame:tc,currentUserControls:Jp,imageOptions:to,showDropEventDebugAlert:_n}=e,Ya=e.UIOptions?.canvasActions,nc={...e.UIOptions,canvasActions:{...UM.canvasActions,...Ya},tools:{image:e.UIOptions?.tools?.image??!0}};Ya?.export&&(nc.canvasActions.export.saveFileToDisk=Ya.export?.saveFileToDisk??UM.canvasActions.export.saveFileToDisk),nc.canvasActions.toggleTheme===null&&(A==null||r)&&(nc.canvasActions.toggleTheme=!0);let WM={maxFileSizeBytes:to?.maxFileSizeBytes??Po.maxFileSizeBytes,maxWidthOrHeight:to?.maxWidthOrHeight??Po.maxWidthOrHeight,placeholderTransitionDuration:to?.placeholderTransitionDuration??Po.placeholderTransitionDuration},Ab=yK(Xp),Lb=TK(l);Lb.current=l;let VM=wK(Qp=>{Ab?.(Qp),Lb.current?.(Qp)},[Ab]),Db=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return vK(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),Db)return;let _b=eu=>{typeof eu.scale=="number"&&eu.scale!==1&&eu.preventDefault()};return document.addEventListener("touchmove",_b,{passive:!1}),()=>{document.removeEventListener("touchmove",_b)}},[Db]),Jl(sx,{store:gt,children:Jl(SM,{langCode:b,theme:A,children:Jl(IM,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:VM,onMount:c,onUnmount:d,onInitialize:p,isCollaborating:m,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:v,activeTool:I,zenModeEnabled:C,gridModeEnabled:P,theme:A,name:L,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:D,UIOptions:nc,onPaste:O,detectScroll:G,handleKeyboardGlobally:z,autoFocus:W,compressImageFile:j,generateIdForFile:X,onLinkOpen:oe,generateLinkForSelection:B,onPointerDown:U,onPointerUp:me,onScrollChange:be,onUserFollow:de,userToFollow:pe,onDuplicate:xe,imageContextMenuItems:ae,validateEmbeddable:at,renderEmbeddable:$e,showDeprecatedFonts:_e,wheelZoomsOnDefault:ko,strokeColorTopPicks:ii,backgroundColorTopPicks:Ql,renderScrollbars:ec,viewportStatusFrame:tc,currentUserControls:Jp,imageOptions:WM,showDropEventDebugAlert:_n,children:we})})})},PK=(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:p,interaction:m,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===m||typeof i=="object"&&i!==null&&typeof m=="object"&&m!==null&&!!i.enabled?.links==!!m.enabled?.links&&!!i.enabled?.embeds==!!m.enabled?.embeds&&!!i.enabled?.interactiveContent==!!m.enabled?.interactiveContent&&!!i.enabled?.navigation==!!m.enabled?.navigation&&!!i.enabled?.browserZoom==!!m.enabled?.browserZoom&&!!i.enabled?.tools?.laser==!!m.enabled?.tools?.laser&&!!i.enabled?.tools?.custom==!!m.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),v=Object.keys(d);if(x.length!==v.length)return!1;let I=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(L=>L==="export"&&o?.canvasActions?.export&&d?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:o?.canvasActions?.[L]===d?.canvasActions?.[L]):o[P]===d[P]),C=(r?.maxWidthOrHeight??Po.maxWidthOrHeight)===(p?.maxWidthOrHeight??Po.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Po.maxFileSizeBytes)===(p?.maxFileSizeBytes??Po.maxFileSizeBytes)&&(r?.placeholderTransitionDuration??Po.placeholderTransitionDuration)===(p?.placeholderTransitionDuration??Po.placeholderTransitionDuration);return I&&C&&SK(l,g)},kK=xK.memo(CK,PK);kK.displayName="Excalidraw";function TWe(e){return Ai(e,!1)}export{Mn as Button,sVe as CaptureUpdateAction,ZWe as DEFAULT_LASER_COLOR,nu as DEFAULT_OVERSCROLL,EK as DefaultSidebar,bs as Ellipsify,kK as Excalidraw,Wa as ExcalidrawAPIContext,vWe as ExcalidrawAPIProvider,YWe as FONT_FAMILY,oo as Fonts,jY as Footer,QY as LiveCollaborationTrigger,XWe as MIME_TYPES,_t as MainMenu,$We as ROUNDNESS,jn as Sidebar,Cl as Stats,KWe as THEME,jWe as UserIdleState,rK as WelcomeScreen,sWe as applyDarkModeFilter,iVe as bumpVersion,oL as captureDragEventData,bVe as convertToExcalidrawElements,Nn as defaultLang,wVe as elementsOverlappingBBox,CC as exportToBlob,mp as exportToCanvas,Sz as exportToClipboard,PC as exportToSvg,fVe as getCommonBounds,mc as getDataURL,eVe as getFormFactor,AWe as getNonDeletedElements,PWe as getSceneVersion,lWe as getStrokeWidthByKey,DWe as getTextFromElements,EVe as getVisibleSceneBounds,kWe as hashElementsVersion,MWe as hashString,TVe as isElementLink,RWe as isInvisiblySmallElement,WWe as isLinearElement,ca as isSpreadsheetValidForChartType,pi as languages,qa as loadFromBlob,oVe as mutateElement,rVe as newElementWith,qWe as normalizeLink,_r as parseDataTransferEvent,iL as parseDragImageMetadata,uK as reconcileElements,df as renderSpreadsheet,ci as restoreAppState,KM as restoreElement,vr as restoreElements,JWe as sceneCoordsToViewportCoords,$a as serializeAsJSON,CVe as setCustomTextMetricsProvider,tVe as throttleRAF,Pm as tryParseSpreadsheet,ue as useEditorInterface,cd as useExcalidrawAPI,TWe as useExcalidrawStateValue,Ce as useI18n,n6 as useOnExcalidrawStateChange,rt as useStylesPanelMode,QWe as viewportCoordsToSceneCoords,wr as zoomToFitBounds};
23
+ `),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=Ce({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:DV,verticalAlign:kk,locked:!1},s=nb({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=_k(a.fontFamily),[c,,d]=LY(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=BY(y).trim();if(x.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=aM(x,s,l),C=T.width>m,P=C?_Y(x,s,m):x;T=C?aM(P,s,l):T;let A=r-T.width/2,L=u-T.height/2,_=Wk({...a,x:A,y:L,text:P,originalText:x,lineHeight:l,autoResize:!C,frameId:v?v.id:null});b.push(_),u+=_.height+p}else E[w-1]?.trim()&&(u+=sM(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:ke(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&IM===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),IM=!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&&Wt(c)?Co(c,{originalText:s,isDeleted:l??c.isDeleted,...dY(c,eM(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=N2({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=zp({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Ye(s=>{a(s,!1),Xp(t)&&Up(t,this.scene)}),onSubmit:Ye(({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&&Gt(()=>{this.setState(m=>({selectedElementIds:ke({...m.selectedElementIds,[d]:!0},m)}))}),c&&tY(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Gt(()=>{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:ke({},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 Wt(r)?r:t?cb(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(Wt(i))return null;if(!tM(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&&Wt(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 tc({point:ne(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:vt(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||!(Wt(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=hb(l,a);return c&&!Xp(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!ec(l)?oM({x:t,y:o},c,a):!0}).filter(l=>ec(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(Dk/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&yY([r],this.state,this.editorInterface)&&JY(ne(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||MY(ne(t,o),r,this.scene.getNonDeletedElementsMap())?!0:tc({point:ne(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:vt(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 $k(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]=Hk(r[s],this.scene.getNonDeletedElementsMap());if(Ql(r[s])&&tc({point:ne(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(vt(r[s]))continue;a=r[s];break}}return $k(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||Wt(this.state.newElement)}handleHoverSelectedLinearElement(t,o,r){let i=this.scene.getNonDeletedElementsMap(),a=me.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let s=-1,l=null;tc({point:ne(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(s=me.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),l=me.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Ut(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Pe.POINTER):this.hitElement(o,r,a)&&(!Ut(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Pe.MOVE)):this.hitElement(o,r,a)&&(!Ut(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Pe.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),me.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}});let c=null,d=a;(d.startBinding||d.endBinding)&&(c=oX(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(Pe.POINTER)}else this.cursor.set(Pe.AUTO)}updateGestureOnPointerDown(t){le.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),le.pointers.size===2&&(le.lastCenter=Ug(le.pointers),le.initialScale=this.state.zoom.value,le.initialDistance=Wg(Array.from(le.pointers.values())))}initialPointerDownState(t){let o=Ce(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=Za(r),c=r.findIndex(Ut)===0;return{origin:o,withCmdOrCtrl:t[X.CTRL_OR_CMD],originInGrid:ob(Ct(o.x,o.y,t[X.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:tf(ic,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,Vk(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;$p=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=fm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=Ye(()=>{Ja=null,$p=!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 Ja=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(Dk/this.state.zoom.value,1),i=wV*2/this.state.zoom.value,[a,s,l,c]=Za(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:uY(t)?Op.ADAPTIVE_RADIUS:Op.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return QV(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){fo({event:t,app:this,selectedElements:o})&&(r||!ln.getReferenceSnapPoints())&&ln.setReferenceSnapPoints(f2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){fo({event:t,app:this,selectedElements:o})&&(r||!ln.getVisibleGaps())&&ln.setVisibleGaps(g2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ye(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return Ye(o=>{o.key===X.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return fm(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Ce(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]=Ct(r.x,r.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),E=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(E<0){let b=me.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());E=b?me.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let g=me.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=ob(jY(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(qt(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]=Ct(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){nX(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(me.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let u=me.addMidpoint(this.state.selectedLinearElement,r,this,!o[X.CTRL_OR_CMD],this.scene);if(!u)return;Gt(()=>{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=me.getElement(p.elementId,c);if(u?.isDeleted)return;if(eo(u)){let g=wr(ne(r.x,r.y),this.scene.getNonDeletedElements(),c);So("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&So("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),p.initialState.lastClickedPoint===-1)return;let E=me.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||!Ok(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=>vt(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:nM(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 v=Math.abs(g.x),T=Math.abs(g.y),C=y&&v<T,P=y&&v>T;C&&(g.x=0),P&&(g.y=0)}if(this.state.croppingElementId){let v=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(v&&to(v)&&v.crop!==null&&t.hit.element===v){let T=v.crop,C=ja(v)&&this.imageCache.get(v.fileId)?.image;if(C&&!(C instanceof Promise)){let P=aX(v),A=vk(r.x-i.x,r.y-i.y);A[0]*=C.naturalWidth/P.width,A[1]*=C.naturalHeight/P.height;let[L,_,k,D,F,Y]=Hk(v,c),z=JE(qE(ne(L,_),ne(F,Y),v.angle)),W=JE(qE(ne(k,_),ne(F,Y),v.angle)),$=JE(qE(ne(L,D),ne(F,Y),v.angle)),H=Sk(Ik(W,z)),re=Sk(Ik($,z)),B=vk(Tk(A,H),Tk(A,re)),U={...T,x:Kl(T.x-B[0]*Math.sign(v.scale[0]),0,C.naturalWidth-T.width),y:Kl(T.y-B[1]*Math.sign(v.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(v,{crop:U});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:w,snapLines:x}=E2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||ZY(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 v=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:L,elementsWithDuplicates:_,origIdToDuplicateId:k}=Yk({type:"in-place",elements:v,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:W})=>({frameId:z.frameId??W.frameId,seed:VV()})});A.forEach(z=>{t.originalElements.set(z.id,Vk(z))});let D=_.map(z=>{if(P.has(z.id)){let W=t.originalElements.get(z.id);if(W)return Co(z,{x:W.x,y:W.y})}return z}),F=this.props.onDuplicate?.(D,v),Y=cM(F||D,Jl(A));Gt(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),W=z&&L.get(z);t.hit.element=W||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,W)=>{let $=k.get(W.id),H=$&&L.get($);return H&&z.push(H),z},[]),t.drag.origin=Ce(o,this.state),this.setState(z=>({...dM(A,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(Y),C.forEach(z=>{sb(z)&&z.boundElements?.some(W=>W.type==="arrow")&&Up(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,ne(E,g)],pressures:w},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Rt(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;Qn(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 me(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,...me.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)me.handleBoxSelection(o,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!o.shiftKey&&Me(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>_n({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?Wb(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},{..._n({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Rt(E[0])?new me(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Po(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*(ic.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*(ic.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ye(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===Dn.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:ql(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,ln.setReferenceSnapPoints(null),ln.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=Ce({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(So("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);sb(x)&&x.boundElements?.filter(v=>v.type==="arrow").map(v=>r.get(v.id)).filter(v=>Ut(v)).forEach(v=>{v&&this.scene.mutateElement(v,{})})}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(dt);else{let x=me.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(dt,"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=me.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(iX(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(dt,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Rt(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=Ce(o,this.state),v=i.points,T=x.x-i.x,C=x.y-i.y;T===v[0][0]&&C===v[0][1]&&(C+=1e-4,T+=1e-4);let P=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...v,ne(T,C)],pressures:P}),this.actionManager.executeAction(dt);return}if(Rt(i)&&this.state.activeTool.type!=="autoshape"){let x=Ce(o,this.state),v=qn(ne(x.x,x.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||v<YV)&&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:[ne(0,0),ne(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(dt)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),Rt(i)&&this.actionManager.executeAction(dt,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:Zt(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ke({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new me(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(Wt(i)){let x=zY(nb({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&&jk(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:jt.NEVER});return}if(vt(i)){let x=SY(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(pb(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,hY(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Ce(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let v=this.scene.getElement(this.state.selectedLinearElement.elementId);if(v?.frameId){let T=hb(v,r);T&&v&&(CY(v,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(v,{groupIds:[]}),TY([v],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let v=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:nM(v),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=A=>{if(A.length>0){for(let L of A){let _=L.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(L,{groupIds:L.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(L=>{L.groupIds.length&&si(C,L.groupIds[L.groupIds.length-1]).length<2&&this.scene.mutateElement(L,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let A=v.filter(L=>iM(L,C,this.state));this.state.editingGroupId&&P(A),C=pb(C,A,T)}else if(!T&&this.state.editingGroupId){let A=v.filter(L=>L.frameId&&!iM(L,C,this.state));P(A)}C=rM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&jk(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:jt.NEVER}),t.resize.isResizing){let x=rM(this.scene.getElementsIncludingDeleted(),this.state,this),v=this.scene.getSelectedElements(this.state).filter(vt);for(let T of v)x=IY(x,ub(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&Rt(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new me(g,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!g&&!p||g&&g.id!==s))&&this.finishImageCropping();let b=this.lastPointerDownEvent,y=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(qt(this.state)&&b&&y){if(this.eraserTrail.endPath(),qn(ne(b.clientX,b.clientY),ne(y.clientX,y.clientY))===0){let v=Ce({clientX:y.clientX,clientY:y.clientY},this.state);this.getElementsAtPosition(v.x,v.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]?VY(this.state,g)?this.setState(x=>{let v={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>si(this.scene.getNonDeletedElements(),C)))delete v[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:ke(v,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let v={...x.selectedElementIds};delete v[g.id];let T=ie(this.scene.getNonDeletedElements(),{selectedElementIds:v});return{..._n({editingGroupId:x.editingGroupId,selectedElementIds:v},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&Rt(T[0])?new me(T[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(x=>{let v={...x.selectedElementIds,[g.id]:!0};return delete v[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>si(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete v[T.id]}),{..._n({editingGroupId:x.editingGroupId,selectedElementIds:v},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Po(g)?"info":!1}}):this.setState(x=>({selectedElementIds:ke({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({..._n({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Rt(g)&&x.selectedLinearElement?.elementId!==g.id?new me(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Ut(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&AY({point:ne(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:vt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(aa):this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Pe.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&&(Wt(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:ke({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Po(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||Me(this.scene.getNonDeletedElements(),this.state)||!Ok(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(Ql);Gk(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(dt);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==Dn.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:Zt(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:ke({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&lM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:ke({},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=db(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<CV){let{x:m,y:p}=zp({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=gi.find(o=>o.code===this.props.langCode)||On;await Sc(t),this.setAppState({})}},mX=()=>{(TM()||SM())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(PM(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};mX();var AM=yb;import{useEffect as uX,useState as hX}from"react";import{jsx as gX}from"react/jsx-runtime";var LM=e=>{let[n,t]=hX(!0);return uX(()=>{let o=async()=>{await Sc(r),t(!1)},r=gi.find(i=>i.code===e.langCode)||On;o()},[e.langCode]),n?gX(ep,{theme:e.theme}):e.children};import fX from"clsx";import{jsx as DM}from"react/jsx-runtime";var _M=({children:e})=>{let{FooterCenterTunnel:n}=et(),t=fe();return DM(n.In,{children:DM("div",{className:fX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},EX=_M;_M.displayName="FooterCenter";import bX from"clsx";import{MQ_MIN_WIDTH_DESKTOP as xX}from"@excalidraw/common";import{jsx as yX,jsxs as vX}from"react/jsx-runtime";var RM=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=fe(),i=t?.formFactor!=="desktop"||r.width<xX;return vX(fn,{...o,className:bX("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?Fx:f("labels.share"),r.collaborators.size>0&&yX("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},wX=RM;RM.displayName="LiveCollaborationTrigger";import{jsx as vr,jsxs as BM}from"react/jsx-runtime";var IX=()=>vr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:vr("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"})}),TX=()=>BM("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[vr("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)"}),vr("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)"}),vr("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)"}),vr("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)"})]}),NM=({style:e,size:n="small",withText:t})=>BM("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[vr(IX,{}),t&&vr(TX,{})]});import{Fragment as zM,jsx as rt,jsxs as kb}from"react/jsx-runtime";var Mb=({icon:e,shortcut:n,children:t})=>{let o=ge();return kb(zM,{children:[rt("div",{className:"welcome-screen-menu-item__icon",children:e}),rt("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&rt("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};Mb.displayName="WelcomeScreenMenuItemContent";var sc=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>rt("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:rt(Mb,{icon:t,shortcut:o,children:n})});sc.displayName="WelcomeScreenMenuItem";var OM=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>rt("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:rt(Mb,{icon:t,shortcut:o,children:e})});OM.displayName="WelcomeScreenMenuItemLink";var bn=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=et();return rt(n.In,{children:rt("div",{className:"welcome-screen-center",children:e||kb(zM,{children:[rt(Ab,{}),rt(Lb,{children:f("welcomeScreen.defaults.center_heading")}),kb(Db,{children:[rt(Rb,{}),rt(_b,{})]})]})})})};bn.displayName="Center";var Ab=({children:e})=>rt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||rt(NM,{withText:!0})});Ab.displayName="Logo";var Lb=({children:e})=>rt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Lb.displayName="Heading";var Db=({children:e})=>rt("div",{className:"welcome-screen-menu",children:e});Db.displayName="Menu";var _b=()=>{let e=tt();return rt(sc,{onSelect:()=>e.executeAction(Hr),shortcut:"?",icon:wi,children:f("helpDialog.title")})};_b.displayName="MenuItemHelp";var Rb=()=>{let e=fe(),n=tt();return e.viewModeEnabled?null:rt(sc,{onSelect:()=>n.executeAction(Ui),shortcut:Ke("loadScene"),icon:Ac,children:f("buttons.load")})};Rb.displayName="MenuItemLoadScene";var FM=({onSelect:e})=>{let{t:n}=Ae();return rt(sc,{shortcut:null,onSelect:e,icon:Lc,children:n("labels.liveCollaboration")})};FM.displayName="MenuItemLiveCollaborationTrigger";bn.Logo=Ab;bn.Heading=Lb;bn.Menu=Db;bn.MenuItem=sc;bn.MenuItemLink=OM;bn.MenuItemHelp=_b;bn.MenuItemLoadScene=Rb;bn.MenuItemLiveCollaborationTrigger=FM;import{jsx as es,jsxs as Nb}from"react/jsx-runtime";var Qp=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=et();return es(n.In,{children:Nb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[wx,es("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};Qp.displayName="MenuHint";var eu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=et();return es(n.In,{children:Nb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[es("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),vx]})})};eu.displayName="ToolbarHint";var tu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=et();return es(n.In,{children:Nb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[es("div",{children:e||f("welcomeScreen.defaults.helpHint")}),yx]})})};tu.displayName="HelpHint";import{Fragment as HM,jsx as lc,jsxs as CX}from"react/jsx-runtime";var nu=e=>lc(HM,{children:e.children||CX(HM,{children:[lc(bn,{}),lc(Qp,{}),lc(eu,{}),lc(tu,{})]})});nu.displayName="WelcomeScreen";nu.Center=bn;nu.Hints={MenuHint:Qp,ToolbarHint:eu,HelpHint:tu};var SX=nu;var PX=()=>{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)})},GM=PX;import{getSceneVersion as $We,hashElementsVersion as ZWe,hashString as jWe,getNonDeletedElements as qWe}from"@excalidraw/element";import{getTextFromElements as QWe}from"@excalidraw/element";import{isInvisiblySmallElement as tVe}from"@excalidraw/element";import kX from"lodash.throttle";import{arrayToMap as MX,isDevEnv as UM,isTestEnv as WM}from"@excalidraw/common";import{orderByFractionalIndex as AX,syncInvalidIndices as VM,validateFractionalIndices as LX}from"@excalidraw/element";var DX=(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)),_X=kX((e,n,t)=>{if(UM()||WM()||window?.DEBUG_FRACTIONAL_INDICES){let o=VM(e.map(r=>({...r})));LX(o,{shouldThrow:WM()||UM(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),RX=(e,n,t)=>{let o=MX(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=DX(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=AX(r);return _X(a,e,n),VM(a),a};import{isLinearElement as dVe}from"@excalidraw/element";import{FONT_FAMILY as pVe,THEME as uVe,MIME_TYPES as hVe,ROUNDNESS as gVe,DEFAULT_LASER_COLOR as fVe,UserIdleState as EVe,normalizeLink as bVe,sceneCoordsToViewportCoords as xVe,viewportCoordsToSceneCoords as wVe,getFormFactor as yVe,throttleRAF as vVe}from"@excalidraw/common";import{mutateElement as TVe,newElementWith as SVe,bumpVersion as CVe}from"@excalidraw/element";import{CaptureUpdateAction as kVe}from"@excalidraw/element";import{getCommonBounds as OVe,getVisibleSceneBounds as FVe,convertToExcalidrawElements as zVe}from"@excalidraw/element";import{elementsOverlappingBBox as GVe}from"@excalidraw/element";import{isElementLink as VVe}from"@excalidraw/element";import{setCustomTextMetricsProvider as KVe}from"@excalidraw/element";import{jsx as cc}from"react/jsx-runtime";GM();var WWe=({children:e})=>{let[n,t]=HX(null);return cc(Qa.Provider,{value:n,children:cc(Jp.Provider,{value:t,children:e})})},UX=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=On.code,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:v,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:A,name:L,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:D,onPaste:F,detectScroll:Y=!0,handleKeyboardGlobally:z=!1,autoFocus:W=!1,compressImageFile:$,generateIdForFile:H,onLinkOpen:re,generateLinkForSelection:B,onPointerDown:U,onPointerUp:ue,onScrollChange:we,onUserFollow:pe,userToFollow:he,onDuplicate:ye,imageContextMenuItems:se,children:ve,validateEmbeddable:st,renderEmbeddable:Ze,showDeprecatedFonts:Re,wheelZoomsOnDefault:Do,strokeColorTopPicks:li,backgroundColorTopPicks:dc,renderScrollbars:mc,viewportStatusFrame:pc,currentUserControls:ou,imageOptions:no,showDropEventDebugAlert:Rn}=e,ts=e.UIOptions?.canvasActions,uc={...e.UIOptions,canvasActions:{...YM.canvasActions,...ts},tools:{image:e.UIOptions?.tools?.image??!0}};ts?.export&&(uc.canvasActions.export.saveFileToDisk=ts.export?.saveFileToDisk??YM.canvasActions.export.saveFileToDisk),uc.canvasActions.toggleTheme===null&&(P==null||r)&&(uc.canvasActions.toggleTheme=!0);let XM={maxFileSizeBytes:no?.maxFileSizeBytes??Lo.maxFileSizeBytes,maxWidthOrHeight:no?.maxWidthOrHeight??Lo.maxWidthOrHeight,placeholderTransitionDuration:no?.placeholderTransitionDuration??Lo.placeholderTransitionDuration},Bb=OX(Jp),Ob=zX(l);Ob.current=l;let KM=BX(ru=>{Bb?.(ru),Ob.current?.(ru)},[Bb]),Fb=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return FX(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),Fb)return;let zb=iu=>{typeof iu.scale=="number"&&iu.scale!==1&&iu.preventDefault()};return document.addEventListener("touchmove",zb,{passive:!1}),()=>{document.removeEventListener("touchmove",zb)}},[Fb]),cc(ux,{store:gt,children:cc(LM,{langCode:b,theme:P,children:cc(AM,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:KM,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:v,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:A,name:L,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:D,UIOptions:uc,onPaste:F,detectScroll:Y,handleKeyboardGlobally:z,autoFocus:W,compressImageFile:$,generateIdForFile:H,onLinkOpen:re,generateLinkForSelection:B,onPointerDown:U,onPointerUp:ue,onScrollChange:we,onUserFollow:pe,userToFollow:he,onDuplicate:ye,imageContextMenuItems:se,validateEmbeddable:st,renderEmbeddable:Ze,showDeprecatedFonts:Re,wheelZoomsOnDefault:Do,strokeColorTopPicks:li,backgroundColorTopPicks:dc,renderScrollbars:mc,viewportStatusFrame:pc,currentUserControls:ou,imageOptions:XM,showDropEventDebugAlert:Rn,children:ve})})})},WX=(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),v=Object.keys(d);if(x.length!==v.length)return!1;let T=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(L=>L==="export"&&o?.canvasActions?.export&&d?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:o?.canvasActions?.[L]===d?.canvasActions?.[L]):o[P]===d[P]),C=(r?.maxWidthOrHeight??Lo.maxWidthOrHeight)===(m?.maxWidthOrHeight??Lo.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Lo.maxFileSizeBytes)===(m?.maxFileSizeBytes??Lo.maxFileSizeBytes)&&(r?.placeholderTransitionDuration??Lo.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Lo.placeholderTransitionDuration);return T&&C&&GX(l,g)},VX=NX.memo(UX,WX);VX.displayName="Excalidraw";function VWe(e){return Ni(e,!1)}export{fn as Button,kVe as CaptureUpdateAction,fVe as DEFAULT_LASER_COLOR,su as DEFAULT_OVERSCROLL,VE as DefaultSidebar,Cs as Ellipsify,VX as Excalidraw,Qa as ExcalidrawAPIContext,WWe as ExcalidrawAPIProvider,pVe as FONT_FAMILY,ro as Fonts,EX as Footer,wX as LiveCollaborationTrigger,hVe as MIME_TYPES,_t as MainMenu,gVe as ROUNDNESS,Er as Sidebar,Hl as Stats,uVe as THEME,EVe as UserIdleState,SX as WelcomeScreen,kWe as applyDarkModeFilter,CVe as bumpVersion,Nh as captureDragEventData,zVe as convertToExcalidrawElements,On as defaultLang,GVe as elementsOverlappingBBox,VC as exportToBlob,xp as exportToCanvas,TH as exportToClipboard,YC as exportToSvg,OVe as getCommonBounds,vc as getDataURL,yVe as getFormFactor,qWe as getNonDeletedElements,$We as getSceneVersion,MWe as getStrokeWidthByKey,QWe as getTextFromElements,FVe as getVisibleSceneBounds,ZWe as hashElementsVersion,jWe as hashString,VVe as isElementLink,tVe as isInvisiblySmallElement,dVe as isLinearElement,Ea as isSpreadsheetValidForChartType,gi as languages,ss as loadFromBlob,TVe as mutateElement,SVe as newElementWith,bVe as normalizeLink,Br as parseDataTransferEvent,Bh as parseDragImageMetadata,RX as reconcileElements,ff as renderSpreadsheet,pi as restoreAppState,ZM as restoreElement,Sr as restoreElements,xVe as sceneCoordsToViewportCoords,rs as serializeAsJSON,KVe as setCustomTextMetricsProvider,vVe as throttleRAF,Dm as tryParseSpreadsheet,ge as useEditorInterface,xd as useExcalidrawAPI,VWe as useExcalidrawStateValue,Ae as useI18n,i6 as useOnExcalidrawStateChange,it as useStylesPanelMode,wVe as viewportCoordsToSceneCoords,Ir as zoomToFitBounds};