@nous-excalidraw/excalidraw 0.18.9-beta.21 → 0.18.9-beta.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import{$ as Su,A as Iu,B as xA,C as o0,D as n0,E as Nc,F as Ns,G as Bs,H as Os,I as Li,J as r0,K as i0,L as a0,M as Bc,N as Oc,O as s0,P as EA,Q as Gr,R as _i,S as Fs,U as l0,W as c0,X as d0,Y as Fc,Z as m0,_ as Cu,a as Jx,aa as p0,b as Hr,ba as u0,c as To,ca as ku,d as Qx,da as Ur,e as Ae,ea as h0,f as e0,fa as Mu,g as ie,ga as g0,h as ki,ha as f0,i as Uo,ia as zc,j as Ls,ja as Pu,k as _s,ka as b0,l as Mi,la as x0,m as Ds,ma as E0,n as Pi,na as zs,o as t0,p as vu,q as Wo,r as yn,s as Yo,t as Ot,u as wn,v as Ai,w as Dc,x as Tu,y as Rs,z as Rc}from"./chunk-YAGSAM37.js";import{a as C}from"./chunk-TFET7NMD.js";import{N as wu}from"./chunk-KGPK36EJ.js";import{c as qx}from"./chunk-3PELD44J.js";import{b as Zx,c as jx,d as k}from"./chunk-SRAX5OIU.js";import zZ,{useCallback as HZ,useContext as GZ,useEffect as UZ,useRef as WZ,useState as YZ}from"react";import{DEFAULT_UI_OPTIONS as mA,isShallowEqual as VZ}from"@nous-excalidraw/common";import AM from"clsx";import cK from"lodash.throttle";import wo,{useContext as Yn}from"react";import{flushSync as Yt}from"react-dom";import dK from"roughjs/bin/rough";import{nanoid as mK}from"nanoid";import{clamp as LM,pointFrom as oe,pointDistance as Hn,vector as _M,pointRotateRads as J1,vectorFromPoint as Q1,vectorSubtract as DM,vectorDot as RM,vectorNormalize as NM}from"@nous-excalidraw/math";import{COLOR_PALETTE as pK,CODES as BM,shouldResizeFromCenter as OM,shouldMaintainAspectRatio as ex,shouldRotateWithDiscreteAngle as FM,isArrowKey as tu,KEYS as Z,APP_NAME as uK,CURSOR_TYPE as Fe,DEFAULT_TRANSFORM_HANDLE_SPACING as hK,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as gK,DEFAULT_VERTICAL_ALIGN as zM,DRAGGING_THRESHOLD as HM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as fK,ELEMENT_TRANSLATE_AMOUNT as GM,EVENT as le,FRAME_STYLE as Nr,IMAGE_MIME_TYPES as bK,IMAGE_RENDER_TIMEOUT as xK,LINE_CONFIRM_THRESHOLD as tx,MAX_ALLOWED_FILE_BYTES as UM,MIME_TYPES as gn,MQ_RIGHT_SIDEBAR_MIN_WIDTH as EK,POINTER_BUTTON as Gn,ROUNDNESS as ou,SCROLL_TIMEOUT as yK,TAP_TWICE_TIMEOUT as WM,TEXT_TO_CENTER_SNAP_THRESHOLD as wK,THEME as ws,TOUCH_CTX_MENU_TIMEOUT as vK,VERTICAL_ALIGN as TK,YOUTUBE_STATES as nu,getInteractiveZoomStep as IK,INITIAL_CANVAS_ZOOM as CK,scaleFontSizeForZoomChange as YM,normalizeSceneFontSizeForZoom as ox,scaleStrokeWidthForZoomChange as VM,getDisplaySceneStrokeWidth as XM,STROKE_WIDTH_CUSTOM_DATA_KEY as SK,getDefaultSceneFontSizeForZoom as kK,POINTER_EVENTS as vs,TOOL_TYPE as fn,supportsResizeObserver as MK,DEFAULT_COLLISION_THRESHOLD as KM,DEFAULT_TEXT_ALIGN as PK,ARROW_TYPE as Br,DEFAULT_REDUCED_GLOBAL_ALPHA as AK,isLocalLink as LK,normalizeLink as nx,toValidURL as _K,getGridPoint as St,getLineHeight as $M,debounce as ZM,distance as Ts,getFontString as rx,getNearestScrollableContainer as DK,isInputLike as jM,isToolIcon as RK,isWritableElement as xc,sceneCoordsToViewportCoords as ru,tupleToCoors as ix,viewportCoordsToSceneCoords as ze,wrapEvent as NK,updateObject as ax,updateActiveTool as bn,isTransparent as BK,easeToValuesRAF as OK,muteFSAbortError as FK,isTestEnv as HP,isDevEnv as GP,easeOut as zK,updateStable as Ec,addEventListener as je,normalizeEOL as HK,getDateTime as qM,isShallowEqual as JM,arrayToMap as iu,applyDarkModeFilter as GK,AppEventBus as UK,randomInteger as WK,CLASSES as sx,Emitter as vi,MINIMUM_ARROW_SIZE as YK,DOUBLE_TAP_POSITION_THRESHOLD as QM,BIND_MODE_TIMEOUT as VK,invariant as xn,getFeatureFlag as Un,createUserAgentDescriptor as UP,getFormFactor as XK,deriveStylesPanelMode as uu,isIOS as KK,isBrave as $K,isSafari as ZK,loadDesktopUIModePreference as jK,setDesktopUIMode as qK,isSelectionLikeTool as au,oneOf as eP}from"@nous-excalidraw/common";import{getObservedAppState as JK,getCommonBounds as Ti,getElementAbsoluteCoords as tP,bindOrUnbindBindingElements as oP,fixBindingsAfterDeletion as QK,getHoveredElementForBinding as Ho,isBindingEnabled as yc,updateBoundElements as su,LinearElementEditor as Ee,newElementWith as Wn,newFrameElement as e$,newFreeDrawElement as t$,newEmbeddableElement as nP,newMagicFrameElement as rP,newIframeElement as o$,newArrowElement as n$,newElement as r$,newImageElement as i$,newLinearElement as a$,newTextElement as iP,refreshTextDimensions as s$,deepCopyElement as aP,duplicateElements as lx,hasBoundTextElement as sP,isArrowElement as Is,isBindingElement as En,isBindingElementType as l$,isBoundToContainer as cx,isFrameLikeElement as Qe,isHoverNativeOutlineShapeElement as c$,isImageElement as Cs,isEmbeddableElement as Go,shouldForceMaintainAspectRatio as lP,isInitializedImageElement as wc,isLinearElement as Bt,isLinearElementType as d$,isUsingAdaptiveRadius as m$,isIframeElement as Ss,isIframeLikeElement as dx,isMagicFrameElement as mx,isTextBindableContainer as cP,isElbowArrow as Vt,isFlowchartNodeElement as p$,isBindableElement as px,isTextElement as kt,getNormalizedDimensions as u$,isElementCompletelyInViewport as ux,isElementInViewport as dP,isInvisiblySmallElement as mP,getCornerRadius as h$,isPathALoop as pP,createSrcDoc as uP,embeddableURLValidator as hx,maybeParseEmbedSrc as g$,getEmbedLink as lu,getInitializedImageElements as f$,normalizeSVG as hP,updateImageCache as b$,getBoundTextElement as gx,getContainerCenter as fx,getContainerElement as gP,isValidTextContainer as fP,redrawTextBoundingBox as bP,hasBoundingBox as x$,getFrameChildren as bx,isCursorInFrame as xx,addElementsToFrame as Ex,replaceAllElementsInFrame as E$,removeElementsFromFrame as y$,getElementsInResizingFrame as xP,getElementsInNewFrame as w$,getContainingFrame as cu,elementOverlapsWithFrame as v$,updateFrameMembershipOfSelectedElements as EP,isElementInFrame as yP,getFrameLikeTitle as T$,getElementsOverlappingFrame as I$,filterElementsEligibleAsFrameChildren as C$,hitElementBoundText as S$,hitElementBoundingBoxOnly as k$,hitElementItself as ks,getVisibleSceneBounds as M$,FlowChartCreator as P$,FlowChartNavigator as A$,getLinkDirectionFromKey as wP,cropElement as L$,wrapText as _$,isElementLink as yx,parseElementLinkFromURL as D$,isMeasureTextSupported as R$,normalizeText as N$,measureText as vP,getLineHeightInPx as TP,getApproxMinLineWidth as B$,getApproxMinLineHeight as O$,getMinTextElementWidth as F$,ShapeCache as vc,getRenderOpacity as z$,editGroupForSelectedElement as H$,getElementsInGroup as Ii,getSelectedGroupIdForElement as G$,getSelectedGroupIds as U$,isElementInGroup as IP,isSelectedViaGroup as W$,selectGroupsForSelectedElements as yo,syncInvalidIndices as WP,syncMovedIndices as CP,excludeElementsInFramesFromSelection as Y$,getSelectionStateForElements as V$,makeNextSelectedElementIds as Me,getResizeOffsetXY as X$,getResizeArrowDirection as K$,transformElements as $$,getCursorForResizingElement as SP,getElementWithTransformHandleType as kP,getTransformHandleTypeFromCoords as MP,dragNewElement as PP,dragSelectedElements as Z$,getDragOffsetXY as j$,isNonDeletedElement as AP,Scene as LP,Store as q$,CaptureUpdateAction as Xt,hitElementBoundingBox as J$,isLineElement as wx,isSimpleArrow as vx,StoreDelta as _P,positionElementsOnGrid as DP,calculateFixedPointForNonElbowArrowBinding as RP,bindOrUnbindBindingElement as Q$,mutateElement as du,getElementBounds as NP,doBoundsIntersect as eZ,isPointInElement as tZ,maxBindingDistance_simple as Tx,convertToExcalidrawElements as BP,getSnapOutlineMidPoint as Ix,handleFocusPointDrag as oZ,handleFocusPointHover as nZ,handleFocusPointPointerDown as rZ,handleFocusPointPointerUp as iZ,maybeHandleArrowPointlikeDrag as mu,getUncroppedWidthAndHeight as aZ,getActiveTextElement as OP,syncElementsStrokeWidthForZoom as sZ}from"@nous-excalidraw/element";import{KEYS as th,MOBILE_ACTION_BUTTON_BG as _A,updateActiveTool as DA}from"@nous-excalidraw/common";import{getNonDeletedElements as oh}from"@nous-excalidraw/element";import{fixBindingsAfterDeletion as RA}from"@nous-excalidraw/element";import{LinearElementEditor as yy}from"@nous-excalidraw/element";import{newElementWith as ad}from"@nous-excalidraw/element";import{getContainerElement as wy}from"@nous-excalidraw/element";import{isBoundToContainer as rd,isElbowArrow as NA,isFrameLikeElement as BA}from"@nous-excalidraw/element";import{getFrameChildren as OA}from"@nous-excalidraw/element";import{getElementsInGroup as nh,selectGroupsForSelectedElements as FA}from"@nous-excalidraw/element";import{CaptureUpdateAction as id}from"@nous-excalidraw/element";import{isDevEnv as TA}from"@nous-excalidraw/common";import{atom as fe,createStore as yA}from"jotai";import{createIsolation as wA}from"jotai-scope";var y0=wA();var{useAtom:Q,useSetAtom:Vo,useAtomValue:Di,useStore:qZ}=y0,w0=y0.Provider,nt=yA();var vA=Zx({"./locales/ar-SA.json":()=>import("./locales/ar-SA-NXDWD63E.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-MXSORGZV.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-O6MV2KSF.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-T2VJNT7N.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-MMW2ORAC.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-MKBCGNOG.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-V77HGUP7.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-I5RFNTM4.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-WLRDEVBV.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-DTI4WUSC.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-ZXDJ2OS4.js"),"./locales/en.json":()=>import("./locales/en-QIAUJ35X.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-DYQHAD43.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-QDSYU5Y3.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-26LZG4PM.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-6YS4KDE4.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-BRLLPTZC.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-OKUZTLYG.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-26MGYIU7.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-Q4ZOGTP2.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-P2OXPSN5.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-2EIKXYN6.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-4CFKVXI2.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-MAND2Z4V.js"),"./locales/kaa.json":()=>import("./locales/kaa-HQRTCXTJ.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-JKIKKTGH.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-HXQ63ZFC.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-PKL3LSGX.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-KXLREZX3.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-MJ4IER3X.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-H6WFQ6FJ.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-GOCK6SJW.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-IXVLDMEQ.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-YG6MYTTD.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-XGWJISD2.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-XVDVCPNC.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-EMX5MJX5.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-ROEINTVO.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-ZYN6SUDY.js"),"./locales/percentages.json":()=>import("./locales/percentages-5DKR754L.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-6VTG7PHC.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5YFKRR5G.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-GEIXXZ67.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-E2P6TFZI.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-YBIIY43T.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-673C2CI2.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-CKZHQ4AP.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-557H2GWM.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XOPKKDWS.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-XBH7DQI3.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-TOCWH3R4.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-GXW6CYY5.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-IJKTNUDG.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-TBZZEA4V.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-MULSGNVB.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-3F3C6RA5.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-JNU5RLIE.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-LENVCA6T.js")});var IA=85,Xo={code:"en",label:"English"},Ni=[Xo,...[{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=>qx[e.code]>=IA).sort((e,o)=>e.label>o.label?1:-1)],Gc="__test__";TA()&&Ni.unshift({code:Gc,label:"test language"},{code:`${Gc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ri=Xo,Hc={},Uc=async e=>{if(Ri=e,document.documentElement.dir=Ri.rtl?"rtl":"ltr",document.documentElement.lang=Ri.code,e.code.startsWith(Gc))Hc={};else try{Hc=await vA(`./locales/${Ri.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Hc=wu}nt.set(T0,e.code)},vn=()=>Ri,v0=(e,o)=>{for(let t=0;t<o.length;++t){let n=o[t];if(e[n]===void 0)return;e=e[n]}if(typeof e=="string")return e},g=(e,o,t)=>{if(Ri.code.startsWith(Gc))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=v0(Hc,n)??v0(wu,n)??t;if(r===void 0){let i=`Can't find translation for ${e}`;if(C.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)r=r.replace(`{{${i}}}`,String(o[i]));return r},T0=fe(Xo.code),Ie=()=>{let e=Di(T0);return{t:g,langCode:e}};import CA from"clsx";import et from"react";import{THEME as SA}from"@nous-excalidraw/common";import{Fragment as Le,jsx as b,jsxs as N}from"react/jsx-runtime";var Io=e=>"var(--icon-fill-color)",I0=e=>e===SA.LIGHT?"#fff":"#1e1e1e",L=(e,o=512)=>{let{width:t=512,height:n=t,mirror:r,style:i,...a}=typeof o=="number"?{width:o}:o;return b("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${n}`,className:CA({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?b("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},pe={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Mt={width:40,height:20},pj=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("rect",{x:3,y:8,width:18,height:4,rx:1}),b("line",{x1:12,y1:8,x2:12,y2:21}),b("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),b("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),Wc=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),b("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),b("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),b("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),b("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),H),C0=L(N("svg",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),b("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),H),S0=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"1"}),b("circle",{cx:"12",cy:"19",r:"1"}),b("circle",{cx:"12",cy:"5",r:"1"})]}),H),k0=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),b("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),b("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),H),M0=L(N("svg",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),b("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),b("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),H),Au=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M6.5 9.5l3.5 -3"}),b("path",{d:"M14 5.5l3 1.5"}),b("path",{d:"M18.5 10l-2.5 7"}),b("path",{d:"M13.5 17.5l-7 -5"})]}),H),Wr=L(N("g",{children:[b("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"}),b("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"}),b("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:b("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"})}),b("g",{mask:"url(#UnlockedIcon)",children:b("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"})})]}),pe),Bi=L(N("g",{strokeWidth:"1.25",children:[b("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"}),b("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),b("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"})]}),pe),P0=L(b("g",{fill:"currentColor",children:b("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}),A0=L(N(Le,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),b("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"}),L0=L(N(Le,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),b("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"}),_0=L(N(Le,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),b("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"}),uj=L(b("g",{fill:"currentColor",children:b("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"}),Yr=L(N("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),$n=L(N("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[b("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"}),b("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Oi=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),H),Fi=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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),zi=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 4l8 16h-16z"})]}),H),Hi=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"})]}),H),Yc=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),b("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),b("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),H),Gi=L(b("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),pe),D0=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),b("path",{d:"M16 7h4"}),b("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),H),Ko=L(N("g",{strokeWidth:"1.25",children:[b("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"}),b("path",{d:"m11.25 5.417 3.333 3.333"})]}),pe),$o=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),b("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),b("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),b("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),b("polyline",{points:"5 20 11 4 13 4 20 20"})]}),H),R0=L(N("g",{stroke:"currentColor",strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 7v-2h13v2"}),b("path",{d:"M10 5v14"}),b("path",{d:"M12 19h-4"}),b("path",{d:"M15 13v-1h6v1"}),b("path",{d:"M18 12v7"}),b("path",{d:"M17 19h2"})]}),H),Ui=L(N("g",{strokeWidth:"1.25",children:[b("path",{d:"M12.5 6.667h.01"}),b("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"}),b("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),b("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),pe),Vc=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M18 13.3l-6.3 -6.3"})]}),H),Lu=L(b("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),pe),_u=L(b("path",{d:"M5 10h10",strokeWidth:"1.25"}),pe),N0=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M21 21l-6 -6"}),b("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"}),b("path",{d:"M3 4v4h4"})]}),H),ft=L(b("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"}),pe),Wi=L(N("g",{strokeWidth:"1.5",children:[b("polyline",{points:"12 16 18 10 12 4"}),b("polyline",{points:"8 4 2 10 8 16"})]}),pe),Hs=L(N("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),pe),Gs=L(b("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"}),pe),Us=L(b("g",{stroke:"currentColor",strokeLinejoin:"round",children:b("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"})}),{...pe,strokeWidth:1.5}),B0=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),b("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),b("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),H),Vr=L(b("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"}),pe),Yi=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"}),b("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),O0=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"}),b("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),Du=L(b("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"}),pe),Xc=L(b("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"}),pe),F0=L(N("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),pe),z0=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),b("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),H),Kc=L(b("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Ws=L(N("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),pe),H0=L("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}),G0=L("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}),Vi=L(b("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"}),pe),hj=L("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}),gj=L("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"),Xi=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),b("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),b("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),H),U0=L(b("g",{strokeWidth:1.5,children:b("path",{d:"M6 18l12 -12"})}),H),$c=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M15 8h.01"}),b("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),b("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),b("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),b("path",{d:"M19 16v6"}),b("path",{d:"M22 19l-3 3l-3 -3"})]}),H),W0=L("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}),fj=L("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}),bj=L("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}),Y0=L("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"),xj=L("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),Ru=L(b("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"}),pe),Nu=L(b("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"}),pe),V0=L("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}),X0=L(b("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"}),pe),Ej=L("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"),yj=L("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}),wj=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 14v-11"}),b("path",{d:"M9 6l3 -3l3 3"})]}),H),vj=L(N(Le,{children:[b("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"}),b("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}),Tj=L(b("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}),K0=N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 10l0 10"}),b("path",{d:"M12 10l4 4"}),b("path",{d:"M12 10l-4 4"}),b("path",{d:"M4 4l16 0"})]}),$0=N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 5l0 14"}),b("path",{d:"M16 9l-4 -4"}),b("path",{d:"M8 9l4 -4"})]}),Bu=L($0,H),Ou=L($0,{...H,style:{transform:"rotate(180deg)"}}),Fu=L(K0,H),zu=L(K0,{...H,style:{transform:"rotate(180deg)"}}),Hu=L(N(Le,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),Gu=L(N(Le,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),Uu=L(N(Le,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),Wu=L(N(Le,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),Z0=L(N(Le,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),j0=L(N(Le,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),Yu=L(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),b("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),pe),Vu=L(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),b("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),pe),Zc=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"9",cy:"7",r:"4"}),b("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),b("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),b("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),H),Ij=L("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"),q0=L("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"),oo=L(N(Le,{children:[b("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("path",{d:"M15 5 5 15M5 5l10 10"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),Cj=L("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}),Sj=L("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}),kj=L("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}),Xu=et.memo(({theme:e})=>L(N(Le,{children:[b("path",{d:"M25 26H111V111H25",fill:Io(e)}),b("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:Io(e),strokeWidth:"2"}),b("path",{d:"M100 100H160V160H100",fill:Io(e)}),b("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:Io(e),strokeWidth:"2"}),N("g",{fill:I0(e),stroke:Io(e),strokeWidth:"6",children:[b("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Ku=et.memo(({theme:e})=>L(N(Le,{children:[b("path",{d:"M25 26H111V111H25",fill:Io(e)}),b("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:Io(e),strokeWidth:"2"}),b("path",{d:"M100 100H160V160H100",fill:Io(e)}),b("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:Io(e),strokeWidth:"2"}),N("g",{fill:I0(e),stroke:Io(e),strokeWidth:"6",children:[b("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),b("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),J0=L(b("g",{strokeWidth:1.25,children:b("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"})}),pe),Q0=L(N(Le,{children:[b("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"}),b("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:b("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"})}),b("g",{mask:"url(#FillHachureIcon)",children:b("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"})})]}),pe),eE=L(N(Le,{children:[N("g",{clipPath:"url(#a)",children:[b("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"}),b("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:b("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"})}),b("g",{mask:"url(#FillCrossHatchIcon)",children:b("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"})})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),tE=L(N(Le,{children:[b("g",{clipPath:"url(#a)",children:b("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"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...pe,fill:"currentColor"}),$u=L(b(Le,{children:b("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),pe),oE=L(b("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),pe),nE=L(b("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),pe),Mj=et.memo(({theme:e})=>L(b("path",{d:"M6 10H34",stroke:Io(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),rE=L(N("g",{strokeWidth:"2",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 12h2"}),b("path",{d:"M17 12h2"}),b("path",{d:"M11 12h2"})]}),H),iE=L(N("g",{strokeWidth:"2",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 12v.01"}),b("path",{d:"M8 12v.01"}),b("path",{d:"M12 12v.01"}),b("path",{d:"M16 12v.01"}),b("path",{d:"M20 12v.01"})]}),H),aE=L(b("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"}),pe),sE=L(b("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"}),pe),lE=L(b("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"}),pe),cE=L(N("svg",{strokeWidth:"1.5",children:[b("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"}),b("path",{d:"M13.3333 3.33331V3.34331"}),b("path",{d:"M16.6667 3.33331V3.34331"}),b("path",{d:"M16.6667 6.66669V6.67669"}),b("path",{d:"M16.6667 10V10.01"}),b("path",{d:"M3.33334 13.3333V13.3433"}),b("path",{d:"M16.6667 13.3333V13.3433"}),b("path",{d:"M3.33334 16.6667V16.6767"}),b("path",{d:"M6.66666 16.6667V16.6767"}),b("path",{d:"M10 16.6667V16.6767"}),b("path",{d:"M13.3333 16.6667V16.6767"}),b("path",{d:"M16.6667 16.6667V16.6767"})]}),pe),dE=L(N("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),b("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),b("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),b("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),b("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),b("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),b("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),b("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),b("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),b("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),b("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),b("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),H),mE=et.memo(({flip:e=!1})=>L(N("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[b("path",{d:"M7,11 H19"}),b("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),Mt)),pE=et.memo(({flip:e=!1})=>L(b("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:b("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),Mt)),uE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[b("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),b("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Mt)),hE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[b("path",{d:"M7,11 H23"}),b("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Mt)),gE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[b("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),b("circle",{cx:"29",cy:"11",r:"4"})]}),Mt)),fE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[b("path",{d:"M7,11 H25",strokeLinecap:"round"}),b("circle",{cx:"29",cy:"11",r:"4"})]}),Mt)),bE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[b("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),b("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Mt)),xE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[b("path",{d:"M7,11 H21"}),b("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Mt)),EE=et.memo(({flip:e=!1})=>L(b("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:b("path",{d:"M11,11 H31 M31,5 V17"})}),Mt)),yE=et.memo(({flip:e=!1})=>L(b("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:b("path",{d:"M35,11 H7 M15,5 V17"})}),Mt)),wE=et.memo(({flip:e=!1})=>L(b("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:b("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),Mt)),vE=et.memo(({flip:e=!1})=>L(b("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:b("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),Mt)),TE=et.memo(({flip:e=!1})=>L(b("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:b("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),Mt)),IE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),b("circle",{cx:"15",cy:"11",r:"4"})]}),Mt)),CE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),b("circle",{cx:"23",cy:"11",r:"4"})]}),Mt)),SE=L(N(Le,{children:[b("g",{clipPath:"url(#a)",children:b("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"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),kE=L(N(Le,{children:[b("g",{clipPath:"url(#a)",children:b("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),ME=L(N(Le,{children:[b("g",{clipPath:"url(#a)",children:b("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),PE=L(b(Le,{children:b("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"})}),pe),Xr=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 7v-2h13v2"}),b("path",{d:"M10 5v14"}),b("path",{d:"M12 19h-4"}),b("path",{d:"M15 13v-1h6v1"}),b("path",{d:"M18 12v7"}),b("path",{d:"M17 19h2"})]}),H),AE=L(b(Le,{children:N("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 12h10"}),b("path",{d:"M7 5v14"}),b("path",{d:"M17 5v14"}),b("path",{d:"M15 19h4"}),b("path",{d:"M15 5h4"}),b("path",{d:"M5 19h4"}),b("path",{d:"M5 5h4"})]})}),H),Ys=L(b(Le,{children:b("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("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"})})}),pe),Zu=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 8l-4 4l4 4"}),b("path",{d:"M17 8l4 4l-4 4"}),b("path",{d:"M14 4l-4 16"})]}),H),jc=Zu,LE=L(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),b("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),H),_E=L(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),b("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),H),DE=L(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),b("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),H),RE=et.memo(({theme:e})=>L(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),b("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),H)),NE=et.memo(({theme:e})=>L(N("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),b("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),H)),BE=et.memo(({theme:e})=>L(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),b("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),b("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),H)),qc=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M21 19h-18l9 -15"}),b("path",{d:"M20.615 15.171h.015"}),b("path",{d:"M19.515 11.771h.015"}),b("path",{d:"M17.715 8.671h.015"}),b("path",{d:"M15.415 5.971h.015"})]}),H),OE=L(b("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}),Pj=L(b("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"})),Ki=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),b("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),b("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),b("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),ju=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),b("path",{d:"M7 11l5 5l5 -5"}),b("path",{d:"M12 4l0 12"})]}),H),$i=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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),FE=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M9.15 14.85l8.85 -10.85"}),b("path",{d:"M6 4l8.85 10.85"})]}),H),zE=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),b("path",{d:"M12 17l0 .01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),Aj=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 4v16l13 -8z"})]}),H),Lj=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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),HE=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 12l5 5l10 -10"})]}),H),Jc=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 9v4"}),b("path",{d:"M12 17h.01"})]}),H),GE=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M11 7l6 6"}),b("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),H),Vs=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 3l-4 7h8z"}),b("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),H),Co=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 7l16 0"}),b("path",{d:"M4 17l16 0"}),b("path",{d:"M7 4l0 16"}),b("path",{d:"M17 4l0 16"})]}),H),Zi=L(b("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),UE=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),b("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),H),WE=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),b("path",{d:"M4 15l8 4l8 -4"}),b("path",{d:"M12 4v7"}),b("path",{d:"M15 8l-3 3l-3 -3"})]}),H),Zn=L(N("g",{strokeWidth:"1.25",children:[b("path",{d:"M4.16602 10H15.8327"}),b("path",{d:"M12.5 13.3333L15.8333 10"}),b("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),pe),Zo=L(N("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[b("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"}),b("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),Kr=L(N("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z"}),b("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),b("path",{d:"M15 6l3 3"}),b("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"}),b("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),_j=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z"}),b("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),b("path",{d:"M15 6l3 3"}),b("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"}),b("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),Dj=L(N("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),b("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),b("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"}),b("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),b("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),b("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),YE=L(N("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),b("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),b("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),b("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),H),ji=L(N("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),b("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),VE=L(N("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),b("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"}),b("path",{d:"M3 3l18 18"})]}),H),XE=L(N("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),b("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),b("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),b("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),KE=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),b("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),b("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),b("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),Kt=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),b("path",{d:"M21 21l-6 -6"})]}),H),$E=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),b("path",{d:"M12 7v5l3 3"}),b("path",{d:"M19 16l-2 3h4l-2 3"})]}),H),ZE=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 8l0 4l2 2"}),b("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),H),jE=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M5 10a7 7 0 0 0 14 0"}),b("path",{d:"M8 21l8 0"}),b("path",{d:"M12 17l0 4"})]}),H),qE=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 3l18 18"}),b("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"}),b("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),b("path",{d:"M8 21l8 0"}),b("path",{d:"M12 17l0 4"})]}),H),Xs=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),H),JE=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 20v.01"}),b("path",{d:"M16 20v.01"}),b("path",{d:"M8 20v.01"}),b("path",{d:"M4 20v.01"}),b("path",{d:"M4 16v.01"}),b("path",{d:"M4 12v.01"}),b("path",{d:"M4 8v.01"}),b("path",{d:"M4 4v.01"}),b("path",{d:"M8 4v.01"}),b("path",{d:"M12 4v.01"}),b("path",{d:"M16 4v.01"}),b("path",{d:"M20 4v.01"}),b("path",{d:"M20 8v.01"}),b("path",{d:"M20 12v.01"}),b("path",{d:"M20 16v.01"}),b("path",{d:"M20 20v.01"})]}),H),QE=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 3v18"}),b("path",{d:"M19 21v-18"}),b("path",{d:"M5 7h14"}),b("path",{d:"M5 15h14"}),b("path",{d:"M8 13v4"}),b("path",{d:"M11 13v4"}),b("path",{d:"M16 13v4"}),b("path",{d:"M14 5v4"}),b("path",{d:"M11 5v4"}),b("path",{d:"M8 5v4"}),b("path",{d:"M3 21h18"})]}),H),ey=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 12l18 0"}),b("path",{d:"M7 16l10 0l-10 5l0 -5"}),b("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),H),ty=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 3l0 18"}),b("path",{d:"M16 7l0 10l5 0l-5 -10"}),b("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),H),qu=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),b("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),Qc=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),b("path",{d:"M22 22l-3 -3"}),b("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),b("path",{d:"M3 11v-1"}),b("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),b("path",{d:"M10 3h1"}),b("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),H),oy=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),b("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),b("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"}),b("path",{d:"M10 15l2 6l2 -6"}),b("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),H),ny=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),b("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),b("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),b("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),b("path",{d:"M11 21v-6l3 6v-6"})]}),H),ry=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M4 8l5 0"}),b("path",{d:"M15 8l4 0"})]}),H),iy=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),b("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),b("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),b("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),H),ay=L(N("g",{stroke:"currentColor",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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}),Rj=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M21 12h-13l3 -3"}),b("path",{d:"M11 15l-3 -3"})]}),H),sy=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M10 9l5 3l-5 3z"})]}),H),ly=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 6h18"}),b("path",{d:"M3 12h18"}),b("path",{d:"M3 18h18"}),b("path",{d:"M6 3v18"}),b("path",{d:"M12 3v18"}),b("path",{d:"M18 3v18"})]}),H),cy=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),H),qi=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 18l12 -12"}),b("path",{d:"M18 10v-4h-4"})]}),H),Ji=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),b("path",{d:"M18 4l3 3l-3 3"})]}),H),Qi=L(N("g",{children:[b("path",{d:"M16,12L20,9L16,6"}),b("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),ed=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 9l6 6l6 -6"})]}),H),dy=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 15l6 -6l6 6"})]}),H),my=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 15l6 -6l6 6"})]}),H),Ju=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),b("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),H),td=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M5 7l0 10"}),b("path",{d:"M7 5l10 0"}),b("path",{d:"M7 19l10 0"}),b("path",{d:"M19 7l0 10"})]}),H),Nj=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),H),py=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M4 6l8 0"}),b("path",{d:"M16 6l4 0"}),b("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M4 12l2 0"}),b("path",{d:"M10 12l10 0"}),b("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M4 18l11 0"}),b("path",{d:"M19 18l1 0"})]}),H),uy=L(N("g",{strokeWidth:1,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),H),hy=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),b("path",{d:"M13.5 6.5l4 4"})]}),H),Bj=L(N("g",{strokeWidth:1,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M11 7l-5 5l5 5"}),b("path",{d:"M17 7l-5 5l5 5"})]}),H),gy=L(N("g",{strokeWidth:"1.75",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M15 4l0 16"})]}),H),Oj=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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),Fj=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 4l18 0"}),b("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),b("path",{d:"M12 16l0 4"}),b("path",{d:"M9 20l6 0"}),b("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),H),od=b("div",{style:{width:"1rem",height:"1rem"}}),fy=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("polyline",{points:"9 6 15 12 9 18"})]}),H),by=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M4 6l8 0"}),b("path",{d:"M16 6l4 0"}),b("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M4 12l2 0"}),b("path",{d:"M10 12l10 0"}),b("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M4 18l11 0"}),b("path",{d:"M19 18l1 0"})]}),H);import xy from"clsx";import eh,{useEffect as PA,useRef as Ey,useState as AA}from"react";import{isPromiseLike as LA}from"@nous-excalidraw/common";import kA from"react";import{jsx as Qu}from"react/jsx-runtime";var MA=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(kA.useRef(Date.now()).current%1600);return Qu("div",{className:`Spinner ${n}`,children:Qu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Qu("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},bt=MA;import{jsx as Ks,jsxs as $s}from"react/jsx-runtime";var q=eh.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=Ne(),a=eh.useRef(null);eh.useImperativeHandle(r,()=>a.current);let s=`ToolIcon_size_${e}`,[l,c]=AA(!1),d=Ey(!0),p=async u=>{let f="onClick"in n&&n.onClick?.(u);if(LA(f))try{c(!0),await f}catch(h){if(h instanceof Pi)console.warn(h);else throw h}finally{d.current&&c(!1)}};PA(()=>(d.current=!0,()=>{d.current=!1}),[]);let m=Ey(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return $s("button",{className:xy("ToolIcon_type_button",s,t,o&&!n.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!n.hidden,"ToolIcon--selected":n.selected,"ToolIcon--plain":n.type==="icon"}),style:n.style,"data-testid":n["data-testid"],hidden:n.hidden,title:n.title,"aria-label":n["aria-label"],type:u,onClick:p,ref:a,disabled:l||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&$s("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&Ks("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&Ks(bt,{})]}),n.showAriaLabel&&$s("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",l&&Ks(bt,{})]}),n.children]})}return $s("label",{className:xy("ToolIcon",t),title:n.title,onPointerDown:u=>{m.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{m.current=null})},children:[Ks("input",{className:`ToolIcon_type_radio ${s}`,type:"radio",name:n.name,"aria-label":n["aria-label"],"aria-keyshortcuts":n["aria-keyshortcuts"],"data-testid":n["data-testid"],id:`${i}-${n.id}`,onChange:()=>{n.onChange?.({pointerType:m.current})},checked:n.checked,ref:a}),$s("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&Ks("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});q.displayName="ToolButton";var nd=[],O=e=>(nd=nd.concat(e),e);import{jsx as HA}from"react/jsx-runtime";var zA=(e,o,t)=>{let n=new Set(ie(e.filter(d=>BA(d)),o).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of n){let p=OA(e,d);for(let m of p)if(!a.has(m.id)){if(rd(m)){let u=wy(m,i);u&&(r[u.id]=!0)}else r[m.id]=!0;a.add(m.id)}}let s=!0,l=e.map(d=>{if(o.selectedElementIds[d.id]){let p=rd(d)?wy(d,i):null;return d.frameId&&n.has(d.frameId)?(s=!1,r[d.id]=!0,d):p?.frameId&&n.has(p?.frameId)?d:(d.boundElements&&d.boundElements.forEach(m=>{let u=t.scene.getNonDeletedElementsMap().get(m.id);u&&NA(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),ad(d,{isDeleted:!0}))}return d.frameId&&n.has(d.frameId)?(s=!1,rd(d)||(r[d.id]=!0),ad(d,{frameId:null})):rd(d)&&o.selectedElementIds[d.containerId]?ad(d,{isDeleted:!0}):d}),c=o.editingGroupId;if(s&&o.editingGroupId){let d=nh(l,o.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(f=>f===o.editingGroupId),u=p.groupIds[m+1];if(u){let f=nh(l,u).filter(h=>!h.isDeleted);f.length>1&&(c=u,f.forEach(h=>{r[h.id]=!0}))}}}}return{elements:l,appState:{...o,...FA({selectedElementIds:r,editingGroupId:c},l,o,null)}}},vy=(e,o)=>{if(e.editingGroupId){let t=nh(oh(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Zs=O({name:"deleteSelectedElements",label:"labels.delete",icon:ft,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:s}=o.selectedLinearElement,l=n.scene.getNonDeletedElementsMap(),c=yy.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(m=>m.id===c.id?ad(m,{isDeleted:!0}):m),p=vy(o,d);return{elements:d,appState:{...p,selectedLinearElement:null},captureUpdate:id.IMMEDIATELY}}return yy.deletePoints(c,n,s),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:id.IMMEDIATELY}}let{elements:r,appState:i}=zA(e,o,n);return RA(r,r.filter(a=>a.isDeleted)),i=vy(i,r),{elements:r,appState:{...i,activeTool:DA(o,{type:n.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ae(oh(e),o)?id.IMMEDIATELY:id.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===th.BACKSPACE||e.key===th.DELETE)&&!e[th.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=dt()==="mobile";return HA(q,{type:"button",icon:ft,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),disabled:!Ae(oh(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?_A:{}}})}});import{KEYS as ea,CODES as ta,isDarwin as sd}from"@nous-excalidraw/common";import{moveOneLeft as GA,moveOneRight as UA,moveAllLeft as WA,moveAllRight as YA}from"@nous-excalidraw/element";import{CaptureUpdateAction as ld}from"@nous-excalidraw/element";import{isDarwin as Ty}from"@nous-excalidraw/common";var B=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,Ty?g("keys.option"):g("keys.alt")).replace(/\bShift\b/i,g("keys.shift")).replace(/\b(Enter|Return)\b/i,g("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,Ty?g("keys.cmd"):g("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,g("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,g("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,g("keys.delete"));import{jsx as cd}from"react/jsx-runtime";var rh=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Ou,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:GA(e,o,n.scene),appState:o,captureUpdate:ld.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ea.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ta.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>cd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${B("CtrlOrCmd+[")}`,children:Ou})}),ih=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Bu,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:UA(e,o,n.scene),appState:o,captureUpdate:ld.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ea.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ta.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>cd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${B("CtrlOrCmd+]")}`,children:Bu})}),ah=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:zu,trackEvent:{category:"element"},perform:(e,o)=>({elements:WA(e,o),appState:o,captureUpdate:ld.IMMEDIATELY}),keyTest:e=>sd?e[ea.CTRL_OR_CMD]&&e.altKey&&e.code===ta.BRACKET_LEFT:e[ea.CTRL_OR_CMD]&&e.shiftKey&&e.code===ta.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>cd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${sd?B("CtrlOrCmd+Alt+["):B("CtrlOrCmd+Shift+[")}`,children:zu})}),sh=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Fu,trackEvent:{category:"element"},perform:(e,o)=>({elements:YA(e,o),appState:o,captureUpdate:ld.IMMEDIATELY}),keyTest:e=>sd?e[ea.CTRL_OR_CMD]&&e.altKey&&e.code===ta.BRACKET_RIGHT:e[ea.CTRL_OR_CMD]&&e.shiftKey&&e.code===ta.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>cd("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${sd?B("CtrlOrCmd+Alt+]"):B("CtrlOrCmd+Shift+]")}`,children:Fu})});import{getNonDeletedElements as VA}from"@nous-excalidraw/element";import{LinearElementEditor as XA}from"@nous-excalidraw/element";import{isLinearElement as KA,isTextElement as $A}from"@nous-excalidraw/element";import{arrayToMap as ZA,KEYS as Iy}from"@nous-excalidraw/common";import{selectGroupsForSelectedElements as jA}from"@nous-excalidraw/element";import{CaptureUpdateAction as qA}from"@nous-excalidraw/element";var lh=O({name:"selectAll",label:"labels.selectAll",icon:JE,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!($A(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...jA({editingGroupId:null,selectedElementIds:r},VA(e),o,n),selectedLinearElement:Object.keys(r).length===1&&KA(e[0])?new XA(e[0],ZA(e)):null},captureUpdate:qA.IMMEDIATELY}},keyTest:e=>e[Iy.CTRL_OR_CMD]&&e.key===Iy.A});import{DEFAULT_GRID_SIZE as Cy,KEYS as Sy,MOBILE_ACTION_BUTTON_BG as JA,arrayToMap as ky}from"@nous-excalidraw/common";import{getNonDeletedElements as My}from"@nous-excalidraw/element";import{LinearElementEditor as QA}from"@nous-excalidraw/element";import{getSelectedElements as e6,getSelectionStateForElements as t6}from"@nous-excalidraw/element";import{syncMovedIndices as o6}from"@nous-excalidraw/element";import{duplicateElements as n6}from"@nous-excalidraw/element";import{CaptureUpdateAction as Py}from"@nous-excalidraw/element";import{jsx as r6}from"react/jsx-runtime";var ch=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Hs,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=QA.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:a,captureUpdate:Py.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=n6({type:"in-place",elements:e,idsOfElementsToDuplicate:ky(e6(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:s})=>{let l=a.frameId&&s.get(a.frameId);return{x:a.x+Cy/2,y:a.y+Cy/2,frameId:l??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:o6(i,ky(r)),appState:{...o,...t6(r,My(i),o)},captureUpdate:Py.IMMEDIATELY}},keyTest:e=>e[Sy.CTRL_OR_CMD]&&e.key===Sy.D,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=dt()==="mobile";return r6(q,{type:"button",icon:Hs,title:`${g("labels.duplicateSelection")} \u2014 ${B("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Ae(My(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?JA:{}}})}});import{pointFrom as dL}from"@nous-excalidraw/math";import{useEffect as Lh,useMemo as Rh,useRef as _h,useState as mL}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as pL,DEFAULT_ELEMENT_BACKGROUND_PICKS as uL,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as hL,DEFAULT_ELEMENT_STROKE_PICKS as gL,ARROW_TYPE as ao,DEFAULT_FONT_FAMILY as fL,FONT_FAMILY as bL,ROUNDNESS as Sd,STROKE_WIDTH_CUSTOM_DATA_KEY as xL,getStrokeWidthPresetsForZoom as EL,getFontSizePresetsForZoom as yL,VERTICAL_ALIGN as Cd,KEYS as ca,randomInteger as wL,arrayToMap as Nh,getFontFamilyString as vL,getLineHeight as TL,isTransparent as IL,reduceToCommonValue as CL,invariant as Bh}from"@nous-excalidraw/common";import{canBecomePolygon as SL,getNonDeletedElements as vw}from"@nous-excalidraw/element";import{bindBindingElement as bw,calculateFixedPointForElbowArrowBinding as xw,updateBoundElements as kL}from"@nous-excalidraw/element";import{LinearElementEditor as Zr}from"@nous-excalidraw/element";import{newElementWith as at}from"@nous-excalidraw/element";import{getArrowheadForPicker as Ew}from"@nous-excalidraw/element";import{getBoundTextElement as ar,redrawTextBoundingBox as al}from"@nous-excalidraw/element";import{isArrowElement as kd,isBoundToContainer as ML,isElbowArrow as Tw,isLinearElement as Dh,isLineElement as yw,isTextElement as Ft,isUsingAdaptiveRadius as PL}from"@nous-excalidraw/element";import{hasStrokeColor as AL}from"@nous-excalidraw/element";import{updateElbowArrowPoints as LL,CaptureUpdateAction as st,toggleLinePolygonState as _L}from"@nous-excalidraw/element";import{deriveStylesPanelMode as DL}from"@nous-excalidraw/common";import{isDevEnv as i6}from"@nous-excalidraw/common";var a6=new Set(["command_palette","export"]),me=(e,o,t,n)=>{try{if(typeof window>"u"||C.VITE_WORKER_ID||C.VITE_APP_ENABLE_TRACKING!=="true"||!a6.has(e)||i6())return;C.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:n}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:n})}catch(r){console.error("error during analytics",r)}};import d6 from"clsx";import s6 from"clsx";import{forwardRef as l6}from"react";import{jsx as c6}from"react/jsx-runtime";var oa=l6((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:a,icon:s,onClick:l}=e;return c6("button",{type:"button",ref:o,title:t,"data-testid":r,className:s6(n,{standalone:a,active:i}),onClick:l,style:e.style,children:s},t)});import{Fragment as p6,jsx as dh,jsxs as m6}from"react/jsx-runtime";var no=e=>dh(p6,{children:e.options.map(o=>e.type==="button"?dh(oa,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):m6("label",{className:d6({active:e.value===o.value}),title:o.text,children:[dh("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import{Popover as Zy}from"radix-ui";import jy from"clsx";import{useRef as qy,useEffect as h4}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as Ky,COLOR_PALETTE as Jy,isColorDark as $y,isWritableElement as g4}from"@nous-excalidraw/common";import{jsx as u6}from"react/jsx-runtime";var dd=()=>u6("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as x6,useRef as E6}from"react";import{createPortal as y6}from"react-dom";import{EVENT as qn,KEYS as w6,rgbToHex as v6}from"@nous-excalidraw/common";import Ay from"react";var mh=Ay.createContext(null),se=()=>Ay.useContext(mh);import{useState as h6,useLayoutEffect as Ly}from"react";import{THEME as g6}from"@nous-excalidraw/common";var md=e=>{let[o,t]=h6(null),n=be(),{theme:r}=se(),{container:i}=Ne();return Ly(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",n.formFactor==="phone"),o.classList.toggle("theme--dark",r===g6.DARK))},[o,r,n.formFactor,e?.className]),Ly(()=>{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]),o};import{useEffect as f6}from"react";import{EVENT as pd}from"@nous-excalidraw/common";function na(e,o,t){f6(()=>{function n(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(pd.POINTER_DOWN,n),document.addEventListener(pd.TOUCH_START,n),()=>{document.removeEventListener(pd.POINTER_DOWN,n),document.removeEventListener(pd.TOUCH_START,n)}},[e,o,t])}import{useRef as b6}from"react";var jn=e=>{let o=b6(e);return Object.assign(o.current,e),o.current};import{jsx as T6}from"react/jsx-runtime";var Jn=fe(null),_y=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=md({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=se(),a=Qn(),s=He(),l=ie(a,i),c=jn({app:s,onCancel:e,onChange:o,onSelect:t,selectedElements:l}),{container:d}=Ne();x6(()=>{let m=p.current;if(!m||!s.canvas||!r)return;let u=!1,f=s.canvas.getContext("2d"),h=({clientX:I,clientY:M})=>{let S=f.getImageData((I-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return v6(S[0],S[1],S[2])},x=({clientX:I,clientY:M,altKey:S})=>{m.style.top=`${M+20}px`,m.style.left=`${I+20}px`;let _=h({clientX:I,clientY:M});u&&c.onChange(n,_,c.selectedElements,{altKey:S}),m.style.background=_},E=()=>{c.onCancel()},w=(I,M)=>{c.onSelect(I,M)},y=I=>{u=!0,I.stopImmediatePropagation()},v=I=>{u=!1,d?.focus(),I.stopImmediatePropagation(),I.preventDefault(),w(h(I),I)},T=I=>{I.key===w6.ESCAPE&&(I.preventDefault(),I.stopImmediatePropagation(),E())};return r.tabIndex=-1,r.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(qn.KEYDOWN,T),r.addEventListener(qn.POINTER_DOWN,y),r.addEventListener(qn.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(qn.BLUR,E),()=>{u=!1,r.removeEventListener(qn.KEYDOWN,T),r.removeEventListener(qn.POINTER_DOWN,y),r.removeEventListener(qn.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(qn.BLUR,E)}},[c,s.canvas,r,n,d,i.offsetLeft,i.offsetTop]);let p=E6(null);return na(p,()=>{e()},m=>!!m.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?y6(T6("div",{ref:p,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as ph}from"radix-ui";import k6 from"clsx";import M6 from"react";import{isInteractive as P6}from"@nous-excalidraw/common";import I6 from"react";import C6 from"clsx";import{jsx as S6}from"react/jsx-runtime";var Ze=I6.forwardRef(({children:e,padding:o,className:t,style:n},r)=>S6("div",{className:C6("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as uh,jsxs as A6}from"react/jsx-runtime";var Tn=M6.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l,preventAutoFocusOnTouch:c=!1},d)=>{let p=be(),m=p.formFactor==="phone"&&!p.isLandscape;return uh(ph.Portal,{container:o,children:A6(ph.Content,{ref:d,className:k6("focus-visible-none",e),"data-prevent-outside-click":!0,side:m?"bottom":"right",align:m?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:o??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:p.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onOpenAutoFocus:u=>{c&&p.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),o&&!P6(document.activeElement)&&o.focus(),r()},children:[uh(Ze,{padding:3,style:n,children:t}),uh(ph.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 L6,useCallback as hh}from"react";var ud=()=>document.querySelector(".excalidraw-wysiwyg"),hd=()=>{let e=ud();return e?{start:e.selectionStart,end:e.selectionEnd}:null},js=e=>{setTimeout(()=>{let o=ud();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},qs=(e,o,t,n)=>{o&&n&&n();let r=o&&t?hd():null;e(),o&&t&&js(r)},Dy=()=>{let[e,o]=L6(null),t=hh(()=>{let i=hd();o(i)},[]),n=hh(()=>{setTimeout(()=>{let i=ud();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,o(null)))},0)},[e]),r=hh(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:n,clearSavedPosition:r,hasSavedPosition:!!e}},Ry=(e=100)=>{let o=ud();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import D6 from"clsx";import{useCallback as R6,useEffect as fh,useRef as By,useState as N6}from"react";import{KEYS as bh,normalizeInputColor as B6}from"@nous-excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as _6}from"@nous-excalidraw/common";var er=({palette:e,color:o})=>{if(!o)return null;for(let[t,n]of Object.entries(e))if(Array.isArray(n)){let r=n.indexOf(o);if(r>-1)return{colorName:t,shade:r}}else if(n===o)return{colorName:t,shade:null};return null},Js=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),gh=({color:e,palette:o})=>!Object.values(o).flat().includes(e),Ny=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[n[o]];return gh({color:s,palette:t})}),i=new Map;return r.forEach(a=>{let s=a[n[o]];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,_6)},ro=fe(null);import{Fragment as O6,jsx as gd,jsxs as Oy}from"react/jsx-runtime";var Fy=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=be(),[a,s]=N6(e),[l,c]=Q(ro);fh(()=>{s(e)},[e]);let d=R6(h=>{let x=h.toLowerCase(),E=B6(x);E&&o(E),s(x)},[o]),p=By(null),m=By(null);fh(()=>{p.current&&p.current.focus()},[l]);let[u,f]=Q(Jn);return fh(()=>()=>{f(null)},[f]),Oy("div",{className:"color-picker__input-label",children:[gd("div",{className:"color-picker__input-hash",children:"#"}),gd("input",{ref:l==="hex"?p:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:h=>{d(h.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:h=>{h.key!==bh.TAB&&(h.key===bh.ESCAPE&&m.current?.focus(),h.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&Oy(O6,{children:[gd("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),gd("div",{ref:m,className:D6("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(h=>h?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:n}),title:`${g("labels.eyeDropper")} \u2014 ${bh.I.toLocaleUpperCase()} or ${B("Alt")} `,children:GE})]})]})};import wh,{useEffect as vh,useImperativeHandle as n4,useState as r4}from"react";import{EVENT as Yy}from"@nous-excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as i4,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as a4,KEYS as s4}from"@nous-excalidraw/common";import G6 from"clsx";import{useEffect as U6,useRef as W6}from"react";import{isColorDark as F6}from"@nous-excalidraw/common";import{jsxs as H6}from"react/jsx-runtime";var z6=({color:e,keyLabel:o,isShade:t=!1})=>H6("div",{className:"color-picker__button__hotkey-label",style:{color:F6(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),ra=z6;import{jsx as xh,jsxs as Y6}from"react/jsx-runtime";var zy=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=Q(ro),a=W6(null);return U6(()=>{a.current&&a.current.focus()},[o,r]),xh("div",{className:"color-picker-content--default",children:e.map((s,l)=>Y6("button",{ref:o===s?a:void 0,tabIndex:-1,type:"button",className:G6("color-picker__button color-picker__button--large has-outline",{active:o===s,"is-transparent":s==="transparent"||!s}),onClick:()=>{t(s),i("custom")},title:s,"aria-label":n,style:{"--swatch-color":s},children:[xh("div",{className:"color-picker__button-outline"}),xh(ra,{color:s,keyLabel:l+1})]},l))})};import V6 from"clsx";import{useEffect as X6,useRef as K6}from"react";import{jsx as Eh,jsxs as Z6}from"react/jsx-runtime";var $6=({palette:e,color:o,onChange:t,activeShade:n,showHotKey:r=!0})=>{let i=er({color:o,palette:e}),[a,s]=Q(ro),l=K6(null);return X6(()=>{l.current&&a==="baseColors"&&l.current.focus()},[i?.colorName,a]),Eh("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,d],p)=>{let m=(Array.isArray(d)?d[n]:d)||"transparent",u=Js[p],f=g(`colors.${c.replace(/\d+/,"")}`,null,"");return Z6("button",{ref:i?.colorName===c?l:void 0,tabIndex:-1,type:"button",className:V6("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===c,"is-transparent":m==="transparent"||!m}),onClick:()=>{t(m),s("baseColors")},title:`${f}${m.startsWith("#")?` ${m}`:""} \u2014 ${u}`,"aria-label":`${f} \u2014 ${u}`,style:m?{"--swatch-color":m}:void 0,"data-testid":`color-${c}`,children:[Eh("div",{className:"color-picker__button-outline"}),r&&Eh(ra,{color:m,keyLabel:u})]},c)})})},Hy=$6;import{jsx as q6}from"react/jsx-runtime";var j6=({children:e})=>q6("div",{className:"color-picker__heading",children:e}),ia=j6;import J6 from"clsx";import{useEffect as Q6,useRef as e4}from"react";import{jsx as Qs,jsxs as Gy}from"react/jsx-runtime";var Uy=({color:e,onChange:o,palette:t,showHotKey:n})=>{let r=er({color:e||"transparent",palette:t}),[i,a]=Q(ro),s=e4(null);if(Q6(()=>{s.current&&i==="shades"&&s.current.focus()},[r,i]),r){let{colorName:l,shade:c}=r,d=t[l];if(Array.isArray(d))return Qs("div",{className:"color-picker-content--default shades",children:d.map((p,m)=>Gy("button",{ref:m===c&&i==="shades"?s:void 0,tabIndex:-1,type:"button",className:J6("color-picker__button color-picker__button--large has-outline",{active:m===c}),"aria-label":"Shade",title:`${l} - ${m+1}`,style:p?{"--swatch-color":p}:void 0,onClick:()=>{o(p),a("shades")},children:[Qs("div",{className:"color-picker__button-outline"}),n&&Qs(ra,{color:p,keyLabel:m+1,isShade:!0})]},m))})}return Gy("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Qs("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Qs("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:g("colorPicker.noShades")})]})};import{COLORS_PER_ROW as aa,COLOR_PALETTE as t4,KEYS as el}from"@nous-excalidraw/common";var yh=(e,o,t)=>{let n=Math.ceil(t/aa);switch(o=o??-1,e){case"ArrowLeft":{let r=o-1;return r<0?t-1:r}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let r=o+aa;return r>=t?o%aa:r}case"ArrowUp":{let r=o-aa,i=r<0?aa*n+r:r;return i>=t?void 0:i}}},o4=({e,colorObj:o,onChange:t,palette:n,customColors:r,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let s=Number(e.code.slice(-1))-1;return t(n[o.colorName][s]),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(Js.includes(e.key)){let s=Js.indexOf(e.key),l=Object.keys(n)[s],c=n[l],d=Array.isArray(c)?c[a]:c;return t(d),i("baseColors"),!0}return!1},Wy=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d})=>{if(e[el.CTRL_OR_CMD])return!1;if(e.key===el.ESCAPE)return d(e),!0;if(e.key===el.ALT)return c(!0),!0;if(e.key===el.I)return c(),!0;let p=er({color:n,palette:t});if(e.key===el.TAB){let m={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},u=Object.entries(m).reduce((w,[y,v])=>(v&&w.push(y),w),[]),f=u.indexOf(o),h=e.shiftKey?-1:1,x=f+h>u.length-1?0:f+h<0?u.length-1:f+h,E=u[x];return E&&a(E),E==="custom"?r(i[0]):E==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(n):v===n?y:null)||r(t4.black)),e.preventDefault(),e.stopPropagation(),!0}if(o4({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:l}))return!0;if(o==="shades"&&p){let{shade:m}=p,u=yh(e.key,m,aa);if(u!==void 0)return r(t[p.colorName][u]),!0}if(o==="baseColors"&&p){let{colorName:m}=p,u=Object.keys(t),f=u.indexOf(m),h=yh(e.key,f,u.length);if(h!==void 0){let x=u[h],E=t[x];return r(Array.isArray(E)?E[l]:E),!0}}if(o==="custom"){let m=n!=null?i.indexOf(n):0,u=yh(e.key,m,i.length);if(u!==void 0){let f=i[u];return r(f),!0}}return!1};import{jsx as tr,jsxs as fd}from"react/jsx-runtime";var Vy=wh.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:a,showTitle:s,onEyeDropperToggle:l,onEscape:c,showHotKey:d=!0},p)=>{let m=s?t==="elementStroke"?g("labels.stroke"):t==="elementBackground"?g("labels.background"):null:null,[u]=wh.useState(()=>t==="canvasBackground"?[]:Ny(n,t,r)),[f,h]=Q(ro),x=er({color:e,palette:r});vh(()=>{if(!f){let v=!!e&&gh({color:e,palette:r}),T=v&&!u.includes(e);h(T?null:v?"custom":x?.shade!=null?"shades":"baseColors")}},[f,e,r,h,x,u]);let[E,w]=r4(x?.shade??(t==="elementBackground"?i4:a4));vh(()=>{x?.shade!=null&&w(x.shade);let v=T=>{T.key===s4.ALT&&l(!1)};return document.addEventListener(Yy.KEYUP,v,{capture:!0}),()=>{document.removeEventListener(Yy.KEYUP,v,{capture:!0})}},[x,l]);let y=wh.useRef(null);return n4(p,()=>y.current),vh(()=>{y?.current?.focus()},[]),tr("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:fd("div",{ref:y,onKeyDown:v=>{Wy({event:v,activeColorPickerSection:f,palette:r,color:e,onChange:o,onEyeDropperToggle:l,customColors:u,setActiveColorPickerSection:h,updateData:i,activeShade:E,onEscape:c})&&(v.preventDefault(),v.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[m&&tr("div",{className:"color-picker__title",children:m}),!!u.length&&fd("div",{children:[tr(ia,{children:g("colorPicker.mostUsedCustomColors")}),tr(zy,{colors:u,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),fd("div",{children:[tr(ia,{children:g("colorPicker.colors")}),tr(Hy,{color:e,palette:r,onChange:o,activeShade:E,showHotKey:d})]}),fd("div",{children:[tr(ia,{children:g("colorPicker.shades")}),tr(Uy,{color:e,onChange:o,palette:r,showHotKey:d})]}),a]})})});import l4 from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as c4,DEFAULT_CANVAS_BACKGROUND_PICKS as d4,DEFAULT_ELEMENT_BACKGROUND_PICKS as m4,DEFAULT_ELEMENT_STROKE_PICKS as p4,isColorDark as u4}from"@nous-excalidraw/common";import{jsx as Th}from"react/jsx-runtime";var Xy=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=p4),o==="elementBackground"&&(r=m4),o==="canvasBackground"&&(r=d4),n&&(r=n),r?Th("div",{className:"color-picker__top-picks",children:r.map(i=>Th("button",{className:l4("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!u4(i,c4)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Th("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as io,jsxs as bd}from"react/jsx-runtime";var f4=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=Jy,updateData:a,getOpenPopup:s,appState:l})=>{let{container:c}=Ne(),d=dt(),p=d!=="full",m=d==="mobile",[,u]=Q(ro),[f,h]=Q(Jn),x=bd("div",{children:[io(ia,{children:g("colorPicker.hexCode")}),io(Fy,{color:o||"",label:n,onChange:y=>{t(y)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),E=qy(null),w=()=>{E.current?.focus()};return io(Tn,{container:c,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:y=>{g4(y.target)||w(),y.preventDefault()},onPointerDownOutside:y=>{f&&y.preventDefault()},onClose:()=>{s()===e&&a({openPopup:null}),u(null),l.editingTextElement&&setTimeout(()=>{let y=document.querySelector(".excalidraw-wysiwyg");y&&y.focus()},0)},children:i?io(Vy,{ref:E,palette:i,color:o,onChange:y=>{let v=l.editingTextElement?hd():null;t(y),l.editingTextElement&&v&&js(v)},onEyeDropperToggle:y=>{h(v=>y?(v=v||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},v.keepOpenOnAlt=!0,v):y===!1||v?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:y=>{f?h(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!m,children:x}):x})},b4=({label:e,color:o,type:t,mode:n="background",onToggle:r,editingTextElement:i})=>{let a=dt(),s=a!=="full",l=a==="mobile",c=d=>{d.preventDefault(),d.stopPropagation(),i&&Ry(),r()};return bd(Zy.Trigger,{type:"button",className:jy("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!$y(o,Ky),"compact-sizing":s,"mobile-border":l}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),"data-openpopup":t,onClick:c,children:[io("div",{className:"color-picker__button-outline",children:!o&&U0}),s&&o&&n==="stroke"&&io("div",{className:"color-picker__button-background",children:io("span",{style:{color:o&&$y(o,Ky)?"#fff":"#111"},children:uy})})]})},tl=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=Jy,topPicks:a,updateData:s,appState:l})=>{let c=qy(l.openPopup);h4(()=>{c.current=l.openPopup},[l.openPopup]);let p=dt()!=="full";return io("div",{children:bd("div",{role:"dialog","aria-modal":"true",className:jy("color-picker-container",{"color-picker-container--no-top-picks":p}),children:[!p&&io(Xy,{activeColor:o,onChange:t,type:e,topPicks:a}),!p&&io(dd,{}),bd(Zy.Root,{open:l.openPopup===e,onOpenChange:m=>{m&&s({openPopup:e})},children:[io(b4,{color:o,label:n,type:e,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&&io(f4,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:s,getOpenPopup:()=>c.current,appState:l})]})]})})};import{Popover as V4}from"radix-ui";import X4 from"clsx";import K4,{useCallback as $4,useMemo as Z4}from"react";import{FONT_FAMILY as kh}from"@nous-excalidraw/common";import N4,{useMemo as rr,useState as B4,useRef as ow,useEffect as nw,useCallback as rw}from"react";import{arrayToList as O4,debounce as F4,FONT_FAMILY as ir,getFontFamilyString as z4}from"@nous-excalidraw/common";import x4 from"clsx";import E4 from"react";import{jsx as y4,jsxs as w4}from"react/jsx-runtime";var xd=E4.forwardRef(({className:e,placeholder:o,onChange:t},n)=>w4("div",{className:x4("QuickSearch__wrapper",e),children:[Kt,y4("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import v4 from"clsx";import{Children as T4}from"react";import{jsx as Qy}from"react/jsx-runtime";var Ed=({className:e,placeholder:o,children:t})=>{let n=!T4.count(t);return Qy("div",{className:v4("ScrollableList__wrapper",e),role:"menu",children:n?Qy("div",{className:"empty",children:o}):t})};import{jsx as I4,jsxs as C4}from"react/jsx-runtime";var ew=({children:e,className:o="",style:t,title:n})=>C4("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&I4("p",{className:"dropdown-menu-group-title",children:n}),e]}),ol=ew;ew.displayName="DropdownMenuGroup";import{THEME as D4}from"@nous-excalidraw/common";import{DropdownMenu as R4}from"radix-ui";import S4,{useContext as k4}from"react";import{composeEventHandlers as M4}from"@nous-excalidraw/common";var Ih=S4.createContext({}),or=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),yd=e=>{let o=k4(Ih);return M4(e,t=>{o.onSelect?.(t)})};import{jsx as P4}from"react/jsx-runtime";var $r=({children:e,...o})=>P4("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as L4,jsx as nl,jsxs as _4}from"react/jsx-runtime";var A4=({textStyle:e,icon:o,shortcut:t,children:n,badge:r})=>{let i=be();return _4(L4,{children:[o&&nl("div",{className:"dropdown-menu-item__icon",children:o}),nl("div",{style:e,className:"dropdown-menu-item__text",children:nl($r,{children:n})}),r&&nl("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&nl("div",{className:"dropdown-menu-item__shortcut",children:t})]})},nr=A4;import{jsx as wd}from"react/jsx-runtime";var Ch=({icon:e,badge:o,value:t,children:n,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=yd(s);return wd(R4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:wd("button",{...l,value:t,className:or(i,a),title:l.title??l["aria-label"],children:wd(nr,{icon:e,shortcut:r,badge:o,children:n})})})};Ch.displayName="DropdownMenuItem";var sa={GREEN:"green",RED:"red",BLUE:"blue"},vd=({type:e=sa.BLUE,children:o})=>{let{theme:t}=jo(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===D4.LIGHT?"1.5px solid white":"none"};switch(e){case sa.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case sa.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case sa.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return wd("div",{className:"DropDownMenuItemBadge",style:n,children:o})};vd.displayName="DropdownMenuItemBadge";Ch.Badge=vd;var Pt=Ch;import{KEYS as la}from"@nous-excalidraw/common";var tw=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[la.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===la.F)return o.current?.focus(),!0;if(e.key===la.ESCAPE)return r(),!0;if(e.key===la.ENTER)return t?.value&&i(t.value),!0;if(e.key===la.ARROW_DOWN)return t?.next?a(t.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===la.ARROW_UP)return t?.prev?a(t.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as In,jsxs as U4}from"react/jsx-runtime";var H4=e=>{switch(e){case ir.Excalifont:case ir.Virgil:return Ko;case ir.Nunito:case ir.Helvetica:return Ys;case ir["Lilita One"]:return AE;case ir["Comic Shanns"]:case ir.Cascadia:return jc;default:return Ys}},G4=(e,o)=>Object.entries(ir).find(([,t])=>t===e)?.[0]??o[0]?.fontFace?.family??"Unknown",iw=N4.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=Ne(),l=He(),{fonts:c}=l,{showDeprecatedFonts:d}=qo(),p=dt(),[m,u]=B4(""),f=ow(null),h=rr(()=>Array.from(yn.registered.entries()).filter(([P,{metadata:D}])=>!D.private&&!D.fallback).map(([P,{metadata:D,fontFaces:z}])=>{let K={value:P,icon:H4(P),text:G4(P,z)};return D.deprecated&&Object.assign(K,{deprecated:D.deprecated,badge:{type:sa.RED,placeholder:g("fontList.badge.old")}}),K}).sort((P,D)=>P.text.toLowerCase()>D.text.toLowerCase()?1:-1),[]),x=rr(()=>new Set(c.getSceneFamilies()),[e]),E=rr(()=>h.filter(P=>x.has(P.value)),[h,x]),w=rr(()=>h.filter(P=>!x.has(P.value)&&(d||!P.deprecated)),[h,x,d]),y=rr(()=>O4([...E,...w].filter(P=>P.text?.toLowerCase().includes(m))),[E,w,m]),v=rr(()=>{let P;return o?P=y.find(D=>D.value===o):e&&(P=y.find(D=>D.value===e)),!P&&m&&(y[0]?.value?n(y[0].value):r()),P},[o,e,m,y,n,r]),T=rw(P=>{let D=null;if(l.state.editingTextElement){let z=document.querySelector(".excalidraw-wysiwyg");z&&(D={start:z.selectionStart,end:z.selectionEnd})}t(P),l.state.editingTextElement&&D&&setTimeout(()=>{let z=document.querySelector(".excalidraw-wysiwyg");z&&D&&(z.focus(),z.selectionStart=D.start,z.selectionEnd=D.end)},0)},[t,l.state.editingTextElement]),I=rw(P=>{tw({event:P,inputRef:f,hoveredFont:v,filteredFonts:y,onSelect:T,onHover:n,onClose:a})&&(P.preventDefault(),P.stopPropagation())},[v,y,T,n,a]);nw(()=>(i(),()=>{a()}),[]);let M=rr(()=>y.filter(P=>x.has(P.value)),[y,x]),S=rr(()=>y.filter(P=>!x.has(P.value)),[y,x]),_=({font:P,order:D})=>{let z=ow(null),K=P.value===v?.value,W=P.value===e;return nw(()=>{K&&(D===0?z.current?.scrollIntoView?.({block:"end"}):z.current?.scrollIntoView?.({block:"nearest"}))},[K,D]),In("button",{ref:z,type:"button",value:P.value,className:or("",W,K),title:P.text,tabIndex:W?0:-1,onClick:Y=>{T(Number(Y.currentTarget.value))},onMouseMove:()=>{v?.value!==P.value&&n(P.value)},children:In(nr,{icon:P.icon,badge:P.badge&&In(vd,{type:P.badge.type,children:P.badge.placeholder}),textStyle:{fontFamily:z4({fontFamily:P.value})},children:P.text})})},A=[];return M.length&&A.push(In(ol,{title:g("fontList.sceneFonts"),children:M.map((P,D)=>In(_,{font:P,order:D},P.value))},"group_1")),S.length&&A.push(In(ol,{title:g("fontList.availableFonts"),children:S.map((P,D)=>In(_,{font:P,order:D+M.length},P.value))},"group_2")),U4(Tn,{className:"properties-content",container:s,style:{width:"15rem"},onClose:()=>{a(),l.state.editingTextElement&&setTimeout(()=>{let P=document.querySelector(".excalidraw-wysiwyg");P&&P.focus()},0)},onPointerLeave:r,onKeyDown:I,preventAutoFocusOnTouch:!!l.state.editingTextElement,children:[p==="full"&&In(xd,{ref:f,placeholder:g("quickSearch.placeholder"),onChange:F4(u,20)}),In(Ed,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:A.length?A:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import{Popover as W4}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as Y4}from"@nous-excalidraw/common";import{jsx as Sh}from"react/jsx-runtime";var aw=({selectedFontFamily:e,isOpened:o=!1,compactMode:t=!1})=>{let n=he(),r=t?{...Y4,width:"2rem",height:"2rem"}:{};return Sh(W4.Trigger,{asChild:!0,children:Sh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Sh(oa,{standalone:!0,icon:$o,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{n(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as rl,jsxs as sw}from"react/jsx-runtime";var lw=[{value:kh.Excalifont,icon:Ko,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:kh.Nunito,icon:Ys,text:g("labels.normal"),testId:"font-family-normal"},{value:kh["Comic Shanns"],icon:jc,text:g("labels.code"),testId:"font-family-code"}],$oe=new Set(lw.map(e=>e.value));var cw=K4.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=Z4(()=>lw,[]),c=$4(d=>{d&&n(d)},[n]);return sw("div",{role:"dialog","aria-modal":"true",className:X4("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&rl("div",{className:"buttonList",children:rl(no,{type:"button",options:l,value:o,onClick:c})}),!s&&rl(dd,{}),sw(V4.Root,{open:e,onOpenChange:a,children:[rl(aw,{selectedFontFamily:o,isOpened:e,compactMode:s}),e&&rl(iw,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import{Popover as Mh}from"radix-ui";import Q4 from"clsx";import uw,{useEffect as eL,useMemo as tL}from"react";import{isArrowKey as oL,KEYS as Cn}from"@nous-excalidraw/common";import{jsx as j4}from"react/jsx-runtime";var Jo=({className:e,icon:o,size:t="1em"})=>j4("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:o});import{Fragment as J4,jsx as dw,jsxs as mw}from"react/jsx-runtime";var q4=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>mw(J4,{children:[mw("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&dw(Jo,{icon:o?dy:ed})]}),o&&dw("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),il=q4;import{jsx as Qo,jsxs as Id}from"react/jsx-runtime";var nL=fe(!1),Td=4,rL="default",iL=e=>e.flatMap(o=>o.options),pw=(e,o)=>{for(let t of e){let n=t.options.find(o);if(n)return n}return null},aL=(e,o)=>e.some(t=>t.options.some(o)),sL=e=>e.flatMap(o=>Array.from({length:Math.ceil(o.options.length/Td)},(t,n)=>o.options.slice(n*Td,n*Td+Td)));function lL({visibleSections:e,hiddenSections:o=[],value:t,label:n,onChange:r,onClose:i}){let{container:a}=Ne(),[s,l]=Q(nL),c=[...e,...o],d=iL(c),p=sL([...e,...s?o:[]]),m=h=>{let x=d.find(E=>E.keyBinding===h.key.toLowerCase());if(!(h.metaKey||h.altKey||h.ctrlKey)&&x)r(x.value),h.preventDefault();else if(h.key===Cn.TAB){let E=d.findIndex(y=>y.value===t),w=h.shiftKey?(d.length+E-1)%d.length:(E+1)%d.length;r(d[w].value)}else if(oL(h.key)){let E=vn().rtl,w=d.findIndex(y=>y.value===t);if(w!==-1){let y=d.length,v=w;switch(h.key){case(E?Cn.ARROW_LEFT:Cn.ARROW_RIGHT):v=(w+1)%y;break;case(E?Cn.ARROW_RIGHT:Cn.ARROW_LEFT):v=(y+w-1)%y;break;case Cn.ARROW_DOWN:{let T=p.findIndex(M=>M.some(S=>S.value===t)),I=p[T];if(T!==-1&&I){let M=I.findIndex(A=>A.value===t),S=p[(T+1)%p.length],_=S[Math.min(M,S.length-1)]??d[w];r(_.value),h.preventDefault(),h.nativeEvent.stopImmediatePropagation(),h.stopPropagation();return}break}case Cn.ARROW_UP:{let T=p.findIndex(M=>M.some(S=>S.value===t)),I=p[T];if(T!==-1&&I){let M=I.findIndex(A=>A.value===t),S=p[(p.length+T-1)%p.length],_=S[Math.min(M,S.length-1)]??d[w];r(_.value),h.preventDefault(),h.nativeEvent.stopImmediatePropagation(),h.stopPropagation();return}break}}r(d[v].value)}h.preventDefault()}else(h.key===Cn.ESCAPE||h.key===Cn.ENTER)&&(h.preventDefault(),i());h.nativeEvent.stopImmediatePropagation(),h.stopPropagation()};eL(()=>{aL(o,h=>h.value===t)&&l(!0)},[t,o,l]);let u=h=>Qo("div",{className:"picker-content",children:h.map(x=>Id("button",{type:"button",className:Q4("picker-option",{active:t===x.value}),onClick:()=>{r(x.value)},title:x.keyBinding?`${x.text} \u2014 ${x.keyBinding.toUpperCase()}`:x.text,"aria-label":x.text||"none","aria-keyshortcuts":x.keyBinding||void 0,ref:E=>{t===x.value&&setTimeout(()=>{E?.focus()},0)},children:[x.icon,x.keyBinding&&Qo("span",{className:"picker-keybinding",children:x.keyBinding})]},x.text))}),f=h=>h.map((x,E)=>x.name===rL?Qo(uw.Fragment,{children:u(x.options)},`${x.name}-${E}`):Id("div",{className:"picker-section",children:[Qo("div",{className:"picker-section-label",children:x.name}),u(x.options)]},`${x.name}-${E}`));return Qo(Mh.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":n,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:m,collisionBoundary:a??void 0,children:Id("div",{className:"picker-sections",children:[f(e),o.length>0&&Qo(il,{label:g("labels.more_options"),open:s,openTrigger:()=>{l(h=>!h)},className:"picker-collapsible",children:Qo("div",{className:"picker-sections",children:f(o)})})]})})}function Ph({value:e,label:o,visibleSections:t,hiddenSections:n,onChange:r}){let[i,a]=uw.useState(!1),s=tL(()=>pw(t,l=>l.value===e)??pw(n??[],l=>l.value===e),[t,n,e]);return Qo("div",{children:Id(Mh.Root,{open:i,onOpenChange:l=>a(l),children:[Qo(Mh.Trigger,{type:"button","aria-label":o,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&Qo(lL,{visibleSections:t,hiddenSections:n,value:e,label:o,onChange:r,onClose:()=>{a(!1)}})]})})}import hw,{useEffect as cL}from"react";import{jsx as Ah,jsxs as gw}from"react/jsx-runtime";var fw=({label:e,value:o,onChange:t,min:n=0,max:r=100,step:i=10,minLabel:a=n,hasCommonValue:s=!0,testId:l})=>{let c=hw.useRef(null),d=hw.useRef(null);return cL(()=>{if(c.current&&d.current){let p=c.current,m=d.current,u=p.offsetWidth,f=parseFloat(getComputedStyle(p).getPropertyValue("--slider-thumb-size"))||16,h=(o-n)/(r-n||1)*100,x=h/100*(u-f)+f/2;m.style.left=`${x}px`,p.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${h}%, var(--button-bg) ${h}%, var(--button-bg) 100%)`}},[r,n,o]),gw("label",{className:"control-label",children:[e,gw("div",{className:"range-wrapper",children:[Ah("input",{style:{"--color-slider-track":s?void 0:"var(--button-bg)"},ref:c,type:"range",min:n,max:r,step:i,onChange:p=>{t(+p.target.value)},value:o,className:"range-input","data-testid":l}),Ah("div",{className:"value-bubble",ref:d,children:o!==n?o:null}),Ah("div",{className:"zero-label",children:a})]})]})};import{Fragment as Hh,jsx as re,jsxs as Lt}from"react/jsx-runtime";var Iw=.1,da=e=>{let o=DL(e.editorInterface);return{stylesPanelMode:o,isCompact:o!=="full",isMobile:o==="mobile"}},At=(e,o,t,n=!1)=>{let r=Nh(ie(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},xt=function(e,o,t,n,r){let i=o.state.editingTextElement,a=vw(e),s=null;if(i&&(s=t(i)),!s)if(Ae(a,o.state)){let c=o.scene.getSelectedElements(o.state),d=n===!0?c:c.filter(p=>n(p));s=CL(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},RL=(e,o,t)=>ML(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),Oh=(e,o,t,n,r)=>{let i=new Set,a=At(e,o,s=>{if(Ft(s)){let l=n(s);i.add(l);let c=at(s,{fontSize:l});return al(c,t.scene.getContainerElement(s),t.scene),c=RL(s,c,t.scene),c}return s},!0);return ie(e,o,{includeBoundTextElement:!0}).forEach(s=>{Ft(s)&&kL(s,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:st.IMMEDIATELY}},NL=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t?.currentItemStrokeColor&&{elements:At(e,o,n=>AL(n.type)?at(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t?.currentItemStrokeColor?st.IMMEDIATELY:st.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=da(n);return Lt(Hh,{children:[i==="full"&&re("h3",{"aria-hidden":"true",children:g("labels.stroke")}),re(tl,{topPicks:gL,palette:hL,type:"elementStroke",label:g("labels.stroke"),color:xt(e,n,a=>a.strokeColor,!0,a=>a?null:o.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:o,updateData:t})]})}}),BL=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t?.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:st.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!IL(t.currentItemBackgroundColor)&&i.every(s=>yw(s)&&SL(s.points))){let s=Nh(i);r=e.map(l=>s.has(l.id)&&yw(l)?at(l,{backgroundColor:t.currentItemBackgroundColor,..._L(l,!0)}):l)}else r=At(e,o,s=>at(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:st.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=da(n);return Lt(Hh,{children:[i==="full"&&re("h3",{"aria-hidden":"true",children:g("labels.background")}),re(tl,{topPicks:uL,palette:pL,type:"elementBackground",label:g("labels.background"),color:xt(e,n,a=>a.backgroundColor,!0,a=>a?null:o.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:o,updateData:t})]})}}),OL=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(me("element","changeFillStyle",`${t} (${n.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:At(e,o,r=>at(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=ie(e,o),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return Lt("fieldset",{children:[re("legend",{children:g("labels.fill")}),re("div",{className:"buttonList",children:re(no,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${B("Alt-Click")})`,icon:i?J0:Q0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:eE,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:tE,testId:"fill-solid"}],value:xt(e,n,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,s)=>{let l=s.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(l)}})})]})}}),FL=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:At(e,o,n=>at(n,{strokeWidth:t,customData:{...n.customData,[xL]:!0}})),appState:{...o,currentItemStrokeWidth:t,currentItemStrokeWidthCustom:!0},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=EL(o.zoom.value);return Lt("fieldset",{children:[re("legend",{children:g("labels.strokeWidth")}),re("div",{className:"buttonList",children:re(no,{group:"stroke-width",options:[{value:i.thin,text:g("labels.thin"),icon:$u,testId:"strokeWidth-thin"},{value:i.bold,text:g("labels.bold"),icon:oE,testId:"strokeWidth-bold"},{value:i.extraBold,text:g("labels.extraBold"),icon:nE,testId:"strokeWidth-extraBold"}],value:xt(e,n,a=>a.strokeWidth,a=>a.hasOwnProperty("strokeWidth"),a=>a?null:o.currentItemStrokeWidth),onChange:a=>t(a)})})]})}}),zL=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:At(e,o,n=>at(n,{seed:wL(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>Lt("fieldset",{children:[re("legend",{children:g("labels.sloppiness")}),re("div",{className:"buttonList",children:re(no,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:aE},{value:1,text:g("labels.artist"),icon:sE},{value:2,text:g("labels.cartoonist"),icon:lE}],value:xt(e,n,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:o.currentItemRoughness),onChange:i=>t(i)})})]})}),Qne=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:At(e,o,n=>at(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>Lt("fieldset",{children:[re("legend",{children:g("labels.strokeStyle")}),re("div",{className:"buttonList",children:re(no,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:$u},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:rE},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:iE}],value:xt(e,n,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:o.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),HL=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:At(e,o,n=>at(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=xt(e,t,i=>i.opacity,!0,i=>i?null:o.currentItemOpacity);return re(fw,{label:g("labels.opacity"),value:r??o.currentItemOpacity,hasCommonValue:r!==null,onChange:n,min:0,max:100,step:10,testId:"opacity"})}}),GL=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>Oh(e,o,n,()=>(Bh(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=da(n),a=yL(o.zoom.value);return Lt("fieldset",{children:[re("legend",{children:g("labels.fontSize")}),re("div",{className:"buttonList",children:re(no,{group:"font-size",options:[{value:a.sm,text:g("labels.small"),icon:SE,testId:"fontSize-small"},{value:a.md,text:g("labels.medium"),icon:kE,testId:"fontSize-medium"},{value:a.lg,text:g("labels.large"),icon:ME,testId:"fontSize-large"},{value:a.xl,text:g("labels.veryLarge"),icon:PE,testId:"fontSize-veryLarge"}],value:xt(e,n,s=>{if(Ft(s))return s.fontSize;let l=ar(s,n.scene.getNonDeletedElementsMap());return l?l.fontSize:null},s=>Ft(s)||ar(s,n.scene.getNonDeletedElementsMap())!==null,s=>s?null:o.currentItemFontSize||a.md),onChange:s=>{qs(()=>t(s),i,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),Fh=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Xr,trackEvent:!1,perform:(e,o,t,n)=>Oh(e,o,n,r=>Math.round(1/(1+Iw)*r.fontSize)),keyTest:e=>e[ca.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ca.CHEVRON_LEFT||e.key===ca.COMMA)}),zh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Xr,trackEvent:!1,perform:(e,o,t,n)=>Oh(e,o,n,r=>Math.round(r.fontSize*(1+Iw))),keyTest:e=>e[ca.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ca.CHEVRON_RIGHT||e.key===ca.PERIOD)}),UL=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,n)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...s}=t;if(i)return{elements:At(e,o,h=>{let x=r?.get(h.id);return x?at(h,{...x}):h},!0),appState:{...o,...s},captureUpdate:st.NEVER};Bh(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=st.EVENTUALLY,p,m=!1;if(l)p=l,d=st.IMMEDIATELY;else if(c){p=c,d=st.EVENTUALLY;let f=ie(e,o,{includeBoundTextElement:!0}).filter(h=>Ft(h));if(f.length>200)m=!0;else{let h=0,x=0;for(;h<f.length&&x<5e3;){let E=f[h];x+=E?.originalText.length||0,h++}x>5e3&&(m=!0)}}let u={appState:{...o,...s},captureUpdate:d};if(p&&!m){let f=new Map,h=new Set,x=!1,E=Array.from(yn.loadedFontsCache.values()),w=Object.entries(bL).find(([T,I])=>I===p)?.[0];c&&w&&E.some(T=>T.startsWith(w))&&(x=!0),Object.assign(u,{elements:At(e,o,T=>{if(Ft(T)&&(T.fontFamily!==p||l)){let I=at(T,{fontFamily:p,lineHeight:TL(p)}),M=r?.get(T.containerId||"")||{},S=n.scene.getContainerElement(T);return a&&S&&M&&n.scene.mutateElement(S,{...M}),x||(h=new Set([...h,...Array.from(I.originalText)])),f.set(I,S),I}return T},!0)});let y=`10px ${vL({fontFamily:p})}`,v=Array.from(h.values()).join();if(x||window.document.fonts.check(y,v))for(let[T,I]of f)al(T,I,n.scene);else window.document.fonts.load(y,v).then(T=>{for(let[I,M]of f){let S=n.scene.getElement(I.id),_=M?n.scene.getElement(M.id):null;S&&al(S,_,n.scene)}n.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=_h(new Map),i=_h(null),[a,s]=mL({}),l=_h(!0),{stylesPanelMode:c,isCompact:d}=da(t),p=Rh(()=>{let m=(u,f)=>xt(u,t,h=>{if(Ft(h))return h.fontFamily;let x=ar(h,f);return x?x.fontFamily:null},h=>Ft(h)||ar(h,f)!==null,h=>h?null:o.currentItemFontFamily||fL);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?m(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&o.openPopup!=="fontFamily"?m(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return Lh(()=>{i.current=p},[p]),Lh(()=>{Object.keys(a).length&&(n(a),s({}))},[a]),Lh(()=>(l.current=!1,()=>{l.current=!0}),[]),Lt(Hh,{children:[c==="full"&&re("legend",{children:g("labels.fontFamily")}),re(cw,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:p,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:c!=="full",onSelect:m=>{qs(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:m}),r.current.clear()},d,!!o.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}=o;if(u?.type==="text"){let f=t.scene.getElement(u.id);r.current.set(u.id,at(f||u,{},!0))}else{let f=ie(e,o,{includeBoundTextElement:!0});for(let h of f)r.current.set(h.id,at(h,{},!0))}s({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s({...u}),r.current.clear(),d&&o.editingTextElement&&js(null)}}})]})}}),WL=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:At(e,o,r=>{if(Ft(r)){let i=at(r,{textAlign:t});return al(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=n.scene.getNonDeletedElementsMap(),{isCompact:a}=da(n);return Lt("fieldset",{children:[re("legend",{children:g("labels.textAlign")}),re("div",{className:"buttonList",children:re(no,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:LE,testId:"align-left"},{value:"center",text:g("labels.center"),icon:_E,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:DE,testId:"align-right"}],value:xt(e,n,s=>{if(Ft(s))return s.textAlign;let l=ar(s,i);return l?l.textAlign:null},s=>Ft(s)||ar(s,i)!==null,s=>s?null:o.currentItemTextAlign),onChange:s=>{qs(()=>t(s),a,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),YL=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:At(e,o,r=>{if(Ft(r)){let i=at(r,{verticalAlign:t});return al(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=da(n);return re("fieldset",{children:re("div",{className:"buttonList",children:re(no,{group:"text-align",options:[{value:Cd.TOP,text:g("labels.alignTop"),icon:re(RE,{theme:o.theme}),testId:"align-top"},{value:Cd.MIDDLE,text:g("labels.centerVertically"),icon:re(BE,{theme:o.theme}),testId:"align-middle"},{value:Cd.BOTTOM,text:g("labels.alignBottom"),icon:re(NE,{theme:o.theme}),testId:"align-bottom"}],value:xt(e,n,a=>{if(Ft(a)&&a.containerId)return a.verticalAlign;let s=ar(a,n.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Ft(a)||ar(a,n.scene.getNonDeletedElementsMap())!==null,a=>a?null:Cd.MIDDLE),onChange:a=>{qs(()=>t(a),i,!!o.editingTextElement,r?.onPreventClose)}})})})}}),ere=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:At(e,o,n=>Tw(n)?n:at(n,{roundness:t==="round"?{type:PL(n.type)?Sd.ADAPTIVE_RADIUS:Sd.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let a=ki(vw(e),o).some(s=>s.roundness?.type===Sd.LEGACY);return Lt("fieldset",{children:[re("legend",{children:g("labels.edges")}),Lt("div",{className:"buttonList",children:[re(no,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:cE},{value:"round",text:g("labels.round"),icon:dE}],value:xt(e,n,s=>a?null:s.roundness?"round":"sharp",s=>!kd(s)&&s.hasOwnProperty("roundness"),s=>s?null:o.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),ww=e=>({visibleSections:[{name:"default",options:[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:re(mE,{flip:e})},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:re(pE,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:re(uE,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:re(hE,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:re(gE,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:re(fE,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:re(bE,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:re(xE,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:re(EE,{flip:e})}]},{name:g("labels.cardinality"),options:[{value:"cardinality_one",text:g("labels.arrowhead_cardinality_one"),icon:re(yE,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:g("labels.arrowhead_cardinality_many"),icon:re(wE,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:g("labels.arrowhead_cardinality_one_or_many"),icon:re(vE,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:g("labels.arrowhead_cardinality_exactly_one"),icon:re(TE,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:g("labels.arrowhead_cardinality_zero_or_one"),icon:re(IE,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:g("labels.arrowhead_cardinality_zero_or_many"),icon:re(CE,{flip:e}),keyBinding:null}]}]}),tre=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>(Bh(t,"actionChangeArrowhead: value must be defined"),{elements:At(e,o,n=>{if(Dh(n)){let{position:r,type:i}=t;if(r==="start")return at(n,{startArrowhead:i});if(r==="end")return at(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=vn().rtl,i=Rh(()=>ww(!r),[r]),a=Rh(()=>ww(!!r),[r]);return Lt("fieldset",{children:[re("legend",{children:g("labels.arrowheads")}),Lt("div",{className:"iconSelectList buttonList",children:[re(Ph,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:xt(e,n,s=>Dh(s)&&Mi(s.type)?Ew(s.startArrowhead):o.currentItemStartArrowhead,!0,s=>s?null:o.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),re(Ph,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:xt(e,n,s=>Dh(s)&&Mi(s.type)?Ew(s.endArrowhead):o.currentItemEndArrowhead,!0,s=>s?null:o.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),VL=O({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,o,t,n)=>!1,PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>Lt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),ore=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=At(e,o,s=>{if(!kd(s))return s;let l=n.scene.getNonDeletedElementsMap(),c=Zr.getPointAtIndexGlobalCoordinates(s,0,l),d=Zr.getPointAtIndexGlobalCoordinates(s,-1,l),p=at(s,{x:t===ao.elbow?c[0]:s.x,y:t===ao.elbow?c[1]:s.y,roundness:t===ao.round?{type:Sd.PROPORTIONAL_RADIUS}:null,elbowed:t===ao.elbow,angle:t===ao.elbow?0:s.angle,points:t===ao.elbow||s.elbowed?[Zr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),Zr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(Tw(p)){p.fixedSegments=null;let m=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let u=Zr.getPointAtIndexGlobalCoordinates(p,0,m),f=Zr.getPointAtIndexGlobalCoordinates(p,-1,m),h=p.startBinding&&m.get(p.startBinding.elementId),x=p.endBinding&&m.get(p.endBinding.elementId),E=h&&p.startBinding?{...p.startBinding,...xw(p,h,"start",m,o.isBindingEnabled)}:null,w=x&&p.endBinding?{...p.endBinding,...xw(p,x,"end",m,o.isBindingEnabled)}:null;p={...p,startBinding:E,endBinding:w,...LL(p,m,{points:[u,f].map(y=>dL(y[0]-p.x,y[1]-p.y)),startBinding:E,endBinding:w,fixedSegments:null})}}else{let m=n.scene.getNonDeletedElementsMap();if(p.startBinding){let u=m.get(p.startBinding.elementId);u&&bw(p,u,o.bindMode==="inside"?"inside":"orbit","start",n.scene)}if(p.endBinding){let u=m.get(p.endBinding.elementId);u&&bw(p,u,o.bindMode==="inside"?"inside":"orbit","end",n.scene)}}return p}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let s=r.find(l=>l.id===a);s&&(i.selectedLinearElement=new Zr(s,Nh(e)))}return{elements:r,appState:i,captureUpdate:st.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Lt("fieldset",{children:[re("legend",{children:g("labels.arrowtypes")}),re("div",{className:"buttonList",children:re(no,{group:"arrowtypes",options:[{value:ao.sharp,text:g("labels.arrowtype_sharp"),icon:qi,testId:"sharp-arrow"},{value:ao.round,text:g("labels.arrowtype_round"),icon:Qi,testId:"round-arrow"},{value:ao.elbow,text:g("labels.arrowtype_elbowed"),icon:Ji,testId:"elbow-arrow"}],value:xt(e,n,r=>kd(r)?r.elbowed?ao.elbow:r.roundness?ao.round:ao.sharp:null,r=>kd(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})});import{clamp as Vh,roundToStep as e_}from"@nous-excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as t_,CURSOR_TYPE as Pw,MAX_ZOOM as Aw,MIN_ZOOM as Lw,THEME as sl,ZOOM_STEP as o_,getInteractiveZoomStep as _w,getDisplayedZoomValue as Dw,getDefaultSceneFontSizeForZoom as n_,scaleStrokeWidthForZoomChange as r_,updateActiveTool as pa,CODES as tn,KEYS as kn}from"@nous-excalidraw/common";import{getNonDeletedElements as i_,syncElementsStrokeWidthForZoom as Md}from"@nous-excalidraw/element";import{newElementWith as a_}from"@nous-excalidraw/element";import{getCommonBounds as s_}from"@nous-excalidraw/element";import{CaptureUpdateAction as So}from"@nous-excalidraw/element";import{useEffect as XL}from"react";import{jsx as $L}from"react/jsx-runtime";var ma=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},Gh=(e,o,t="bottom")=>{let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,s=o.left+o.width/2-n.width/2;s<0?s=a:s+n.width>=r&&(s=r-n.width-a);let l;t==="bottom"?(l=o.top+o.height+a,l+n.height>=i&&(l=o.top-n.height-a)):(l=o.top-n.height-a,l<0&&(l=o.top+o.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},KL=(e,o,t,n)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=n?"50ch":"10ch",o.style.maxWidth=n?"50ch":"15ch",o.textContent=t;let r=e.getBoundingClientRect();Gh(o,r)},$t=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(XL(()=>()=>ma().classList.remove("excalidraw-tooltip--visible"),[]),r?null:$L("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>KL(i.currentTarget,ma(),o,t),onPointerLeave:()=>ma().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import{CURSOR_TYPE as Uh,MIME_TYPES as Wh,THEME as Sw}from"@nous-excalidraw/common";var kw='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',ZL='<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"/>',Mw='<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"/>',jL=`data:${Wh.svg},${encodeURIComponent(`${kw}${Mw}</svg>`)}`,qL=`data:${Wh.svg},${encodeURIComponent(`${kw}${ZL}${Mw}</svg>`)}`,Zt=e=>{e&&(e.style.cursor="")},ve=(e,o)=>{e&&(e.style.cursor=o)},en,Cw,Yh=(e,o)=>{let n=()=>{let r=o===Sw.DARK;en=document.createElement("canvas"),en.theme=o,en.height=20,en.width=20;let i=en.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(en.width/2,en.height/2,5,0,2*Math.PI),i.fillStyle=r?"#000":"#fff",i.fill(),i.strokeStyle=r?"#fff":"#000",i.stroke(),Cw=en.toDataURL(Wh.svg)};(!en||en.theme!==o)&&n(),ve(e,`url(${Cw}) ${20/2} ${20/2}, auto`)},jt=(e,o)=>{if(e)if(o.activeTool.type==="selection")Zt(e);else if(wn(o))e.style.cursor=Uh.GRAB;else if(Ot(o))Yh(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===Sw.LIGHT?jL:qL;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Uh.AUTO):e.style.cursor=Uh.CROSSHAIR};import{getDefaultSceneFontSizeForZoom as JL,scaleStrokeWidthForZoomChange as QL}from"@nous-excalidraw/common";var Sn=({viewportX:e,viewportY:o,nextZoom:t},n)=>{let r=e-n.offsetLeft,i=o-n.offsetTop,a=n.zoom.value,s=n.scrollX+(r-r/a),l=n.scrollY+(i-i/a),c=-(r-r/t),d=-(i-i/t);return{scrollX:s+c,scrollY:l+d,zoom:{value:t},currentItemStrokeWidth:QL(n.currentItemStrokeWidth,a,t,n.currentItemStrokeWidthCustom),currentItemFontSize:JL(t)}};import{jsx as _d,jsxs as m_}from"react/jsx-runtime";var l_=O({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t?.viewBackgroundColor?So.IMMEDIATELY:So.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n,data:r})=>_d(tl,{palette:null,topPicks:t_,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),Mn=O({name:"clearCanvas",label:"labels.clearCanvas",icon:ft,trackEvent:{category:"canvas"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,n)=>(n.imageCache.clear(),{elements:e.map(r=>a_(r,{isDeleted:!0})),appState:{...Yo(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:n.state.preferredSelectionTool.type}:o.activeTool},captureUpdate:So.IMMEDIATELY})}),Pd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Lu,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=Dw(o.zoom.value),i=Sn({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:To(r+_w(o.zoom.value,"in"))},o);return{elements:Md(e,o.zoom.value,i.zoom.value),appState:{...o,...i,userToFollow:null},captureUpdate:So.EVENTUALLY}},PanelComponent:({updateData:e,appState:o})=>_d(q,{type:"button",className:"zoom-in-button zoom-button",icon:Lu,title:`${g("buttons.zoomIn")} \u2014 ${B("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=Aw,onClick:()=>{e(null)}}),keyTest:e=>(e.code===tn.EQUAL||e.code===tn.NUM_ADD)&&(e[kn.CTRL_OR_CMD]||e.shiftKey)}),Ad=O({name:"zoomOut",label:"buttons.zoomOut",icon:_u,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=Dw(o.zoom.value),i=Sn({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:To(r-_w(o.zoom.value,"out"))},o);return{elements:Md(e,o.zoom.value,i.zoom.value),appState:{...o,...i,userToFollow:null},captureUpdate:So.EVENTUALLY}},PanelComponent:({updateData:e,appState:o})=>_d(q,{type:"button",className:"zoom-out-button zoom-button",icon:_u,title:`${g("buttons.zoomOut")} \u2014 ${B("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=Lw,onClick:()=>{e(null)}}),keyTest:e=>(e.code===tn.MINUS||e.code===tn.NUM_SUBTRACT)&&(e[kn.CTRL_OR_CMD]||e.shiftKey)}),Ld=O({name:"resetZoom",label:"buttons.resetZoom",icon:N0,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=Sn({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:To(1)},o);return{elements:Md(e,o.zoom.value,r.zoom.value),appState:{...o,...r,userToFollow:null},captureUpdate:So.EVENTUALLY}},PanelComponent:({updateData:e,appState:o})=>_d($t,{label:g("buttons.resetZoom"),style:{height:"100%"},children:m_(q,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===tn.ZERO||e.code===tn.NUM_ZERO)&&(e[kn.CTRL_OR_CMD]||e.shiftKey)}),c_=(e,o,t=1)=>{let[n,r,i,a]=e,s=i-n,l=o.width/s,c=a-r,d=o.height/c,m=Math.min(l,d)*Vh(t,.1,1);return Math.min(m,1)},Rw=({bounds:e,appState:o,canvasOffsets:t,fitCanvasOffsets:n,scrollCanvasOffsets:r,fitToViewport:i=!1,viewportZoomFactor:a=1,minZoom:s=-1/0,maxZoom:l=1/0,elements:c})=>{a=Vh(a,Lw,Aw);let[d,p,m,u]=e,f=(d+m)/2,h=(p+u)/2,x=n??t,E=r??x??t,w=x?.left??0,y=x?.top??0,v=x?.right??0,T=x?.bottom??0,I=o.width-w-v,M=o.height-y-T,S;if(i){let D=m-d,z=u-p;S=Math.min(I/D,M/z)*a}else S=c_(e,{width:I,height:M},a);let _=To(Vh(e_(S,o_,"floor"),s,l)),A=Jx({scenePoint:{x:f,y:h},viewportDimensions:{width:o.width,height:o.height},offsets:E,zoom:{value:_}}),P=o.zoom.value;return{appState:{...o,scrollX:A.scrollX,scrollY:A.scrollY,zoom:{value:_},currentItemStrokeWidth:r_(o.currentItemStrokeWidth,P,_,o.currentItemStrokeWidthCustom),currentItemFontSize:n_(_)},...c&&{elements:Md(c,P,_)},captureUpdate:So.EVENTUALLY}},ua=({canvasOffsets:e,fitCanvasOffsets:o,scrollCanvasOffsets:t,targetElements:n,appState:r,fitToViewport:i,viewportZoomFactor:a,minZoom:s,maxZoom:l,elements:c})=>{let d=s_(i_(n));return Rw({canvasOffsets:e,fitCanvasOffsets:o,scrollCanvasOffsets:t,bounds:d,appState:r,fitToViewport:i,viewportZoomFactor:a,minZoom:s,maxZoom:l,elements:c})},zre=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Qc,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return ua({targetElements:r.length?r:e,elements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===tn.TWO&&e.shiftKey&&!e.altKey&&!e[kn.CTRL_OR_CMD]}),Hre=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Qc,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return ua({targetElements:r.length?r:e,elements:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===tn.THREE&&e.shiftKey&&!e.altKey&&!e[kn.CTRL_OR_CMD]}),d_=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Qc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>ua({targetElements:e,elements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===tn.ONE&&e.shiftKey&&!e.altKey&&!e[kn.CTRL_OR_CMD]}),jr=O({name:"toggleTheme",label:(e,o)=>o.theme===sl.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,o)=>e.theme===sl.LIGHT?Gs:Us,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===sl.LIGHT?sl.DARK:sl.LIGHT)},captureUpdate:So.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===tn.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),Gre=O({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return Ot(o)?r=pa(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):r=pa(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:So.IMMEDIATELY}},keyTest:e=>e.key===kn.E}),Ure=O({name:"toggleLassoTool",label:"toolBar.lasso",icon:$n,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.state.preferredSelectionTool.type!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=pa(o,{type:"lasso",fromSelection:!1}),ve(n.interactiveCanvas,Pw.CROSSHAIR)):r=pa(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:So.NEVER}}}),Nw=O({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Ki,viewMode:!1,perform:(e,o,t,n)=>{let r;return wn(o)?r=pa(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=pa(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),ve(n.interactiveCanvas,Pw.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:So.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[kn.CTRL_OR_CMD]&&e.key===kn.H});import{updateActiveTool as Bw}from"@nous-excalidraw/common";import{CaptureUpdateAction as p_}from"@nous-excalidraw/element";var u_=O({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=Bw(o,{type:"embeddable"});return jt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:Bw(o,{type:"embeddable"})},captureUpdate:p_.EVENTUALLY}}});import{pointFrom as Ow}from"@nous-excalidraw/math";import{bindOrUnbindBindingElement as h_}from"@nous-excalidraw/element/binding";import{isValidPolygon as Fw,LinearElementEditor as Dd,newElementWith as Xh}from"@nous-excalidraw/element";import{isBindingElement as zw,isFreeDrawElement as Hw,isLinearElement as Gw,isLineElement as Rd}from"@nous-excalidraw/element";import{KEYS as Kh,arrayToMap as g_,invariant as Uw,shouldRotateWithDiscreteAngle as f_,updateActiveTool as Ww}from"@nous-excalidraw/common";import{isPathALoop as b_}from"@nous-excalidraw/element";import{isInvisiblySmallElement as $h}from"@nous-excalidraw/element";import{CaptureUpdateAction as Yw}from"@nous-excalidraw/element";import{jsx as x_}from"react/jsx-runtime";var _t=O({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let r=e,{interactiveCanvas:i,focusContainer:a,scene:s}=n,l=s.getNonDeletedElementsMap();if(t&&o.selectedLinearElement){let{event:m,sceneCoords:u}=t,f=Dd.getElement(o.selectedLinearElement.elementId,l);Uw(f,"Arrow element should exist if selectedLinearElement is set"),Uw(u,"sceneCoords should be defined if actionFinalize is called with event");let h=Dd.handlePointerUp(m,o.selectedLinearElement,o,n.scene);if(zw(f)&&!o.selectedLinearElement.segmentMidPointHoveredCoords){let x=!!o.newElement,w=(x||!o.selectedLinearElement.selectedPointsIndices?[f.points.length-1]:o.selectedLinearElement.selectedPointsIndices).reduce((y,v)=>(y.set(v,{point:Dd.pointFromAbsoluteCoords(f,Ow(u.x-h.pointerOffset.x,u.y-h.pointerOffset.y),l)}),y),new Map)??new Map;h_(f,w,u.x-h.pointerOffset.x,u.y-h.pointerOffset.y,s,o,{newArrow:x,altKey:m.altKey,angleLocked:f_(m)})}else Rd(f)&&o.selectedLinearElement?.isEditing&&!o.newElement&&!Fw(f.points)&&s.mutateElement(f,{polygon:!1});if(h!==o.selectedLinearElement){f&&$h(f)&&(r=r.map(E=>E.id===f.id?Xh(E,{isDeleted:!0}):E));let x=o.activeTool?.locked;return{elements:f.points.length<2||$h(f)?e.map(E=>E.id===f.id?Xh(E,{isDeleted:!0}):E):r,appState:{...o,cursorButton:"up",selectedLinearElement:x?null:{...h,selectedPointsIndices:null,isEditing:!1,initialState:{...h.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,newElement:null,multiElement:null},captureUpdate:Yw.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||zw(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let m=l.get(Object.keys(o.selectedElementIds)[0]);m&&(c=m)}if(c){if(o.selectedLinearElement&&o.multiElement&&c.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:m}=c,{lastCommittedPoint:u}=o.selectedLinearElement;(!u||m[m.length-1]!==u)&&s.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&$h(c)&&(r=r.map(m=>m.id===c?.id?Xh(m,{isDeleted:!0}):m)),Gw(c)||Hw(c)){if(b_(c.points,o.zoom.value)&&(Rd(c)||Hw(c))){let u=c.points,f=u[0],h=u.map((x,E)=>E===u.length-1?Ow(f[0],f[1]):x);Rd(c)?s.mutateElement(c,{points:h,polygon:!0}):s.mutateElement(c,{points:h})}Rd(c)&&!Fw(c.points)&&s.mutateElement(c,{polygon:!1})}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Zt(i);let d;o.activeTool.type==="eraser"?d=Ww(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):d=Ww(o,{type:n.state.preferredSelectionTool.type});let p=c&&Gw(c)?new Dd(c,g_(r)):o.selectedLinearElement;return p=p&&{...p,isEditing:o.newElement?!1:p.isEditing,initialState:{...p.initialState,lastClickedPoint:-1,origin:null}},{elements:r,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:d,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:p},captureUpdate:Yw.IMMEDIATELY}},keyTest:(e,o)=>e.key===Kh.ESCAPE&&o.selectedLinearElement?.isEditing||(e.key===Kh.ESCAPE||e.key===Kh.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>x_(q,{type:"button",icon:Y0,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as Kw,isSomeElementSelected as E_,makeNextSelectedElementIds as y_,selectGroupsForSelectedElements as w_}from"@nous-excalidraw/element";import{CaptureUpdateAction as Vw}from"@nous-excalidraw/element";import{KEYS as v_,isWritableElement as T_,updateActiveTool as Xw}from"@nous-excalidraw/common";var I_=(e,o)=>e.activeTool.type==="eraser"?Xw(e,{...e.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):Xw(e,{type:o.state.preferredSelectionTool.type}),C_=(e,o,t)=>{if(!e.editingGroupId)return null;let n=o.scene.getNonDeletedElements(),r=o.scene.getSelectedElements({selectedElementIds:t,elements:n}),i=r.length?r:Kw(n,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},S_=O({name:"deselect",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let r=I_(o,n);if(o.editingGroupId){let i=n.scene.getNonDeletedElements(),a=Object.keys(o.selectedElementIds).length>0?o.selectedElementIds:Kw(i,o.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...o,...w_({editingGroupId:C_(o,n,a),selectedElementIds:a},i,o,n),activeEmbeddable:null,activeTool:r,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null},captureUpdate:Vw.IMMEDIATELY}}return{appState:{...o,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:y_({},o),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null},captureUpdate:Vw.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key!==v_.ESCAPE||T_(e.target)?!1:!o.newElement&&o.multiElement===null&&!o.selectedLinearElement?.isEditing&&(o.activeEmbeddable!==null||o.activeTool.type!==n.state.preferredSelectionTool.type||!!o.editingGroupId||!!o.selectedLinearElement||E_(n.scene.getNonDeletedElements(),o))});import{KEYS as ba,DEFAULT_EXPORT_PADDING as pD,EXPORT_SCALES as uD,THEME as pl}from"@nous-excalidraw/common";import{getNonDeletedElements as hD}from"@nous-excalidraw/element";import{CaptureUpdateAction as Mo}from"@nous-excalidraw/element";import k_ from"clsx";import{jsx as $w,jsxs as M_}from"react/jsx-runtime";var ll=({children:e,checked:o,onChange:t,className:n})=>M_("div",{className:k_("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[$w("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:Kc}),$w("div",{className:"Checkbox-label",children:e})]});import{THEME as cl}from"@nous-excalidraw/common";import{jsx as dl}from"react/jsx-runtime";var jw=e=>{let o=e.title||(e.value===cl.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return dl(q,{type:"icon",icon:e.value===cl.LIGHT?Zw.MOON:Zw.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===cl.DARK?cl.LIGHT:cl.DARK),"data-testid":"toggle-dark-mode"})},Zw={SUN:dl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:dl("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:dl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:dl("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 P_}from"react";import{focusNearestParent as A_,KEYS as L_}from"@nous-excalidraw/common";import{jsx as qw,jsxs as __}from"react/jsx-runtime";var Jw=e=>{let{id:o}=Ne(),[t,n]=P_(e.value),r=a=>{e.ignoreFocus||A_(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===L_.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return __("div",{className:"ProjectName",children:[qw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),qw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>n(a.target.value)})]})};import{useCallback as D_,useEffect as R_,useRef as N_}from"react";import{jsx as Nd,jsxs as z_}from"react/jsx-runtime";var B_=5e3,O_=({progress:e})=>Nd("div",{className:"Toast__progress-bar",children:Nd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),F_=({message:e,onClose:o,closable:t=!1,duration:n=B_,style:r})=>{let i=N_(0),a=n!==1/0,s=D_(()=>{a&&(i.current=window.setTimeout(()=>o(),n))},[o,n,a]);return R_(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,n,a]),z_("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Nd("div",{className:"Toast__message",children:e}),t&&Nd(q,{icon:oo,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})},Bd=Object.assign(F_,{ProgressBar:O_});import{DEFAULT_EXPORT_PADDING as oD,DEFAULT_FILENAME as nD,IMAGE_MIME_TYPES as iv,isFirefox as rD,MIME_TYPES as iD,cloneJSON as aD,SVG_DOCUMENT_PREAMBLE as sD,arrayToMap as lD}from"@nous-excalidraw/common";import{getNonDeletedElements as cD}from"@nous-excalidraw/element";import{isFrameLikeElement as dD}from"@nous-excalidraw/element";import{getElementsOverlappingFrame as mD}from"@nous-excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as H_,EXPORT_DATA_TYPES as ml,MIME_TYPES as qt,arrayToMap as G_,isMemberOf as U_,isPromiseLike as W_,EVENT as Od}from"@nous-excalidraw/common";import{mutateElement as Y_}from"@nous-excalidraw/element";import{deepCopyElement as V_}from"@nous-excalidraw/element";import{isFrameLikeElement as X_,isInitializedImageElement as K_}from"@nous-excalidraw/element";import{getContainingFrame as Qw}from"@nous-excalidraw/element";var dae="clipboard"in navigator&&"readText"in navigator.clipboard,Fd="clipboard"in navigator&&"writeText"in navigator.clipboard,ha="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,$_=e=>!!([ml.excalidraw,ml.excalidrawClipboard,ml.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),ev=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Od.PASTE,{clipboardData:new DataTransfer});if(e)for(let[n,r]of Object.entries(e)){if(typeof r!="string"){o=o||[],o.push(r);continue}try{if(t.clipboardData?.items.add(r,n),t.clipboardData?.getData(n)!==r)throw new Error(`Failed to set "${n}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let n=-1;for(let r of o){n++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[n]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},Z_=({elements:e,files:o})=>{let t=G_(e),n=new Set(e.filter(s=>X_(s))),r=!1,i=e.reduce((s,l)=>(K_(l)&&(r=!0,o&&o[l.fileId]&&(s[l.fileId]=o[l.fileId])),s),{});r&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:ml.excalidrawClipboard,elements:e.map(s=>{if(Qw(s,t)&&!n.has(Qw(s,t))){let l=V_(s);return Y_(l,t,{frameId:null}),l}return s}),files:o?i:void 0};return JSON.stringify(a)},zd=async(e,o,t)=>{let n=Z_({elements:e,files:o});await ko({[qt.excalidrawClipboard]:n,[qt.text]:n},t)};function tv(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let n=t.textContent?.trim();n&&o.push({type:"text",value:n})}else if(t instanceof HTMLImageElement){let n=t.getAttribute("src");n&&n.startsWith("http")&&o.push({type:"imageUrl",value:n})}else o=o.concat(tv(t));return o}var j_=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,qt.html),n=tv(t.body);if(n.length)return{type:"mixedContent",value:n}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},ov=async()=>{let e={},o;try{o=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let n=await navigator.clipboard?.readText();if(n)return{[qt.text]:n}}}catch(n){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${n.message}). Failling back to navigator.clipboard.read()`);else{if(n.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${n.message}`),e;throw n}}throw t}for(let t of o)for(let n of t.types)if(U_(H_,n))try{if(n===qt.text||n===qt.html)e[n]=await(await t.getType(n)).text();else if(m0(n)){let r=await t.getType(n),i=E0(r,n,void 0);e[n]=i}else throw new vu(`Unsupported clipboard type: ${n}`)}catch(r){console.warn(r instanceof vu?r.message:`Cannot retrieve ${n} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},q_=async(e,o=!1)=>{try{let t=e.findByType(qt.html),n=!o&&t&&j_(t);return n?n.value.every(r=>r.type==="text")?{type:"text",value:e.getData(qt.text)??n.value.map(r=>r.value).join(`
2
- `).trim()}:n:{type:"text",value:(e.getData(qt.text)||"").trim()}}catch{return{type:"text",value:""}}},J_=function(e){return this.find(o=>o.type===e)||null},Q_=function(e){return this.find(t=>t.type===e)?.value??null},eD=function(){return this.filter(e=>e.kind==="file")},nv=e=>{let o;rv(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=new Set;for(let n of Array.from(o||[]))t.has(n.type)||t.add(n.type);return t},ga=async e=>{let o;rv(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=(await Promise.all(Array.from(o||[]).map(async n=>{if(n.kind==="file"){let r=n.getAsFile();if(r){let i=await x0(n);return r=await zs(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(n.kind==="string"){let{type:r}=n,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(a=>{n.getAsString(s=>a(s))}),{type:r,kind:"string",value:i}}return null}))).filter(n=>n!=null);return Object.assign(t,{findByType:J_,getData:Q_,getFiles:eD})},Hd=async(e,o=!1)=>{let t=await q_(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let n=JSON.parse(t.value),r=n.type===ml.excalidrawClipboardWithAPI;if($_(n))return{elements:n.elements,files:n.files,text:o?JSON.stringify(n.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},Gd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[qt.png]:e})])}catch(o){if(W_(e))await navigator.clipboard.write([new ClipboardItem({[qt.png]:await e})]);else throw o}},ko=async(e,o)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[qt.text]:e}:e);try{if(o){for(let[r,i]of t)if(o.clipboardData?.setData(r,i),o.clipboardData?.getData(r)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}let n=t.find(([r])=>r===qt.text);if(Fd&&n)try{await navigator.clipboard.writeText(n[1]);return}catch(r){console.error(r)}if(n&&!tD(n[1]))throw new Error("Error copying to clipboard.")},tD=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let n=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${n}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let r=!1;try{t.select(),t.setSelectionRange(0,t.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),r},rv=e=>e.type===Od.PASTE||e.type===Od.COPY||e.type===Od.CUT;var qr=(e,{selectedElementIds:o},t)=>{e=cD(e);let n=lD(e),r=t&&Ae(e,{selectedElementIds:o}),i=null,a=r?ie(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(a.length===1&&dD(a[0])?(i=a[0],a=mD(e,i,n)):a.length>1&&(a=ie(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:i,exportedElements:aD(a)}},Jr=async(e,o,t,n,{exportBackground:r,exportPadding:i=oD,viewBackgroundColor:a,name:s=t.name||nD,fileHandle:l=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let p=Oc(o,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},n,{exportingFrame:c});if(e==="svg")return Tu(p.then(m=>new Blob([sD+m.outerHTML],{type:iD.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[iv.svg],fileHandle:l});if(e==="clipboard-svg"){let m=await p.then(u=>u.outerHTML);try{await ko(m)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let d=Bc(o,t,n,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let p=Ur(d);return t.exportEmbedScene&&(p=p.then(m=>import("./data/image-LRQMDLTI.js").then(({encodePngMetadata:u})=>u({blob:m,metadata:Rs(o,t,n,"local")})))),Tu(p,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[iv.png],fileHandle:l})}else if(e==="clipboard")try{let p=Ur(d);await Gd(p)}catch(p){throw console.warn(p),p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):rD&&p.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
1
+ import{$ as Su,A as Iu,B as xA,C as o0,D as n0,E as Nc,F as Ns,G as Bs,H as Os,I as Li,J as r0,K as i0,L as a0,M as Bc,N as Oc,O as s0,P as EA,Q as Gr,R as _i,S as Fs,U as l0,W as c0,X as d0,Y as Fc,Z as m0,_ as Cu,a as Jx,aa as p0,b as Hr,ba as u0,c as To,ca as ku,d as Qx,da as Ur,e as Ae,ea as h0,f as e0,fa as Mu,g as ie,ga as g0,h as ki,ha as f0,i as Uo,ia as zc,j as Ls,ja as Pu,k as _s,ka as b0,l as Mi,la as x0,m as Ds,ma as E0,n as Pi,na as zs,o as t0,p as vu,q as Wo,r as yn,s as Yo,t as Ot,u as wn,v as Ai,w as Dc,x as Tu,y as Rs,z as Rc}from"./chunk-JWDEJ6N5.js";import{a as C}from"./chunk-MW6O7B5J.js";import{N as wu}from"./chunk-KGPK36EJ.js";import{c as qx}from"./chunk-3PELD44J.js";import{b as Zx,c as jx,d as k}from"./chunk-SRAX5OIU.js";import zZ,{useCallback as HZ,useContext as GZ,useEffect as UZ,useRef as WZ,useState as YZ}from"react";import{DEFAULT_UI_OPTIONS as mA,isShallowEqual as VZ}from"@nous-excalidraw/common";import AM from"clsx";import cK from"lodash.throttle";import wo,{useContext as Yn}from"react";import{flushSync as Yt}from"react-dom";import dK from"roughjs/bin/rough";import{nanoid as mK}from"nanoid";import{clamp as LM,pointFrom as oe,pointDistance as Hn,vector as _M,pointRotateRads as J1,vectorFromPoint as Q1,vectorSubtract as DM,vectorDot as RM,vectorNormalize as NM}from"@nous-excalidraw/math";import{COLOR_PALETTE as pK,CODES as BM,shouldResizeFromCenter as OM,shouldMaintainAspectRatio as ex,shouldRotateWithDiscreteAngle as FM,isArrowKey as tu,KEYS as Z,APP_NAME as uK,CURSOR_TYPE as Fe,DEFAULT_TRANSFORM_HANDLE_SPACING as hK,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as gK,DEFAULT_VERTICAL_ALIGN as zM,DRAGGING_THRESHOLD as HM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as fK,ELEMENT_TRANSLATE_AMOUNT as GM,EVENT as le,FRAME_STYLE as Nr,IMAGE_MIME_TYPES as bK,IMAGE_RENDER_TIMEOUT as xK,LINE_CONFIRM_THRESHOLD as tx,MAX_ALLOWED_FILE_BYTES as UM,MIME_TYPES as gn,MQ_RIGHT_SIDEBAR_MIN_WIDTH as EK,POINTER_BUTTON as Gn,ROUNDNESS as ou,SCROLL_TIMEOUT as yK,TAP_TWICE_TIMEOUT as WM,TEXT_TO_CENTER_SNAP_THRESHOLD as wK,THEME as ws,TOUCH_CTX_MENU_TIMEOUT as vK,VERTICAL_ALIGN as TK,YOUTUBE_STATES as nu,getInteractiveZoomStep as IK,INITIAL_CANVAS_ZOOM as CK,scaleFontSizeForZoomChange as YM,normalizeSceneFontSizeForZoom as ox,scaleStrokeWidthForZoomChange as VM,getDisplaySceneStrokeWidth as XM,STROKE_WIDTH_CUSTOM_DATA_KEY as SK,getDefaultSceneFontSizeForZoom as kK,POINTER_EVENTS as vs,TOOL_TYPE as fn,supportsResizeObserver as MK,DEFAULT_COLLISION_THRESHOLD as KM,DEFAULT_TEXT_ALIGN as PK,ARROW_TYPE as Br,DEFAULT_REDUCED_GLOBAL_ALPHA as AK,isLocalLink as LK,normalizeLink as nx,toValidURL as _K,getGridPoint as St,getLineHeight as $M,debounce as ZM,distance as Ts,getFontString as rx,getNearestScrollableContainer as DK,isInputLike as jM,isToolIcon as RK,isWritableElement as xc,sceneCoordsToViewportCoords as ru,tupleToCoors as ix,viewportCoordsToSceneCoords as ze,wrapEvent as NK,updateObject as ax,updateActiveTool as bn,isTransparent as BK,easeToValuesRAF as OK,muteFSAbortError as FK,isTestEnv as HP,isDevEnv as GP,easeOut as zK,updateStable as Ec,addEventListener as je,normalizeEOL as HK,getDateTime as qM,isShallowEqual as JM,arrayToMap as iu,applyDarkModeFilter as GK,AppEventBus as UK,randomInteger as WK,CLASSES as sx,Emitter as vi,MINIMUM_ARROW_SIZE as YK,DOUBLE_TAP_POSITION_THRESHOLD as QM,BIND_MODE_TIMEOUT as VK,invariant as xn,getFeatureFlag as Un,createUserAgentDescriptor as UP,getFormFactor as XK,deriveStylesPanelMode as uu,isIOS as KK,isBrave as $K,isSafari as ZK,loadDesktopUIModePreference as jK,setDesktopUIMode as qK,isSelectionLikeTool as au,oneOf as eP}from"@nous-excalidraw/common";import{getObservedAppState as JK,getCommonBounds as Ti,getElementAbsoluteCoords as tP,bindOrUnbindBindingElements as oP,fixBindingsAfterDeletion as QK,getHoveredElementForBinding as Ho,isBindingEnabled as yc,updateBoundElements as su,LinearElementEditor as Ee,newElementWith as Wn,newFrameElement as e$,newFreeDrawElement as t$,newEmbeddableElement as nP,newMagicFrameElement as rP,newIframeElement as o$,newArrowElement as n$,newElement as r$,newImageElement as i$,newLinearElement as a$,newTextElement as iP,refreshTextDimensions as s$,deepCopyElement as aP,duplicateElements as lx,hasBoundTextElement as sP,isArrowElement as Is,isBindingElement as En,isBindingElementType as l$,isBoundToContainer as cx,isFrameLikeElement as Qe,isHoverNativeOutlineShapeElement as c$,isImageElement as Cs,isEmbeddableElement as Go,shouldForceMaintainAspectRatio as lP,isInitializedImageElement as wc,isLinearElement as Bt,isLinearElementType as d$,isUsingAdaptiveRadius as m$,isIframeElement as Ss,isIframeLikeElement as dx,isMagicFrameElement as mx,isTextBindableContainer as cP,isElbowArrow as Vt,isFlowchartNodeElement as p$,isBindableElement as px,isTextElement as kt,getNormalizedDimensions as u$,isElementCompletelyInViewport as ux,isElementInViewport as dP,isInvisiblySmallElement as mP,getCornerRadius as h$,isPathALoop as pP,createSrcDoc as uP,embeddableURLValidator as hx,maybeParseEmbedSrc as g$,getEmbedLink as lu,getInitializedImageElements as f$,normalizeSVG as hP,updateImageCache as b$,getBoundTextElement as gx,getContainerCenter as fx,getContainerElement as gP,isValidTextContainer as fP,redrawTextBoundingBox as bP,hasBoundingBox as x$,getFrameChildren as bx,isCursorInFrame as xx,addElementsToFrame as Ex,replaceAllElementsInFrame as E$,removeElementsFromFrame as y$,getElementsInResizingFrame as xP,getElementsInNewFrame as w$,getContainingFrame as cu,elementOverlapsWithFrame as v$,updateFrameMembershipOfSelectedElements as EP,isElementInFrame as yP,getFrameLikeTitle as T$,getElementsOverlappingFrame as I$,filterElementsEligibleAsFrameChildren as C$,hitElementBoundText as S$,hitElementBoundingBoxOnly as k$,hitElementItself as ks,getVisibleSceneBounds as M$,FlowChartCreator as P$,FlowChartNavigator as A$,getLinkDirectionFromKey as wP,cropElement as L$,wrapText as _$,isElementLink as yx,parseElementLinkFromURL as D$,isMeasureTextSupported as R$,normalizeText as N$,measureText as vP,getLineHeightInPx as TP,getApproxMinLineWidth as B$,getApproxMinLineHeight as O$,getMinTextElementWidth as F$,ShapeCache as vc,getRenderOpacity as z$,editGroupForSelectedElement as H$,getElementsInGroup as Ii,getSelectedGroupIdForElement as G$,getSelectedGroupIds as U$,isElementInGroup as IP,isSelectedViaGroup as W$,selectGroupsForSelectedElements as yo,syncInvalidIndices as WP,syncMovedIndices as CP,excludeElementsInFramesFromSelection as Y$,getSelectionStateForElements as V$,makeNextSelectedElementIds as Me,getResizeOffsetXY as X$,getResizeArrowDirection as K$,transformElements as $$,getCursorForResizingElement as SP,getElementWithTransformHandleType as kP,getTransformHandleTypeFromCoords as MP,dragNewElement as PP,dragSelectedElements as Z$,getDragOffsetXY as j$,isNonDeletedElement as AP,Scene as LP,Store as q$,CaptureUpdateAction as Xt,hitElementBoundingBox as J$,isLineElement as wx,isSimpleArrow as vx,StoreDelta as _P,positionElementsOnGrid as DP,calculateFixedPointForNonElbowArrowBinding as RP,bindOrUnbindBindingElement as Q$,mutateElement as du,getElementBounds as NP,doBoundsIntersect as eZ,isPointInElement as tZ,maxBindingDistance_simple as Tx,convertToExcalidrawElements as BP,getSnapOutlineMidPoint as Ix,handleFocusPointDrag as oZ,handleFocusPointHover as nZ,handleFocusPointPointerDown as rZ,handleFocusPointPointerUp as iZ,maybeHandleArrowPointlikeDrag as mu,getUncroppedWidthAndHeight as aZ,getActiveTextElement as OP,syncElementsStrokeWidthForZoom as sZ}from"@nous-excalidraw/element";import{KEYS as th,MOBILE_ACTION_BUTTON_BG as _A,updateActiveTool as DA}from"@nous-excalidraw/common";import{getNonDeletedElements as oh}from"@nous-excalidraw/element";import{fixBindingsAfterDeletion as RA}from"@nous-excalidraw/element";import{LinearElementEditor as yy}from"@nous-excalidraw/element";import{newElementWith as ad}from"@nous-excalidraw/element";import{getContainerElement as wy}from"@nous-excalidraw/element";import{isBoundToContainer as rd,isElbowArrow as NA,isFrameLikeElement as BA}from"@nous-excalidraw/element";import{getFrameChildren as OA}from"@nous-excalidraw/element";import{getElementsInGroup as nh,selectGroupsForSelectedElements as FA}from"@nous-excalidraw/element";import{CaptureUpdateAction as id}from"@nous-excalidraw/element";import{isDevEnv as TA}from"@nous-excalidraw/common";import{atom as fe,createStore as yA}from"jotai";import{createIsolation as wA}from"jotai-scope";var y0=wA();var{useAtom:Q,useSetAtom:Vo,useAtomValue:Di,useStore:qZ}=y0,w0=y0.Provider,nt=yA();var vA=Zx({"./locales/ar-SA.json":()=>import("./locales/ar-SA-NXDWD63E.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-MXSORGZV.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-O6MV2KSF.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-T2VJNT7N.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-MMW2ORAC.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-MKBCGNOG.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-V77HGUP7.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-I5RFNTM4.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-WLRDEVBV.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-DTI4WUSC.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-ZXDJ2OS4.js"),"./locales/en.json":()=>import("./locales/en-QIAUJ35X.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-DYQHAD43.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-QDSYU5Y3.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-26LZG4PM.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-6YS4KDE4.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-BRLLPTZC.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-OKUZTLYG.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-26MGYIU7.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-Q4ZOGTP2.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-P2OXPSN5.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-2EIKXYN6.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-4CFKVXI2.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-MAND2Z4V.js"),"./locales/kaa.json":()=>import("./locales/kaa-HQRTCXTJ.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-JKIKKTGH.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-HXQ63ZFC.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-PKL3LSGX.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-KXLREZX3.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-MJ4IER3X.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-H6WFQ6FJ.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-GOCK6SJW.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-IXVLDMEQ.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-YG6MYTTD.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-XGWJISD2.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-XVDVCPNC.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-EMX5MJX5.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-ROEINTVO.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-ZYN6SUDY.js"),"./locales/percentages.json":()=>import("./locales/percentages-5DKR754L.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-6VTG7PHC.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5YFKRR5G.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-GEIXXZ67.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-E2P6TFZI.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-YBIIY43T.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-673C2CI2.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-CKZHQ4AP.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-557H2GWM.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XOPKKDWS.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-XBH7DQI3.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-TOCWH3R4.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-GXW6CYY5.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-IJKTNUDG.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-TBZZEA4V.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-MULSGNVB.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-3F3C6RA5.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-JNU5RLIE.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-LENVCA6T.js")});var IA=85,Xo={code:"en",label:"English"},Ni=[Xo,...[{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=>qx[e.code]>=IA).sort((e,o)=>e.label>o.label?1:-1)],Gc="__test__";TA()&&Ni.unshift({code:Gc,label:"test language"},{code:`${Gc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ri=Xo,Hc={},Uc=async e=>{if(Ri=e,document.documentElement.dir=Ri.rtl?"rtl":"ltr",document.documentElement.lang=Ri.code,e.code.startsWith(Gc))Hc={};else try{Hc=await vA(`./locales/${Ri.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Hc=wu}nt.set(T0,e.code)},vn=()=>Ri,v0=(e,o)=>{for(let t=0;t<o.length;++t){let n=o[t];if(e[n]===void 0)return;e=e[n]}if(typeof e=="string")return e},g=(e,o,t)=>{if(Ri.code.startsWith(Gc))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=v0(Hc,n)??v0(wu,n)??t;if(r===void 0){let i=`Can't find translation for ${e}`;if(C.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)r=r.replace(`{{${i}}}`,String(o[i]));return r},T0=fe(Xo.code),Ie=()=>{let e=Di(T0);return{t:g,langCode:e}};import CA from"clsx";import et from"react";import{THEME as SA}from"@nous-excalidraw/common";import{Fragment as Le,jsx as b,jsxs as N}from"react/jsx-runtime";var Io=e=>"var(--icon-fill-color)",I0=e=>e===SA.LIGHT?"#fff":"#1e1e1e",L=(e,o=512)=>{let{width:t=512,height:n=t,mirror:r,style:i,...a}=typeof o=="number"?{width:o}:o;return b("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${n}`,className:CA({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?b("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},pe={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Mt={width:40,height:20},pj=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("rect",{x:3,y:8,width:18,height:4,rx:1}),b("line",{x1:12,y1:8,x2:12,y2:21}),b("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),b("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),Wc=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),b("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),b("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),b("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),b("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),H),C0=L(N("svg",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),b("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),H),S0=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"1"}),b("circle",{cx:"12",cy:"19",r:"1"}),b("circle",{cx:"12",cy:"5",r:"1"})]}),H),k0=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),b("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),b("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),H),M0=L(N("svg",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),b("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),b("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),H),Au=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M6.5 9.5l3.5 -3"}),b("path",{d:"M14 5.5l3 1.5"}),b("path",{d:"M18.5 10l-2.5 7"}),b("path",{d:"M13.5 17.5l-7 -5"})]}),H),Wr=L(N("g",{children:[b("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"}),b("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"}),b("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:b("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"})}),b("g",{mask:"url(#UnlockedIcon)",children:b("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"})})]}),pe),Bi=L(N("g",{strokeWidth:"1.25",children:[b("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"}),b("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),b("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"})]}),pe),P0=L(b("g",{fill:"currentColor",children:b("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}),A0=L(N(Le,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),b("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"}),L0=L(N(Le,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),b("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"}),_0=L(N(Le,{children:[b("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"}),b("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),b("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"}),uj=L(b("g",{fill:"currentColor",children:b("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"}),Yr=L(N("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),$n=L(N("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[b("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"}),b("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Oi=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),H),Fi=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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),zi=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 4l8 16h-16z"})]}),H),Hi=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"})]}),H),Yc=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),b("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),b("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),H),Gi=L(b("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),pe),D0=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),b("path",{d:"M16 7h4"}),b("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),H),Ko=L(N("g",{strokeWidth:"1.25",children:[b("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"}),b("path",{d:"m11.25 5.417 3.333 3.333"})]}),pe),$o=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),b("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),b("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),b("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),b("polyline",{points:"5 20 11 4 13 4 20 20"})]}),H),R0=L(N("g",{stroke:"currentColor",strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 7v-2h13v2"}),b("path",{d:"M10 5v14"}),b("path",{d:"M12 19h-4"}),b("path",{d:"M15 13v-1h6v1"}),b("path",{d:"M18 12v7"}),b("path",{d:"M17 19h2"})]}),H),Ui=L(N("g",{strokeWidth:"1.25",children:[b("path",{d:"M12.5 6.667h.01"}),b("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"}),b("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),b("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),pe),Vc=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M18 13.3l-6.3 -6.3"})]}),H),Lu=L(b("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),pe),_u=L(b("path",{d:"M5 10h10",strokeWidth:"1.25"}),pe),N0=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M21 21l-6 -6"}),b("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"}),b("path",{d:"M3 4v4h4"})]}),H),ft=L(b("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"}),pe),Wi=L(N("g",{strokeWidth:"1.5",children:[b("polyline",{points:"12 16 18 10 12 4"}),b("polyline",{points:"8 4 2 10 8 16"})]}),pe),Hs=L(N("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),pe),Gs=L(b("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"}),pe),Us=L(b("g",{stroke:"currentColor",strokeLinejoin:"round",children:b("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"})}),{...pe,strokeWidth:1.5}),B0=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),b("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),b("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),H),Vr=L(b("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"}),pe),Yi=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"}),b("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),O0=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"12",cy:"12",r:"9"}),b("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),Du=L(b("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"}),pe),Xc=L(b("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"}),pe),F0=L(N("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),pe),z0=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),b("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),H),Kc=L(b("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Ws=L(N("g",{strokeWidth:"1.25",children:[b("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"}),b("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"})]}),pe),H0=L("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}),G0=L("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}),Vi=L(b("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"}),pe),hj=L("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}),gj=L("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"),Xi=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),b("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),b("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),H),U0=L(b("g",{strokeWidth:1.5,children:b("path",{d:"M6 18l12 -12"})}),H),$c=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M15 8h.01"}),b("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),b("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),b("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),b("path",{d:"M19 16v6"}),b("path",{d:"M22 19l-3 3l-3 -3"})]}),H),W0=L("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}),fj=L("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}),bj=L("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}),Y0=L("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"),xj=L("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),Ru=L(b("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"}),pe),Nu=L(b("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"}),pe),V0=L("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}),X0=L(b("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"}),pe),Ej=L("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"),yj=L("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}),wj=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 14v-11"}),b("path",{d:"M9 6l3 -3l3 3"})]}),H),vj=L(N(Le,{children:[b("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"}),b("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}),Tj=L(b("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}),K0=N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 10l0 10"}),b("path",{d:"M12 10l4 4"}),b("path",{d:"M12 10l-4 4"}),b("path",{d:"M4 4l16 0"})]}),$0=N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 5l0 14"}),b("path",{d:"M16 9l-4 -4"}),b("path",{d:"M8 9l4 -4"})]}),Bu=L($0,H),Ou=L($0,{...H,style:{transform:"rotate(180deg)"}}),Fu=L(K0,H),zu=L(K0,{...H,style:{transform:"rotate(180deg)"}}),Hu=L(N(Le,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),Gu=L(N(Le,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),Uu=L(N(Le,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),Wu=L(N(Le,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),Z0=L(N(Le,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),j0=L(N(Le,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),Yu=L(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),b("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),pe),Vu=L(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[b("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),b("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),b("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),b("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"})]}),pe),Zc=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("circle",{cx:"9",cy:"7",r:"4"}),b("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),b("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),b("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),H),Ij=L("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"),q0=L("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"),oo=L(N(Le,{children:[b("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("path",{d:"M15 5 5 15M5 5l10 10"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),Cj=L("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}),Sj=L("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}),kj=L("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}),Xu=et.memo(({theme:e})=>L(N(Le,{children:[b("path",{d:"M25 26H111V111H25",fill:Io(e)}),b("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:Io(e),strokeWidth:"2"}),b("path",{d:"M100 100H160V160H100",fill:Io(e)}),b("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:Io(e),strokeWidth:"2"}),N("g",{fill:I0(e),stroke:Io(e),strokeWidth:"6",children:[b("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Ku=et.memo(({theme:e})=>L(N(Le,{children:[b("path",{d:"M25 26H111V111H25",fill:Io(e)}),b("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:Io(e),strokeWidth:"2"}),b("path",{d:"M100 100H160V160H100",fill:Io(e)}),b("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:Io(e),strokeWidth:"2"}),N("g",{fill:I0(e),stroke:Io(e),strokeWidth:"6",children:[b("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),b("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),b("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),b("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),J0=L(b("g",{strokeWidth:1.25,children:b("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"})}),pe),Q0=L(N(Le,{children:[b("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"}),b("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:b("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"})}),b("g",{mask:"url(#FillHachureIcon)",children:b("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"})})]}),pe),eE=L(N(Le,{children:[N("g",{clipPath:"url(#a)",children:[b("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"}),b("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:b("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"})}),b("g",{mask:"url(#FillCrossHatchIcon)",children:b("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"})})]}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),tE=L(N(Le,{children:[b("g",{clipPath:"url(#a)",children:b("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"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...pe,fill:"currentColor"}),$u=L(b(Le,{children:b("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),pe),oE=L(b("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),pe),nE=L(b("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),pe),Mj=et.memo(({theme:e})=>L(b("path",{d:"M6 10H34",stroke:Io(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),rE=L(N("g",{strokeWidth:"2",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 12h2"}),b("path",{d:"M17 12h2"}),b("path",{d:"M11 12h2"})]}),H),iE=L(N("g",{strokeWidth:"2",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 12v.01"}),b("path",{d:"M8 12v.01"}),b("path",{d:"M12 12v.01"}),b("path",{d:"M16 12v.01"}),b("path",{d:"M20 12v.01"})]}),H),aE=L(b("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"}),pe),sE=L(b("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"}),pe),lE=L(b("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"}),pe),cE=L(N("svg",{strokeWidth:"1.5",children:[b("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"}),b("path",{d:"M13.3333 3.33331V3.34331"}),b("path",{d:"M16.6667 3.33331V3.34331"}),b("path",{d:"M16.6667 6.66669V6.67669"}),b("path",{d:"M16.6667 10V10.01"}),b("path",{d:"M3.33334 13.3333V13.3433"}),b("path",{d:"M16.6667 13.3333V13.3433"}),b("path",{d:"M3.33334 16.6667V16.6767"}),b("path",{d:"M6.66666 16.6667V16.6767"}),b("path",{d:"M10 16.6667V16.6767"}),b("path",{d:"M13.3333 16.6667V16.6767"}),b("path",{d:"M16.6667 16.6667V16.6767"})]}),pe),dE=L(N("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),b("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),b("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),b("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),b("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),b("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),b("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),b("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),b("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),b("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),b("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),b("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),H),mE=et.memo(({flip:e=!1})=>L(N("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[b("path",{d:"M7,11 H19"}),b("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),Mt)),pE=et.memo(({flip:e=!1})=>L(b("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:b("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),Mt)),uE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[b("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),b("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Mt)),hE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[b("path",{d:"M7,11 H23"}),b("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Mt)),gE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[b("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),b("circle",{cx:"29",cy:"11",r:"4"})]}),Mt)),fE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[b("path",{d:"M7,11 H25",strokeLinecap:"round"}),b("circle",{cx:"29",cy:"11",r:"4"})]}),Mt)),bE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[b("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),b("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Mt)),xE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[b("path",{d:"M7,11 H21"}),b("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Mt)),EE=et.memo(({flip:e=!1})=>L(b("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:b("path",{d:"M11,11 H31 M31,5 V17"})}),Mt)),yE=et.memo(({flip:e=!1})=>L(b("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:b("path",{d:"M35,11 H7 M15,5 V17"})}),Mt)),wE=et.memo(({flip:e=!1})=>L(b("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:b("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),Mt)),vE=et.memo(({flip:e=!1})=>L(b("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:b("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),Mt)),TE=et.memo(({flip:e=!1})=>L(b("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:b("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),Mt)),IE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),b("circle",{cx:"15",cy:"11",r:"4"})]}),Mt)),CE=et.memo(({flip:e=!1})=>L(N("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),b("circle",{cx:"23",cy:"11",r:"4"})]}),Mt)),SE=L(N(Le,{children:[b("g",{clipPath:"url(#a)",children:b("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"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),kE=L(N(Le,{children:[b("g",{clipPath:"url(#a)",children:b("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),ME=L(N(Le,{children:[b("g",{clipPath:"url(#a)",children:b("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),b("defs",{children:b("clipPath",{id:"a",children:b("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),pe),PE=L(b(Le,{children:b("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"})}),pe),Xr=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 7v-2h13v2"}),b("path",{d:"M10 5v14"}),b("path",{d:"M12 19h-4"}),b("path",{d:"M15 13v-1h6v1"}),b("path",{d:"M18 12v7"}),b("path",{d:"M17 19h2"})]}),H),AE=L(b(Le,{children:N("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 12h10"}),b("path",{d:"M7 5v14"}),b("path",{d:"M17 5v14"}),b("path",{d:"M15 19h4"}),b("path",{d:"M15 5h4"}),b("path",{d:"M5 19h4"}),b("path",{d:"M5 5h4"})]})}),H),Ys=L(b(Le,{children:b("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:b("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"})})}),pe),Zu=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 8l-4 4l4 4"}),b("path",{d:"M17 8l4 4l-4 4"}),b("path",{d:"M14 4l-4 16"})]}),H),jc=Zu,LE=L(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),b("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),H),_E=L(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),b("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),H),DE=L(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),b("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),b("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),H),RE=et.memo(({theme:e})=>L(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),b("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),H)),NE=et.memo(({theme:e})=>L(N("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),b("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),H)),BE=et.memo(({theme:e})=>L(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),b("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),b("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),H)),qc=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M21 19h-18l9 -15"}),b("path",{d:"M20.615 15.171h.015"}),b("path",{d:"M19.515 11.771h.015"}),b("path",{d:"M17.715 8.671h.015"}),b("path",{d:"M15.415 5.971h.015"})]}),H),OE=L(b("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}),Pj=L(b("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"})),Ki=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),b("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),b("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),b("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),ju=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),b("path",{d:"M7 11l5 5l5 -5"}),b("path",{d:"M12 4l0 12"})]}),H),$i=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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),FE=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M9.15 14.85l8.85 -10.85"}),b("path",{d:"M6 4l8.85 10.85"})]}),H),zE=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),b("path",{d:"M12 17l0 .01"}),b("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),Aj=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M7 4v16l13 -8z"})]}),H),Lj=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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),HE=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 12l5 5l10 -10"})]}),H),Jc=L(N(Le,{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 9v4"}),b("path",{d:"M12 17h.01"})]}),H),GE=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M11 7l6 6"}),b("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),H),Vs=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 3l-4 7h8z"}),b("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),b("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),H),Co=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 7l16 0"}),b("path",{d:"M4 17l16 0"}),b("path",{d:"M7 4l0 16"}),b("path",{d:"M17 4l0 16"})]}),H),Zi=L(b("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),UE=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),b("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),H),WE=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),b("path",{d:"M4 15l8 4l8 -4"}),b("path",{d:"M12 4v7"}),b("path",{d:"M15 8l-3 3l-3 -3"})]}),H),Zn=L(N("g",{strokeWidth:"1.25",children:[b("path",{d:"M4.16602 10H15.8327"}),b("path",{d:"M12.5 13.3333L15.8333 10"}),b("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),pe),Zo=L(N("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[b("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"}),b("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),Kr=L(N("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z"}),b("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),b("path",{d:"M15 6l3 3"}),b("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"}),b("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),_j=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z"}),b("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),b("path",{d:"M15 6l3 3"}),b("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"}),b("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),Dj=L(N("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),b("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),b("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"}),b("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),b("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),b("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),YE=L(N("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),b("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),b("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),b("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),H),ji=L(N("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),b("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),VE=L(N("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),b("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"}),b("path",{d:"M3 3l18 18"})]}),H),XE=L(N("g",{stroke:"currentColor",fill:"none",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),b("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),b("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),b("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),KE=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),b("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),b("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),b("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),Kt=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),b("path",{d:"M21 21l-6 -6"})]}),H),$E=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),b("path",{d:"M12 7v5l3 3"}),b("path",{d:"M19 16l-2 3h4l-2 3"})]}),H),ZE=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 8l0 4l2 2"}),b("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),H),jE=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M5 10a7 7 0 0 0 14 0"}),b("path",{d:"M8 21l8 0"}),b("path",{d:"M12 17l0 4"})]}),H),qE=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 3l18 18"}),b("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"}),b("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),b("path",{d:"M8 21l8 0"}),b("path",{d:"M12 17l0 4"})]}),H),Xs=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),H),JE=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M12 20v.01"}),b("path",{d:"M16 20v.01"}),b("path",{d:"M8 20v.01"}),b("path",{d:"M4 20v.01"}),b("path",{d:"M4 16v.01"}),b("path",{d:"M4 12v.01"}),b("path",{d:"M4 8v.01"}),b("path",{d:"M4 4v.01"}),b("path",{d:"M8 4v.01"}),b("path",{d:"M12 4v.01"}),b("path",{d:"M16 4v.01"}),b("path",{d:"M20 4v.01"}),b("path",{d:"M20 8v.01"}),b("path",{d:"M20 12v.01"}),b("path",{d:"M20 16v.01"}),b("path",{d:"M20 20v.01"})]}),H),QE=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 3v18"}),b("path",{d:"M19 21v-18"}),b("path",{d:"M5 7h14"}),b("path",{d:"M5 15h14"}),b("path",{d:"M8 13v4"}),b("path",{d:"M11 13v4"}),b("path",{d:"M16 13v4"}),b("path",{d:"M14 5v4"}),b("path",{d:"M11 5v4"}),b("path",{d:"M8 5v4"}),b("path",{d:"M3 21h18"})]}),H),ey=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 12l18 0"}),b("path",{d:"M7 16l10 0l-10 5l0 -5"}),b("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),H),ty=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M12 3l0 18"}),b("path",{d:"M16 7l0 10l5 0l-5 -10"}),b("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),H),qu=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),b("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),Qc=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),b("path",{d:"M22 22l-3 -3"}),b("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),b("path",{d:"M3 11v-1"}),b("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),b("path",{d:"M10 3h1"}),b("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),H),oy=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),b("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),b("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"}),b("path",{d:"M10 15l2 6l2 -6"}),b("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),H),ny=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),b("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),b("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),b("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),b("path",{d:"M11 21v-6l3 6v-6"})]}),H),ry=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M4 8l5 0"}),b("path",{d:"M15 8l4 0"})]}),H),iy=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),b("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),b("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),b("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),H),ay=L(N("g",{stroke:"currentColor",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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}),Rj=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M21 12h-13l3 -3"}),b("path",{d:"M11 15l-3 -3"})]}),H),sy=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M10 9l5 3l-5 3z"})]}),H),ly=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 6h18"}),b("path",{d:"M3 12h18"}),b("path",{d:"M3 18h18"}),b("path",{d:"M6 3v18"}),b("path",{d:"M12 3v18"}),b("path",{d:"M18 3v18"})]}),H),cy=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("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"}),b("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),H),qi=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 18l12 -12"}),b("path",{d:"M18 10v-4h-4"})]}),H),Ji=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),b("path",{d:"M18 4l3 3l-3 3"})]}),H),Qi=L(N("g",{children:[b("path",{d:"M16,12L20,9L16,6"}),b("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),ed=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 9l6 6l6 -6"})]}),H),dy=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 15l6 -6l6 6"})]}),H),my=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 15l6 -6l6 6"})]}),H),Ju=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),b("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),H),td=L(N("g",{children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M5 7l0 10"}),b("path",{d:"M7 5l10 0"}),b("path",{d:"M7 19l10 0"}),b("path",{d:"M19 7l0 10"})]}),H),Nj=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),H),py=L(N("g",{strokeWidth:1.5,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M4 6l8 0"}),b("path",{d:"M16 6l4 0"}),b("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M4 12l2 0"}),b("path",{d:"M10 12l10 0"}),b("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M4 18l11 0"}),b("path",{d:"M19 18l1 0"})]}),H),uy=L(N("g",{strokeWidth:1,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),H),hy=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),b("path",{d:"M13.5 6.5l4 4"})]}),H),Bj=L(N("g",{strokeWidth:1,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M11 7l-5 5l5 5"}),b("path",{d:"M17 7l-5 5l5 5"})]}),H),gy=L(N("g",{strokeWidth:"1.75",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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"}),b("path",{d:"M15 4l0 16"})]}),H),Oj=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("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),Fj=L(N("g",{strokeWidth:"1.25",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M3 4l18 0"}),b("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),b("path",{d:"M12 16l0 4"}),b("path",{d:"M9 20l6 0"}),b("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),H),od=b("div",{style:{width:"1rem",height:"1rem"}}),fy=L(N("g",{strokeWidth:"1.5",children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("polyline",{points:"9 6 15 12 9 18"})]}),H),by=L(N("g",{strokeWidth:1.25,children:[b("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),b("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M4 6l8 0"}),b("path",{d:"M16 6l4 0"}),b("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M4 12l2 0"}),b("path",{d:"M10 12l10 0"}),b("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),b("path",{d:"M4 18l11 0"}),b("path",{d:"M19 18l1 0"})]}),H);import xy from"clsx";import eh,{useEffect as PA,useRef as Ey,useState as AA}from"react";import{isPromiseLike as LA}from"@nous-excalidraw/common";import kA from"react";import{jsx as Qu}from"react/jsx-runtime";var MA=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(kA.useRef(Date.now()).current%1600);return Qu("div",{className:`Spinner ${n}`,children:Qu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Qu("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},bt=MA;import{jsx as Ks,jsxs as $s}from"react/jsx-runtime";var q=eh.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=Ne(),a=eh.useRef(null);eh.useImperativeHandle(r,()=>a.current);let s=`ToolIcon_size_${e}`,[l,c]=AA(!1),d=Ey(!0),p=async u=>{let f="onClick"in n&&n.onClick?.(u);if(LA(f))try{c(!0),await f}catch(h){if(h instanceof Pi)console.warn(h);else throw h}finally{d.current&&c(!1)}};PA(()=>(d.current=!0,()=>{d.current=!1}),[]);let m=Ey(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return $s("button",{className:xy("ToolIcon_type_button",s,t,o&&!n.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!n.hidden,"ToolIcon--selected":n.selected,"ToolIcon--plain":n.type==="icon"}),style:n.style,"data-testid":n["data-testid"],hidden:n.hidden,title:n.title,"aria-label":n["aria-label"],type:u,onClick:p,ref:a,disabled:l||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&$s("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&Ks("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&Ks(bt,{})]}),n.showAriaLabel&&$s("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",l&&Ks(bt,{})]}),n.children]})}return $s("label",{className:xy("ToolIcon",t),title:n.title,onPointerDown:u=>{m.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{m.current=null})},children:[Ks("input",{className:`ToolIcon_type_radio ${s}`,type:"radio",name:n.name,"aria-label":n["aria-label"],"aria-keyshortcuts":n["aria-keyshortcuts"],"data-testid":n["data-testid"],id:`${i}-${n.id}`,onChange:()=>{n.onChange?.({pointerType:m.current})},checked:n.checked,ref:a}),$s("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&Ks("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});q.displayName="ToolButton";var nd=[],O=e=>(nd=nd.concat(e),e);import{jsx as HA}from"react/jsx-runtime";var zA=(e,o,t)=>{let n=new Set(ie(e.filter(d=>BA(d)),o).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of n){let p=OA(e,d);for(let m of p)if(!a.has(m.id)){if(rd(m)){let u=wy(m,i);u&&(r[u.id]=!0)}else r[m.id]=!0;a.add(m.id)}}let s=!0,l=e.map(d=>{if(o.selectedElementIds[d.id]){let p=rd(d)?wy(d,i):null;return d.frameId&&n.has(d.frameId)?(s=!1,r[d.id]=!0,d):p?.frameId&&n.has(p?.frameId)?d:(d.boundElements&&d.boundElements.forEach(m=>{let u=t.scene.getNonDeletedElementsMap().get(m.id);u&&NA(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),ad(d,{isDeleted:!0}))}return d.frameId&&n.has(d.frameId)?(s=!1,rd(d)||(r[d.id]=!0),ad(d,{frameId:null})):rd(d)&&o.selectedElementIds[d.containerId]?ad(d,{isDeleted:!0}):d}),c=o.editingGroupId;if(s&&o.editingGroupId){let d=nh(l,o.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(f=>f===o.editingGroupId),u=p.groupIds[m+1];if(u){let f=nh(l,u).filter(h=>!h.isDeleted);f.length>1&&(c=u,f.forEach(h=>{r[h.id]=!0}))}}}}return{elements:l,appState:{...o,...FA({selectedElementIds:r,editingGroupId:c},l,o,null)}}},vy=(e,o)=>{if(e.editingGroupId){let t=nh(oh(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Zs=O({name:"deleteSelectedElements",label:"labels.delete",icon:ft,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:s}=o.selectedLinearElement,l=n.scene.getNonDeletedElementsMap(),c=yy.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(m=>m.id===c.id?ad(m,{isDeleted:!0}):m),p=vy(o,d);return{elements:d,appState:{...p,selectedLinearElement:null},captureUpdate:id.IMMEDIATELY}}return yy.deletePoints(c,n,s),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:id.IMMEDIATELY}}let{elements:r,appState:i}=zA(e,o,n);return RA(r,r.filter(a=>a.isDeleted)),i=vy(i,r),{elements:r,appState:{...i,activeTool:DA(o,{type:n.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ae(oh(e),o)?id.IMMEDIATELY:id.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===th.BACKSPACE||e.key===th.DELETE)&&!e[th.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=dt()==="mobile";return HA(q,{type:"button",icon:ft,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),disabled:!Ae(oh(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?_A:{}}})}});import{KEYS as ea,CODES as ta,isDarwin as sd}from"@nous-excalidraw/common";import{moveOneLeft as GA,moveOneRight as UA,moveAllLeft as WA,moveAllRight as YA}from"@nous-excalidraw/element";import{CaptureUpdateAction as ld}from"@nous-excalidraw/element";import{isDarwin as Ty}from"@nous-excalidraw/common";var B=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,Ty?g("keys.option"):g("keys.alt")).replace(/\bShift\b/i,g("keys.shift")).replace(/\b(Enter|Return)\b/i,g("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,Ty?g("keys.cmd"):g("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,g("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,g("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,g("keys.delete"));import{jsx as cd}from"react/jsx-runtime";var rh=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Ou,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:GA(e,o,n.scene),appState:o,captureUpdate:ld.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ea.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ta.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>cd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${B("CtrlOrCmd+[")}`,children:Ou})}),ih=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Bu,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:UA(e,o,n.scene),appState:o,captureUpdate:ld.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ea.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ta.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>cd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${B("CtrlOrCmd+]")}`,children:Bu})}),ah=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:zu,trackEvent:{category:"element"},perform:(e,o)=>({elements:WA(e,o),appState:o,captureUpdate:ld.IMMEDIATELY}),keyTest:e=>sd?e[ea.CTRL_OR_CMD]&&e.altKey&&e.code===ta.BRACKET_LEFT:e[ea.CTRL_OR_CMD]&&e.shiftKey&&e.code===ta.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>cd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${sd?B("CtrlOrCmd+Alt+["):B("CtrlOrCmd+Shift+[")}`,children:zu})}),sh=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Fu,trackEvent:{category:"element"},perform:(e,o)=>({elements:YA(e,o),appState:o,captureUpdate:ld.IMMEDIATELY}),keyTest:e=>sd?e[ea.CTRL_OR_CMD]&&e.altKey&&e.code===ta.BRACKET_RIGHT:e[ea.CTRL_OR_CMD]&&e.shiftKey&&e.code===ta.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>cd("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${sd?B("CtrlOrCmd+Alt+]"):B("CtrlOrCmd+Shift+]")}`,children:Fu})});import{getNonDeletedElements as VA}from"@nous-excalidraw/element";import{LinearElementEditor as XA}from"@nous-excalidraw/element";import{isLinearElement as KA,isTextElement as $A}from"@nous-excalidraw/element";import{arrayToMap as ZA,KEYS as Iy}from"@nous-excalidraw/common";import{selectGroupsForSelectedElements as jA}from"@nous-excalidraw/element";import{CaptureUpdateAction as qA}from"@nous-excalidraw/element";var lh=O({name:"selectAll",label:"labels.selectAll",icon:JE,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!($A(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...jA({editingGroupId:null,selectedElementIds:r},VA(e),o,n),selectedLinearElement:Object.keys(r).length===1&&KA(e[0])?new XA(e[0],ZA(e)):null},captureUpdate:qA.IMMEDIATELY}},keyTest:e=>e[Iy.CTRL_OR_CMD]&&e.key===Iy.A});import{DEFAULT_GRID_SIZE as Cy,KEYS as Sy,MOBILE_ACTION_BUTTON_BG as JA,arrayToMap as ky}from"@nous-excalidraw/common";import{getNonDeletedElements as My}from"@nous-excalidraw/element";import{LinearElementEditor as QA}from"@nous-excalidraw/element";import{getSelectedElements as e6,getSelectionStateForElements as t6}from"@nous-excalidraw/element";import{syncMovedIndices as o6}from"@nous-excalidraw/element";import{duplicateElements as n6}from"@nous-excalidraw/element";import{CaptureUpdateAction as Py}from"@nous-excalidraw/element";import{jsx as r6}from"react/jsx-runtime";var ch=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Hs,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=QA.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:a,captureUpdate:Py.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=n6({type:"in-place",elements:e,idsOfElementsToDuplicate:ky(e6(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:s})=>{let l=a.frameId&&s.get(a.frameId);return{x:a.x+Cy/2,y:a.y+Cy/2,frameId:l??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:o6(i,ky(r)),appState:{...o,...t6(r,My(i),o)},captureUpdate:Py.IMMEDIATELY}},keyTest:e=>e[Sy.CTRL_OR_CMD]&&e.key===Sy.D,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=dt()==="mobile";return r6(q,{type:"button",icon:Hs,title:`${g("labels.duplicateSelection")} \u2014 ${B("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Ae(My(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?JA:{}}})}});import{pointFrom as dL}from"@nous-excalidraw/math";import{useEffect as Lh,useMemo as Rh,useRef as _h,useState as mL}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as pL,DEFAULT_ELEMENT_BACKGROUND_PICKS as uL,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as hL,DEFAULT_ELEMENT_STROKE_PICKS as gL,ARROW_TYPE as ao,DEFAULT_FONT_FAMILY as fL,FONT_FAMILY as bL,ROUNDNESS as Sd,STROKE_WIDTH_CUSTOM_DATA_KEY as xL,getStrokeWidthPresetsForZoom as EL,getFontSizePresetsForZoom as yL,VERTICAL_ALIGN as Cd,KEYS as ca,randomInteger as wL,arrayToMap as Nh,getFontFamilyString as vL,getLineHeight as TL,isTransparent as IL,reduceToCommonValue as CL,invariant as Bh}from"@nous-excalidraw/common";import{canBecomePolygon as SL,getNonDeletedElements as vw}from"@nous-excalidraw/element";import{bindBindingElement as bw,calculateFixedPointForElbowArrowBinding as xw,updateBoundElements as kL}from"@nous-excalidraw/element";import{LinearElementEditor as Zr}from"@nous-excalidraw/element";import{newElementWith as at}from"@nous-excalidraw/element";import{getArrowheadForPicker as Ew}from"@nous-excalidraw/element";import{getBoundTextElement as ar,redrawTextBoundingBox as al}from"@nous-excalidraw/element";import{isArrowElement as kd,isBoundToContainer as ML,isElbowArrow as Tw,isLinearElement as Dh,isLineElement as yw,isTextElement as Ft,isUsingAdaptiveRadius as PL}from"@nous-excalidraw/element";import{hasStrokeColor as AL}from"@nous-excalidraw/element";import{updateElbowArrowPoints as LL,CaptureUpdateAction as st,toggleLinePolygonState as _L}from"@nous-excalidraw/element";import{deriveStylesPanelMode as DL}from"@nous-excalidraw/common";import{isDevEnv as i6}from"@nous-excalidraw/common";var a6=new Set(["command_palette","export"]),me=(e,o,t,n)=>{try{if(typeof window>"u"||C.VITE_WORKER_ID||C.VITE_APP_ENABLE_TRACKING!=="true"||!a6.has(e)||i6())return;C.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:n}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:n})}catch(r){console.error("error during analytics",r)}};import d6 from"clsx";import s6 from"clsx";import{forwardRef as l6}from"react";import{jsx as c6}from"react/jsx-runtime";var oa=l6((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:a,icon:s,onClick:l}=e;return c6("button",{type:"button",ref:o,title:t,"data-testid":r,className:s6(n,{standalone:a,active:i}),onClick:l,style:e.style,children:s},t)});import{Fragment as p6,jsx as dh,jsxs as m6}from"react/jsx-runtime";var no=e=>dh(p6,{children:e.options.map(o=>e.type==="button"?dh(oa,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):m6("label",{className:d6({active:e.value===o.value}),title:o.text,children:[dh("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import{Popover as Zy}from"radix-ui";import jy from"clsx";import{useRef as qy,useEffect as h4}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as Ky,COLOR_PALETTE as Jy,isColorDark as $y,isWritableElement as g4}from"@nous-excalidraw/common";import{jsx as u6}from"react/jsx-runtime";var dd=()=>u6("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as x6,useRef as E6}from"react";import{createPortal as y6}from"react-dom";import{EVENT as qn,KEYS as w6,rgbToHex as v6}from"@nous-excalidraw/common";import Ay from"react";var mh=Ay.createContext(null),se=()=>Ay.useContext(mh);import{useState as h6,useLayoutEffect as Ly}from"react";import{THEME as g6}from"@nous-excalidraw/common";var md=e=>{let[o,t]=h6(null),n=be(),{theme:r}=se(),{container:i}=Ne();return Ly(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",n.formFactor==="phone"),o.classList.toggle("theme--dark",r===g6.DARK))},[o,r,n.formFactor,e?.className]),Ly(()=>{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]),o};import{useEffect as f6}from"react";import{EVENT as pd}from"@nous-excalidraw/common";function na(e,o,t){f6(()=>{function n(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(pd.POINTER_DOWN,n),document.addEventListener(pd.TOUCH_START,n),()=>{document.removeEventListener(pd.POINTER_DOWN,n),document.removeEventListener(pd.TOUCH_START,n)}},[e,o,t])}import{useRef as b6}from"react";var jn=e=>{let o=b6(e);return Object.assign(o.current,e),o.current};import{jsx as T6}from"react/jsx-runtime";var Jn=fe(null),_y=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=md({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=se(),a=Qn(),s=He(),l=ie(a,i),c=jn({app:s,onCancel:e,onChange:o,onSelect:t,selectedElements:l}),{container:d}=Ne();x6(()=>{let m=p.current;if(!m||!s.canvas||!r)return;let u=!1,f=s.canvas.getContext("2d"),h=({clientX:I,clientY:M})=>{let S=f.getImageData((I-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return v6(S[0],S[1],S[2])},x=({clientX:I,clientY:M,altKey:S})=>{m.style.top=`${M+20}px`,m.style.left=`${I+20}px`;let _=h({clientX:I,clientY:M});u&&c.onChange(n,_,c.selectedElements,{altKey:S}),m.style.background=_},E=()=>{c.onCancel()},w=(I,M)=>{c.onSelect(I,M)},y=I=>{u=!0,I.stopImmediatePropagation()},v=I=>{u=!1,d?.focus(),I.stopImmediatePropagation(),I.preventDefault(),w(h(I),I)},T=I=>{I.key===w6.ESCAPE&&(I.preventDefault(),I.stopImmediatePropagation(),E())};return r.tabIndex=-1,r.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(qn.KEYDOWN,T),r.addEventListener(qn.POINTER_DOWN,y),r.addEventListener(qn.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(qn.BLUR,E),()=>{u=!1,r.removeEventListener(qn.KEYDOWN,T),r.removeEventListener(qn.POINTER_DOWN,y),r.removeEventListener(qn.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(qn.BLUR,E)}},[c,s.canvas,r,n,d,i.offsetLeft,i.offsetTop]);let p=E6(null);return na(p,()=>{e()},m=>!!m.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?y6(T6("div",{ref:p,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as ph}from"radix-ui";import k6 from"clsx";import M6 from"react";import{isInteractive as P6}from"@nous-excalidraw/common";import I6 from"react";import C6 from"clsx";import{jsx as S6}from"react/jsx-runtime";var Ze=I6.forwardRef(({children:e,padding:o,className:t,style:n},r)=>S6("div",{className:C6("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as uh,jsxs as A6}from"react/jsx-runtime";var Tn=M6.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l,preventAutoFocusOnTouch:c=!1},d)=>{let p=be(),m=p.formFactor==="phone"&&!p.isLandscape;return uh(ph.Portal,{container:o,children:A6(ph.Content,{ref:d,className:k6("focus-visible-none",e),"data-prevent-outside-click":!0,side:m?"bottom":"right",align:m?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:o??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:p.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onOpenAutoFocus:u=>{c&&p.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),o&&!P6(document.activeElement)&&o.focus(),r()},children:[uh(Ze,{padding:3,style:n,children:t}),uh(ph.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 L6,useCallback as hh}from"react";var ud=()=>document.querySelector(".excalidraw-wysiwyg"),hd=()=>{let e=ud();return e?{start:e.selectionStart,end:e.selectionEnd}:null},js=e=>{setTimeout(()=>{let o=ud();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},qs=(e,o,t,n)=>{o&&n&&n();let r=o&&t?hd():null;e(),o&&t&&js(r)},Dy=()=>{let[e,o]=L6(null),t=hh(()=>{let i=hd();o(i)},[]),n=hh(()=>{setTimeout(()=>{let i=ud();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,o(null)))},0)},[e]),r=hh(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:n,clearSavedPosition:r,hasSavedPosition:!!e}},Ry=(e=100)=>{let o=ud();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import D6 from"clsx";import{useCallback as R6,useEffect as fh,useRef as By,useState as N6}from"react";import{KEYS as bh,normalizeInputColor as B6}from"@nous-excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as _6}from"@nous-excalidraw/common";var er=({palette:e,color:o})=>{if(!o)return null;for(let[t,n]of Object.entries(e))if(Array.isArray(n)){let r=n.indexOf(o);if(r>-1)return{colorName:t,shade:r}}else if(n===o)return{colorName:t,shade:null};return null},Js=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),gh=({color:e,palette:o})=>!Object.values(o).flat().includes(e),Ny=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[n[o]];return gh({color:s,palette:t})}),i=new Map;return r.forEach(a=>{let s=a[n[o]];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,_6)},ro=fe(null);import{Fragment as O6,jsx as gd,jsxs as Oy}from"react/jsx-runtime";var Fy=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=be(),[a,s]=N6(e),[l,c]=Q(ro);fh(()=>{s(e)},[e]);let d=R6(h=>{let x=h.toLowerCase(),E=B6(x);E&&o(E),s(x)},[o]),p=By(null),m=By(null);fh(()=>{p.current&&p.current.focus()},[l]);let[u,f]=Q(Jn);return fh(()=>()=>{f(null)},[f]),Oy("div",{className:"color-picker__input-label",children:[gd("div",{className:"color-picker__input-hash",children:"#"}),gd("input",{ref:l==="hex"?p:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:h=>{d(h.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:h=>{h.key!==bh.TAB&&(h.key===bh.ESCAPE&&m.current?.focus(),h.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&Oy(O6,{children:[gd("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),gd("div",{ref:m,className:D6("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(h=>h?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:n}),title:`${g("labels.eyeDropper")} \u2014 ${bh.I.toLocaleUpperCase()} or ${B("Alt")} `,children:GE})]})]})};import wh,{useEffect as vh,useImperativeHandle as n4,useState as r4}from"react";import{EVENT as Yy}from"@nous-excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as i4,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as a4,KEYS as s4}from"@nous-excalidraw/common";import G6 from"clsx";import{useEffect as U6,useRef as W6}from"react";import{isColorDark as F6}from"@nous-excalidraw/common";import{jsxs as H6}from"react/jsx-runtime";var z6=({color:e,keyLabel:o,isShade:t=!1})=>H6("div",{className:"color-picker__button__hotkey-label",style:{color:F6(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),ra=z6;import{jsx as xh,jsxs as Y6}from"react/jsx-runtime";var zy=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=Q(ro),a=W6(null);return U6(()=>{a.current&&a.current.focus()},[o,r]),xh("div",{className:"color-picker-content--default",children:e.map((s,l)=>Y6("button",{ref:o===s?a:void 0,tabIndex:-1,type:"button",className:G6("color-picker__button color-picker__button--large has-outline",{active:o===s,"is-transparent":s==="transparent"||!s}),onClick:()=>{t(s),i("custom")},title:s,"aria-label":n,style:{"--swatch-color":s},children:[xh("div",{className:"color-picker__button-outline"}),xh(ra,{color:s,keyLabel:l+1})]},l))})};import V6 from"clsx";import{useEffect as X6,useRef as K6}from"react";import{jsx as Eh,jsxs as Z6}from"react/jsx-runtime";var $6=({palette:e,color:o,onChange:t,activeShade:n,showHotKey:r=!0})=>{let i=er({color:o,palette:e}),[a,s]=Q(ro),l=K6(null);return X6(()=>{l.current&&a==="baseColors"&&l.current.focus()},[i?.colorName,a]),Eh("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,d],p)=>{let m=(Array.isArray(d)?d[n]:d)||"transparent",u=Js[p],f=g(`colors.${c.replace(/\d+/,"")}`,null,"");return Z6("button",{ref:i?.colorName===c?l:void 0,tabIndex:-1,type:"button",className:V6("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===c,"is-transparent":m==="transparent"||!m}),onClick:()=>{t(m),s("baseColors")},title:`${f}${m.startsWith("#")?` ${m}`:""} \u2014 ${u}`,"aria-label":`${f} \u2014 ${u}`,style:m?{"--swatch-color":m}:void 0,"data-testid":`color-${c}`,children:[Eh("div",{className:"color-picker__button-outline"}),r&&Eh(ra,{color:m,keyLabel:u})]},c)})})},Hy=$6;import{jsx as q6}from"react/jsx-runtime";var j6=({children:e})=>q6("div",{className:"color-picker__heading",children:e}),ia=j6;import J6 from"clsx";import{useEffect as Q6,useRef as e4}from"react";import{jsx as Qs,jsxs as Gy}from"react/jsx-runtime";var Uy=({color:e,onChange:o,palette:t,showHotKey:n})=>{let r=er({color:e||"transparent",palette:t}),[i,a]=Q(ro),s=e4(null);if(Q6(()=>{s.current&&i==="shades"&&s.current.focus()},[r,i]),r){let{colorName:l,shade:c}=r,d=t[l];if(Array.isArray(d))return Qs("div",{className:"color-picker-content--default shades",children:d.map((p,m)=>Gy("button",{ref:m===c&&i==="shades"?s:void 0,tabIndex:-1,type:"button",className:J6("color-picker__button color-picker__button--large has-outline",{active:m===c}),"aria-label":"Shade",title:`${l} - ${m+1}`,style:p?{"--swatch-color":p}:void 0,onClick:()=>{o(p),a("shades")},children:[Qs("div",{className:"color-picker__button-outline"}),n&&Qs(ra,{color:p,keyLabel:m+1,isShade:!0})]},m))})}return Gy("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Qs("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Qs("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:g("colorPicker.noShades")})]})};import{COLORS_PER_ROW as aa,COLOR_PALETTE as t4,KEYS as el}from"@nous-excalidraw/common";var yh=(e,o,t)=>{let n=Math.ceil(t/aa);switch(o=o??-1,e){case"ArrowLeft":{let r=o-1;return r<0?t-1:r}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let r=o+aa;return r>=t?o%aa:r}case"ArrowUp":{let r=o-aa,i=r<0?aa*n+r:r;return i>=t?void 0:i}}},o4=({e,colorObj:o,onChange:t,palette:n,customColors:r,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let s=Number(e.code.slice(-1))-1;return t(n[o.colorName][s]),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(Js.includes(e.key)){let s=Js.indexOf(e.key),l=Object.keys(n)[s],c=n[l],d=Array.isArray(c)?c[a]:c;return t(d),i("baseColors"),!0}return!1},Wy=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d})=>{if(e[el.CTRL_OR_CMD])return!1;if(e.key===el.ESCAPE)return d(e),!0;if(e.key===el.ALT)return c(!0),!0;if(e.key===el.I)return c(),!0;let p=er({color:n,palette:t});if(e.key===el.TAB){let m={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},u=Object.entries(m).reduce((w,[y,v])=>(v&&w.push(y),w),[]),f=u.indexOf(o),h=e.shiftKey?-1:1,x=f+h>u.length-1?0:f+h<0?u.length-1:f+h,E=u[x];return E&&a(E),E==="custom"?r(i[0]):E==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(n):v===n?y:null)||r(t4.black)),e.preventDefault(),e.stopPropagation(),!0}if(o4({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:l}))return!0;if(o==="shades"&&p){let{shade:m}=p,u=yh(e.key,m,aa);if(u!==void 0)return r(t[p.colorName][u]),!0}if(o==="baseColors"&&p){let{colorName:m}=p,u=Object.keys(t),f=u.indexOf(m),h=yh(e.key,f,u.length);if(h!==void 0){let x=u[h],E=t[x];return r(Array.isArray(E)?E[l]:E),!0}}if(o==="custom"){let m=n!=null?i.indexOf(n):0,u=yh(e.key,m,i.length);if(u!==void 0){let f=i[u];return r(f),!0}}return!1};import{jsx as tr,jsxs as fd}from"react/jsx-runtime";var Vy=wh.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:a,showTitle:s,onEyeDropperToggle:l,onEscape:c,showHotKey:d=!0},p)=>{let m=s?t==="elementStroke"?g("labels.stroke"):t==="elementBackground"?g("labels.background"):null:null,[u]=wh.useState(()=>t==="canvasBackground"?[]:Ny(n,t,r)),[f,h]=Q(ro),x=er({color:e,palette:r});vh(()=>{if(!f){let v=!!e&&gh({color:e,palette:r}),T=v&&!u.includes(e);h(T?null:v?"custom":x?.shade!=null?"shades":"baseColors")}},[f,e,r,h,x,u]);let[E,w]=r4(x?.shade??(t==="elementBackground"?i4:a4));vh(()=>{x?.shade!=null&&w(x.shade);let v=T=>{T.key===s4.ALT&&l(!1)};return document.addEventListener(Yy.KEYUP,v,{capture:!0}),()=>{document.removeEventListener(Yy.KEYUP,v,{capture:!0})}},[x,l]);let y=wh.useRef(null);return n4(p,()=>y.current),vh(()=>{y?.current?.focus()},[]),tr("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:fd("div",{ref:y,onKeyDown:v=>{Wy({event:v,activeColorPickerSection:f,palette:r,color:e,onChange:o,onEyeDropperToggle:l,customColors:u,setActiveColorPickerSection:h,updateData:i,activeShade:E,onEscape:c})&&(v.preventDefault(),v.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[m&&tr("div",{className:"color-picker__title",children:m}),!!u.length&&fd("div",{children:[tr(ia,{children:g("colorPicker.mostUsedCustomColors")}),tr(zy,{colors:u,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),fd("div",{children:[tr(ia,{children:g("colorPicker.colors")}),tr(Hy,{color:e,palette:r,onChange:o,activeShade:E,showHotKey:d})]}),fd("div",{children:[tr(ia,{children:g("colorPicker.shades")}),tr(Uy,{color:e,onChange:o,palette:r,showHotKey:d})]}),a]})})});import l4 from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as c4,DEFAULT_CANVAS_BACKGROUND_PICKS as d4,DEFAULT_ELEMENT_BACKGROUND_PICKS as m4,DEFAULT_ELEMENT_STROKE_PICKS as p4,isColorDark as u4}from"@nous-excalidraw/common";import{jsx as Th}from"react/jsx-runtime";var Xy=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=p4),o==="elementBackground"&&(r=m4),o==="canvasBackground"&&(r=d4),n&&(r=n),r?Th("div",{className:"color-picker__top-picks",children:r.map(i=>Th("button",{className:l4("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!u4(i,c4)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Th("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as io,jsxs as bd}from"react/jsx-runtime";var f4=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=Jy,updateData:a,getOpenPopup:s,appState:l})=>{let{container:c}=Ne(),d=dt(),p=d!=="full",m=d==="mobile",[,u]=Q(ro),[f,h]=Q(Jn),x=bd("div",{children:[io(ia,{children:g("colorPicker.hexCode")}),io(Fy,{color:o||"",label:n,onChange:y=>{t(y)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),E=qy(null),w=()=>{E.current?.focus()};return io(Tn,{container:c,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:y=>{g4(y.target)||w(),y.preventDefault()},onPointerDownOutside:y=>{f&&y.preventDefault()},onClose:()=>{s()===e&&a({openPopup:null}),u(null),l.editingTextElement&&setTimeout(()=>{let y=document.querySelector(".excalidraw-wysiwyg");y&&y.focus()},0)},children:i?io(Vy,{ref:E,palette:i,color:o,onChange:y=>{let v=l.editingTextElement?hd():null;t(y),l.editingTextElement&&v&&js(v)},onEyeDropperToggle:y=>{h(v=>y?(v=v||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},v.keepOpenOnAlt=!0,v):y===!1||v?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:y=>{f?h(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!m,children:x}):x})},b4=({label:e,color:o,type:t,mode:n="background",onToggle:r,editingTextElement:i})=>{let a=dt(),s=a!=="full",l=a==="mobile",c=d=>{d.preventDefault(),d.stopPropagation(),i&&Ry(),r()};return bd(Zy.Trigger,{type:"button",className:jy("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!$y(o,Ky),"compact-sizing":s,"mobile-border":l}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),"data-openpopup":t,onClick:c,children:[io("div",{className:"color-picker__button-outline",children:!o&&U0}),s&&o&&n==="stroke"&&io("div",{className:"color-picker__button-background",children:io("span",{style:{color:o&&$y(o,Ky)?"#fff":"#111"},children:uy})})]})},tl=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=Jy,topPicks:a,updateData:s,appState:l})=>{let c=qy(l.openPopup);h4(()=>{c.current=l.openPopup},[l.openPopup]);let p=dt()!=="full";return io("div",{children:bd("div",{role:"dialog","aria-modal":"true",className:jy("color-picker-container",{"color-picker-container--no-top-picks":p}),children:[!p&&io(Xy,{activeColor:o,onChange:t,type:e,topPicks:a}),!p&&io(dd,{}),bd(Zy.Root,{open:l.openPopup===e,onOpenChange:m=>{m&&s({openPopup:e})},children:[io(b4,{color:o,label:n,type:e,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&&io(f4,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:s,getOpenPopup:()=>c.current,appState:l})]})]})})};import{Popover as V4}from"radix-ui";import X4 from"clsx";import K4,{useCallback as $4,useMemo as Z4}from"react";import{FONT_FAMILY as kh}from"@nous-excalidraw/common";import N4,{useMemo as rr,useState as B4,useRef as ow,useEffect as nw,useCallback as rw}from"react";import{arrayToList as O4,debounce as F4,FONT_FAMILY as ir,getFontFamilyString as z4}from"@nous-excalidraw/common";import x4 from"clsx";import E4 from"react";import{jsx as y4,jsxs as w4}from"react/jsx-runtime";var xd=E4.forwardRef(({className:e,placeholder:o,onChange:t},n)=>w4("div",{className:x4("QuickSearch__wrapper",e),children:[Kt,y4("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import v4 from"clsx";import{Children as T4}from"react";import{jsx as Qy}from"react/jsx-runtime";var Ed=({className:e,placeholder:o,children:t})=>{let n=!T4.count(t);return Qy("div",{className:v4("ScrollableList__wrapper",e),role:"menu",children:n?Qy("div",{className:"empty",children:o}):t})};import{jsx as I4,jsxs as C4}from"react/jsx-runtime";var ew=({children:e,className:o="",style:t,title:n})=>C4("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&I4("p",{className:"dropdown-menu-group-title",children:n}),e]}),ol=ew;ew.displayName="DropdownMenuGroup";import{THEME as D4}from"@nous-excalidraw/common";import{DropdownMenu as R4}from"radix-ui";import S4,{useContext as k4}from"react";import{composeEventHandlers as M4}from"@nous-excalidraw/common";var Ih=S4.createContext({}),or=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),yd=e=>{let o=k4(Ih);return M4(e,t=>{o.onSelect?.(t)})};import{jsx as P4}from"react/jsx-runtime";var $r=({children:e,...o})=>P4("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as L4,jsx as nl,jsxs as _4}from"react/jsx-runtime";var A4=({textStyle:e,icon:o,shortcut:t,children:n,badge:r})=>{let i=be();return _4(L4,{children:[o&&nl("div",{className:"dropdown-menu-item__icon",children:o}),nl("div",{style:e,className:"dropdown-menu-item__text",children:nl($r,{children:n})}),r&&nl("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&nl("div",{className:"dropdown-menu-item__shortcut",children:t})]})},nr=A4;import{jsx as wd}from"react/jsx-runtime";var Ch=({icon:e,badge:o,value:t,children:n,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=yd(s);return wd(R4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:wd("button",{...l,value:t,className:or(i,a),title:l.title??l["aria-label"],children:wd(nr,{icon:e,shortcut:r,badge:o,children:n})})})};Ch.displayName="DropdownMenuItem";var sa={GREEN:"green",RED:"red",BLUE:"blue"},vd=({type:e=sa.BLUE,children:o})=>{let{theme:t}=jo(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===D4.LIGHT?"1.5px solid white":"none"};switch(e){case sa.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case sa.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case sa.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return wd("div",{className:"DropDownMenuItemBadge",style:n,children:o})};vd.displayName="DropdownMenuItemBadge";Ch.Badge=vd;var Pt=Ch;import{KEYS as la}from"@nous-excalidraw/common";var tw=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[la.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===la.F)return o.current?.focus(),!0;if(e.key===la.ESCAPE)return r(),!0;if(e.key===la.ENTER)return t?.value&&i(t.value),!0;if(e.key===la.ARROW_DOWN)return t?.next?a(t.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===la.ARROW_UP)return t?.prev?a(t.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as In,jsxs as U4}from"react/jsx-runtime";var H4=e=>{switch(e){case ir.Excalifont:case ir.Virgil:return Ko;case ir.Nunito:case ir.Helvetica:return Ys;case ir["Lilita One"]:return AE;case ir["Comic Shanns"]:case ir.Cascadia:return jc;default:return Ys}},G4=(e,o)=>Object.entries(ir).find(([,t])=>t===e)?.[0]??o[0]?.fontFace?.family??"Unknown",iw=N4.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=Ne(),l=He(),{fonts:c}=l,{showDeprecatedFonts:d}=qo(),p=dt(),[m,u]=B4(""),f=ow(null),h=rr(()=>Array.from(yn.registered.entries()).filter(([P,{metadata:D}])=>!D.private&&!D.fallback).map(([P,{metadata:D,fontFaces:z}])=>{let K={value:P,icon:H4(P),text:G4(P,z)};return D.deprecated&&Object.assign(K,{deprecated:D.deprecated,badge:{type:sa.RED,placeholder:g("fontList.badge.old")}}),K}).sort((P,D)=>P.text.toLowerCase()>D.text.toLowerCase()?1:-1),[]),x=rr(()=>new Set(c.getSceneFamilies()),[e]),E=rr(()=>h.filter(P=>x.has(P.value)),[h,x]),w=rr(()=>h.filter(P=>!x.has(P.value)&&(d||!P.deprecated)),[h,x,d]),y=rr(()=>O4([...E,...w].filter(P=>P.text?.toLowerCase().includes(m))),[E,w,m]),v=rr(()=>{let P;return o?P=y.find(D=>D.value===o):e&&(P=y.find(D=>D.value===e)),!P&&m&&(y[0]?.value?n(y[0].value):r()),P},[o,e,m,y,n,r]),T=rw(P=>{let D=null;if(l.state.editingTextElement){let z=document.querySelector(".excalidraw-wysiwyg");z&&(D={start:z.selectionStart,end:z.selectionEnd})}t(P),l.state.editingTextElement&&D&&setTimeout(()=>{let z=document.querySelector(".excalidraw-wysiwyg");z&&D&&(z.focus(),z.selectionStart=D.start,z.selectionEnd=D.end)},0)},[t,l.state.editingTextElement]),I=rw(P=>{tw({event:P,inputRef:f,hoveredFont:v,filteredFonts:y,onSelect:T,onHover:n,onClose:a})&&(P.preventDefault(),P.stopPropagation())},[v,y,T,n,a]);nw(()=>(i(),()=>{a()}),[]);let M=rr(()=>y.filter(P=>x.has(P.value)),[y,x]),S=rr(()=>y.filter(P=>!x.has(P.value)),[y,x]),_=({font:P,order:D})=>{let z=ow(null),K=P.value===v?.value,W=P.value===e;return nw(()=>{K&&(D===0?z.current?.scrollIntoView?.({block:"end"}):z.current?.scrollIntoView?.({block:"nearest"}))},[K,D]),In("button",{ref:z,type:"button",value:P.value,className:or("",W,K),title:P.text,tabIndex:W?0:-1,onClick:Y=>{T(Number(Y.currentTarget.value))},onMouseMove:()=>{v?.value!==P.value&&n(P.value)},children:In(nr,{icon:P.icon,badge:P.badge&&In(vd,{type:P.badge.type,children:P.badge.placeholder}),textStyle:{fontFamily:z4({fontFamily:P.value})},children:P.text})})},A=[];return M.length&&A.push(In(ol,{title:g("fontList.sceneFonts"),children:M.map((P,D)=>In(_,{font:P,order:D},P.value))},"group_1")),S.length&&A.push(In(ol,{title:g("fontList.availableFonts"),children:S.map((P,D)=>In(_,{font:P,order:D+M.length},P.value))},"group_2")),U4(Tn,{className:"properties-content",container:s,style:{width:"15rem"},onClose:()=>{a(),l.state.editingTextElement&&setTimeout(()=>{let P=document.querySelector(".excalidraw-wysiwyg");P&&P.focus()},0)},onPointerLeave:r,onKeyDown:I,preventAutoFocusOnTouch:!!l.state.editingTextElement,children:[p==="full"&&In(xd,{ref:f,placeholder:g("quickSearch.placeholder"),onChange:F4(u,20)}),In(Ed,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:A.length?A:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import{Popover as W4}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as Y4}from"@nous-excalidraw/common";import{jsx as Sh}from"react/jsx-runtime";var aw=({selectedFontFamily:e,isOpened:o=!1,compactMode:t=!1})=>{let n=he(),r=t?{...Y4,width:"2rem",height:"2rem"}:{};return Sh(W4.Trigger,{asChild:!0,children:Sh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Sh(oa,{standalone:!0,icon:$o,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{n(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as rl,jsxs as sw}from"react/jsx-runtime";var lw=[{value:kh.Excalifont,icon:Ko,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:kh.Nunito,icon:Ys,text:g("labels.normal"),testId:"font-family-normal"},{value:kh["Comic Shanns"],icon:jc,text:g("labels.code"),testId:"font-family-code"}],$oe=new Set(lw.map(e=>e.value));var cw=K4.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=Z4(()=>lw,[]),c=$4(d=>{d&&n(d)},[n]);return sw("div",{role:"dialog","aria-modal":"true",className:X4("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&rl("div",{className:"buttonList",children:rl(no,{type:"button",options:l,value:o,onClick:c})}),!s&&rl(dd,{}),sw(V4.Root,{open:e,onOpenChange:a,children:[rl(aw,{selectedFontFamily:o,isOpened:e,compactMode:s}),e&&rl(iw,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import{Popover as Mh}from"radix-ui";import Q4 from"clsx";import uw,{useEffect as eL,useMemo as tL}from"react";import{isArrowKey as oL,KEYS as Cn}from"@nous-excalidraw/common";import{jsx as j4}from"react/jsx-runtime";var Jo=({className:e,icon:o,size:t="1em"})=>j4("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:o});import{Fragment as J4,jsx as dw,jsxs as mw}from"react/jsx-runtime";var q4=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>mw(J4,{children:[mw("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&dw(Jo,{icon:o?dy:ed})]}),o&&dw("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),il=q4;import{jsx as Qo,jsxs as Id}from"react/jsx-runtime";var nL=fe(!1),Td=4,rL="default",iL=e=>e.flatMap(o=>o.options),pw=(e,o)=>{for(let t of e){let n=t.options.find(o);if(n)return n}return null},aL=(e,o)=>e.some(t=>t.options.some(o)),sL=e=>e.flatMap(o=>Array.from({length:Math.ceil(o.options.length/Td)},(t,n)=>o.options.slice(n*Td,n*Td+Td)));function lL({visibleSections:e,hiddenSections:o=[],value:t,label:n,onChange:r,onClose:i}){let{container:a}=Ne(),[s,l]=Q(nL),c=[...e,...o],d=iL(c),p=sL([...e,...s?o:[]]),m=h=>{let x=d.find(E=>E.keyBinding===h.key.toLowerCase());if(!(h.metaKey||h.altKey||h.ctrlKey)&&x)r(x.value),h.preventDefault();else if(h.key===Cn.TAB){let E=d.findIndex(y=>y.value===t),w=h.shiftKey?(d.length+E-1)%d.length:(E+1)%d.length;r(d[w].value)}else if(oL(h.key)){let E=vn().rtl,w=d.findIndex(y=>y.value===t);if(w!==-1){let y=d.length,v=w;switch(h.key){case(E?Cn.ARROW_LEFT:Cn.ARROW_RIGHT):v=(w+1)%y;break;case(E?Cn.ARROW_RIGHT:Cn.ARROW_LEFT):v=(y+w-1)%y;break;case Cn.ARROW_DOWN:{let T=p.findIndex(M=>M.some(S=>S.value===t)),I=p[T];if(T!==-1&&I){let M=I.findIndex(A=>A.value===t),S=p[(T+1)%p.length],_=S[Math.min(M,S.length-1)]??d[w];r(_.value),h.preventDefault(),h.nativeEvent.stopImmediatePropagation(),h.stopPropagation();return}break}case Cn.ARROW_UP:{let T=p.findIndex(M=>M.some(S=>S.value===t)),I=p[T];if(T!==-1&&I){let M=I.findIndex(A=>A.value===t),S=p[(p.length+T-1)%p.length],_=S[Math.min(M,S.length-1)]??d[w];r(_.value),h.preventDefault(),h.nativeEvent.stopImmediatePropagation(),h.stopPropagation();return}break}}r(d[v].value)}h.preventDefault()}else(h.key===Cn.ESCAPE||h.key===Cn.ENTER)&&(h.preventDefault(),i());h.nativeEvent.stopImmediatePropagation(),h.stopPropagation()};eL(()=>{aL(o,h=>h.value===t)&&l(!0)},[t,o,l]);let u=h=>Qo("div",{className:"picker-content",children:h.map(x=>Id("button",{type:"button",className:Q4("picker-option",{active:t===x.value}),onClick:()=>{r(x.value)},title:x.keyBinding?`${x.text} \u2014 ${x.keyBinding.toUpperCase()}`:x.text,"aria-label":x.text||"none","aria-keyshortcuts":x.keyBinding||void 0,ref:E=>{t===x.value&&setTimeout(()=>{E?.focus()},0)},children:[x.icon,x.keyBinding&&Qo("span",{className:"picker-keybinding",children:x.keyBinding})]},x.text))}),f=h=>h.map((x,E)=>x.name===rL?Qo(uw.Fragment,{children:u(x.options)},`${x.name}-${E}`):Id("div",{className:"picker-section",children:[Qo("div",{className:"picker-section-label",children:x.name}),u(x.options)]},`${x.name}-${E}`));return Qo(Mh.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":n,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:m,collisionBoundary:a??void 0,children:Id("div",{className:"picker-sections",children:[f(e),o.length>0&&Qo(il,{label:g("labels.more_options"),open:s,openTrigger:()=>{l(h=>!h)},className:"picker-collapsible",children:Qo("div",{className:"picker-sections",children:f(o)})})]})})}function Ph({value:e,label:o,visibleSections:t,hiddenSections:n,onChange:r}){let[i,a]=uw.useState(!1),s=tL(()=>pw(t,l=>l.value===e)??pw(n??[],l=>l.value===e),[t,n,e]);return Qo("div",{children:Id(Mh.Root,{open:i,onOpenChange:l=>a(l),children:[Qo(Mh.Trigger,{type:"button","aria-label":o,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&Qo(lL,{visibleSections:t,hiddenSections:n,value:e,label:o,onChange:r,onClose:()=>{a(!1)}})]})})}import hw,{useEffect as cL}from"react";import{jsx as Ah,jsxs as gw}from"react/jsx-runtime";var fw=({label:e,value:o,onChange:t,min:n=0,max:r=100,step:i=10,minLabel:a=n,hasCommonValue:s=!0,testId:l})=>{let c=hw.useRef(null),d=hw.useRef(null);return cL(()=>{if(c.current&&d.current){let p=c.current,m=d.current,u=p.offsetWidth,f=parseFloat(getComputedStyle(p).getPropertyValue("--slider-thumb-size"))||16,h=(o-n)/(r-n||1)*100,x=h/100*(u-f)+f/2;m.style.left=`${x}px`,p.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${h}%, var(--button-bg) ${h}%, var(--button-bg) 100%)`}},[r,n,o]),gw("label",{className:"control-label",children:[e,gw("div",{className:"range-wrapper",children:[Ah("input",{style:{"--color-slider-track":s?void 0:"var(--button-bg)"},ref:c,type:"range",min:n,max:r,step:i,onChange:p=>{t(+p.target.value)},value:o,className:"range-input","data-testid":l}),Ah("div",{className:"value-bubble",ref:d,children:o!==n?o:null}),Ah("div",{className:"zero-label",children:a})]})]})};import{Fragment as Hh,jsx as re,jsxs as Lt}from"react/jsx-runtime";var Iw=.1,da=e=>{let o=DL(e.editorInterface);return{stylesPanelMode:o,isCompact:o!=="full",isMobile:o==="mobile"}},At=(e,o,t,n=!1)=>{let r=Nh(ie(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},xt=function(e,o,t,n,r){let i=o.state.editingTextElement,a=vw(e),s=null;if(i&&(s=t(i)),!s)if(Ae(a,o.state)){let c=o.scene.getSelectedElements(o.state),d=n===!0?c:c.filter(p=>n(p));s=CL(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},RL=(e,o,t)=>ML(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),Oh=(e,o,t,n,r)=>{let i=new Set,a=At(e,o,s=>{if(Ft(s)){let l=n(s);i.add(l);let c=at(s,{fontSize:l});return al(c,t.scene.getContainerElement(s),t.scene),c=RL(s,c,t.scene),c}return s},!0);return ie(e,o,{includeBoundTextElement:!0}).forEach(s=>{Ft(s)&&kL(s,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:st.IMMEDIATELY}},NL=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t?.currentItemStrokeColor&&{elements:At(e,o,n=>AL(n.type)?at(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t?.currentItemStrokeColor?st.IMMEDIATELY:st.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=da(n);return Lt(Hh,{children:[i==="full"&&re("h3",{"aria-hidden":"true",children:g("labels.stroke")}),re(tl,{topPicks:gL,palette:hL,type:"elementStroke",label:g("labels.stroke"),color:xt(e,n,a=>a.strokeColor,!0,a=>a?null:o.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:o,updateData:t})]})}}),BL=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t?.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:st.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!IL(t.currentItemBackgroundColor)&&i.every(s=>yw(s)&&SL(s.points))){let s=Nh(i);r=e.map(l=>s.has(l.id)&&yw(l)?at(l,{backgroundColor:t.currentItemBackgroundColor,..._L(l,!0)}):l)}else r=At(e,o,s=>at(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:st.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=da(n);return Lt(Hh,{children:[i==="full"&&re("h3",{"aria-hidden":"true",children:g("labels.background")}),re(tl,{topPicks:uL,palette:pL,type:"elementBackground",label:g("labels.background"),color:xt(e,n,a=>a.backgroundColor,!0,a=>a?null:o.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:o,updateData:t})]})}}),OL=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(me("element","changeFillStyle",`${t} (${n.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:At(e,o,r=>at(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=ie(e,o),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return Lt("fieldset",{children:[re("legend",{children:g("labels.fill")}),re("div",{className:"buttonList",children:re(no,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${B("Alt-Click")})`,icon:i?J0:Q0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:eE,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:tE,testId:"fill-solid"}],value:xt(e,n,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,s)=>{let l=s.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(l)}})})]})}}),FL=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:At(e,o,n=>at(n,{strokeWidth:t,customData:{...n.customData,[xL]:!0}})),appState:{...o,currentItemStrokeWidth:t,currentItemStrokeWidthCustom:!0},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=EL(o.zoom.value);return Lt("fieldset",{children:[re("legend",{children:g("labels.strokeWidth")}),re("div",{className:"buttonList",children:re(no,{group:"stroke-width",options:[{value:i.thin,text:g("labels.thin"),icon:$u,testId:"strokeWidth-thin"},{value:i.bold,text:g("labels.bold"),icon:oE,testId:"strokeWidth-bold"},{value:i.extraBold,text:g("labels.extraBold"),icon:nE,testId:"strokeWidth-extraBold"}],value:xt(e,n,a=>a.strokeWidth,a=>a.hasOwnProperty("strokeWidth"),a=>a?null:o.currentItemStrokeWidth),onChange:a=>t(a)})})]})}}),zL=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:At(e,o,n=>at(n,{seed:wL(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>Lt("fieldset",{children:[re("legend",{children:g("labels.sloppiness")}),re("div",{className:"buttonList",children:re(no,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:aE},{value:1,text:g("labels.artist"),icon:sE},{value:2,text:g("labels.cartoonist"),icon:lE}],value:xt(e,n,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:o.currentItemRoughness),onChange:i=>t(i)})})]})}),Qne=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:At(e,o,n=>at(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>Lt("fieldset",{children:[re("legend",{children:g("labels.strokeStyle")}),re("div",{className:"buttonList",children:re(no,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:$u},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:rE},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:iE}],value:xt(e,n,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:o.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),HL=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:At(e,o,n=>at(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=xt(e,t,i=>i.opacity,!0,i=>i?null:o.currentItemOpacity);return re(fw,{label:g("labels.opacity"),value:r??o.currentItemOpacity,hasCommonValue:r!==null,onChange:n,min:0,max:100,step:10,testId:"opacity"})}}),GL=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>Oh(e,o,n,()=>(Bh(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=da(n),a=yL(o.zoom.value);return Lt("fieldset",{children:[re("legend",{children:g("labels.fontSize")}),re("div",{className:"buttonList",children:re(no,{group:"font-size",options:[{value:a.sm,text:g("labels.small"),icon:SE,testId:"fontSize-small"},{value:a.md,text:g("labels.medium"),icon:kE,testId:"fontSize-medium"},{value:a.lg,text:g("labels.large"),icon:ME,testId:"fontSize-large"},{value:a.xl,text:g("labels.veryLarge"),icon:PE,testId:"fontSize-veryLarge"}],value:xt(e,n,s=>{if(Ft(s))return s.fontSize;let l=ar(s,n.scene.getNonDeletedElementsMap());return l?l.fontSize:null},s=>Ft(s)||ar(s,n.scene.getNonDeletedElementsMap())!==null,s=>s?null:o.currentItemFontSize||a.md),onChange:s=>{qs(()=>t(s),i,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),Fh=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Xr,trackEvent:!1,perform:(e,o,t,n)=>Oh(e,o,n,r=>Math.round(1/(1+Iw)*r.fontSize)),keyTest:e=>e[ca.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ca.CHEVRON_LEFT||e.key===ca.COMMA)}),zh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Xr,trackEvent:!1,perform:(e,o,t,n)=>Oh(e,o,n,r=>Math.round(r.fontSize*(1+Iw))),keyTest:e=>e[ca.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ca.CHEVRON_RIGHT||e.key===ca.PERIOD)}),UL=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,n)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...s}=t;if(i)return{elements:At(e,o,h=>{let x=r?.get(h.id);return x?at(h,{...x}):h},!0),appState:{...o,...s},captureUpdate:st.NEVER};Bh(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=st.EVENTUALLY,p,m=!1;if(l)p=l,d=st.IMMEDIATELY;else if(c){p=c,d=st.EVENTUALLY;let f=ie(e,o,{includeBoundTextElement:!0}).filter(h=>Ft(h));if(f.length>200)m=!0;else{let h=0,x=0;for(;h<f.length&&x<5e3;){let E=f[h];x+=E?.originalText.length||0,h++}x>5e3&&(m=!0)}}let u={appState:{...o,...s},captureUpdate:d};if(p&&!m){let f=new Map,h=new Set,x=!1,E=Array.from(yn.loadedFontsCache.values()),w=Object.entries(bL).find(([T,I])=>I===p)?.[0];c&&w&&E.some(T=>T.startsWith(w))&&(x=!0),Object.assign(u,{elements:At(e,o,T=>{if(Ft(T)&&(T.fontFamily!==p||l)){let I=at(T,{fontFamily:p,lineHeight:TL(p)}),M=r?.get(T.containerId||"")||{},S=n.scene.getContainerElement(T);return a&&S&&M&&n.scene.mutateElement(S,{...M}),x||(h=new Set([...h,...Array.from(I.originalText)])),f.set(I,S),I}return T},!0)});let y=`10px ${vL({fontFamily:p})}`,v=Array.from(h.values()).join();if(x||window.document.fonts.check(y,v))for(let[T,I]of f)al(T,I,n.scene);else window.document.fonts.load(y,v).then(T=>{for(let[I,M]of f){let S=n.scene.getElement(I.id),_=M?n.scene.getElement(M.id):null;S&&al(S,_,n.scene)}n.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=_h(new Map),i=_h(null),[a,s]=mL({}),l=_h(!0),{stylesPanelMode:c,isCompact:d}=da(t),p=Rh(()=>{let m=(u,f)=>xt(u,t,h=>{if(Ft(h))return h.fontFamily;let x=ar(h,f);return x?x.fontFamily:null},h=>Ft(h)||ar(h,f)!==null,h=>h?null:o.currentItemFontFamily||fL);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?m(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&o.openPopup!=="fontFamily"?m(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return Lh(()=>{i.current=p},[p]),Lh(()=>{Object.keys(a).length&&(n(a),s({}))},[a]),Lh(()=>(l.current=!1,()=>{l.current=!0}),[]),Lt(Hh,{children:[c==="full"&&re("legend",{children:g("labels.fontFamily")}),re(cw,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:p,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:c!=="full",onSelect:m=>{qs(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:m}),r.current.clear()},d,!!o.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}=o;if(u?.type==="text"){let f=t.scene.getElement(u.id);r.current.set(u.id,at(f||u,{},!0))}else{let f=ie(e,o,{includeBoundTextElement:!0});for(let h of f)r.current.set(h.id,at(h,{},!0))}s({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s({...u}),r.current.clear(),d&&o.editingTextElement&&js(null)}}})]})}}),WL=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:At(e,o,r=>{if(Ft(r)){let i=at(r,{textAlign:t});return al(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=n.scene.getNonDeletedElementsMap(),{isCompact:a}=da(n);return Lt("fieldset",{children:[re("legend",{children:g("labels.textAlign")}),re("div",{className:"buttonList",children:re(no,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:LE,testId:"align-left"},{value:"center",text:g("labels.center"),icon:_E,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:DE,testId:"align-right"}],value:xt(e,n,s=>{if(Ft(s))return s.textAlign;let l=ar(s,i);return l?l.textAlign:null},s=>Ft(s)||ar(s,i)!==null,s=>s?null:o.currentItemTextAlign),onChange:s=>{qs(()=>t(s),a,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),YL=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:At(e,o,r=>{if(Ft(r)){let i=at(r,{verticalAlign:t});return al(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=da(n);return re("fieldset",{children:re("div",{className:"buttonList",children:re(no,{group:"text-align",options:[{value:Cd.TOP,text:g("labels.alignTop"),icon:re(RE,{theme:o.theme}),testId:"align-top"},{value:Cd.MIDDLE,text:g("labels.centerVertically"),icon:re(BE,{theme:o.theme}),testId:"align-middle"},{value:Cd.BOTTOM,text:g("labels.alignBottom"),icon:re(NE,{theme:o.theme}),testId:"align-bottom"}],value:xt(e,n,a=>{if(Ft(a)&&a.containerId)return a.verticalAlign;let s=ar(a,n.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Ft(a)||ar(a,n.scene.getNonDeletedElementsMap())!==null,a=>a?null:Cd.MIDDLE),onChange:a=>{qs(()=>t(a),i,!!o.editingTextElement,r?.onPreventClose)}})})})}}),ere=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:At(e,o,n=>Tw(n)?n:at(n,{roundness:t==="round"?{type:PL(n.type)?Sd.ADAPTIVE_RADIUS:Sd.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let a=ki(vw(e),o).some(s=>s.roundness?.type===Sd.LEGACY);return Lt("fieldset",{children:[re("legend",{children:g("labels.edges")}),Lt("div",{className:"buttonList",children:[re(no,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:cE},{value:"round",text:g("labels.round"),icon:dE}],value:xt(e,n,s=>a?null:s.roundness?"round":"sharp",s=>!kd(s)&&s.hasOwnProperty("roundness"),s=>s?null:o.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),ww=e=>({visibleSections:[{name:"default",options:[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:re(mE,{flip:e})},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:re(pE,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:re(uE,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:re(hE,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:re(gE,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:re(fE,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:re(bE,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:re(xE,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:re(EE,{flip:e})}]},{name:g("labels.cardinality"),options:[{value:"cardinality_one",text:g("labels.arrowhead_cardinality_one"),icon:re(yE,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:g("labels.arrowhead_cardinality_many"),icon:re(wE,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:g("labels.arrowhead_cardinality_one_or_many"),icon:re(vE,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:g("labels.arrowhead_cardinality_exactly_one"),icon:re(TE,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:g("labels.arrowhead_cardinality_zero_or_one"),icon:re(IE,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:g("labels.arrowhead_cardinality_zero_or_many"),icon:re(CE,{flip:e}),keyBinding:null}]}]}),tre=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>(Bh(t,"actionChangeArrowhead: value must be defined"),{elements:At(e,o,n=>{if(Dh(n)){let{position:r,type:i}=t;if(r==="start")return at(n,{startArrowhead:i});if(r==="end")return at(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:st.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=vn().rtl,i=Rh(()=>ww(!r),[r]),a=Rh(()=>ww(!!r),[r]);return Lt("fieldset",{children:[re("legend",{children:g("labels.arrowheads")}),Lt("div",{className:"iconSelectList buttonList",children:[re(Ph,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:xt(e,n,s=>Dh(s)&&Mi(s.type)?Ew(s.startArrowhead):o.currentItemStartArrowhead,!0,s=>s?null:o.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),re(Ph,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:xt(e,n,s=>Dh(s)&&Mi(s.type)?Ew(s.endArrowhead):o.currentItemEndArrowhead,!0,s=>s?null:o.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),VL=O({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,o,t,n)=>!1,PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>Lt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),ore=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=At(e,o,s=>{if(!kd(s))return s;let l=n.scene.getNonDeletedElementsMap(),c=Zr.getPointAtIndexGlobalCoordinates(s,0,l),d=Zr.getPointAtIndexGlobalCoordinates(s,-1,l),p=at(s,{x:t===ao.elbow?c[0]:s.x,y:t===ao.elbow?c[1]:s.y,roundness:t===ao.round?{type:Sd.PROPORTIONAL_RADIUS}:null,elbowed:t===ao.elbow,angle:t===ao.elbow?0:s.angle,points:t===ao.elbow||s.elbowed?[Zr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),Zr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(Tw(p)){p.fixedSegments=null;let m=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let u=Zr.getPointAtIndexGlobalCoordinates(p,0,m),f=Zr.getPointAtIndexGlobalCoordinates(p,-1,m),h=p.startBinding&&m.get(p.startBinding.elementId),x=p.endBinding&&m.get(p.endBinding.elementId),E=h&&p.startBinding?{...p.startBinding,...xw(p,h,"start",m,o.isBindingEnabled)}:null,w=x&&p.endBinding?{...p.endBinding,...xw(p,x,"end",m,o.isBindingEnabled)}:null;p={...p,startBinding:E,endBinding:w,...LL(p,m,{points:[u,f].map(y=>dL(y[0]-p.x,y[1]-p.y)),startBinding:E,endBinding:w,fixedSegments:null})}}else{let m=n.scene.getNonDeletedElementsMap();if(p.startBinding){let u=m.get(p.startBinding.elementId);u&&bw(p,u,o.bindMode==="inside"?"inside":"orbit","start",n.scene)}if(p.endBinding){let u=m.get(p.endBinding.elementId);u&&bw(p,u,o.bindMode==="inside"?"inside":"orbit","end",n.scene)}}return p}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let s=r.find(l=>l.id===a);s&&(i.selectedLinearElement=new Zr(s,Nh(e)))}return{elements:r,appState:i,captureUpdate:st.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Lt("fieldset",{children:[re("legend",{children:g("labels.arrowtypes")}),re("div",{className:"buttonList",children:re(no,{group:"arrowtypes",options:[{value:ao.sharp,text:g("labels.arrowtype_sharp"),icon:qi,testId:"sharp-arrow"},{value:ao.round,text:g("labels.arrowtype_round"),icon:Qi,testId:"round-arrow"},{value:ao.elbow,text:g("labels.arrowtype_elbowed"),icon:Ji,testId:"elbow-arrow"}],value:xt(e,n,r=>kd(r)?r.elbowed?ao.elbow:r.roundness?ao.round:ao.sharp:null,r=>kd(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})});import{clamp as Vh,roundToStep as e_}from"@nous-excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as t_,CURSOR_TYPE as Pw,MAX_ZOOM as Aw,MIN_ZOOM as Lw,THEME as sl,ZOOM_STEP as o_,getInteractiveZoomStep as _w,getDisplayedZoomValue as Dw,getDefaultSceneFontSizeForZoom as n_,scaleStrokeWidthForZoomChange as r_,updateActiveTool as pa,CODES as tn,KEYS as kn}from"@nous-excalidraw/common";import{getNonDeletedElements as i_,syncElementsStrokeWidthForZoom as Md}from"@nous-excalidraw/element";import{newElementWith as a_}from"@nous-excalidraw/element";import{getCommonBounds as s_}from"@nous-excalidraw/element";import{CaptureUpdateAction as So}from"@nous-excalidraw/element";import{useEffect as XL}from"react";import{jsx as $L}from"react/jsx-runtime";var ma=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},Gh=(e,o,t="bottom")=>{let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,s=o.left+o.width/2-n.width/2;s<0?s=a:s+n.width>=r&&(s=r-n.width-a);let l;t==="bottom"?(l=o.top+o.height+a,l+n.height>=i&&(l=o.top-n.height-a)):(l=o.top-n.height-a,l<0&&(l=o.top+o.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},KL=(e,o,t,n)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=n?"50ch":"10ch",o.style.maxWidth=n?"50ch":"15ch",o.textContent=t;let r=e.getBoundingClientRect();Gh(o,r)},$t=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(XL(()=>()=>ma().classList.remove("excalidraw-tooltip--visible"),[]),r?null:$L("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>KL(i.currentTarget,ma(),o,t),onPointerLeave:()=>ma().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import{CURSOR_TYPE as Uh,MIME_TYPES as Wh,THEME as Sw}from"@nous-excalidraw/common";var kw='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',ZL='<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"/>',Mw='<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"/>',jL=`data:${Wh.svg},${encodeURIComponent(`${kw}${Mw}</svg>`)}`,qL=`data:${Wh.svg},${encodeURIComponent(`${kw}${ZL}${Mw}</svg>`)}`,Zt=e=>{e&&(e.style.cursor="")},ve=(e,o)=>{e&&(e.style.cursor=o)},en,Cw,Yh=(e,o)=>{let n=()=>{let r=o===Sw.DARK;en=document.createElement("canvas"),en.theme=o,en.height=20,en.width=20;let i=en.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(en.width/2,en.height/2,5,0,2*Math.PI),i.fillStyle=r?"#000":"#fff",i.fill(),i.strokeStyle=r?"#fff":"#000",i.stroke(),Cw=en.toDataURL(Wh.svg)};(!en||en.theme!==o)&&n(),ve(e,`url(${Cw}) ${20/2} ${20/2}, auto`)},jt=(e,o)=>{if(e)if(o.activeTool.type==="selection")Zt(e);else if(wn(o))e.style.cursor=Uh.GRAB;else if(Ot(o))Yh(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===Sw.LIGHT?jL:qL;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Uh.AUTO):e.style.cursor=Uh.CROSSHAIR};import{getDefaultSceneFontSizeForZoom as JL,scaleStrokeWidthForZoomChange as QL}from"@nous-excalidraw/common";var Sn=({viewportX:e,viewportY:o,nextZoom:t},n)=>{let r=e-n.offsetLeft,i=o-n.offsetTop,a=n.zoom.value,s=n.scrollX+(r-r/a),l=n.scrollY+(i-i/a),c=-(r-r/t),d=-(i-i/t);return{scrollX:s+c,scrollY:l+d,zoom:{value:t},currentItemStrokeWidth:QL(n.currentItemStrokeWidth,a,t,n.currentItemStrokeWidthCustom),currentItemFontSize:JL(t)}};import{jsx as _d,jsxs as m_}from"react/jsx-runtime";var l_=O({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t?.viewBackgroundColor?So.IMMEDIATELY:So.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n,data:r})=>_d(tl,{palette:null,topPicks:t_,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),Mn=O({name:"clearCanvas",label:"labels.clearCanvas",icon:ft,trackEvent:{category:"canvas"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,n)=>(n.imageCache.clear(),{elements:e.map(r=>a_(r,{isDeleted:!0})),appState:{...Yo(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:n.state.preferredSelectionTool.type}:o.activeTool},captureUpdate:So.IMMEDIATELY})}),Pd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Lu,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=Dw(o.zoom.value),i=Sn({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:To(r+_w(o.zoom.value,"in"))},o);return{elements:Md(e,o.zoom.value,i.zoom.value),appState:{...o,...i,userToFollow:null},captureUpdate:So.EVENTUALLY}},PanelComponent:({updateData:e,appState:o})=>_d(q,{type:"button",className:"zoom-in-button zoom-button",icon:Lu,title:`${g("buttons.zoomIn")} \u2014 ${B("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=Aw,onClick:()=>{e(null)}}),keyTest:e=>(e.code===tn.EQUAL||e.code===tn.NUM_ADD)&&(e[kn.CTRL_OR_CMD]||e.shiftKey)}),Ad=O({name:"zoomOut",label:"buttons.zoomOut",icon:_u,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=Dw(o.zoom.value),i=Sn({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:To(r-_w(o.zoom.value,"out"))},o);return{elements:Md(e,o.zoom.value,i.zoom.value),appState:{...o,...i,userToFollow:null},captureUpdate:So.EVENTUALLY}},PanelComponent:({updateData:e,appState:o})=>_d(q,{type:"button",className:"zoom-out-button zoom-button",icon:_u,title:`${g("buttons.zoomOut")} \u2014 ${B("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=Lw,onClick:()=>{e(null)}}),keyTest:e=>(e.code===tn.MINUS||e.code===tn.NUM_SUBTRACT)&&(e[kn.CTRL_OR_CMD]||e.shiftKey)}),Ld=O({name:"resetZoom",label:"buttons.resetZoom",icon:N0,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=Sn({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:To(1)},o);return{elements:Md(e,o.zoom.value,r.zoom.value),appState:{...o,...r,userToFollow:null},captureUpdate:So.EVENTUALLY}},PanelComponent:({updateData:e,appState:o})=>_d($t,{label:g("buttons.resetZoom"),style:{height:"100%"},children:m_(q,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===tn.ZERO||e.code===tn.NUM_ZERO)&&(e[kn.CTRL_OR_CMD]||e.shiftKey)}),c_=(e,o,t=1)=>{let[n,r,i,a]=e,s=i-n,l=o.width/s,c=a-r,d=o.height/c,m=Math.min(l,d)*Vh(t,.1,1);return Math.min(m,1)},Rw=({bounds:e,appState:o,canvasOffsets:t,fitCanvasOffsets:n,scrollCanvasOffsets:r,fitToViewport:i=!1,viewportZoomFactor:a=1,minZoom:s=-1/0,maxZoom:l=1/0,elements:c})=>{a=Vh(a,Lw,Aw);let[d,p,m,u]=e,f=(d+m)/2,h=(p+u)/2,x=n??t,E=r??x??t,w=x?.left??0,y=x?.top??0,v=x?.right??0,T=x?.bottom??0,I=o.width-w-v,M=o.height-y-T,S;if(i){let D=m-d,z=u-p;S=Math.min(I/D,M/z)*a}else S=c_(e,{width:I,height:M},a);let _=To(Vh(e_(S,o_,"floor"),s,l)),A=Jx({scenePoint:{x:f,y:h},viewportDimensions:{width:o.width,height:o.height},offsets:E,zoom:{value:_}}),P=o.zoom.value;return{appState:{...o,scrollX:A.scrollX,scrollY:A.scrollY,zoom:{value:_},currentItemStrokeWidth:r_(o.currentItemStrokeWidth,P,_,o.currentItemStrokeWidthCustom),currentItemFontSize:n_(_)},...c&&{elements:Md(c,P,_)},captureUpdate:So.EVENTUALLY}},ua=({canvasOffsets:e,fitCanvasOffsets:o,scrollCanvasOffsets:t,targetElements:n,appState:r,fitToViewport:i,viewportZoomFactor:a,minZoom:s,maxZoom:l,elements:c})=>{let d=s_(i_(n));return Rw({canvasOffsets:e,fitCanvasOffsets:o,scrollCanvasOffsets:t,bounds:d,appState:r,fitToViewport:i,viewportZoomFactor:a,minZoom:s,maxZoom:l,elements:c})},zre=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Qc,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return ua({targetElements:r.length?r:e,elements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===tn.TWO&&e.shiftKey&&!e.altKey&&!e[kn.CTRL_OR_CMD]}),Hre=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Qc,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return ua({targetElements:r.length?r:e,elements:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===tn.THREE&&e.shiftKey&&!e.altKey&&!e[kn.CTRL_OR_CMD]}),d_=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Qc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>ua({targetElements:e,elements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===tn.ONE&&e.shiftKey&&!e.altKey&&!e[kn.CTRL_OR_CMD]}),jr=O({name:"toggleTheme",label:(e,o)=>o.theme===sl.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,o)=>e.theme===sl.LIGHT?Gs:Us,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===sl.LIGHT?sl.DARK:sl.LIGHT)},captureUpdate:So.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===tn.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),Gre=O({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return Ot(o)?r=pa(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):r=pa(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:So.IMMEDIATELY}},keyTest:e=>e.key===kn.E}),Ure=O({name:"toggleLassoTool",label:"toolBar.lasso",icon:$n,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.state.preferredSelectionTool.type!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=pa(o,{type:"lasso",fromSelection:!1}),ve(n.interactiveCanvas,Pw.CROSSHAIR)):r=pa(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:So.NEVER}}}),Nw=O({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Ki,viewMode:!1,perform:(e,o,t,n)=>{let r;return wn(o)?r=pa(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=pa(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),ve(n.interactiveCanvas,Pw.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:So.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[kn.CTRL_OR_CMD]&&e.key===kn.H});import{updateActiveTool as Bw}from"@nous-excalidraw/common";import{CaptureUpdateAction as p_}from"@nous-excalidraw/element";var u_=O({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=Bw(o,{type:"embeddable"});return jt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:Bw(o,{type:"embeddable"})},captureUpdate:p_.EVENTUALLY}}});import{pointFrom as Ow}from"@nous-excalidraw/math";import{bindOrUnbindBindingElement as h_}from"@nous-excalidraw/element/binding";import{isValidPolygon as Fw,LinearElementEditor as Dd,newElementWith as Xh}from"@nous-excalidraw/element";import{isBindingElement as zw,isFreeDrawElement as Hw,isLinearElement as Gw,isLineElement as Rd}from"@nous-excalidraw/element";import{KEYS as Kh,arrayToMap as g_,invariant as Uw,shouldRotateWithDiscreteAngle as f_,updateActiveTool as Ww}from"@nous-excalidraw/common";import{isPathALoop as b_}from"@nous-excalidraw/element";import{isInvisiblySmallElement as $h}from"@nous-excalidraw/element";import{CaptureUpdateAction as Yw}from"@nous-excalidraw/element";import{jsx as x_}from"react/jsx-runtime";var _t=O({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let r=e,{interactiveCanvas:i,focusContainer:a,scene:s}=n,l=s.getNonDeletedElementsMap();if(t&&o.selectedLinearElement){let{event:m,sceneCoords:u}=t,f=Dd.getElement(o.selectedLinearElement.elementId,l);Uw(f,"Arrow element should exist if selectedLinearElement is set"),Uw(u,"sceneCoords should be defined if actionFinalize is called with event");let h=Dd.handlePointerUp(m,o.selectedLinearElement,o,n.scene);if(zw(f)&&!o.selectedLinearElement.segmentMidPointHoveredCoords){let x=!!o.newElement,w=(x||!o.selectedLinearElement.selectedPointsIndices?[f.points.length-1]:o.selectedLinearElement.selectedPointsIndices).reduce((y,v)=>(y.set(v,{point:Dd.pointFromAbsoluteCoords(f,Ow(u.x-h.pointerOffset.x,u.y-h.pointerOffset.y),l)}),y),new Map)??new Map;h_(f,w,u.x-h.pointerOffset.x,u.y-h.pointerOffset.y,s,o,{newArrow:x,altKey:m.altKey,angleLocked:f_(m)})}else Rd(f)&&o.selectedLinearElement?.isEditing&&!o.newElement&&!Fw(f.points)&&s.mutateElement(f,{polygon:!1});if(h!==o.selectedLinearElement){f&&$h(f)&&(r=r.map(E=>E.id===f.id?Xh(E,{isDeleted:!0}):E));let x=o.activeTool?.locked;return{elements:f.points.length<2||$h(f)?e.map(E=>E.id===f.id?Xh(E,{isDeleted:!0}):E):r,appState:{...o,cursorButton:"up",selectedLinearElement:x?null:{...h,selectedPointsIndices:null,isEditing:!1,initialState:{...h.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,newElement:null,multiElement:null},captureUpdate:Yw.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||zw(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let m=l.get(Object.keys(o.selectedElementIds)[0]);m&&(c=m)}if(c){if(o.selectedLinearElement&&o.multiElement&&c.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:m}=c,{lastCommittedPoint:u}=o.selectedLinearElement;(!u||m[m.length-1]!==u)&&s.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&$h(c)&&(r=r.map(m=>m.id===c?.id?Xh(m,{isDeleted:!0}):m)),Gw(c)||Hw(c)){if(b_(c.points,o.zoom.value)&&(Rd(c)||Hw(c))){let u=c.points,f=u[0],h=u.map((x,E)=>E===u.length-1?Ow(f[0],f[1]):x);Rd(c)?s.mutateElement(c,{points:h,polygon:!0}):s.mutateElement(c,{points:h})}Rd(c)&&!Fw(c.points)&&s.mutateElement(c,{polygon:!1})}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Zt(i);let d;o.activeTool.type==="eraser"?d=Ww(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):d=Ww(o,{type:n.state.preferredSelectionTool.type});let p=c&&Gw(c)?new Dd(c,g_(r)):o.selectedLinearElement;return p=p&&{...p,isEditing:o.newElement?!1:p.isEditing,initialState:{...p.initialState,lastClickedPoint:-1,origin:null}},{elements:r,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:d,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:p},captureUpdate:Yw.IMMEDIATELY}},keyTest:(e,o)=>e.key===Kh.ESCAPE&&o.selectedLinearElement?.isEditing||(e.key===Kh.ESCAPE||e.key===Kh.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>x_(q,{type:"button",icon:Y0,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as Kw,isSomeElementSelected as E_,makeNextSelectedElementIds as y_,selectGroupsForSelectedElements as w_}from"@nous-excalidraw/element";import{CaptureUpdateAction as Vw}from"@nous-excalidraw/element";import{KEYS as v_,isWritableElement as T_,updateActiveTool as Xw}from"@nous-excalidraw/common";var I_=(e,o)=>e.activeTool.type==="eraser"?Xw(e,{...e.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):Xw(e,{type:o.state.preferredSelectionTool.type}),C_=(e,o,t)=>{if(!e.editingGroupId)return null;let n=o.scene.getNonDeletedElements(),r=o.scene.getSelectedElements({selectedElementIds:t,elements:n}),i=r.length?r:Kw(n,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},S_=O({name:"deselect",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let r=I_(o,n);if(o.editingGroupId){let i=n.scene.getNonDeletedElements(),a=Object.keys(o.selectedElementIds).length>0?o.selectedElementIds:Kw(i,o.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...o,...w_({editingGroupId:C_(o,n,a),selectedElementIds:a},i,o,n),activeEmbeddable:null,activeTool:r,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null},captureUpdate:Vw.IMMEDIATELY}}return{appState:{...o,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:y_({},o),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null},captureUpdate:Vw.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key!==v_.ESCAPE||T_(e.target)?!1:!o.newElement&&o.multiElement===null&&!o.selectedLinearElement?.isEditing&&(o.activeEmbeddable!==null||o.activeTool.type!==n.state.preferredSelectionTool.type||!!o.editingGroupId||!!o.selectedLinearElement||E_(n.scene.getNonDeletedElements(),o))});import{KEYS as ba,DEFAULT_EXPORT_PADDING as pD,EXPORT_SCALES as uD,THEME as pl}from"@nous-excalidraw/common";import{getNonDeletedElements as hD}from"@nous-excalidraw/element";import{CaptureUpdateAction as Mo}from"@nous-excalidraw/element";import k_ from"clsx";import{jsx as $w,jsxs as M_}from"react/jsx-runtime";var ll=({children:e,checked:o,onChange:t,className:n})=>M_("div",{className:k_("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[$w("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:Kc}),$w("div",{className:"Checkbox-label",children:e})]});import{THEME as cl}from"@nous-excalidraw/common";import{jsx as dl}from"react/jsx-runtime";var jw=e=>{let o=e.title||(e.value===cl.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return dl(q,{type:"icon",icon:e.value===cl.LIGHT?Zw.MOON:Zw.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===cl.DARK?cl.LIGHT:cl.DARK),"data-testid":"toggle-dark-mode"})},Zw={SUN:dl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:dl("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:dl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:dl("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 P_}from"react";import{focusNearestParent as A_,KEYS as L_}from"@nous-excalidraw/common";import{jsx as qw,jsxs as __}from"react/jsx-runtime";var Jw=e=>{let{id:o}=Ne(),[t,n]=P_(e.value),r=a=>{e.ignoreFocus||A_(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===L_.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return __("div",{className:"ProjectName",children:[qw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),qw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>n(a.target.value)})]})};import{useCallback as D_,useEffect as R_,useRef as N_}from"react";import{jsx as Nd,jsxs as z_}from"react/jsx-runtime";var B_=5e3,O_=({progress:e})=>Nd("div",{className:"Toast__progress-bar",children:Nd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),F_=({message:e,onClose:o,closable:t=!1,duration:n=B_,style:r})=>{let i=N_(0),a=n!==1/0,s=D_(()=>{a&&(i.current=window.setTimeout(()=>o(),n))},[o,n,a]);return R_(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,n,a]),z_("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Nd("div",{className:"Toast__message",children:e}),t&&Nd(q,{icon:oo,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})},Bd=Object.assign(F_,{ProgressBar:O_});import{DEFAULT_EXPORT_PADDING as oD,DEFAULT_FILENAME as nD,IMAGE_MIME_TYPES as iv,isFirefox as rD,MIME_TYPES as iD,cloneJSON as aD,SVG_DOCUMENT_PREAMBLE as sD,arrayToMap as lD}from"@nous-excalidraw/common";import{getNonDeletedElements as cD}from"@nous-excalidraw/element";import{isFrameLikeElement as dD}from"@nous-excalidraw/element";import{getElementsOverlappingFrame as mD}from"@nous-excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as H_,EXPORT_DATA_TYPES as ml,MIME_TYPES as qt,arrayToMap as G_,isMemberOf as U_,isPromiseLike as W_,EVENT as Od}from"@nous-excalidraw/common";import{mutateElement as Y_}from"@nous-excalidraw/element";import{deepCopyElement as V_}from"@nous-excalidraw/element";import{isFrameLikeElement as X_,isInitializedImageElement as K_}from"@nous-excalidraw/element";import{getContainingFrame as Qw}from"@nous-excalidraw/element";var dae="clipboard"in navigator&&"readText"in navigator.clipboard,Fd="clipboard"in navigator&&"writeText"in navigator.clipboard,ha="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,$_=e=>!!([ml.excalidraw,ml.excalidrawClipboard,ml.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),ev=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Od.PASTE,{clipboardData:new DataTransfer});if(e)for(let[n,r]of Object.entries(e)){if(typeof r!="string"){o=o||[],o.push(r);continue}try{if(t.clipboardData?.items.add(r,n),t.clipboardData?.getData(n)!==r)throw new Error(`Failed to set "${n}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let n=-1;for(let r of o){n++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[n]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},Z_=({elements:e,files:o})=>{let t=G_(e),n=new Set(e.filter(s=>X_(s))),r=!1,i=e.reduce((s,l)=>(K_(l)&&(r=!0,o&&o[l.fileId]&&(s[l.fileId]=o[l.fileId])),s),{});r&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:ml.excalidrawClipboard,elements:e.map(s=>{if(Qw(s,t)&&!n.has(Qw(s,t))){let l=V_(s);return Y_(l,t,{frameId:null}),l}return s}),files:o?i:void 0};return JSON.stringify(a)},zd=async(e,o,t)=>{let n=Z_({elements:e,files:o});await ko({[qt.excalidrawClipboard]:n,[qt.text]:n},t)};function tv(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let n=t.textContent?.trim();n&&o.push({type:"text",value:n})}else if(t instanceof HTMLImageElement){let n=t.getAttribute("src");n&&n.startsWith("http")&&o.push({type:"imageUrl",value:n})}else o=o.concat(tv(t));return o}var j_=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,qt.html),n=tv(t.body);if(n.length)return{type:"mixedContent",value:n}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},ov=async()=>{let e={},o;try{o=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let n=await navigator.clipboard?.readText();if(n)return{[qt.text]:n}}}catch(n){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${n.message}). Failling back to navigator.clipboard.read()`);else{if(n.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${n.message}`),e;throw n}}throw t}for(let t of o)for(let n of t.types)if(U_(H_,n))try{if(n===qt.text||n===qt.html)e[n]=await(await t.getType(n)).text();else if(m0(n)){let r=await t.getType(n),i=E0(r,n,void 0);e[n]=i}else throw new vu(`Unsupported clipboard type: ${n}`)}catch(r){console.warn(r instanceof vu?r.message:`Cannot retrieve ${n} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},q_=async(e,o=!1)=>{try{let t=e.findByType(qt.html),n=!o&&t&&j_(t);return n?n.value.every(r=>r.type==="text")?{type:"text",value:e.getData(qt.text)??n.value.map(r=>r.value).join(`
2
+ `).trim()}:n:{type:"text",value:(e.getData(qt.text)||"").trim()}}catch{return{type:"text",value:""}}},J_=function(e){return this.find(o=>o.type===e)||null},Q_=function(e){return this.find(t=>t.type===e)?.value??null},eD=function(){return this.filter(e=>e.kind==="file")},nv=e=>{let o;rv(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=new Set;for(let n of Array.from(o||[]))t.has(n.type)||t.add(n.type);return t},ga=async e=>{let o;rv(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=(await Promise.all(Array.from(o||[]).map(async n=>{if(n.kind==="file"){let r=n.getAsFile();if(r){let i=await x0(n);return r=await zs(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(n.kind==="string"){let{type:r}=n,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(a=>{n.getAsString(s=>a(s))}),{type:r,kind:"string",value:i}}return null}))).filter(n=>n!=null);return Object.assign(t,{findByType:J_,getData:Q_,getFiles:eD})},Hd=async(e,o=!1)=>{let t=await q_(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let n=JSON.parse(t.value),r=n.type===ml.excalidrawClipboardWithAPI;if($_(n))return{elements:n.elements,files:n.files,text:o?JSON.stringify(n.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},Gd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[qt.png]:e})])}catch(o){if(W_(e))await navigator.clipboard.write([new ClipboardItem({[qt.png]:await e})]);else throw o}},ko=async(e,o)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[qt.text]:e}:e);try{if(o){for(let[r,i]of t)if(o.clipboardData?.setData(r,i),o.clipboardData?.getData(r)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}let n=t.find(([r])=>r===qt.text);if(Fd&&n)try{await navigator.clipboard.writeText(n[1]);return}catch(r){console.error(r)}if(n&&!tD(n[1]))throw new Error("Error copying to clipboard.")},tD=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let n=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${n}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let r=!1;try{t.select(),t.setSelectionRange(0,t.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),r},rv=e=>e.type===Od.PASTE||e.type===Od.COPY||e.type===Od.CUT;var qr=(e,{selectedElementIds:o},t)=>{e=cD(e);let n=lD(e),r=t&&Ae(e,{selectedElementIds:o}),i=null,a=r?ie(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(a.length===1&&dD(a[0])?(i=a[0],a=mD(e,i,n)):a.length>1&&(a=ie(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:i,exportedElements:aD(a)}},Jr=async(e,o,t,n,{exportBackground:r,exportPadding:i=oD,viewBackgroundColor:a,name:s=t.name||nD,fileHandle:l=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let p=Oc(o,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},n,{exportingFrame:c});if(e==="svg")return Tu(p.then(m=>new Blob([sD+m.outerHTML],{type:iD.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[iv.svg],fileHandle:l});if(e==="clipboard-svg"){let m=await p.then(u=>u.outerHTML);try{await ko(m)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let d=Bc(o,t,n,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let p=Ur(d);return t.exportEmbedScene&&(p=p.then(m=>import("./data/image-F5QONZ27.js").then(({encodePngMetadata:u})=>u({blob:m,metadata:Rs(o,t,n,"local")})))),Tu(p,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[iv.png],fileHandle:l})}else if(e==="clipboard")try{let p=Ur(d);await Gd(p)}catch(p){throw console.warn(p),p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):rD&&p.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
3
3
 
4
4
  ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var av=async(e,o,t)=>{let n=c0(o);if(!d0(n))throw new Error("fileHandle should exist and should be of type svg or png when resaving");let{elements:r,appState:i,files:a}=await e,{exportBackground:s,viewBackgroundColor:l}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:d}=qr(r,i,!1);return await Jr(n,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:o,exportingFrame:d}),{fileHandle:o}};import{Fragment as dv,jsx as on,jsxs as mv}from"react/jsx-runtime";var jh=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:Mo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:n,app:r})=>on(Jw,{label:g("labels.fileTitle"),value:r.getName(),onChange:i=>o(i),ignoreFocus:n?.ignoreFocus??!1})}),sv=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:Mo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=hD(e),i=Ae(n,o)?ie(n,o):n;return on(dv,{children:uD.map(a=>{let[s,l]=s0(i,pD,a),c=`${g("imageExportDialog.label.scale")} ${a}x (${s}x${l})`;return on(q,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),qh=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:Mo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>on(ll,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),Ud=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:Mo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>mv(ll,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),on($t,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:on("div",{className:"excalidraw-tooltip-icon",children:V0})})]})}),fa=!1,Zh=(e,o)=>{let t=o.message??g("progressDialog.defaultMessage");e.setAppState({toast:{message:o.progress!=null?mv(dv,{children:[t,on(Bd.ProgressBar,{progress:o.progress})]}):t,duration:1/0}})};async function gD(e,o){if(o.app.state.isLoading&&(Zh(o.app,{progress:null}),await o.app.onStateChange({predicate:t=>!t.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let t of e){if(o.signal.aborted){e.return();return}if(t.type==="progress")Zh(o.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(Zh(o.app,{progress:null}),await e)}function lv(e,o,t,n){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{n.props.onExport&&await gD(n.props.onExport("json",{elements:e,appState:o,files:t},{signal:i}),{app:n,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:o,files:n.files})});return{abortController:r,data:a}}var Qr=O({name:"saveToActiveFile",label:"buttons.save",icon:Vr,trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{if(fa)return!1;fa=!0;let r=o.fileHandle,i=n.getName(),{abortController:a,data:s}=lv(e,o,n.files,n);try{let{fileHandle:l}=Fc(r)?await av(s,r,i):await Rc({data:s,filename:i,fileHandle:r});return{captureUpdate:Mo.NEVER,appState:{fileHandle:l,toast:{message:r&&l?.name?g("toast.fileSavedToFilename").replace("{filename}",`"${l.name}"`):g("toast.fileSaved"),duration:1500}}}}catch(l){return a.abort(),l?.name!=="AbortError"?console.error(l):console.warn(l),{captureUpdate:Mo.NEVER,appState:{toast:null}}}finally{fa=!1}},keyTest:e=>e.key===ba.S&&e[ba.CTRL_OR_CMD]&&!e.shiftKey}),ul=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Vr,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,n)=>{if(fa)return!1;fa=!0;let{abortController:r,data:i}=lv(e,o,n.files,n);try{let{fileHandle:a}=await Rc({data:i,filename:n.getName(),fileHandle:null});return{captureUpdate:Mo.NEVER,appState:{openDialog:null,fileHandle:a,toast:{message:g("toast.fileSaved"),duration:3e3}}}}catch(a){return r.abort(),a?.name!=="AbortError"?console.error(a):console.warn(a),{captureUpdate:Mo.NEVER,appState:{toast:null}}}finally{fa=!1}},keyTest:e=>e.key.toLowerCase()===ba.S&&e.shiftKey&&e[ba.CTRL_OR_CMD],PanelComponent:({updateData:e})=>on(q,{type:"button",icon:G0,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:be().formFactor==="phone",hidden:!Ai,onClick:()=>e(null),"data-testid":"save-as-button"})}),xa=O({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{try{let{elements:r,appState:i,files:a}=await Iu(o,e);return{elements:r,appState:i,files:a,captureUpdate:Mo.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...o,errorMessage:r.message},files:n.files,captureUpdate:Mo.EVENTUALLY}}},keyTest:e=>e[ba.CTRL_OR_CMD]&&e.key===ba.O}),cv=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t,n)=>(n.sessionExportThemeOverride=t?pl.DARK:pl.LIGHT,{appState:{...o,exportWithDarkMode:t},captureUpdate:Mo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>on("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:on(jw,{value:e.exportWithDarkMode?pl.DARK:pl.LIGHT,onChange:t=>{o(t===pl.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as fD,DEFAULT_FONT_FAMILY as bD,DEFAULT_TEXT_ALIGN as xD,CODES as pv,KEYS as uv,STROKE_WIDTH_CUSTOM_DATA_KEY as Jh,getLineHeight as ED}from"@nous-excalidraw/common";import{newElementWith as Wd}from"@nous-excalidraw/element";import{hasBoundTextElement as yD,canApplyRoundnessTypeToElement as wD,getDefaultRoundnessTypeForElement as vD,isFrameLikeElement as TD,isArrowElement as ID,isExcalidrawElement as CD,isTextElement as Qh}from"@nous-excalidraw/element";import{getBoundTextElement as SD,redrawTextBoundingBox as kD}from"@nous-excalidraw/element";import{CaptureUpdateAction as eg}from"@nous-excalidraw/element";var hv="{}",tg=O({name:"copyStyles",label:"labels.copyStyles",icon:qu,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=[],i=e.find(a=>o.selectedElementIds[a.id]);if(r.push(i),i&&yD(i)){let a=SD(i,n.scene.getNonDeletedElementsMap());r.push(a)}return i&&(hv=JSON.stringify(r)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:eg.EVENTUALLY}},keyTest:e=>e[uv.CTRL_OR_CMD]&&e.altKey&&e.code===pv.C}),og=O({name:"pasteStyles",label:"labels.pasteStyles",icon:qu,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=JSON.parse(hv),i=r[0],a=r[1];if(!CD(i))return{elements:e,captureUpdate:eg.EVENTUALLY};let s=ie(e,o,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(Qh(c)&&c.containerId&&(d=a),!d)return c;let p={...c.customData};d?.customData?.[Jh]?p[Jh]=!0:delete p[Jh];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,customData:p,roundness:d.roundness?wD(d.roundness.type,c)?d.roundness:vD(c):null});if(Qh(m)){let u=d.fontSize||fD,f=d.fontFamily||bD;m=Wd(m,{fontSize:u,fontFamily:f,textAlign:d.textAlign||xD,lineHeight:d.lineHeight||ED(f)});let h=null;m.containerId&&(h=s.find(x=>Qh(m)&&x.id===m.containerId)||null),kD(m,h,n.scene)}return m.type==="arrow"&&ID(d)&&(m=Wd(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),TD(c)&&(m=Wd(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:eg.IMMEDIATELY}},keyTest:e=>e[uv.CTRL_OR_CMD]&&e.altKey&&e.code===pv.V});import{KEYS as MD}from"@nous-excalidraw/common";import{CaptureUpdateAction as PD}from"@nous-excalidraw/element";var ei=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:O0,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:n})=>(o.openDialog?.name==="help"&&n(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:PD.EVENTUALLY}),keyTest:e=>e.key===MD.QUESTION_MARK});import{getNonDeletedElements as Vd}from"@nous-excalidraw/element";import{newElementWith as bv}from"@nous-excalidraw/element";import{isBoundToContainer as AD}from"@nous-excalidraw/element";import{frameAndChildrenSelectedTogether as LD,getElementsInResizingFrame as _D,getFrameLikeElements as DD,getRootElements as RD,groupByFrameLikes as ND,removeElementsFromFrame as BD,replaceAllElementsInFrame as OD}from"@nous-excalidraw/element";import{KEYS as Xd,randomId as FD,arrayToMap as ng}from"@nous-excalidraw/common";import{getSelectedGroupIds as Yd,selectGroup as zD,selectGroupsForSelectedElements as HD,getElementsInGroup as gv,addToGroup as GD,removeFromSelectedGroups as UD,isElementInGroup as xv}from"@nous-excalidraw/element";import{syncMovedIndices as WD}from"@nous-excalidraw/element";import{CaptureUpdateAction as hl}from"@nous-excalidraw/element";import{jsx as Ea}from"react/jsx-runtime";var YD=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((n,r)=>n&&xv(r,t),!0))return!0}return!1},fv=(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!YD(n)&&!LD(n)},rg=O({name:"group",label:"labels.group",icon:e=>Ea(Xu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=RD(n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:o,elements:e,captureUpdate:hl.EVENTUALLY};let i=Yd(o);if(i.length===1){let x=i[0],E=new Set(gv(e,x).map(v=>v.id)),w=new Set(r.map(v=>v.id));if(new Set([...Array.from(E),...Array.from(w)]).size===E.size)return{appState:o,elements:e,captureUpdate:hl.EVENTUALLY}}let a=[...e];new Set(r.map(x=>x.frameId)).size>1&&ND(r).forEach((E,w)=>{BD(E,n.scene.getNonDeletedElementsMap())});let l=FD(),c=ng(r);a=a.map(x=>c.get(x.id)?bv(x,{groupIds:GD(x.groupIds,l,o.editingGroupId)}):x);let d=gv(a,l),p=d[d.length-1],m=a.lastIndexOf(p),u=a.slice(m+1),f=a.slice(0,m).filter(x=>!xv(x,l)),h=WD([...f,...d,...u],ng(d));return{appState:{...o,...zD(l,{...o,selectedGroupIds:{}},Vd(a))},elements:h,captureUpdate:hl.IMMEDIATELY}},predicate:(e,o,t,n)=>fv(e,o,n),keyTest:e=>!e.shiftKey&&e[Xd.CTRL_OR_CMD]&&e.key===Xd.G,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ea(q,{hidden:!fv(e,o,n),type:"button",icon:Ea(Xu,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${B("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:Ae(Vd(e),o)})}),ig=O({name:"ungroup",label:"labels.ungroup",icon:e=>Ea(Ku,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=Yd(o),i=ng(e);if(r.length===0)return{appState:o,elements:e,captureUpdate:hl.EVENTUALLY};let a=[...e],s=[];a=a.map(m=>{AD(m)&&s.push(m.id);let u=UD(m.groupIds,o.selectedGroupIds);return u.length===m.groupIds.length?m:bv(m,{groupIds:u})});let l=HD(o,Vd(a),o,null),c=n.scene.getSelectedElements(o),d=new Set(c.filter(m=>m.frameId).map(m=>m.frameId));return DD(e).filter(m=>d.has(m.id)).forEach(m=>{m&&(a=OD(a,_D(a,m,o,i),m,n))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((m,[u,f])=>(f&&!s.includes(u)&&(m[u]=!0),m),{}),{appState:{...o,...l},elements:a,captureUpdate:hl.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Xd.CTRL_OR_CMD]&&e.key===Xd.G.toUpperCase(),predicate:(e,o)=>Yd(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>Ea(q,{type:"button",hidden:Yd(o).length===0,icon:Ea(Ku,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${B("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:Ae(Vd(e),o)})});import qD from"clsx";import{CaptureUpdateAction as Tv}from"@nous-excalidraw/element";import{invariant as JD}from"@nous-excalidraw/common";import{COLOR_CHARCOAL_BLACK as VD,COLOR_VOICE_CALL as XD,COLOR_WHITE as $d,THEME as KD,UserIdleState as Ev}from"@nous-excalidraw/common";var Kd=(e,o,t,n,r,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+n-i,t),e.quadraticCurveTo(o+n,t,o+n,t+i),e.lineTo(o+n,t+r-i),e.quadraticCurveTo(o+n,t+r,o+n-i,t+r),e.lineTo(o+i,t+r),e.quadraticCurveTo(o,t+r,o,t+r-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function $D(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);o=(o<<5)-o+n}return o}var ti=(e,o)=>`hsl(${Math.abs($D(o?.id||e))%37*10}, 100%, 83%)`,yv=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},wv=({context:e,renderConfig:o,appState:t,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,a]of o.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>n-d||l<0||l>r-p;s=Math.max(s,0),s=Math.min(s,n-d),l=Math.max(l,0),l=Math.min(l,r-p);let u=ti(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),h=m||f===Ev.IDLE||f===Ev.AWAY;h&&(e.globalAlpha=.3),o.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 x=t.theme===KD.DARK?"#2f6330":XD,E=c?.isSpeaking;E&&(e.fillStyle=x,e.strokeStyle=x,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(),h?(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=o.remotePointerUsernames.get(i)||"";if(!m&&w){e.font="600 12px sans-serif";let y=(E?s+0:s)+d/2,v=(E?l+0:l)+p+2,T=5,I=3,M=e.measureText(w),S=M.actualBoundingBoxDescent+M.actualBoundingBoxAscent,_=Math.max(S,12),A=y-1,P=v-1,D=M.width+2+T*2+2,z=_+2+I*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(A,P,D,z,8),e.fillStyle=u,e.fill(),e.strokeStyle=$d,e.stroke(),E&&(e.beginPath(),e.roundRect(A-2,P-2,D+4,z+4,8),e.strokeStyle=x,e.stroke())):Kd(e,A,P,D,z,8,$d),e.fillStyle=VD,e.fillText(w,y+T+1,v+I+M.actualBoundingBoxAscent+Math.floor((_-S)/2)+2),E){e.fillStyle=x;let K=8,W=8,Y=5;e.fillRect(A+D+W,P+(z/2-K/2),2,K),e.fillRect(A+D+W+Y,P+(z/2-K*2/2),2,K*2),e.fillRect(A+D+W+Y*2,P+(z/2-K/2),2,K)}}e.restore(),e.closePath()}};import ZD from"clsx";import{useState as jD}from"react";import{jsx as vv}from"react/jsx-runtime";var ag=({color:e,onClick:o,name:t,src:n,className:r})=>{let i=yv(t),[a,s]=jD(!1),l=!a&&n,c=l?void 0:{background:e};return vv("div",{className:ZD("Avatar",r),style:c,onClick:o,children:l?vv("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as nn,jsxs as Zd}from"react/jsx-runtime";var QD=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>(JD(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:Tv.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:Tv.EVENTUALLY}),PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:a}=o,s=ti(n,r),l=qD({"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:g("userList.hint.isSpeaking"),children:[nn("div",{}),nn("div",{}),nn("div",{})]}):r.isMuted?nn("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:qE}):nn("div",{title:g("userList.hint.inCall"),children:jE}):null;return i?Zd("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[nn(ag,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),nn("div",{className:"UserList__collaborator-name",children:r.username}),Zd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&nn("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:ji}),c]})]}):Zd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[nn(ag,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&nn("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{LIBRARY_DISABLED_TYPES as e8,randomId as t8}from"@nous-excalidraw/common";import{deepCopyElement as o8}from"@nous-excalidraw/element";import{CaptureUpdateAction as sg}from"@nous-excalidraw/element";var lg=O({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of e8)if(r.some(a=>a.type===i))return{captureUpdate:sg.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:t8(),status:"unpublished",elements:r.map(o8),created:Date.now()},...i])).then(()=>({captureUpdate:sg.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:sg.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as ya}from"@nous-excalidraw/element";import{isFrameLikeElement as n8}from"@nous-excalidraw/element";import{updateFrameMembershipOfSelectedElements as r8}from"@nous-excalidraw/element";import{KEYS as sr,arrayToMap as i8}from"@nous-excalidraw/common";import{alignElements as a8}from"@nous-excalidraw/element";import{CaptureUpdateAction as wa}from"@nous-excalidraw/element";import{getSelectedElementsByGroup as s8}from"@nous-excalidraw/element";import{jsx as Ta}from"react/jsx-runtime";var Dt=(e,o)=>{let t=o.scene.getSelectedElements(e);return s8(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(n=>n8(n))},va=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=a8(r,n,t.scene,o),a=i8(i);return r8(e.map(s=>a.get(s.id)||s),o,t)},l8=O({name:"alignTop",label:"labels.alignTop",icon:Hu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Dt(o,n),perform:(e,o,t,n)=>({appState:o,elements:va(e,o,n,{position:"start",axis:"y"}),captureUpdate:wa.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ta(q,{hidden:!Dt(o,n),type:"button",icon:Hu,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${B("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:Ae(ya(e),o)})}),c8=O({name:"alignBottom",label:"labels.alignBottom",icon:Gu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Dt(o,n),perform:(e,o,t,n)=>({appState:o,elements:va(e,o,n,{position:"end",axis:"y"}),captureUpdate:wa.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ta(q,{hidden:!Dt(o,n),type:"button",icon:Gu,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${B("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:Ae(ya(e),o)})}),d8=O({name:"alignLeft",label:"labels.alignLeft",icon:Uu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Dt(o,n),perform:(e,o,t,n)=>({appState:o,elements:va(e,o,n,{position:"start",axis:"x"}),captureUpdate:wa.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ta(q,{hidden:!Dt(o,n),type:"button",icon:Uu,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${B("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:Ae(ya(e),o)})}),m8=O({name:"alignRight",label:"labels.alignRight",icon:Wu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Dt(o,n),perform:(e,o,t,n)=>({appState:o,elements:va(e,o,n,{position:"end",axis:"x"}),captureUpdate:wa.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ta(q,{hidden:!Dt(o,n),type:"button",icon:Wu,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${B("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:Ae(ya(e),o)})}),p8=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Yu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Dt(o,n),perform:(e,o,t,n)=>({appState:o,elements:va(e,o,n,{position:"center",axis:"y"}),captureUpdate:wa.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ta(q,{hidden:!Dt(o,n),type:"button",icon:Yu,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:Ae(ya(e),o)})}),u8=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Vu,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Dt(o,n),perform:(e,o,t,n)=>({appState:o,elements:va(e,o,n,{position:"center",axis:"x"}),captureUpdate:wa.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ta(q,{hidden:!Dt(o,n),type:"button",icon:Vu,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:Ae(ya(e),o)})});import{getNonDeletedElements as Iv}from"@nous-excalidraw/element";import{isFrameLikeElement as h8}from"@nous-excalidraw/element";import{CODES as Cv,KEYS as Sv,arrayToMap as g8}from"@nous-excalidraw/common";import{updateFrameMembershipOfSelectedElements as f8}from"@nous-excalidraw/element";import{distributeElements as b8}from"@nous-excalidraw/element";import{CaptureUpdateAction as kv}from"@nous-excalidraw/element";import{getSelectedElementsByGroup as x8}from"@nous-excalidraw/element";import{jsx as Av}from"react/jsx-runtime";var Mv=(e,o)=>{let t=o.scene.getSelectedElements(e);return x8(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(n=>h8(n))},Pv=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=b8(r,t.scene.getNonDeletedElementsMap(),n,o,t.scene),a=g8(i);return f8(e.map(s=>a.get(s.id)||s),o,t)},E8=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:Pv(e,o,n,{space:"between",axis:"x"}),captureUpdate:kv.IMMEDIATELY}),keyTest:e=>!e[Sv.CTRL_OR_CMD]&&e.altKey&&e.code===Cv.H,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Av(q,{hidden:!Mv(o,n),type:"button",icon:Z0,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${B("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:Ae(Iv(e),o)})}),y8=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:Pv(e,o,n,{space:"between",axis:"y"}),captureUpdate:kv.IMMEDIATELY}),keyTest:e=>!e[Sv.CTRL_OR_CMD]&&e.altKey&&e.code===Cv.V,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Av(q,{hidden:!Mv(o,n),type:"button",icon:j0,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${B("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:Ae(Iv(e),o)})});import{getNonDeletedElements as w8}from"@nous-excalidraw/element";import{bindOrUnbindBindingElements as v8}from"@nous-excalidraw/element";import{getCommonBoundingBox as Lv}from"@nous-excalidraw/element";import{newElementWith as T8}from"@nous-excalidraw/element";import{deepCopyElement as I8}from"@nous-excalidraw/element";import{resizeMultipleElements as C8}from"@nous-excalidraw/element";import{isArrowElement as _v,isElbowArrow as S8}from"@nous-excalidraw/element";import{updateFrameMembershipOfSelectedElements as Dv}from"@nous-excalidraw/element";import{CODES as Rv,KEYS as k8,arrayToMap as M8}from"@nous-excalidraw/common";import{CaptureUpdateAction as Nv}from"@nous-excalidraw/element";var cg=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:ty,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:Dv(Bv(e,n.scene.getNonDeletedElementsMap(),o,"horizontal",n),o,n),appState:o,captureUpdate:Nv.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Rv.H}),dg=O({name:"flipVertical",label:"labels.flipVertical",icon:ey,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:Dv(Bv(e,n.scene.getNonDeletedElementsMap(),o,"vertical",n),o,n),appState:o,captureUpdate:Nv.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Rv.V&&!e[k8.CTRL_OR_CMD]}),Bv=(e,o,t,n,r)=>{let i=ie(w8(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=P8(i,o,n,r),s=M8(a);return e.map(l=>s.get(l.id)||l)},P8=(e,o,t,n)=>{if(e.every(m=>_v(m)&&(m.startBinding||m.endBinding)))return e.map(m=>{let u=m;return T8(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=Lv(e);C8(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(m=>[m.id,I8(m)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),v8(e.filter(_v),n.scene,n.state);let{elbowArrows:a,otherElements:s}=e.reduce((m,u)=>S8(u)?{...m,elbowArrows:m.elbowArrows.concat(u)}:{...m,otherElements:m.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=Lv(e),[d,p]=[r-l,i-c];return s.forEach(m=>n.scene.mutateElement(m,{x:m.x+d,y:m.y+p})),a.forEach(m=>n.scene.mutateElement(m,{x:m.x+d,y:m.y+p})),e};import{isTextElement as A8}from"@nous-excalidraw/element";import{getTextFromElements as L8}from"@nous-excalidraw/element";import{CODES as _8,KEYS as Ov,isFirefox as D8}from"@nous-excalidraw/common";import{CaptureUpdateAction as Jt}from"@nous-excalidraw/element";var Ia=O({name:"copy",label:"labels.copy",icon:Hs,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await zd(r,n.files,t)}catch(i){return{captureUpdate:Jt.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Jt.EVENTUALLY}},keyTest:void 0}),mg=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r;try{r=await ov()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),D8?{captureUpdate:Jt.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:Jt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard(ev({types:r}))}catch(i){return console.error(i),{captureUpdate:Jt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Jt.EVENTUALLY}},keyTest:void 0}),jd=O({name:"cut",label:"labels.cut",icon:FE,trackEvent:{category:"element"},perform:(e,o,t,n)=>(Ia.perform(e,o,t,n),Zs.perform(e,o,null,n)),keyTest:e=>e[Ov.CTRL_OR_CMD]&&e.key===Ov.X}),R8=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:oy,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Jt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=qr(e,o,!0);try{await Jr("clipboard-svg",r,o,n.files,{...o,exportingFrame:i,name:n.getName()});let a=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Jt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Jt.EVENTUALLY}}},predicate:e=>Fd&&e.length>0,keywords:["svg","clipboard","copy"]}),N8=O({name:"copyAsPng",label:"labels.copyAsPng",icon:ny,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Jt.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=qr(e,o,!0);try{return await Jr("clipboard",i,o,n.files,{...o,exportingFrame:a,name:n.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:r.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Jt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...o,errorMessage:s.message},captureUpdate:Jt.EVENTUALLY}}},predicate:e=>ha&&e.length>0,keyTest:e=>e.code===_8.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),qd=O({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{ko(L8(r))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Jt.EVENTUALLY}},predicate:(e,o,t,n)=>Fd&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(A8),keywords:["text","clipboard","copy"]});import{CODES as B8,KEYS as O8}from"@nous-excalidraw/common";import{CaptureUpdateAction as F8}from"@nous-excalidraw/element";var Ca=O({name:"gridMode",icon:ly,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:F8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[O8.CTRL_OR_CMD]&&e.code===B8.QUOTE});import{CODES as z8,KEYS as H8}from"@nous-excalidraw/common";import{CaptureUpdateAction as G8}from"@nous-excalidraw/element";var lr=O({name:"zenMode",label:"buttons.zenMode",icon:iy,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:G8.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t,n)=>n.editorInterface.formFactor!=="phone"&&typeof t.zenModeEnabled>"u",keyTest:e=>!e[H8.CTRL_OR_CMD]&&e.altKey&&e.code===z8.Z});import{CODES as U8,KEYS as W8}from"@nous-excalidraw/common";import{CaptureUpdateAction as Y8}from"@nous-excalidraw/element";var gl=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:ry,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:Y8.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[W8.CTRL_OR_CMD]&&e.altKey&&e.code===U8.S});import{CaptureUpdateAction as V8}from"@nous-excalidraw/element";var fl=O({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,o){let t=o.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...o,bindingPreference:t,isBindingEnabled:t==="enabled"},captureUpdate:V8.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as X8}from"@nous-excalidraw/element";var bl=O({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,o){return{appState:{...o,isMidpointSnappingEnabled:!this.checked(o)},captureUpdate:X8.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as K8,KEYS as $8}from"@nous-excalidraw/common";import{CaptureUpdateAction as Z8}from"@nous-excalidraw/element";var cr=O({name:"stats",label:"stats.fullTitle",icon:QE,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:Z8.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[$8.CTRL_OR_CMD]&&e.altKey&&e.code===K8.SLASH});import{BOUND_TEXT_PADDING as Fv,ROUNDNESS as zv,TEXT_ALIGN as Uv,VERTICAL_ALIGN as Wv,arrayToMap as Yv,getFontString as j8}from"@nous-excalidraw/common";import{getOriginalContainerHeightFromCache as q8,isBoundToContainer as Hv,resetOriginalContainerCache as J8,updateOriginalContainerCache as Q8}from"@nous-excalidraw/element";import{computeBoundTextPosition as e7,computeContainerDimensionForBoundText as Gv,getBoundTextElement as Vv,redrawTextBoundingBox as Xv}from"@nous-excalidraw/element";import{hasBoundTextElement as t7,isArrowElement as o7,isTextBindableContainer as pg,isTextElement as xl,isUsingAdaptiveRadius as n7}from"@nous-excalidraw/element";import{measureText as r7}from"@nous-excalidraw/element";import{syncMovedIndices as Kv}from"@nous-excalidraw/element";import{newElement as i7}from"@nous-excalidraw/element";import{CaptureUpdateAction as ug}from"@nous-excalidraw/element";var hg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>n.scene.getSelectedElements(o).some(i=>t7(i)),perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=n.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=Vv(a,i);if(s){let{width:l,height:c}=r7(s.originalText,j8(s),s.lineHeight),d=q8(a.id);J8(a.id);let{x:p,y:m}=e7(a,s,i);n.scene.mutateElement(s,{containerId:null,width:l,height:c,text:s.originalText,x:p,y:m}),n.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:o,captureUpdate:ug.IMMEDIATELY}}}),gg=O({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);if(r.length===2){let i=xl(r[0])||xl(r[1]),a;if(pg(r[0])?a=r[0]:pg(r[1])&&(a=r[1]),i&&a&&Vv(a,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i,a;xl(r[0])&&pg(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),n.scene.mutateElement(i,{containerId:a.id,verticalAlign:Wv.MIDDLE,textAlign:Uv.CENTER,autoResize:!0,angle:o7(a)?0:a?.angle??0}),n.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return Xv(i,a,n.scene),Q8(a.id,s),{elements:a7(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:ug.IMMEDIATELY}}}),a7=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===t.id);n.splice(r,1);let i=n.findIndex(a=>a.id===o.id);return n.splice(i+1,0,t),Kv(n,Yv([o,t])),n},s7=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===o.id);n.splice(r,1);let i=n.findIndex(a=>a.id===t.id);return n.splice(i,0,o),Kv(n,Yv([o,t])),n},$v=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=r.some(a=>xl(a)&&!Hv(a));return r.length>0&&i},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=e.slice(),a={};for(let s of r)if(xl(s)&&!Hv(s)){let l=i7({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...s.boundElements||[],{id:s.id,type:"text"}],angle:s.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:n7("rectangle")?zv.ADAPTIVE_RADIUS:zv.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-Fv,y:s.y-Fv,width:Gv(s.width,"rectangle"),height:Gv(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)&&n.scene.mutateElement(p,{startBinding:m,endBinding:u})})}n.scene.mutateElement(s,{containerId:l.id,verticalAlign:Wv.MIDDLE,boundElements:null,textAlign:Uv.CENTER,autoResize:!0}),Xv(s,l,n.scene),i=s7([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:ug.IMMEDIATELY}}});import{isEmbeddableElement as I7}from"@nous-excalidraw/element";import{KEYS as r2}from"@nous-excalidraw/common";import{CaptureUpdateAction as C7}from"@nous-excalidraw/element";import{pointFrom as Jv}from"@nous-excalidraw/math";import l7 from"clsx";import{useCallback as Zv,useEffect as jv,useLayoutEffect as c7,useRef as d7,useState as m7}from"react";import{EVENT as fg,HYPERLINK_TOOLTIP_DELAY as p7,KEYS as Jd}from"@nous-excalidraw/common";import{getElementAbsoluteCoords as wg}from"@nous-excalidraw/element";import{hitElementBoundingBox as u7}from"@nous-excalidraw/element";import{isElementLink as h7}from"@nous-excalidraw/element";import{getEmbedLink as g7,embeddableURLValidator as f7}from"@nous-excalidraw/element";import{sceneCoordsToViewportCoords as Qv,viewportCoordsToSceneCoords as b7,wrapEvent as x7,isLocalLink as E7,normalizeLink as bg}from"@nous-excalidraw/common";import{isEmbeddableElement as xg}from"@nous-excalidraw/element";import{jsx as Sa,jsxs as qv}from"react/jsx-runtime";var vg=380,y7=42,Eg=5,e2=85,w7=500,yg=!1,Qd=new Map,t2=({element:e,scene:o,setAppState:t,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),s=jo(),l=qo(),c=be(),d=e.link||"",[p,m]=m7(d),u=d7(null),f=s.showHyperlinkPopup==="editor",h=Zv(()=>{if(!u.current)return;let v=bg(u.current.value)||null;if(!e.link&&v&&me("hyperlink","create"),xg(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!f7(v,l.validateEmbeddable))v&&r({message:g("toast.unableToEmbed"),closable:!0}),e.link&&Qd.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:T,height:I}=e,M=g7(v);M?.error instanceof URIError&&r({message:g("toast.unrecognizedLinkFormat"),closable:!0});let S=M?M.intrinsicSize.w/M.intrinsicSize.h:1,_=Qd.get(e.id)!==e.link;o.mutateElement(e,{..._?{width:M?.type==="video"?T>I?T:I*S:T,height:M?.type==="video"&&T>I?T/S:I}:{},link:v}),i(e,!0),Qd.has(e.id)&&Qd.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);c7(()=>()=>{h()},[h]),jv(()=>{f&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[f,c.formFactor,c.isTouchScreen]),jv(()=>{let v=null,T=I=>{if(f)return;v&&clearTimeout(v),T7(e,a,s,Jv(I.clientX,I.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},w7))};return window.addEventListener(fg.POINTER_MOVE,T,!1),()=>{window.removeEventListener(fg.POINTER_MOVE,T,!1),v&&clearTimeout(v)}},[s,e,f,t,a]);let x=Zv(()=>{me("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),E=()=>{me("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:w,y}=o2(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:qv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${w}px`,width:vg,padding:Eg},children:[f?Sa("input",{className:l7("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:u,value:p,onChange:v=>m(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[Jd.CTRL_OR_CMD]&&v.key===Jd.K&&v.preventDefault(),(v.key===Jd.ENTER||v.key===Jd.ESCAPE)&&(h(),t({showHyperlinkPopup:"info"}))}}):e.link?Sa("a",{href:bg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:E7(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&n){let T=x7(fg.EXCALIDRAW_LINK,v.nativeEvent);n({...e,link:bg(e.link)},T),T.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Sa("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),qv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&Sa(q,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:E,className:"excalidraw-hyperlinkContainer--edit",icon:Ko}),Sa(q,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:td}),d&&!xg(e)&&Sa(q,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:ft})]})]})},o2=(e,o,t)=>{let[n,r]=wg(e,t),{x:i,y:a}=Qv({sceneX:n+e.width/2,sceneY:r},o),s=i-o.offsetLeft-vg/2,l=a-o.offsetTop-e2;return{x:s,y:l}},Tg=(e,o)=>{let t=ie(e,o);return xg(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},El=null,n2=(e,o,t)=>{El&&clearTimeout(El),El=window.setTimeout(()=>v7(e,o,t),p7)},v7=(e,o,t)=>{if(!e.link)return;let n=ma();n.classList.add("excalidraw-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=h7(e.link)?g("labels.link.goToElement"):e.link;let[r,i,a,s]=wg(e,t),[l,c,d,p]=n0([r,i,a,s],e.angle,o),m=Qv({sceneX:l,sceneY:c},o);Gh(n,{left:m.x,top:m.y,width:d,height:p},"top"),me("hyperlink","tooltip","link-icon"),yg=!0},Ig=()=>{El&&clearTimeout(El),yg&&(yg=!1,ma().classList.remove("excalidraw-tooltip--visible"))},T7=(e,o,t,[n,r])=>{let{x:i,y:a}=b7({clientX:n,clientY:r},t),s=15/t.zoom.value;if(u7(Jv(i,a),e,o))return!1;let[l,c,d]=wg(e,o);if(i>=l&&i<=d&&a>=c-e2&&a<=c)return!1;let{x:p,y:m}=o2(e,t,o);return!(n>=p-s&&n<=p+vg+Eg*2+s&&r>=m-s&&r<=m+s+Eg*2+y7)};import{jsx as S7}from"react/jsx-runtime";var yl=O({name:"hyperlink",label:(e,o)=>Tg(e,o),icon:Ws,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:C7.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[r2.CTRL_OR_CMD]&&e.key===r2.K,predicate:(e,o)=>ie(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=ie(e,o);return S7(q,{type:"button",icon:Ws,"aria-label":g(Tg(e,o)),title:`${I7(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${B("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as i2,arrayToMap as Sg,randomId as k7}from"@nous-excalidraw/common";import{elementsAreInSameGroup as M7,newElementWith as a2,selectGroupsFromGivenElements as s2}from"@nous-excalidraw/element";import{CaptureUpdateAction as l2}from"@nous-excalidraw/element";var Cg=e=>e.every(o=>!o.locked),wl=O({name:"toggleElementLock",label:(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return Cg(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=ie(o,e);return Cg(t)?Bi:Wr},trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=Cg(r),a=Sg(r),s=r.length>1&&M7(r),c=r.length===1||s?null:k7(),d={...o.lockedMultiSelections};if(i)d={...o.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let E=r[0].groupIds.at(-1);delete d[E]}let p=e.map(E=>{if(!a.has(E.id))return E;let w=E.groupIds;return i?c&&(w=[...w,c]):w=w.filter(y=>!o.lockedMultiSelections[y]),a2(E,{locked:i,groupIds:w.length!==E.groupIds.length?w:E.groupIds})}),m=Sg(p),u=i?{}:Object.fromEntries(r.map(E=>[E.id,!0])),f=r.map(E=>m.get(E.id)||E),h=i?{}:s2(f,o),x=i?c||(s?r[0].groupIds.at(-1):r[0].id):null;return{elements:p,appState:{...o,selectedElementIds:u,selectedGroupIds:h,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:d,activeLockedId:x},captureUpdate:l2.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key.toLocaleLowerCase()===i2.L&&e[i2.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),c2=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Wr,predicate:(e,o)=>ie(e,o).length===0&&e.some(n=>n.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),n=e.map(a=>{if(a.locked){let s=a.groupIds.filter(l=>!o.lockedMultiSelections[l]);return a2(a,{locked:!1,groupIds:a.groupIds.length!==s.length?s:a.groupIds})}return a}),r=Sg(n),i=t.map(a=>r.get(a.id)||a);return{elements:n,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:s2(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:l2.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as mO,isLinearElement as pO,isLineElement as Ya}from"@nous-excalidraw/element";import{arrayToMap as uO,invariant as Rf}from"@nous-excalidraw/common";import{toggleLinePolygonState as hO,CaptureUpdateAction as _I}from"@nous-excalidraw/element";import iI from"clsx";import r9 from"fuzzy";import{useEffect as Sm,useRef as aI,useMemo as i9,useState as Cm}from"react";import{DEFAULT_SIDEBAR as oI,EVENT as Mm,KEYS as _o,capitalizeString as a9,isWritableElement as s9}from"@nous-excalidraw/common";import{CaptureUpdateAction as mR}from"@nous-excalidraw/element";import{useEffect as Cl,useMemo as d2,useRef as Lg,useState as P7}from"react";import{bumpVersion as vl,getLinearElementSubType as Ma,mutateElement as _g,updateElbowArrowPoints as A7}from"@nous-excalidraw/element";import{pointFrom as tm,pointRotateRads as L7}from"@nous-excalidraw/math";import{hasBoundTextElement as _7,isArrowBoundToElement as D7,isArrowElement as R7,isElbowArrow as N7,isLinearElement as Bg,isUsingAdaptiveRadius as B7}from"@nous-excalidraw/element";import{getCommonBoundingBox as O7,getElementAbsoluteCoords as F7}from"@nous-excalidraw/element";import{getBoundTextElement as g2,getBoundTextMaxHeight as z7,getBoundTextMaxWidth as H7,redrawTextBoundingBox as G7}from"@nous-excalidraw/element";import{wrapText as U7}from"@nous-excalidraw/element";import{assertNever as W7,CLASSES as Y7,getFontString as kg,isProdEnv as V7,mapFind as X7,reduceToCommonValue as K7,ROUNDNESS as Mg,sceneCoordsToViewportCoords as $7,updateActiveTool as m2}from"@nous-excalidraw/common";import{measureText as p2}from"@nous-excalidraw/element";import{LinearElementEditor as Z7}from"@nous-excalidraw/element";import{newArrowElement as Pg,newElement as j7,newLinearElement as q7}from"@nous-excalidraw/element";import{ShapeCache as J7}from"@nous-excalidraw/element";import{updateBindings as Q7}from"@nous-excalidraw/element";import{jsx as Ng}from"react/jsx-runtime";var eR=8,tR=10,Tl=["rectangle","diamond","triangle","ellipse"],Il=["line","sharpArrow","curvedArrow","elbowArrow"],oR=new Set(Tl),nR=new Set(Il),Pa=e=>oR.has(e),om=e=>e==="arrow"||nR.has(e),Po=fe(null),Sl=new Map,kl=new Map,rR=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Lg(null);return Cl(()=>{if(o.length===0){e.updateEditorAtom(Po,null);return}let n=Aa(o);n&&!t.current?t.current=n:(t.current&&!n||t.current&&n!==t.current)&&(e.updateEditorAtom(Po,null),t.current=null)},[o,e]),Cl(()=>()=>{Sl.clear(),kl.clear()},[]),Ng(iR,{app:e,elements:o})},iR=({app:e,elements:o})=>{let t=Aa(o),n=d2(()=>t==="generic"?b2(o):[],[t,o]),r=d2(()=>t==="linear"?Rg(o):[],[t,o]),i=t==="generic"?n.every(p=>p.type===n[0].type):t==="linear"?r.every(p=>Ma(p)===Ma(r[0])):!1,[a,s]=P7({x:0,y:0}),l=Lg(""),c=Lg(null);Cl(()=>{let p=[...n,...r].sort((x,E)=>x.id.localeCompare(E.id)),m=`
5
5
  ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${p.map(x=>x.id).join(",")}`;if(m===l.current)return;l.current=m;let u;if(p.length===1){let[x,,,E,w,y]=F7(p[0],e.scene.getNonDeletedElementsMap());u=L7(tm(x,E),tm(w,y),p[0].angle)}else{let{minX:x,maxY:E}=O7(p);u=tm(x,E)}let{x:f,y:h}=$7({sceneX:u[0],sceneY:u[1]},e.state);s({x:f,y:h})},[n,r,e.scene,e.state]),Cl(()=>{for(let p of r){let m=Dg(p.id,dR(p));kl.has(m)||kl.set(m,p)}},[r]),Cl(()=>{for(let p of n)if(!Sl.has(p.id)){let m=g2(p,e.scene.getNonDeletedElementsMap());m&&Sl.set(p.id,{fontSize:m.fontSize})}},[n,e.scene]);let d=t==="linear"?[["line",Gi],["sharpArrow",qi],["curvedArrow",Qi],["elbowArrow",Ji]]:t==="generic"?[["rectangle",Oi],["diamond",Fi],["triangle",zi],["ellipse",Hi]]:[];return Ng("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(tR+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-eR}px`,zIndex:2},className:Y7.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([p,m])=>{let u=i&&(t==="generic"&&n[0].type===p||t==="linear"&&Ma(r[0])===p);return Ng(q,{className:"Shape",type:"radio",icon:m,checked:u,name:"convertElementType-option",title:p,keyBindingLabel:"","aria-label":p,"data-testid":`toolbar-${p}`,onChange:()=>{e.state.activeTool.type!==p&&me("convertElementType",p,"ui"),Og(e,{conversionType:t,nextType:p}),c.current?.focus()}},`${o[0].id}${o[0].version}_${p}`)})})},aR=(e,o,t)=>{let n=H7(e,o),r=z7(e,o),i=U7(o.text,kg(o),n),a=p2(i,kg(o),o.lineHeight),s=o.fontSize;for(;(a.width>n||a.height>r)&&s>0;){s-=1;let l={...o,fontSize:s};a=p2(o.text,kg(l),o.lineHeight)}_g(o,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),G7(o,e,t)},Og=(e,{conversionType:o,nextType:t,direction:n="right"})=>{if(!o)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((s,l)=>({...s,[l.id]:!0}),{}),a=n==="right"?1:-1;if(o==="generic"){let s=b2(r),c=s.every(d=>d.type===s[0].type)?Tl.indexOf(s[0].type):-1;if(t=t??Tl[(c+Tl.length+a)%Tl.length],t&&Pa(t)){let d={};for(let m of s){let u=h2(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=g2(m,e.scene.getNonDeletedElementsMap());u&&(Sl.get(m.id)&&_g(u,e.scene.getNonDeletedElementsMap(),{fontSize:Sl.get(m.id)?.fontSize??u.fontSize}),aR(m,u,e.scene))}e.setState(m=>({selectedElementIds:i,activeTool:m2(m,{type:"selection"})}))}}if(o==="linear"){let s=Rg(r);if(!t){let c=K7(s,Ma),d=c?Il.indexOf(c):-1;t=Il[(d+Il.length+a)%Il.length]}if(om(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let p of s){let m=kl.get(Dg(p.id,t));if(m&&Ma(m)===t)d.set(m.id,m),c.push(m);else{let u=h2(p,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let p of c)if(Bg(p))if(N7(p)){let m=sR(p);if(m.length<2)continue;let u=[];for(let h=1;h<m.length-2;h++)u.push({start:m[h],end:m[h+1],index:h+1});let f=A7(p,e.scene.getNonDeletedElementsMap(),{points:m,fixedSegments:u});_g(p,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let m=X7(["line","sharpArrow","curvedArrow"],u=>kl.get(Dg(p.id,u)));if(m){let u=m.points;e.scene.mutateElement(p,{points:u})}}}let l=Rg(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new Z7(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:m2(c,{type:"selection"})}))}return!0},Aa=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(Pa(t.type))return"generic";f2(t)&&(o=!0)}return o?"linear":null},f2=e=>Bg(e)&&(!R7(e)||!D7(e)&&!_7(e)),Dg=(e,o)=>`${e}:${o}`,b2=e=>e.filter(o=>Pa(o.type)),Rg=e=>e.filter(o=>f2(o)),em=20,ka=(e,o)=>e[0]===o[0],Ag=(e,o)=>e[1]===o[1],u2=(e,o)=>ka(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),sR=e=>{let o=[e.points[0]],t=lR(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],s=[...t[i]];Math.abs(s[0]-a[0])<em?s[0]=a[0]:Math.abs(s[1]-a[1])<em&&(s[1]=a[1]),ka(a,s)||Ag(a,s)||o.push(tm(a[0],s[1])),o.push(s)}let n=[o[0]];for(let i=1;i<o.length-1;++i)ka(o[i-1],o[i])&&ka(o[i],o[i+1])||Ag(o[i-1],o[i])&&Ag(o[i],o[i+1])||n.push(o[i]);n.push(o[o.length-1]);let r=[n[0]];for(let i=1;i<n.length-1;++i){let a=r[r.length-1],s=n[i],l=n[i+1],c=ka(a,s),d=ka(s,l);if(c!==d){let p=u2(a,s),m=u2(s,l);if(p<em||m<em){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(n[n.length-1]),r},lR=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[n,r]=o[o.length-1],[i,a]=e[t];(n!==i||r!==a)&&o.push(e[t])}return o},h2=(e,o,t)=>{if(!cR(e.type,o)){if(!V7())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(J7.delete(e),Pa(o)){let n=vl(j7({...e,type:o,roundness:(o==="diamond"||o==="triangle")&&e.roundness?{type:B7(o)?Mg.ADAPTIVE_RADIUS:Mg.PROPORTIONAL_RADIUS}:e.roundness}));return Q7(n,t.scene,t.state),n}if(om(o))switch(o){case"line":return vl(q7({...e,type:"line"}));case"sharpArrow":return vl(Pg({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return vl(Pg({...e,type:"arrow",elbowed:!1,roundness:{type:Mg.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return vl(Pg({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return W7(o,`unhandled conversion type: ${o}`),e},cR=(e,o)=>!!(Pa(e)&&Pa(o)||om(e)&&om(o)),dR=e=>Bg(e)?Ma(e):e.type,x2=rR;var E2=O({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,n){return nt.set(Po,{type:"panel"}),{captureUpdate:mR.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>Aa(e)!==null});import{canCreateLinkFromElements as Fg,defaultGetElementLinkFromSelection as pR,getLinkIdAndTypeFromSelection as uR}from"@nous-excalidraw/element";import{CaptureUpdateAction as Ml}from"@nous-excalidraw/element";var nm=O({name:"copyElementLink",label:"labels.copyElementLink",icon:$i,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=ie(e,o);try{if(window.location){let i=uR(r,o);return i?(await ko(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):pR(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:Ml.EVENTUALLY}):{appState:o,elements:e,app:n,captureUpdate:Ml.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:n,captureUpdate:Ml.EVENTUALLY}},predicate:(e,o)=>Fg(ie(e,o))}),y2=O({name:"linkToElement",label:"labels.linkToElement",icon:td,perform:(e,o,t,n)=>{let r=ie(e,o);return r.length!==1||!Fg(r)?{elements:e,appState:o,app:n,captureUpdate:Ml.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:ie(e,o)[0].id}},captureUpdate:Ml.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=ie(e,o);return o.openDialog?.name!=="elementLinkSelector"&&r.length===1&&Fg(r)},trackEvent:!1});import{isDarwin as w2}from"@nous-excalidraw/common";var hR={toggleTheme:[B("Shift+Alt+D")],saveScene:[B("CtrlOrCmd+S")],loadScene:[B("CtrlOrCmd+O")],clearCanvas:[B("CtrlOrCmd+Delete")],imageExport:[B("CtrlOrCmd+Shift+E")],commandPalette:[B("CtrlOrCmd+/"),B("CtrlOrCmd+Shift+P")],cut:[B("CtrlOrCmd+X")],copy:[B("CtrlOrCmd+C")],paste:[B("CtrlOrCmd+V")],copyStyles:[B("CtrlOrCmd+Alt+C")],pasteStyles:[B("CtrlOrCmd+Alt+V")],selectAll:[B("CtrlOrCmd+A")],deleteSelectedElements:[B("Delete")],duplicateSelection:[B("CtrlOrCmd+D"),B(`Alt+${g("helpDialog.drag")}`)],sendBackward:[B("CtrlOrCmd+[")],bringForward:[B("CtrlOrCmd+]")],sendToBack:[w2?B("CtrlOrCmd+Alt+["):B("CtrlOrCmd+Shift+[")],bringToFront:[w2?B("CtrlOrCmd+Alt+]"):B("CtrlOrCmd+Shift+]")],copyAsPng:[B("Shift+Alt+C")],group:[B("CtrlOrCmd+G")],ungroup:[B("CtrlOrCmd+Shift+G")],gridMode:[B("CtrlOrCmd+'")],zenMode:[B("Alt+Z")],objectsSnapMode:[B("Alt+S")],stats:[B("Alt+/")],addToLibrary:[],flipHorizontal:[B("Shift+H")],flipVertical:[B("Shift+V")],viewMode:[B("Alt+R")],hyperlink:[B("CtrlOrCmd+K")],toggleElementLock:[B("CtrlOrCmd+Shift+L")],resetZoom:[B("CtrlOrCmd+0")],zoomOut:[B("CtrlOrCmd+-")],zoomIn:[B("CtrlOrCmd++")],zoomToFitSelection:[B("Shift+3")],zoomToFit:[B("Shift+1")],zoomToFitSelectionInViewport:[B("Shift+2")],toggleEraserTool:[B("E")],toggleHandTool:[B("H")],setFrameAsActiveTool:[B("F")],saveFileToDisk:[B("CtrlOrCmd+S")],saveToActiveFile:[B("CtrlOrCmd+S")],toggleShortcuts:[B("?")],searchMenu:[B("CtrlOrCmd+F")],wrapSelectionInFrame:[],toolLock:[B("Q")]},De=(e,o=0)=>{let t=hR[e];return t&&t.length>0?t[o]||t[0]:""};var gR="\\u0300-\\u036f",fR="\\ufe20-\\ufe2f",bR="\\u20d0-\\u20ff",xR=gR+fR+bR,ER=`[${xR}]`,yR=RegExp(ER,"g"),wR=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,vR={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},oi=e=>e.replace(wR,o=>vR[o]||o).replace(yR,"");import OB from"clsx";import{useEffect as FB,useState as zB}from"react";import{KEYS as HB,queryFocusableElements as LT}from"@nous-excalidraw/common";import{useCallback as TR,useState as IR}from"react";var v2=()=>{let[e,o]=IR(null),t=TR(n=>o(n),[]);return[e,t]};import{useState as CT,useCallback as sf,useMemo as ST,useEffect as lf,memo as kT,useRef as vB}from"react";import{LIBRARY_DISABLED_TYPES as TB,randomId as IB,isShallowEqual as CB,KEYS as SB,isWritableElement as kB,addEventListener as MB,EVENT as PB,CLASSES as vT}from"@nous-excalidraw/common";import{useEffect as S2,useRef as k2}from"react";import{URL_HASH_KEYS as Gg,URL_QUERY_KEYS as Ug,APP_NAME as M2,EVENT as im,DEFAULT_SIDEBAR as MR,LIBRARY_SIDEBAR_TAB as PR,arrayToMap as Wg,cloneJSON as AR,preventUnload as LR,promiseTry as P2,resolvablePromise as _R,toValidURL as DR,Queue as RR,Emitter as NR}from"@nous-excalidraw/common";import{hashElementsVersion as BR,hashString as OR}from"@nous-excalidraw/element";import{getCommonBoundingBox as Hg}from"@nous-excalidraw/element";import{MIME_TYPES as ni}from"@nous-excalidraw/common";var dr=({elements:e,appState:o,files:t,maxWidthOrHeight:n,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=Gr(e,null,{deleteInvisibleElements:!0}),l=_i(o,null),{exportBackground:c,viewBackgroundColor:d}=l;return Bc(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(n){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let h=Math.max(p,m),x=n<h?n/h:o?.exportScale??1;return u.width=p*x,u.height=m*x,{canvas:u,scale:x}}let f=r?.(p,m)||{width:p,height:m};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},T2=async e=>{let{mimeType:o=ni.png,quality:t}=e;o===ni.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ni.png}" mimeType`),o==="image/jpg"&&(o=ni.jpg),o===ni.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ni.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let n=await dr(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((r,i)=>{n.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===ni.png&&e.appState?.exportEmbedScene&&(a=await l0({blob:a,metadata:Rs(e.elements,e.appState,e.files||{},"local")})),r(a)},o,t)})},Pn=async({elements:e,appState:o=Yo(),files:t={},exportPadding:n,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=Gr(e,null,{deleteInvisibleElements:!0}),d={..._i(o,null),exportPadding:n};return Oc(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},CR=async e=>{if(e.type==="svg"){let o=await Pn(e);await ko(o.outerHTML)}else if(e.type==="png")await Gd(T2(e));else if(e.type==="json")await zd(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as I2,useState as SR}from"react";import{COLOR_PALETTE as kR}from"@nous-excalidraw/common";var zg=fe(new Map),C2=async e=>await Pn({elements:e,appState:{exportBackground:!1,viewBackgroundColor:kR.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),rm=(e,o,t,n)=>{let[r,i]=SR();return I2(()=>{if(o)if(e){let a=t.get(e);a?i(a):(async()=>{let s=await C2(o);s.querySelector(".style-fonts")?.remove(),s&&(t.set(e,s),i(s))})()}else(async()=>{let a=await C2(o);i(a)})()},[e,o,t,i]),I2(()=>{let a=n.current;if(a)return r&&(a.innerHTML=r.outerHTML),()=>{a.innerHTML=""}},[r,n]),r},La=()=>{let[e]=Q(zg);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var FR=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],L2=new NR,An=fe({status:"loaded",isInitialized:!1,libraryItems:[]}),Pl=e=>AR(e),zR=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((n,r)=>n.id===o.elements[r].id&&n.versionNonce===o.elements[r].versionNonce)),_2=(e,o)=>{let t=[];for(let n of o)zR(e,n)&&t.push(n);return[...t,...e]},D2=(e,o)=>{let t=Wg(o),n={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let i of e)t.has(i.id)||n.deletedItems.set(i.id,i);let r=Wg(e);for(let i of o){let a=r.get(i.id);a?Xg(a)!==Xg(i)&&n.updatedItems.set(i.id,i):n.addedItems.set(i.id,i)}return n},Yg=class{constructor(o){k(this,"currLibraryItems",[]);k(this,"prevLibraryItems",Pl(this.currLibraryItems));k(this,"app");k(this,"updateQueue",[]);k(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);k(this,"notifyListeners",()=>{if(this.updateQueue.length>0)nt.set(An,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{nt.set(An,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=Pl(this.currLibraryItems);let t=Pl(this.currLibraryItems);this.app.props.onLibraryChange?.(t),L2.trigger(D2(o,t),t)}catch(o){console.error(o)}}});k(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],nt.set(zg,new Map)});k(this,"resetLibrary",()=>this.setLibrary([]));k(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(Pl(t))}catch{return o(this.currLibraryItems)}}));k(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i="unpublished"})=>(r&&this.app.setState({openSidebar:{name:MR.name,tab:PR}}),this.setLibrary(()=>new Promise(async(a,s)=>{try{let l=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;l instanceof Blob?c=await ku(l,i):c=Fs(l,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:c.length}))?(t&&this.app.focusContainer(),a(n?_2(this.currLibraryItems,c):c)):s(new Pi)}catch(l){s(l)}}))));k(this,"setLibrary",o=>{let t=new Promise(async(n,r)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=Pl(await o),n(this.currLibraryItems)}catch(i){r(i)}}).catch(n=>{if(n.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw n}).finally(()=>{this.updateQueue=this.updateQueue.filter(n=>n!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},R2=Yg,Da=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=u=>e.slice(u*t,u*t+t).reduce((h,x)=>{let{height:E}=Hg(x.elements);return Math.max(h,E)},0),i=u=>{let f=0,h=0,x=0;for(let E of e){if(f%t===0&&(h=0),h===u){let{width:w}=Hg(E.elements);x=Math.max(x,w)}f++,h++}return x},a=0,s=0,l=0,c=0,d=0,p=0,m=0;for(let u of e){d&&d%t===0&&(s+=l+50,a=0,p=0,m++),p===0&&(l=r(m)),c=i(p);let{minX:f,minY:h,width:x,height:E}=Hg(u.elements),w=(c-x)/2,y=(l-E)/2;n.push(...u.elements.map(v=>({...v,x:v.x+a+w-f,y:v.y+s+y-h}))),a+=c+50,d++,p++}return n},HR=(e,o=FR)=>{if(typeof o=="function"?o(e):o.some(t=>{let n=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:r,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${n.hostname}$`).test(r)&&new RegExp(`^${n.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},Vg=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Gg.addLibrary)||new URLSearchParams(window.location.search).get(Ug.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},mr=class mr{constructor(o){k(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,n=!0){let r=()=>new Promise(async(i,a)=>{try{let s=await o.load({source:t});i(Fs(s?.libraryItems||[],"published"))}catch(s){a(s)}});return n?mr.queue.push(r):r()}getLibraryItems(o){return mr.getLibraryItems(this.adapter,o,!1)}};k(mr,"queue",new RR),k(mr,"run",async(o,t)=>{let n=new mr(o);return mr.queue.push(()=>t(n))});var _a=mr,Al=0,am=0,Xg=e=>`${e.id}:${e.name||""}:${BR(e.elements)}`,sm=e=>OR(e.map(o=>Xg(o)).sort().join()),A2=async(e,o)=>{try{return am++,await _a.run(e,async t=>{let n=Wg(await t.getLibraryItems("save"));for(let[s]of o.deletedItems)n.delete(s);let r=[];for(let[s,l]of o.addedItems)n.has(s)?n.set(s,l):r.push(l);if(o.updatedItems)for(let[s,l]of o.updatedItems)n.set(s,l);let i=r.concat(Array.from(n.values())),a=sm(i);return a!==Al&&await e.save({libraryItems:i}),Al=a,i})}finally{am--}},GR=e=>{let{excalidrawAPI:o}=e,t=k2(e);t.current=e;let n=k2(!1);S2(()=>{if(!o)return;n.current=!1;let r=async({libraryUrl:s,idToken:l})=>{let c=new Promise(async(p,m)=>{try{s=decodeURIComponent(s),s=DR(s),HR(s,t.current.validateLibraryUrl);let f=await(await fetch(s)).blob();p(f)}catch(u){m(u)}}),d=l!==o.id;await(d&&document.hidden?new Promise(p=>{window.addEventListener("focus",()=>p(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:d,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(p){throw o.updateScene({appState:{errorMessage:p.message}}),p}finally{if(window.location.hash.includes(Gg.addLibrary)){let p=new URLSearchParams(window.location.hash.slice(1));p.delete(Gg.addLibrary),window.history.replaceState({},M2,`#${p.toString()}`)}else if(window.location.search.includes(Ug.addLibrary)){let p=new URLSearchParams(window.location.search);p.delete(Ug.addLibrary),window.history.replaceState({},M2,`?${p.toString()}`)}}},i=s=>{s.preventDefault();let l=Vg();l&&(s.stopImmediatePropagation(),window.history.replaceState({},"",s.oldURL),r(l))},a=Vg();if(a&&r(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(s=>{o.updateLibrary({libraryItems:s,merge:!0})}).catch(s=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${s?.message}`)})),"adapter"in t.current&&t.current.adapter){let s=t.current.adapter,l=t.current.migrationAdapter,c=_R();l?c.resolve(P2(l.load).then(async d=>{let p=null;try{if(!d)return _a.getLibraryItems(s,"load");p=Fs(d.libraryItems||[],"published");let m=await A2(s,D2([],p));try{await l.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return m}catch(m){return console.error(`couldn't migrate legacy library data: ${m.message}`),p}}).catch(d=>(console.error(`error during library migration: ${d.message}`),_a.getLibraryItems(s,"load")))):c.resolve(P2(_a.getLibraryItems,s,"load")),o.updateLibrary({libraryItems:c.then(d=>{let p=d||[];return Al=sm(p),p}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(im.HASHCHANGE,i),()=>{window.removeEventListener(im.HASHCHANGE,i)}},[o]),S2(()=>{let r=L2.on(async(a,s)=>{let l=n.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&Al!==sm(s)&&await A2(c,a)}catch(d){console.error(`couldn't persist library update: ${d.message}`,a),l&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{am&&LR(a)};return window.addEventListener(im.BEFORE_UNLOAD,i),()=>{window.removeEventListener(im.BEFORE_UNLOAD,i),r(),Al=0,am=0}},[])};import VR from"clsx";import{VERSIONS as UR}from"@nous-excalidraw/common";import{jsx as YR}from"react/jsx-runtime";var WR=({theme:e,id:o,libraryReturnUrl:t})=>{let n=t||window.location.origin+window.location.pathname;return YR("a",{className:"library-menu-browse-button",href:`${C.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${n}&useHash=true&token=${o}&theme=${e}&version=${UR.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},N2=WR;import{jsx as XR,jsxs as KR}from"react/jsx-runtime";var lm=({libraryReturnUrl:e,theme:o,id:t,style:n,children:r,className:i})=>KR("div",{className:VR("library-menu-control-buttons",i),style:n,children:[XR(N2,{id:t,libraryReturnUrl:e,theme:o}),r]});import{useCallback as Ba,useEffect as of,useMemo as nf,useRef as ET,useState as yT}from"react";import{MIME_TYPES as gB,arrayToMap as fB,nextAnimationFrame as bB}from"@nous-excalidraw/common";import{duplicateElements as xB}from"@nous-excalidraw/element";import EB from"clsx";import $R from"lodash.throttle";import{useEffect as ZR}from"react";var jR=fe(0),B2=e=>{let[o,t]=Q(jR);return ZR(()=>{let{current:n}=e;if(!n)return;let r=$R(()=>{let{scrollTop:i}=n;t(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,t]),o};import VN from"clsx";import{useCallback as XN,useState as Qg}from"react";import{muteFSAbortError as KN}from"@nous-excalidraw/common";import{flushSync as O2}from"react-dom";import qR from"clsx";import{jsx as cm,jsxs as QR}from"react/jsx-runtime";var JR=({label:e,onClick:o,className:t,children:n,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return QR("button",{className:qR("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:o,...s,children:[n&&cm("div",{style:a?{visibility:"hidden"}:{},children:n}),cm("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&cm("div",{style:{position:"absolute",inset:0},children:cm(bt,{})})]})},Ln=JR;import{jsx as F2,jsxs as z2}from"react/jsx-runtime";var eN=e=>{let{onConfirm:o,onCancel:t,children:n,confirmText:r=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...s}=e,l=he(),c=Vo(Ra),{container:d}=Ne();return z2(qe,{onCloseRequest:t,size:"small",...s,className:`confirm-dialog ${a}`,children:[n,z2("div",{className:"confirm-dialog-buttons",children:[F2(Ln,{label:i,onClick:()=>{l({openMenu:null}),c(!1),O2(()=>{t()}),d?.focus()}}),F2(Ln,{label:r,onClick:()=>{l({openMenu:null}),c(!1),O2(()=>{o()}),d?.focus()},actionType:"danger"})]})]})},dm=eN;import{useCallback as sN,useEffect as Zg,useRef as H2,useState as Kg}from"react";import{EDITOR_LS_KEYS as $g,EXPORT_DATA_TYPES as lN,MIME_TYPES as G2,VERSIONS as cN,chunk as dN,getExportSource as mN}from"@nous-excalidraw/common";var so=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};k(so,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(n){return console.warn(`localStorage.setItem error: ${n.message}`),!1}}),k(so,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import mm from"react";var tN=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,oN=/{{([\w-]+)}}/,nN=/<([\w-]+)>/,rN=/<\/([\w-]+)>/,iN=(e,o)=>{let t=[{name:"",children:[]}];return e.split(tN).filter(Boolean).forEach(n=>{let r=n.match(nN),i=n.match(rN),a=n.match(oN);if(r!==null){let s=r[1];o.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=mm.createElement(mm.Fragment,{},...l.children),d=o[l.name];typeof d=="function"&&t[t.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${n} for interpolating ${e}`);else if(a!==null){let s=a[1];o.hasOwnProperty(s)?t[t.length-1].children.push(o[s]):console.warn(`Trans: key ${s} not in props for interpolating ${e}`)}else t[t.length-1].children.push(n)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},aN=({i18nKey:e,children:o,...t})=>{let{t:n}=Ie();return mm.createElement(mm.Fragment,{},...iN(n(e),t))},Rt=aN;import{jsx as xe,jsxs as vt}from"react/jsx-runtime";var pN=async e=>{let n=Math.round(8),r=Math.max(Math.round(128/64),2),i=dN(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(n*2)-n*2,a.height=i.length*128+(i.length+1)*(n*2)-n*2;let s=a.getContext("2d");s.fillStyle="#fff",s.fillRect(0,0,a.width,a.height);for(let[l,c]of e.entries()){let d=await dr({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:p,height:m}=d,u=Math.floor(l/6)*(128+n*2),f=l%6*(128+n*2);s.drawImage(d,f+(128-p)/2+n,u+(128-m)/2+n),s.lineWidth=r,s.strokeStyle="#ced4da",s.strokeRect(f+n/2,u+n/2,128+n,128+n)}return await zc(new File([await Ur(a)],"preview",{type:G2.png}),{outputType:G2.jpg,maxWidthOrHeight:5e3})},uN=({libItem:e,appState:o,index:t,onChange:n,onRemove:r})=>{let i=H2(null),a=H2(null);return Zg(()=>{let s=i.current;s&&(async()=>{let l=await Pn({elements:e.elements,appState:{...o,viewBackgroundColor:"#fff",exportBackground:!0},files:null,skipInliningFonts:!0});s.innerHTML=l.outerHTML})()},[e.elements,o]),vt("div",{className:"single-library-item",children:[e.status==="published"&&xe("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),xe("div",{ref:i,className:"single-library-item__svg"}),xe(q,{"aria-label":g("buttons.remove"),type:"button",icon:oo,className:"single-library-item--remove",onClick:r.bind(null,e.id),title:g("buttons.remove")}),vt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[vt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[vt("div",{style:{padding:"0.5em 0"},children:[xe("span",{style:{fontWeight:500,color:"#868e96"},children:g("publishDialog.itemName")}),xe("span",{"aria-hidden":"true",className:"required",children:"*"})]}),xe("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:s=>{n(s.target.value,t)}})]}),xe("span",{className:"error",children:e.error})]})]})},hN=({onClose:e,libraryItems:o,appState:t,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:a})=>{let[s,l]=Kg({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,d]=Kg(!1);Zg(()=>{let y=so.get($g.PUBLISH_LIBRARY);y&&l(y)},[]);let[p,m]=Kg(o.slice());Zg(()=>{m(o.slice())},[o]);let u=y=>{l({...s,[y.target.name]:y.target.value})},f=async y=>{y.preventDefault(),d(!0);let v=[],T=!1;if(p.forEach(P=>{let D="";P.name||(D=g("publishDialog.errors.required"),T=!0),v.push({...P,error:D})}),T){m(v),d(!1);return}let I=await pN(p),M={type:lN.excalidrawLibrary,version:cN.excalidrawLibrary,source:mN(),libraryItems:p},S=JSON.stringify(M,null,2),_=new Blob([S],{type:"application/json"}),A=new FormData;A.append("excalidrawLib",_),A.append("previewImage",I),A.append("previewImageType",I.type),A.append("title",s.name),A.append("authorName",s.authorName),A.append("githubHandle",s.githubHandle),A.append("name",s.name),A.append("description",s.description),A.append("twitterHandle",s.twitterHandle),A.append("website",s.website),fetch(`${C.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:A}).then(P=>P.ok?P.json().then(({url:D})=>{so.delete($g.PUBLISH_LIBRARY),n({url:D,authorName:s.authorName,items:p})}):P.json().catch(()=>{throw new Error(P.statusText||"something went wrong")}).then(D=>{throw new Error(D.message||P.statusText||"something went wrong")}),P=>{console.error(P),r(P),d(!1)}).catch(P=>{console.error(P),r(P),d(!1)})},h=()=>{let y=[];return p.forEach((v,T)=>{y.push(xe("div",{className:"single-library-item-wrapper",children:xe(uN,{libItem:v,appState:t,index:T,onChange:(I,M)=>{let S=p.slice();S[M].name=I,m(S)},onRemove:a})},T))}),xe("div",{className:"selected-library-items",children:y})},x=sN(()=>{i(p),so.set($g.PUBLISH_LIBRARY,s),e()},[p,e,i,s]),E=!!o.length,w=o.some(y=>y.status==="published");return xe(qe,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:E?vt("form",{onSubmit:f,children:[xe("div",{className:"publish-library-note",children:xe(Rt,{i18nKey:"publishDialog.noteDescription",link:y=>xe("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:y})})}),xe("span",{className:"publish-library-note",children:xe(Rt,{i18nKey:"publishDialog.noteGuidelines",link:y=>xe("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),xe("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),w&&xe("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),h(),vt("div",{className:"publish-library__fields",children:[vt("label",{children:[vt("div",{children:[xe("span",{children:g("publishDialog.libraryName")}),xe("span",{"aria-hidden":"true",className:"required",children:"*"})]}),xe("input",{type:"text",name:"name",required:!0,value:s.name,onChange:u,placeholder:g("publishDialog.placeholder.libraryName")})]}),vt("label",{style:{alignItems:"flex-start"},children:[vt("div",{children:[xe("span",{children:g("publishDialog.libraryDesc")}),xe("span",{"aria-hidden":"true",className:"required",children:"*"})]}),xe("textarea",{name:"description",rows:4,required:!0,value:s.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),vt("label",{children:[vt("div",{children:[xe("span",{children:g("publishDialog.authorName")}),xe("span",{"aria-hidden":"true",className:"required",children:"*"})]}),xe("input",{type:"text",name:"authorName",required:!0,value:s.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),vt("label",{children:[xe("span",{children:g("publishDialog.githubUsername")}),xe("input",{type:"text",name:"githubHandle",value:s.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),vt("label",{children:[xe("span",{children:g("publishDialog.twitterUsername")}),xe("input",{type:"text",name:"twitterHandle",value:s.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),vt("label",{children:[xe("span",{children:g("publishDialog.website")}),xe("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:s.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),xe("span",{className:"publish-library-note",children:xe(Rt,{i18nKey:"publishDialog.noteLicense",link:y=>xe("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),vt("div",{className:"publish-library__buttons",children:[xe(Ln,{label:g("buttons.saveLibNames"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),xe(Ln,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:c})]})]}):xe("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},U2=hN;import pT from"react";import{DropdownMenu as GN}from"radix-ui";import{CLASSES as UN}from"@nous-excalidraw/common";import bN from"clsx";import{useCallback as xN,useEffect as EN,useRef as yN}from"react";import{CLASSES as wN,EVENT as X2,KEYS as vN}from"@nous-excalidraw/common";import{DropdownMenu as TN}from"radix-ui";import{forwardRef as W2}from"react";import Y2 from"clsx";import{jsx as V2}from"react/jsx-runtime";var gN=W2(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>V2("div",{className:Y2("Stack Stack_horizontal",r),style:{"--gap":o,alignItems:t,justifyContent:n,...i},ref:a,children:e})),fN=W2(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>V2("div",{className:Y2("Stack Stack_vertical",r),style:{"--gap":o,justifyItems:t,justifyContent:n,...i},ref:a,children:e})),Tt={Row:gN,Col:fN};import{jsx as pm}from"react/jsx-runtime";var K2=({children:e,onClickOutside:o,className:t="",onSelect:n,open:r=!0,align:i="end",style:a})=>{let s=be(),l=yN(null),c=jn({onClickOutside:o});na(l,xN(p=>{l.current?.closest(`.${wN.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(p.target)||c.onClickOutside?.()},[c])),EN(()=>{if(!r)return;let p=u=>{u.key===vN.ESCAPE&&(u.stopImmediatePropagation(),c.onClickOutside?.())},m={capture:!0};return document.addEventListener(X2.KEYDOWN,p,m),()=>{document.removeEventListener(X2.KEYDOWN,p,m)}},[c,r]);let d=bN(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return pm(Ih.Provider,{value:{onSelect:n},children:pm(TN.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:p=>p.preventDefault(),children:s.formFactor==="phone"?pm(Tt.Col,{className:"dropdown-menu-container",children:e}):pm(Ze,{className:"dropdown-menu-container",padding:2,children:e})})})};K2.displayName="DropdownMenuContent";var $2=K2;import{jsx as CN}from"react/jsx-runtime";var IN=({children:e,className:o="",selected:t,...n})=>CN("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),Z2=IN;import{DropdownMenu as SN}from"radix-ui";import{jsx as jg}from"react/jsx-runtime";var j2=({icon:e,shortcut:o,href:t,children:n,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=yd(r);return jg(SN.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:jg("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:or(i,a),title:l.title??l["aria-label"],children:jg(nr,{icon:e,shortcut:o,children:n})})})},Na=j2;j2.displayName="DropdownMenuItemLink";import{jsx as kN}from"react/jsx-runtime";var q2=()=>kN("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),J2=q2;q2.displayName="DropdownMenuSeparator";import{DropdownMenu as RN}from"radix-ui";import MN from"clsx";import{DropdownMenu as PN}from"radix-ui";import{useCallback as AN,useState as Q2}from"react";import{jsx as Jg}from"react/jsx-runtime";var qg=-4,LN=4,eT=({children:e,className:o})=>{let t=be(),n=MN(`dropdown-menu dropdown-submenu ${o}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=AN(c=>{if(c){let p=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(p){let m=c.getBoundingClientRect().width,f=window.innerWidth-p.right;f<m+20&&(a(f-m+qg),l(qg+8))}}},[]),[i,a]=Q2(LN),[s,l]=Q2(qg);return Jg(PN.SubContent,{className:n,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?Jg(Tt.Col,{className:"dropdown-menu-container",children:e}):Jg(Ze,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},tT=eT;eT.displayName="DropdownMenuSubContent";import{DropdownMenu as _N}from"radix-ui";import{jsx as oT,jsxs as DN}from"react/jsx-runtime";var nT=({children:e,icon:o,shortcut:t,className:n})=>DN(_N.SubTrigger,{className:`${or(n)} dropdown-menu__submenu-trigger`,children:[oT(nr,{icon:o,shortcut:t,children:e}),oT("div",{className:"dropdown-menu__submenu-trigger-icon",children:fy})]}),rT=nT;nT.displayName="DropdownMenuSubTrigger";import iT from"react";var um=e=>o=>{let t=iT.Children.toArray(o).find(n=>iT.isValidElement(n)&&typeof n.type!="string"&&n?.type.displayName&&n.type.displayName===e);return t||null},aT=um("DropdownMenuTrigger"),sT=um("DropdownMenuContent"),lT=um("DropdownMenuSubTrigger"),cT=um("DropdownMenuSubContent");import{jsxs as NN}from"react/jsx-runtime";var hm=({children:e})=>{let o=lT(e),t=cT(e);return NN(RN.Sub,{children:[o,t]})};hm.Trigger=rT;hm.Content=tT;hm.displayName="DropdownMenuSub";var pr=hm;import BN from"clsx";import{DropdownMenu as ON}from"radix-ui";import{jsx as FN}from"react/jsx-runtime";var dT=({className:e="",children:o,onToggle:t,title:n,...r})=>{let i=be(),a=BN(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return FN(ON.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:o})},mT=dT;dT.displayName="DropdownMenuTrigger";import{jsx as HN}from"react/jsx-runtime";var zN=e=>HN(Pt,{...e,icon:e.checked?Kc:od}),Ao=zN;import{jsx as YN,jsxs as WN}from"react/jsx-runtime";var Lo=({children:e,open:o})=>{let t=aT(e),n=sT(e),r=n&&pT.isValidElement(n)?pT.cloneElement(n,{open:o}):n;return YN(GN.Root,{open:o,modal:!1,children:WN("div",{className:UN.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Lo.Trigger=mT;Lo.Content=$2;Lo.Item=Pt;Lo.ItemCheckbox=Ao;Lo.ItemLink=Na;Lo.ItemCustom=Z2;Lo.Group=ol;Lo.Separator=J2;Lo.Sub=pr;var ce=Lo;Lo.displayName="DropdownMenu";import{jsx as zt,jsxs as gm}from"react/jsx-runtime";var $N=(e,o)=>e.filter(t=>o.includes(t.id)),ZN=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:a,className:s})=>{let[l]=Q(An),[c,d]=Q(Ra),p=()=>{let A=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),P=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return zt(dm,{onConfirm:()=>{o.length?n():r(),u(!1)},onCancel:()=>{u(!1)},title:P,children:zt("p",{children:A})})},[m,u]=Qg(!1),f=!!o.length,h=f?l.libraryItems.filter(A=>o.includes(A.id)):l.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[E,w]=Qg(!1),[y,v]=Qg(null),T=XN(()=>gm(qe,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[zt("p",{children:zt(Rt,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:A=>zt("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:A})})}),zt(q,{type:"button",title:g("buttons.close"),"aria-label":g("buttons.close"),label:g("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),I=(A,P)=>{w(!1),v({url:A.url,authorName:A.authorName});let D=P.slice();D.forEach(z=>{o.includes(z.id)&&(z.status="published")}),t.setLibrary(D)},M=async()=>{try{await t.updateLibrary({libraryItems:Dc({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(A){if(A?.name==="AbortError"){console.warn(A);return}e({errorMessage:g("errors.importLibraryError")})}},S=async()=>{let A=f?h:await t.getLatestLibrary();o0(A).catch(KN).catch(P=>{e({errorMessage:P.message})})},_=()=>gm(ce,{open:c,children:[zt(ce.Trigger,{onToggle:()=>d(!c),children:S0}),gm(ce.Content,{onClickOutside:()=>d(!1),onSelect:()=>d(!1),className:"library-menu",children:[!f&&zt(ce.Item,{onSelect:M,icon:Vi,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!h.length&&zt(ce.Item,{onSelect:S,icon:Vr,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),f&&zt(ce.Item,{icon:OE,onSelect:()=>w(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")}),!!h.length&&zt(ce.Item,{onSelect:()=>u(!0),icon:ft,children:x})]})]});return gm("div",{className:VN("library-menu-dropdown-container",s),children:[_(),o.length>0&&zt("div",{className:"library-actions-counter",children:o.length}),m&&p(),E&&zt(U2,{onClose:()=>w(!1),libraryItems:$N(l.libraryItems,o),appState:a,onSuccess:A=>I(A,l.libraryItems),onError:A=>window.alert(A),updateItemsInStorage:()=>t.setLibrary(l.libraryItems),onRemove:A=>i(o.filter(P=>P!==A))}),y&&T()]})},uT=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:n}=He(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=La(),a=se(),s=he(),[l]=Q(An),c=async p=>{let m=p.filter(u=>!e.includes(u.id));n.setLibrary(m).catch(()=>{s({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return zt(ZN,{appState:a,setAppState:s,selectedItems:e,onSelectItems:o,library:n,onRemoveFromLibrary:()=>c(l.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:t})};import{memo as nB,useEffect as rB,useState as iB}from"react";import jN,{useCallback as qN}from"react";function JN(){return[!1,qN(o=>o(),[])]}var hT=jN.useTransition||JN;import gT from"clsx";import{memo as QN,useRef as eB,useState as tB}from"react";import{jsx as fm,jsxs as oB}from"react/jsx-runtime";var fT=QN(({id:e,elements:o,isPending:t,onClick:n,selected:r,onToggle:i,onDrag:a,svgCache:s})=>{let l=eB(null),c=rm(e,o,s,l),[d,p]=tB(!1),m=be().formFactor==="phone",u=t&&fm("div",{className:"library-unit__adder",children:C0});return oB("div",{className:gT("library-unit",{"library-unit__active":o,"library-unit--hover":o&&d,"library-unit--selected":r,"library-unit--skeleton":!c}),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[fm("div",{className:gT("library-unit__dragger",{"library-unit__pulse":!!t}),ref:l,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):n(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}p(!1),a(e,f)}}),u,e&&o&&(d||m||r)&&fm(ll,{checked:r,onChange:(f,h)=>i(e,h),className:"library-unit__checkbox"})]})}),bT=()=>fm("div",{className:"library-unit library-unit--skeleton"});import{Fragment as aB,jsx as bm}from"react/jsx-runtime";var xm=({children:e})=>bm("div",{className:"library-menu-items-container__grid",children:e}),Ll=nB(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:a})=>{let[,s]=hT(),[l,c]=iB(0);return rB(()=>{l<e.length&&s(()=>{c(l+a)})},[l,e.length,s,a]),bm(aB,{children:e.map((d,p)=>p<l?bm(fT,{elements:d?.elements,isPending:!d?.id&&!!d?.elements,onClick:r,svgCache:i,id:d?.id,selected:n(d.id),onToggle:o,onDrag:t},d?.id??p):bm(bT,{},p))})});import ef from"clsx";import{forwardRef as dB,useRef as mB,useImperativeHandle as pB,useLayoutEffect as uB,useState as hB}from"react";import sB from"clsx";import{composeEventHandlers as lB}from"@nous-excalidraw/common";import{jsx as cB}from"react/jsx-runtime";var Et=({type:e="button",onSelect:o,selected:t,children:n,className:r="",...i})=>cB("button",{onClick:lB(i.onClick,a=>{o()}),type:e,className:sB("excalidraw-button",r,{selected:t}),...i,children:n});import{jsx as tf,jsxs as xT}from"react/jsx-runtime";var ur=dB(({onChange:e,label:o,fullWidth:t,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,icon:l,className:c,type:d,...p},m)=>{let u=mB(null);pB(m,()=>u.current),uB(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[f,h]=hB(!1);return xT("div",{className:ef("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,o&&tf("div",{className:"ExcTextField__label",children:o}),xT("div",{className:ef("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[tf("input",{className:ef({"is-redacted":"value"in p&&p.value&&s&&!f}),readOnly:r,value:"value"in p?p.value:void 0,defaultValue:"defaultValue"in p?p.defaultValue:void 0,placeholder:n,ref:u,onChange:x=>e?.(x.target.value),onKeyDown:a,type:d}),s&&tf(Et,{onSelect:()=>h(!f),style:{border:0,userSelect:"none"},children:f?VE:ji})]})]})});import{Fragment as wT,jsx as mt,jsxs as rn}from"react/jsx-runtime";var yB=17,wB=64;function rf({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:n,pendingElements:r,theme:i,id:a,libraryReturnUrl:s,onSelectItems:l,selectedItems:c}){let d=be(),p=ET(null),m=B2(p);of(()=>{m>0&&p.current?.scrollTo(0,m)},[]);let{svgCache:u}=La(),[f,h]=yT(null),[x,E]=yT(""),w=!o.length&&!r.length,y=!w&&!!x.trim(),v=nf(()=>{let G=oi(x.trim().toLowerCase());return G?o.filter(J=>{let $=J.name||"";return $.trim()&&oi($.toLowerCase()).includes(G)}):[]},[o,x]),T=nf(()=>o.filter(G=>G.status!=="published"),[o]),I=nf(()=>o.filter(G=>G.status==="published"),[o]),M=Ba((G,J)=>{let $=!c.includes(G),ee=[...T,...I];if($){if(J.shiftKey&&f){let R=ee.findIndex(Pe=>Pe.id===f),F=ee.findIndex(Pe=>Pe.id===G);if(R===-1||F===-1){l([...c,G]);return}let ne=fB(c),ue=Math.min(R,F),Te=Math.max(R,F),Se=ee.reduce((Pe,de,_e)=>((_e>=ue&&_e<=Te||ne.has(de.id))&&Pe.push(de.id),Pe),[]);l(Se)}else l([...c,G]);h(G)}else h(null),l(c.filter(R=>R!==G))},[f,l,I,c,T]);of(()=>{c.length||h(null)},[c]);let S=Ba(G=>{let J;return c.includes(G)?J=o.filter($=>c.includes($.id)):J=o.filter($=>$.id===G),J.map($=>({...$,elements:xB({type:"everything",elements:$.elements,randomizeSeed:!0}).duplicatedElements}))},[o,c]),_=Ba((G,J)=>{let $={itemIds:c.includes(G)?c:[G]};J.dataTransfer.setData(gB.excalidrawlibIds,JSON.stringify($))},[c]),A=Ba(G=>G?c.includes(G):!1,[c]),P=Ba(()=>{t(r)},[r,t]),D=Ba(G=>{G&&n(S(G))},[S,n]),z=u.size>=(v.length?v:o).length?wB:yB,K=ET(null);of(()=>{bB(()=>{K.current?.focus()})},[]);let W=!y&&rn(wT,{children:[!w&&mt("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),!r.length&&!T.length?rn("div",{className:"library-menu-items__no-items",children:[!I.length&&mt("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),mt("div",{className:"library-menu-items__no-items__hint",children:I.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):rn(xm,{children:[r.length>0&&mt(Ll,{itemsRenderedPerBatch:z,items:[{id:null,elements:r}],onItemSelectToggle:M,onItemDrag:_,onClick:P,isItemSelected:A,svgCache:u}),mt(Ll,{itemsRenderedPerBatch:z,items:T,onItemSelectToggle:M,onItemDrag:_,onClick:D,isItemSelected:A,svgCache:u})]}),I.length>0&&mt("div",{className:"library-menu-items-container__header",style:{marginTop:"0.75rem"},children:g("labels.excalidrawLib")}),I.length>0&&mt(xm,{children:mt(Ll,{itemsRenderedPerBatch:z,items:I,onItemSelectToggle:M,onItemDrag:_,onClick:D,isItemSelected:A,svgCache:u})})]}),Y=y&&rn(wT,{children:[rn("div",{className:"library-menu-items-container__header",children:[g("library.search.heading"),!e&&rn("div",{className:"library-menu-items-container__header__hint",style:{cursor:"pointer"},onPointerDown:G=>G.preventDefault(),onClick:G=>{E("")},children:[mt("kbd",{children:"esc"})," to clear"]})]}),v.length>0?mt(xm,{children:mt(Ll,{itemsRenderedPerBatch:z,items:v,onItemSelectToggle:M,onItemDrag:_,onClick:D,isItemSelected:A,svgCache:u})}):rn("div",{className:"library-menu-items__no-items",children:[mt("div",{className:"library-menu-items__no-items__hint",children:g("library.search.noResults")}),mt(Et,{onPointerDown:G=>G.preventDefault(),onSelect:()=>{E("")},style:{width:"auto",marginTop:"1rem"},children:g("library.search.clearSearch")})]})]});return rn("div",{className:"library-menu-items-container",style:r.length||T.length||I.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[rn("div",{className:"library-menu-items-header",children:[!w&&mt(ur,{ref:K,type:"search",className:EB("library-menu-items-container__search",{hideCancelButton:d.formFactor!=="phone"}),placeholder:g("library.search.inputPlaceholder"),value:x,onChange:G=>E(G)}),mt(uT,{selectedItems:c,onSelectItems:l,className:"library-menu-dropdown-container--in-heading"})]}),rn(Tt.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:I.length>0?1:"0 1 auto",margin:w?"auto":0},ref:p,children:[e&&mt("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:mt(bt,{})}),W,Y,w&&mt(lm,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:s,theme:i})]})]})}import{jsx as hr,jsxs as IT}from"react/jsx-runtime";var Ra=fe(!1),TT=({children:e})=>hr("div",{className:"layer-ui__library",children:e}),AB=kT(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:n,libraryReturnUrl:r,library:i,id:a,theme:s,selectedItems:l,onSelectItems:c})=>{let[d]=Q(An),p=sf(f=>{(async(x,E)=>{me("element","addToLibrary","ui");for(let y of TB)if(x.some(v=>v.type===y))return n({errorMessage:g(`errors.libraryElementTypeError.${y}`)});let w=[{status:"unpublished",elements:x,id:IB(),created:Date.now()},...E];t(),i.setLibrary(w).catch(()=>{n({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,d.libraryItems)},[t,i,n,d.libraryItems]),m=ST(()=>d.libraryItems,[d]);if(d.status==="loading"&&!d.isInitialized)return hr(TT,{children:hr("div",{className:"layer-ui__library-message",children:IT("div",{children:[hr(bt,{size:"2em"}),hr("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=d.libraryItems.length>0||o.length>0;return IT(TT,{children:[hr(rf,{isLoading:d.status==="loading",libraryItems:m,onAddToLibrary:p,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:r,theme:s,onSelectItems:c,selectedItems:l}),u&&hr(lm,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:r,theme:s})]})}),af=(e,o)=>({elements:e,pending:ie(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),LB=(e,o)=>{let t=Qn(),[n,r]=CT(()=>af(t,e.selectedElementIds)),i=vB(new Map);return lf(()=>{for(let a of n.pending)i.current.set(a.id,a.version)},[n.pending]),lf(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&r(a=>{if(!CB(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),af(t,e.selectedElementIds);let s=o.scene.getNonDeletedElementsMap();for(let l of Object.keys(e.selectedElementIds)){let c=s.get(l)?.version;if(c&&c!==i.current.get(l))return af(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),n.pending},MT=kT(()=>{let e=He(),{onInsertElements:o}=e,t=qo(),n=se(),r=he(),[i,a]=CT([]),s=ST(()=>e.library,[e.library]),l=LB(n,e);lf(()=>MB(document,PB.KEYDOWN,p=>{if(p.key===SB.ESCAPE&&p.target instanceof HTMLElement){let m=p.target;if(m.closest(`.${vT.SIDEBAR}`))i.length>0?(p.stopPropagation(),a([])):kB(m)&&m instanceof HTMLInputElement&&!m.value&&(p.stopPropagation(),r({openSidebar:null}),e.focusContainer());else if(i.length>0){let{x:u,y:f}=e.lastViewportPosition;document.elementFromPoint(u,f)?.closest(`.${vT.SIDEBAR}`)&&(p.stopPropagation(),a([]))}}},{capture:!0}),[i,r,e]);let c=sf(p=>{o(Da(p)),e.focusContainer()},[o,e]),d=sf(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return hr(AB,{pendingElements:l,onInsertLibraryItems:c,onAddToLibrary:d,setAppState:r,libraryReturnUrl:t.libraryReturnUrl,library:s,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:a})});import _B from"clsx";import{useRef as DB}from"react";import{createPortal as RB}from"react-dom";import{KEYS as NB}from"@nous-excalidraw/common";import{jsx as PT,jsxs as BB}from"react/jsx-runtime";var AT=e=>{let{closeOnClickOutside:o=!0}=e,t=md({className:"excalidraw-modal-container"}),n=DB(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===NB.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return RB(BB("div",{className:_B("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[PT("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),PT("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as _l,jsxs as UB}from"react/jsx-runtime";function GB(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var qe=e=>{let[o,t]=v2(),[n]=zB(document.activeElement),{id:r}=Ne(),i=be().formFactor==="phone";FB(()=>{if(!o)return;let c=LT(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let d=p=>{if(p.key===HB.TAB){let m=LT(o),{activeElement:u}=document,f=m.findIndex(h=>h===u);f===0&&p.shiftKey?(m[m.length-1].focus(),p.preventDefault()):f===m.length-1&&!p.shiftKey&&(m[0].focus(),p.preventDefault())}};return o.addEventListener("keydown",d),()=>o.removeEventListener("keydown",d)},[o,e.autofocus]);let a=he(),s=Vo(Ra),l=()=>{a({openMenu:null}),s(!1),n.focus(),e.onCloseRequest()};return _l(AT,{className:OB("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:GB(e.size),onCloseRequest:l,closeOnClickOutside:e.closeOnClickOutside,children:UB(Ze,{ref:t,children:[e.title&&_l("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:_l("span",{className:"Dialog__titleContent",children:e.title})}),i&&_l("button",{className:"Dialog__close",onClick:l,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:oo}),_l("div",{className:"Dialog__content",children:e.children})]})})};import{KEYS as We}from"@nous-excalidraw/common";var Em=[{icon:Ki,value:"hand",key:We.H,numericKey:null,fillable:!1,toolbar:!0},{icon:Yr,value:"selection",key:We.V,numericKey:We[1],fillable:!0,toolbar:!0},{icon:Oi,value:"rectangle",key:We.R,numericKey:We[2],fillable:!0,toolbar:!0},{icon:Fi,value:"diamond",key:We.D,numericKey:We[3],fillable:!0,toolbar:!0},{icon:zi,value:"triangle",key:We.G,numericKey:null,fillable:!0,toolbar:!0},{icon:Hi,value:"ellipse",key:We.O,numericKey:We[4],fillable:!0,toolbar:!0},{icon:Yc,value:"arrow",key:We.A,numericKey:We[5],fillable:!0,toolbar:!0},{icon:Gi,value:"line",key:We.L,numericKey:We[6],fillable:!0,toolbar:!0},{icon:Ko,value:"freedraw",key:[We.P,We.X],numericKey:We[7],fillable:!1,toolbar:!0},{icon:$o,value:"text",key:We.T,numericKey:We[8],fillable:!1,toolbar:!0},{icon:Ui,value:"image",key:null,numericKey:We[9],fillable:!1,toolbar:!0},{icon:Vc,value:"eraser",key:We.E,numericKey:We[0],fillable:!1,toolbar:!0},{icon:Zo,value:"laser",key:We.K,numericKey:null,fillable:!1,toolbar:!1}],cf=e=>e.state.preferredSelectionTool.type==="lasso"?[{value:"lasso",icon:Yr,key:We.V,numericKey:We[1],fillable:!0,toolbar:!0},...Em.slice(1)]:Em,_T=(e,o)=>cf(o).find((n,r)=>n.numericKey!=null&&e===n.numericKey.toString()||n.key&&(typeof n.key=="string"?n.key===e:n.key.includes(e)))?.value||null;import sn from"clsx";import{useRef as qB,useState as JB}from"react";import{Popover as gr}from"radix-ui";import{CLASSES as zT,KEYS as BT,capitalizeString as Fa,isTransparent as wm}from"@nous-excalidraw/common";import{shouldAllowVerticalAlign as HT,suppportsHorizontalAlign as GT,hasBoundTextElement as vm,isElbowArrow as uf,isImageElement as UT,isLinearElement as hf,isTextElement as Im,isArrowElement as OT,hasStrokeColor as FT,toolIsArrow as Tm}from"@nous-excalidraw/element";import{createIsolation as WB}from"jotai-scope";import df from"react";import an from"tunnel-rat";var mf=df.createContext(null),Re=()=>df.useContext(mf),YB=WB(),DT=()=>df.useMemo(()=>({MainMenuTunnel:an(),WelcomeScreenMenuHintTunnel:an(),WelcomeScreenToolbarHintTunnel:an(),WelcomeScreenHelpHintTunnel:an(),WelcomeScreenCenterTunnel:an(),FooterCenterTunnel:an(),DefaultSidebarTriggerTunnel:an(),DefaultSidebarTabTriggersTunnel:an(),OverwriteConfirmDialogTunnel:an(),TTDDialogTriggerTunnel:an(),tunnelsJotai:YB}),[]);import{CODES as VB,KEYS as XB}from"@nous-excalidraw/common";import{CaptureUpdateAction as KB}from"@nous-excalidraw/element";var ri=O({name:"viewMode",label:"labels.viewMode",icon:ji,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:KB.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[XB.CTRL_OR_CMD]&&e.altKey&&e.code===VB.R});import{useEffect as $B,useState as ZB}from"react";import RT from"clsx";import{capitalizeString as NT}from"@nous-excalidraw/common";import{Popover as pf}from"radix-ui";import{jsx as ym,jsxs as jB}from"react/jsx-runtime";var Oa=({app:e,options:o,activeTool:t,defaultOption:n,className:r="Shape",namePrefix:i,title:a,"data-testid":s,onToolChange:l,displayedOption:c,fillable:d=!1})=>{let[p,m]=ZB(!1),u=t.type,f=c.type===u,h=32/2+10,{container:x}=Ne();return!o.some(E=>E.type===u)&&p&&m(!1),$B(()=>{let E=e.onPointerDownEmitter.on(()=>{m(!1)});return()=>E?.()},[e]),jB(pf.Root,{open:p,children:[ym(pf.Trigger,{asChild:!0,children:ym(q,{className:RT(r,{fillable:d,active:o.some(E=>E.type===t.type)}),type:"radio",icon:c.icon,checked:f,name:"editor-current-shape",title:a,"aria-label":a,"data-testid":s,onPointerDown:()=>{m(E=>!E),l(n)}})}),ym(pf.Content,{className:"tool-popover-content",sideOffset:h,collisionBoundary:x??void 0,children:o.map(({type:E,icon:w,title:y})=>ym(q,{className:RT(r,{active:u===E}),type:"radio",icon:w,checked:u===E,name:`${i}-option`,title:y||NT(E),keyBindingLabel:"","aria-label":y||NT(E),"data-testid":`toolbar-${E}`,onChange:()=>{e.state.activeTool.type!==E&&me("toolbar",E,"ui"),e.setActiveTool({type:E}),l?.(E)}},E))})]})};import{Fragment as Qt,jsx as j,jsxs as ge}from"react/jsx-runtime";var gf=sn([zT.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),Dl=(e,o)=>{let t=o[0]?.type||null;for(let n of o)if(n.type!==t){t=null;break}return FT(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(n=>FT(n.type))},Rl=(e,o)=>Uo(e.activeTool.type)||o.some(t=>Uo(t.type)),WT=({appState:e,elementsMap:o,renderAction:t,app:n})=>{let r=ki(o,e),i=!1;r.length===2&&(vm(r[0])||vm(r[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),s=be(),l=document.documentElement.getAttribute("dir")==="rtl",c=Uo(e.activeTool.type)&&!wm(e.currentItemBackgroundColor)||r.some(f=>Uo(f.type)&&!wm(f.backgroundColor)),d=r.length===1||i,p=!e.selectedLinearElement?.isEditing&&r.length===1&&hf(r[0])&&!uf(r[0]),m=!e.croppingElementId&&r.length===1&&UT(r[0]),u=!i&&Dt(e,n);return ge("div",{className:"selected-shape-actions",children:[j("div",{children:Dl(e,r)&&t("changeStrokeColor")}),Rl(e,r)&&j("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(Ls(e.activeTool.type)||r.some(f=>Ls(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(_s(e.activeTool.type)||r.some(f=>_s(f.type)))&&ge(Qt,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Ds(e.activeTool.type)||r.some(f=>Ds(f.type)))&&j(Qt,{children:t("changeRoundness")}),(Tm(e.activeTool.type)||r.some(f=>Tm(f.type)))&&j(Qt,{children:t("changeArrowType")}),(e.activeTool.type==="text"||r.some(Im))&&ge(Qt,{children:[j("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),(e.activeTool.type==="text"||GT(r,o))&&t("changeTextAlign")]}),HT(r,o)&&t("changeVerticalAlign"),(Mi(e.activeTool.type)||r.some(f=>Mi(f.type)))&&j(Qt,{children:t("changeArrowhead")}),t("changeOpacity"),ge("fieldset",{children:[j("legend",{children:g("labels.layers")}),ge("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&ge("fieldset",{children:[j("legend",{children:g("labels.align")}),ge("div",{className:"buttonList",children:[l?ge(Qt,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):ge(Qt,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),r.length>2&&t("distributeHorizontally"),j("div",{style:{flexBasis:"100%",height:0}}),ge("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),r.length>2&&t("distributeVertically")]})]})]}),!a&&r.length>0&&ge("fieldset",{children:[j("legend",{children:g("labels.actions")}),ge("div",{className:"buttonList",children:[s.formFactor!=="phone"&&t("duplicateSelection"),s.formFactor!=="phone"&&t("deleteSelectedElements"),t("group"),t("ungroup"),d&&t("hyperlink"),m&&t("cropEditor"),p&&t("toggleLinearEditor")]})]})]})},YT=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r})=>{let i=Uo(e.activeTool.type)&&!wm(e.currentItemBackgroundColor)||n.some(l=>Uo(l.type)&&!wm(l.backgroundColor)),a=n.length>0||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",s=e.openPopup==="compactStrokeStyles";return a?j("div",{className:"compact-action-item",children:ge(gr.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[j(gr.Trigger,{asChild:!0,children:j("button",{type:"button",className:sn("compact-action-button properties-trigger",{active:s}),title:g("labels.stroke"),onClick:l=>{l.preventDefault(),l.stopPropagation(),t({openPopup:s?null:"compactStrokeStyles"})},children:py})}),s&&j(Tn,{className:gf,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:ge("div",{className:"selected-shape-actions",children:[i&&o("changeFillStyle"),(Ls(e.activeTool.type)||n.some(l=>Ls(l.type)))&&o("changeStrokeWidth"),(_s(e.activeTool.type)||n.some(l=>_s(l.type)))&&ge(Qt,{children:[o("changeStrokeStyle"),o("changeSloppiness")]}),(Ds(e.activeTool.type)||n.some(l=>Ds(l.type)))&&o("changeRoundness"),o("changeOpacity")]})})]})}):null},VT=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r,app:i})=>{let a=Tm(e.activeTool.type)||n.some(l=>Tm(l.type)),s=e.openPopup==="compactArrowProperties";return a?j("div",{className:"compact-action-item",children:ge(gr.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[j(gr.Trigger,{asChild:!0,children:j("button",{type:"button",className:sn("compact-action-button properties-trigger",{active:s}),title:g("labels.arrowtypes"),onClick:l=>{l.preventDefault(),l.stopPropagation(),t({openPopup:s?null:"compactArrowProperties"})},children:(()=>{let l=xt(n,i,c=>OT(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>OT(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?Ji:l==="round"?Qi:qi})()})}),s&&j(Tn,{container:r,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:o("changeArrowProperties")})]})}):null},XT=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r,elementsMap:i})=>{let{saveCaretPosition:a,restoreCaretPosition:s}=Dy(),l=e.openPopup==="compactTextProperties";return j("div",{className:"compact-action-item",children:ge(gr.Root,{open:l,onOpenChange:c=>{c?(e.editingTextElement&&a(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&s())},children:[j(gr.Trigger,{asChild:!0,children:j("button",{type:"button",className:sn("compact-action-button properties-trigger",{active:l}),title:g("labels.textAlign"),onClick:c=>{c.preventDefault(),c.stopPropagation(),l?t({openPopup:null}):(e.editingTextElement&&a(),t({openPopup:"compactTextProperties"}))},children:R0})}),e.openPopup==="compactTextProperties"&&j(Tn,{className:gf,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&s()},children:ge("div",{className:"selected-shape-actions",children:[(e.activeTool.type==="text"||n.some(Im))&&o("changeFontSize"),(e.activeTool.type==="text"||GT(n,i))&&o("changeTextAlign"),HT(n,i)&&o("changeVerticalAlign")]})})]})})},KT=({appState:e,renderAction:o,targetElements:t,setAppState:n,container:r,app:i,showDuplicate:a,showDelete:s})=>{let l=!!(e.editingTextElement||e.newElement),c=!e.croppingElementId&&t.length===1&&UT(t[0]),d=t.length===1,p=Dt(e,i),m=!1;t.length===2&&(vm(t[0])||vm(t[1]))&&(m=!0);let u=document.documentElement.getAttribute("dir")==="rtl",f=e.openPopup==="compactOtherProperties";return l||t.length===0?null:j("div",{className:"compact-action-item",children:ge(gr.Root,{open:f,onOpenChange:h=>{n(h?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[j(gr.Trigger,{asChild:!0,children:j("button",{type:"button",className:sn("compact-action-button properties-trigger",{active:f}),title:g("labels.actions"),onClick:h=>{h.preventDefault(),h.stopPropagation(),n({openPopup:f?null:"compactOtherProperties"})},children:k0})}),f&&j(Tn,{className:gf,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:ge("div",{className:"selected-shape-actions",children:[ge("fieldset",{children:[j("legend",{children:g("labels.layers")}),ge("div",{className:"buttonList",children:[o("sendToBack"),o("sendBackward"),o("bringForward"),o("bringToFront")]})]}),p&&!m&&ge("fieldset",{children:[j("legend",{children:g("labels.align")}),ge("div",{className:"buttonList",children:[u?ge(Qt,{children:[o("alignRight"),o("alignHorizontallyCentered"),o("alignLeft")]}):ge(Qt,{children:[o("alignLeft"),o("alignHorizontallyCentered"),o("alignRight")]}),t.length>2&&o("distributeHorizontally"),j("div",{style:{flexBasis:"100%",height:0}}),ge("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[o("alignTop"),o("alignVerticallyCentered"),o("alignBottom"),t.length>2&&o("distributeVertically")]})]})]}),ge("fieldset",{children:[j("legend",{children:g("labels.actions")}),ge("div",{className:"buttonList",children:[o("group"),o("ungroup"),d&&o("hyperlink"),c&&o("cropEditor"),a&&o("duplicateSelection"),s&&o("deleteSelectedElements")]})]})]})})]})})},QB=({appState:e,renderAction:o,targetElements:t})=>!e.selectedLinearElement?.isEditing&&t.length===1&&hf(t[0])&&!uf(t[0])?j("div",{className:"compact-action-item",children:o("toggleLinearEditor")}):null,$T=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=ki(o,e),{container:a}=Ne(),s=!!(e.editingTextElement||e.newElement),l=!e.selectedLinearElement?.isEditing&&i.length===1&&hf(i[0])&&!uf(i[0]);return ge("div",{className:"compact-shape-actions",children:[Dl(e,i)&&j("div",{className:sn("compact-action-item"),children:t("changeStrokeColor")}),Rl(e,i)&&j("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),j(YT,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a}),j(VT,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,app:n}),l&&j("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),(e.activeTool.type==="text"||i.some(Im))&&ge(Qt,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(XT,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,elementsMap:o})]}),!s&&i.length>0&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),!s&&i.length>0&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),j(KT,{appState:e,renderAction:t,targetElements:i,setAppState:r,container:a,app:n})]})},ZT=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=ki(o,e),{container:a}=Ne(),s=qB(null),l=s.current?.getBoundingClientRect()?.width??0,c=9,d=6,p=32,m=c*p+(c-1)*d,u=p+d,f=l>=m+u,h=l>=m+2*u;return ge(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:d,pointerEvents:"none"},ref:s,children:[ge("div",{style:{display:"flex",flexDirection:"row",gap:d,flex:1},children:[Dl(e,i)&&j("div",{className:sn("compact-action-item"),children:t("changeStrokeColor")}),Rl(e,i)&&j("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),j(YT,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a}),j(VT,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,app:n}),j(QB,{appState:e,renderAction:t,targetElements:i}),(e.activeTool.type==="text"||i.some(Im))&&ge(Qt,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(XT,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,elementsMap:o})]}),j(KT,{appState:e,renderAction:t,targetElements:i,setAppState:r,container:a,app:n,showDuplicate:!h,showDelete:!f})]}),ge("div",{style:{display:"flex",flexDirection:"row",gap:d},children:[j("div",{className:"compact-action-item",children:t("undo")}),j("div",{className:"compact-action-item",children:t("redo")}),h&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),f&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},jT=({activeTool:e,setAppState:o,app:t,UIOptions:n})=>{let[r,i]=JB(!1),a=dt(),s=a==="full",l=a==="compact",c=[{type:"selection",icon:Yr,title:Fa(g("toolBar.selection"))},{type:"lasso",icon:$n,title:Fa(g("toolBar.lasso"))}],d=e.type==="frame",p=e.type==="laser",m=s&&e.type==="lasso"&&t.state.preferredSelectionTool.type!=="lasso",u=e.type==="embeddable",{TTDDialogTriggerTunnel:f}=Re();return ge(Qt,{children:[cf(t).map(({value:h,icon:x,key:E,numericKey:w,fillable:y,toolbar:v})=>{if(v===!1||n.tools?.[h]===!1)return null;let T=g(`toolBar.${h}`),I=E&&Fa(typeof E=="string"?E:E[0]),M=I?`${I} ${g("helpDialog.or")} ${w}`:`${w}`,S=h==="hand"?void 0:w||I;return(h==="selection"||h==="lasso")&&l?j(Oa,{app:t,options:c,activeTool:e,defaultOption:t.state.preferredSelectionTool.type,namePrefix:"selectionType",title:Fa(g("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:_=>{(_==="selection"||_==="lasso")&&(t.setActiveTool({type:_}),o({preferredSelectionTool:{type:_,initialized:!0}}))},displayedOption:c.find(_=>_.type===t.state.preferredSelectionTool.type)||c[0],fillable:e.type==="selection"},"selection-popover"):j(q,{className:sn("Shape",{fillable:y}),type:"radio",icon:x,checked:e.type===h,name:"editor-current-shape",title:`${Fa(T)} \u2014 ${M}`,keyBindingLabel:S,"aria-label":Fa(T),"aria-keyshortcuts":M,"data-testid":`toolbar-${h}`,onPointerDown:({pointerType:_})=>{!t.state.penDetected&&_==="pen"&&t.togglePenMode(!0),h==="selection"&&(t.state.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:_})=>{t.state.activeTool.type!==h&&me("toolbar",h,"ui"),h==="image"?t.setActiveTool({type:h}):t.setActiveTool({type:h})}},h)}),j("div",{className:"App-toolbar__divider"}),ge(ce,{open:r,children:[j(ce.Trigger,{className:sn("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":d||u||m||p&&!t.props.isCollaborating}),onToggle:()=>{i(!r),o({openMenu:null,openPopup:null})},title:g("toolBar.extraTools"),children:d?Co:u?Wi:p&&!t.props.isCollaborating?Zo:m?$n:Vs}),ge(ce.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[j(ce.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:Co,shortcut:BT.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:d,children:g("toolBar.frame")}),j(ce.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:Wi,"data-testid":"toolbar-embeddable",selected:u,children:g("toolBar.embeddable")}),j(ce.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:Zo,"data-testid":"toolbar-laser",selected:p,shortcut:BT.K.toLocaleUpperCase(),children:g("toolBar.laser")}),s&&j(ce.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:$n,"data-testid":"toolbar-lasso",selected:m,children:g("toolBar.lasso")}),j("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&j(f.Out,{}),j(ce.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Zi,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&j(ce.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:Kr,"data-testid":"toolbar-magicframe",badge:j(ce.Item.Badge,{children:"AI"}),children:g("toolBar.magicframe")})]})]})]})},qT=({renderAction:e,zoom:o})=>j("div",{className:zT.ZOOM_ACTIONS,onPointerDown:t=>t.stopPropagation(),onClick:t=>t.stopPropagation(),onDoubleClick:t=>t.stopPropagation(),children:j(Tt.Col,{gap:1,children:ge(Tt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})})}),JT=({renderAction:e,className:o})=>ge("div",{className:`undo-redo-buttons ${o}`,children:[j("div",{className:"undo-button-container",children:j($t,{label:g("buttons.undo"),children:e("undo")})}),j("div",{className:"redo-button-container",children:ge($t,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),QT=({actionManager:e,showExitZenModeBtn:o})=>j("button",{type:"button",className:sn("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(lr),children:g("buttons.exitZenMode")}),eI=({actionManager:e})=>j("button",{type:"button",className:"disable-view-mode",onClick:()=>e.executeAction(ri),children:hy});import{useRef as e9}from"react";var ff=e=>{let o=e9({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as o9,jsxs as t9}from"react/jsx-runtime";var ii=fe(null),tI=()=>{let[e,o]=Q(ii),t=Be();return e&&e==="clearCanvas"?o9(dm,{onConfirm:()=>{t.executeAction(Mn),o(null)},onCancel:()=>o(null),title:g("clearCanvasDialog.title"),children:t9("p",{className:"clear-canvas__content",children:[" ",g("alerts.clearReset")]})}):null};var bf={};jx(bf,{toggleTheme:()=>n9});var n9={...jr,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(jr,"commandPalette")}};import{jsx as pt,jsxs as ln}from"react/jsx-runtime";var l9=fe(null),Ye={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links",library:"Library"},nI=e=>{switch(e){case Ye.app:return 1;case Ye.export:return 2;case Ye.editor:return 3;case Ye.tools:return 4;case Ye.elements:return 5;case Ye.links:return 6;default:return 10}},km=({shortcut:e,className:o,children:t})=>{let n=e.replace("++","+$").split("+");return ln("div",{className:iI("shortcut",o),children:[n.map((r,i)=>pt("div",{className:"shortcut-wrapper",children:pt("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),pt("div",{className:"shortcut-desc",children:t})]})},sI=e=>!e.altKey&&e[_o.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===_o.P||e.key===_o.SLASH),c9=Object.assign(e=>{let o=se(),t=he();return Sm(()=>{let n=r=>{sI(r)&&(r.preventDefault(),r.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&me("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(Mm.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(Mm.KEYDOWN,n,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:pt(d9,{...e})},{defaultItems:bf});function d9({customCommandPaletteItems:e}){let o=He(),t=se(),n=he(),r=qo(),i=Be(),[a,s]=Q(l9),[l,c]=Cm(null),d=aI(null),p=jn({uiAppState:t,customCommandPaletteItems:e,appProps:r}),[m]=Q(An),u=i9(()=>m.libraryItems?.filter(S=>!!S.name).map(S=>({label:S.name,icon:pt(m9,{id:S.id,elements:S.elements}),category:"Library",order:nI("Library"),haystack:oi(S.name),perform:()=>{o.onInsertElements(Da([S]))}}))||[],[o,m.libraryItems]);Sm(()=>{let{uiAppState:S,customCommandPaletteItems:_,appProps:A}=p,P=W=>{let Y="";return W.label&&(typeof W.label=="function"?Y=g(W.label(o.scene.getNonDeletedElements(),S,o)):Y=g(W.label)),Y},D=W=>typeof W.icon=="function"?W.icon(S,o.scene.getNonDeletedElements()):W.icon,z=[],K=(W,Y,G)=>{let J={label:P(W),icon:D(W),category:Y,shortcut:De(W.name),keywords:W.keywords,predicate:W.predicate,viewMode:W.viewMode,perform:()=>{i.executeAction(W,"commandPalette")}};return G?G(J,W):J};if(S&&o.scene&&i){let W=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,yl,nm,y2].map(R=>K(R,Ye.elements,(F,ne)=>({...F,predicate:ne.predicate?ne.predicate:(ue,Te,Se,Pe)=>ie(ue,Te).length>0}))),Y=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(R=>K(R,Ye.tools)),G=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(R=>K(R,Ye.editor)),J=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(R=>K(R,Ye.export));z=[...W,...G,{label:P(Mn),icon:D(Mn),shortcut:De(Mn.name),category:Ye.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{nt.set(ii,"clearCanvas")}},{label:g("buttons.exportImage"),category:Ye.export,icon:$c,shortcut:De("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...J];let $=[{label:g("toolBar.library"),category:Ye.app,icon:Wc,viewMode:!1,perform:()=>{S.openSidebar?n({openSidebar:null}):n({openSidebar:{name:oI.name,tab:oI.defaultTab}})}},{label:g("search.title"),category:Ye.app,icon:Kt,viewMode:!0,perform:()=>{i.executeAction(Nl)}},{label:g("labels.shapeSwitch"),category:Ye.elements,icon:Xs,perform:()=>{i.executeAction(E2)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:Ye.elements,icon:Xi,viewMode:!1,predicate:(R,F)=>{let ne=ie(R,F);return ne.length>0&&Dl(F,ne)},perform:()=>{n(R=>({openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:Xi,category:Ye.elements,viewMode:!1,predicate:(R,F)=>{let ne=ie(R,F);return ne.length>0&&Rl(F,ne)},perform:()=>{n(R=>({openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:Xi,category:Ye.editor,viewMode:!1,perform:()=>{n(R=>({openMenu:R.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Em.reduce((R,F)=>{let{value:ne,icon:ue,key:Te,numericKey:Se}=F;if(A.UIOptions.tools?.[ne]===!1)return R;let de=Te&&a9(typeof Te=="string"?Te:Te[0])||Se,_e={label:g(`toolBar.${ne}`),category:Ye.tools,shortcut:de,icon:ue,keywords:["toolbar"],viewMode:!1,perform:({event:ct})=>{ne==="image"?o.setActiveTool({type:ne}):o.setActiveTool({type:ne})}};return R.push(_e),R},[]),...Y,{label:g("toolBar.lock"),category:Ye.tools,icon:S.activeTool.locked?Bi:Wr,shortcut:_o.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:Ye.tools,icon:KE,viewMode:!1,predicate:A.aiEnabled,perform:()=>{n(R=>({...R,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:Ye.tools,icon:Zi,viewMode:!1,predicate:A.aiEnabled,perform:()=>{n(R=>({...R,openDialog:{name:"ttd",tab:"mermaid"}}))}}],ee=[...z,...$,..._||[]].map(R=>({...R,icon:R.icon||Xs,order:R.order??nI(R.category),haystack:`${oi(R.label.toLocaleLowerCase())} ${R.keywords?.join(" ")||""}`}));c(ee),s([...ee,...u].find(R=>R.label===a?.label)??null)}},[p,o,i,c,a?.label,s,n,u]);let[f,h]=Cm(""),[x,E]=Cm(null),[w,y]=Cm({}),v=S=>{n({openDialog:null},S),h("")},T=(S,_)=>{t.openDialog?.name==="commandPalette"&&(_.stopPropagation(),_.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),v(()=>{S.perform({actionManager:i,event:_}),s(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},I=ff(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,r,o):S.predicate===void 0||S.predicate),M=ff(S=>{let _=s9(S.target)||sI(S)||S.key===_o.ESCAPE;if(_&&S.key!==_o.ARROW_UP&&S.key!==_o.ARROW_DOWN&&S.key!==_o.ENTER)return;let A=Object.values(w).flat(),P=a&&!f&&I(a);if(S.key===_o.ARROW_UP){S.preventDefault();let D=A.findIndex(W=>W.label===x?.label);if(P){if(D===0){E(a);return}if(x===a){let W=A[A.length-1];W&&E(W);return}}let z;D===-1?z=A.length-1:z=D===0?A.length-1:(D-1)%A.length;let K=A[z];K&&E(K);return}if(S.key===_o.ARROW_DOWN){S.preventDefault();let D=A.findIndex(W=>W.label===x?.label);if(P){if(!x||D===A.length-1){E(a);return}if(x===a){let W=A[0];W&&E(W);return}}let z=(D+1)%A.length,K=A[z];K&&E(K);return}if(S.key===_o.ENTER&&x&&setTimeout(()=>{T(x,S)}),!_){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){d?.current?.focus();return}S.preventDefault()}});return Sm(()=>(window.addEventListener(Mm.KEYDOWN,M,{capture:!0}),()=>window.removeEventListener(Mm.KEYDOWN,M,{capture:!0})),[M]),Sm(()=>{if(!l)return;let S=D=>{let z={};for(let K of D)z[K.category]?z[K.category].push(K):z[K.category]=[K];return z},_=f?.length>1?[...l.filter(I).sort((D,z)=>D.order-z.order),...u]:l.filter(I).sort((D,z)=>D.order-z.order),A=!f&&a&&I(a);if(!f){y(S(A?_.filter(D=>D.label!==a?.label):_)),E(A?a:_[0]||null);return}let P=oi(f.toLocaleLowerCase().replace(/[<>_| -]/g,""));_=r9.filter(P,_,{extract:D=>D.haystack??""}).sort((D,z)=>z.score-D.score).map(D=>D.original),y(S(_)),E(_[0]??null)},[f,l,I,a,u]),ln(qe,{onCloseRequest:()=>v(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[pt(ur,{value:f,placeholder:g("commandPalette.search.placeholder"),onChange:S=>{h(S)},selectOnRender:!0,ref:d}),o.editorInterface.formFactor!=="phone"&&ln("div",{className:"shortcuts-wrapper",children:[pt(km,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),pt(km,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),pt(km,{shortcut:B("Esc"),children:g("commandPalette.shortcuts.close")})]}),ln("div",{className:"commands",children:[a&&!f&&ln("div",{className:"command-category",children:[ln("div",{className:"command-category-title",children:[g("commandPalette.recents"),pt("div",{className:"icon",style:{marginLeft:"6px"},children:$E})]}),pt(rI,{command:a,isSelected:a.label===x?.label,onClick:S=>T(a,S),disabled:!I(a),onMouseMove:()=>E(a),showShortcut:o.editorInterface.formFactor!=="phone",appState:t})]}),Object.keys(w).length>0?Object.keys(w).map((S,_)=>ln("div",{className:"command-category",children:[pt("div",{className:"command-category-title",children:S}),w[S].map(A=>pt(rI,{command:A,isSelected:A.label===x?.label,onClick:P=>T(A,P),onMouseMove:()=>E(A),showShortcut:o.editorInterface.formFactor!=="phone",appState:t,size:S==="Library"?"large":"small"},A.label))]},S)):l?ln("div",{className:"no-match",children:[pt("div",{className:"icon",children:Kt})," ",g("commandPalette.search.noMatch")]}):null]})]})}var m9=({id:e,elements:o})=>{let t=aI(null),{svgCache:n}=La();return rm(e,o,n,t),pt("div",{className:"library-item-icon",ref:t})},rI=({command:e,isSelected:o,disabled:t,onMouseMove:n,onClick:r,showShortcut:i,appState:a,size:s="small"})=>{let l=()=>{};return ln("div",{className:iI("command-item",{"item-selected":o,"item-disabled":t,"command-item-large":s==="large"}),ref:c=>{o&&!t&&c?.scrollIntoView?.({block:"nearest"})},onClick:t?l:r,onMouseMove:t?l:n,title:t?g("commandPalette.itemNotAvailable"):"",children:[ln("div",{className:"name",children:[e.icon&&pt(Jo,{className:"icon",size:"var(--icon-size, 1rem)",icon:typeof e.icon=="function"?e.icon(a,[]):e.icon}),pt($r,{children:e.label})]}),i&&e.shortcut&&pt(km,{shortcut:e.shortcut})]})};import{getSizeFromPoints as mCe,randomInteger as cO,getUpdatedTimestamp as dO}from"@nous-excalidraw/common";import kIe from"roughjs/bin/rough";import{isRightAngleRads as PIe,lineSegment as AIe,pointFrom as LIe,pointRotateRads as _Ie}from"@nous-excalidraw/math";import{BOUND_TEXT_PADDING as RIe,DEFAULT_REDUCED_GLOBAL_ALPHA as NIe,ELEMENT_READY_TO_ERASE_OPACITY as BIe,FRAME_STYLE as OIe,DARK_THEME_FILTER as FIe,MIME_TYPES as LI,THEME as zIe,distance as HIe,getFontString as GIe,isRTL as UIe,getVerticalOffset as WIe,invariant as YIe,applyDarkModeFilter as VIe,isSafari as XIe,isTransparent as KIe}from"@nous-excalidraw/common";import B2e from"roughjs/bin/rough";import{arrayToMap as F2e,invariant as MI,rescalePoints as z2e,sizeOf as H2e,STROKE_WIDTH as j9}from"@nous-excalidraw/common";import{degreesToRadians as Lf,lineSegment as U2e,pointDistance as W2e,pointFrom as yt,pointFromArray as q9,pointRotateRads as Wa}from"@nous-excalidraw/math";import{pointsOnBezierCurves as Nxe}from"points-on-curve";import{invariant as Oxe}from"@nous-excalidraw/common";import{curve as zxe,lineSegment as Hxe,pointFrom as Gxe,pointDistance as Uxe,pointFromArray as Wxe,pointFromVector as Yxe,pointRotateRads as Vxe,polygon as Xxe,polygonFromPoints as Kxe,PRECISION as $xe,segmentsIntersectAt as Zxe,vector as jxe,vectorAdd as qxe,vectorFromPoint as Jxe,vectorScale as Qxe}from"@nous-excalidraw/math";import{getElementAbsoluteCoords as t0e}from"@nous-excalidraw/element";var xf=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointsOnBezierCurves as X2e}from"points-on-curve";import{getDisplaySceneStrokeWidth as J9}from"@nous-excalidraw/common";import{simplify as N9}from"points-on-curve";import{getStroke as B9}from"perfect-freehand";import{pointFrom as O9,pointDistance as yI,pointRotateRads as E2e}from"@nous-excalidraw/math";import{ROUGHNESS as wI,THEME as Af,isTransparent as Hl,assertNever as F9,COLOR_PALETTE as z9,LINE_POLYGON_POINT_MERGE_DISTANCE as w2e,applyDarkModeFilter as Gl,isCrispScreenStroke as H9,getTierScreenStrokeWidth as vI}from"@nous-excalidraw/common";import{RoughGenerator as G9}from"roughjs/bin/generator";import{ROUNDNESS as i0e,assertNever as a0e}from"@nous-excalidraw/common";import{pointsEqual as l0e}from"@nous-excalidraw/math";var lI=e=>!!e&&e.type==="embeddable";var cI=e=>!!e&&e.type==="iframe",Ef=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),fr=e=>e!=null&&e.type==="text";var Pm=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var ai=e=>e!=null&&p9(e.type);var br=e=>e!=null&&e.type==="arrow",Bl=e=>br(e)&&e.elbowed;var p9=e=>e==="arrow"||e==="line";var za=e=>e!==null&&"containerId"in e&&e.containerId!==null&&fr(e);import{DEFAULT_ADAPTIVE_RADIUS as _9,DEFAULT_PROPORTIONAL_RADIUS as kf,invariant as _ve,LINE_CONFIRM_THRESHOLD as D9,ROUNDNESS as Mf}from"@nous-excalidraw/common";import{bezierEquation as Rve,curve as Nve,curveCatmullRomCubicApproxPoints as Bve,curveOffsetPoints as Ove,lineSegment as Fve,lineSegmentIntersectionPoints as zve,pointDistance as R9,pointFrom as Hve,pointFromArray as Gve,pointFromVector as Uve,pointRotateRads as Wve,pointTranslate as Yve,rectangle as Vve,vectorFromPoint as Xve,vectorNormalize as Kve,vectorScale as $ve}from"@nous-excalidraw/math";import{STROKE_WIDTH_CUSTOM_DATA_KEY as u9,STROKE_WIDTH_SCREEN as p0e,getDisplaySceneStrokeWidth as u0e,getEffectiveStrokeWidth as h9,getTierScreenStrokeWidth as h0e}from"@nous-excalidraw/common";var Ol=e=>e.customData?.[u9]===!0,si=(e,o,t=o)=>h9(e.strokeWidth,o,t,Ol(e));import{invariant as ove,isTransparent as nve}from"@nous-excalidraw/common";import{curveIntersectLineSegment as ive,isPointWithinBounds as ave,lineSegment as sve,lineSegmentIntersectionPoints as lve,pointFrom as cve,pointFromVector as dve,pointRotateRads as mve,pointsEqual as pve,vectorFromPoint as uve,vectorNormalize as hve,vectorScale as gve}from"@nous-excalidraw/math";import{ellipse as bve,ellipseSegmentInterceptPoints as xve}from"@nous-excalidraw/math/ellipse";import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Bwe,ARROW_LABEL_WIDTH_FRACTION as Owe,BOUND_TEXT_PADDING as Fwe,DEFAULT_FONT_SIZE as zwe,TEXT_ALIGN as Hwe,VERTICAL_ALIGN as Gwe,getFontString as Uwe,isProdEnv as Wwe,invariant as Ywe}from"@nous-excalidraw/common";import{pointFrom as Xwe,pointRotateRads as Kwe}from"@nous-excalidraw/math";import{pointCenter as Mye,pointFrom as Pye,pointRotateRads as Aye,pointsEqual as Lye,pointDistance as _ye,vectorFromPoint as Dye,curveLength as Rye,curvePointAtLength as Nye}from"@nous-excalidraw/math";import{DRAGGING_THRESHOLD as Fye,KEYS as zye,shouldRotateWithDiscreteAngle as Hye,getGridPoint as Gye,invariant as Uye,isShallowEqual as Wye,getFeatureFlag as Yye}from"@nous-excalidraw/common";import{deconstructLinearOrFreeDrawElement as Xye,getSnapOutlineMidPoint as Kye,isPathALoop as $ye,moveArrowAboveBindable as Zye,projectFixedPointOntoDiagonal as jye}from"@nous-excalidraw/element";import{arrayToMap as SEe,getFeatureFlag as kEe,invariant as MEe,isTransparent as PEe}from"@nous-excalidraw/common";import{PRECISION as LEe,clamp as _Ee,lineSegment as DEe,pointDistance as REe,pointDistanceSq as NEe,pointFrom as BEe,pointFromVector as OEe,pointRotateRads as FEe,pointsEqual as zEe,vectorFromPoint as HEe,vectorNormalize as GEe,vectorScale as UEe}from"@nous-excalidraw/math";import{curvePointDistance as w0e,distanceToLineSegment as v0e,pointRotateRads as T0e}from"@nous-excalidraw/math";import{ellipse as C0e,ellipseDistanceFromPoint as S0e}from"@nous-excalidraw/math/ellipse";import{invariant as _0e,isDevEnv as D0e,isTestEnv as R0e}from"@nous-excalidraw/common";import{pointFrom as B0e,pointFromVector as O0e,pointRotateRads as F0e,pointScaleFromOrigin as z0e,pointsEqual as H0e,triangleIncludesPoint as G0e,vectorCross as U0e,vectorFromPoint as f9,vectorScale as W0e}from"@nous-excalidraw/math";var Cf=[1,0],dI=[0,1],Sf=[-1,0],mI=[0,-1],Am=e=>{let[o,t]=e,n=Math.abs(o),r=Math.abs(t);return o>r?Cf:o<=-r?Sf:t>n?dI:mI},pI=(e,o)=>Am(f9(e,o)),Lm=(e,o)=>_m(pI(e,o)),If=(e,o)=>e[0]===o[0]&&e[1]===o[1],_m=e=>If(e,Cf)||If(e,Sf);import{clamp as Z0e,pointDistance as j0e,pointFrom as q0e,pointScaleFromOrigin as J0e,pointsEqual as Q0e,pointTranslate as eEe,vector as tEe,vectorCross as oEe,vectorFromPoint as nEe,vectorScale as rEe}from"@nous-excalidraw/math";import{BinaryHeap as aEe,invariant as sEe,isAnyTrue as lEe,getSizeFromPoints as cEe,isDevEnv as dEe,arrayToMap as mEe}from"@nous-excalidraw/common";var eye=10/1.5;import{SHIFT_LOCKING_ANGLE as lye,viewportCoordsToSceneCoords as cye}from"@nous-excalidraw/common";import{normalizeRadians as mye,radiansBetweenAngles as pye,radiansDifference as uye}from"@nous-excalidraw/math";import{pointsEqual as gye}from"@nous-excalidraw/math";import{BOUND_TEXT_PADDING as uwe,DEFAULT_FONT_SIZE as hwe,DEFAULT_FONT_FAMILY as gwe,getFontString as fwe,isTestEnv as bwe,normalizeEOL as xwe}from"@nous-excalidraw/common";var Ewe="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Swe,isTestEnv as kwe}from"@nous-excalidraw/common";var Nm=(e,o=1)=>{if(e.length>=3){let[t,n]=[e[0],e[e.length-1]];return R9(t,n)<=D9/o}return!1},_n=(e,o)=>{if(o.roundness?.type===Mf.PROPORTIONAL_RADIUS||o.roundness?.type===Mf.LEGACY)return e*kf;if(o.roundness?.type===Mf.ADAPTIVE_RADIUS){let t=o.roundness?.value??_9,n=t/kf;return e<=n?e*kf:t}return 0};var EI=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="triangle"||e==="image";var Ht=class Ht{};k(Ht,"rg",new G9),k(Ht,"cache",new WeakMap),k(Ht,"get",(o,t,n,r)=>{let i=Ht.cache.get(o),a=r??n,s=n===void 0?void 0:vI(n);if(i&&(t===null||i.theme===t)&&(n===void 0||i.zoom===n)&&i.strokeWidth===o.strokeWidth&&i.strokeWidthCustom===Ol(o)&&(s===void 0||i.tierScreenStrokeWidth===s)&&i.strokeStyle===o.strokeStyle&&i.roughness===o.roughness&&(a===void 0||i.renderScale===a))return i.shape}),k(Ht,"delete",o=>{Ht.cache.delete(o),zm.delete(o)}),k(Ht,"destroy",()=>{Ht.cache=new WeakMap}),k(Ht,"generateElementShape",(o,t)=>{let n=t?.zoom??1,r=t?.renderScale??n,i=t?.isExporting?void 0:Ht.get(o,t?t.theme:null,n,r);if(i!==void 0)return i;zm.delete(o);let a=Y9(o,Ht.rg,{isExporting:t?.isExporting??!1,canvasBackgroundColor:t?.canvasBackgroundColor??z9.white,embedsValidationStatus:t?.embedsValidationStatus??null,theme:t?.theme??Af.LIGHT,zoom:n,renderScale:r});return t?.isExporting||Ht.cache.set(o,{shape:a,theme:t?.theme||Af.LIGHT,zoom:n,strokeWidth:o.strokeWidth,strokeWidthCustom:Ol(o),tierScreenStrokeWidth:vI(n),strokeStyle:o.strokeStyle,roughness:o.roughness,renderScale:r}),a});var Ua=Ht,U9=e=>[8,8+e],SI=e=>[1.5,6+e];function W9(e){let o=e.roughness,t=Math.max(e.width,e.height),n=Math.min(e.width,e.height);return n>=20&&t>=50||n>=15&&e.roundness&&EI(e.type)||ai(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var Do=(e,o=!1,t=!1,n=1,r=n)=>{let i=si(e,n,r),a=H9(n),s={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?U9(i):e.strokeStyle==="dotted"?SI(i):void 0,disableMultiStroke:a||e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?i+.5:i,fillWeight:i/2,hachureGap:i*4,roughness:a?wI.architect:W9(e),stroke:t?Gl(e.strokeColor):e.strokeColor,preserveVertices:a||o||e.roughness<wI.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"triangle":case"ellipse":return s.fillStyle=e.fillStyle,s.fill=Hl(e.backgroundColor)?void 0:t?Gl(e.backgroundColor):e.backgroundColor,e.type==="ellipse"&&(s.curveFitting=1),s;case"line":case"freedraw":return Nm(e.points)&&(s.fillStyle=e.fillStyle,s.fill=e.backgroundColor==="transparent"?void 0:t?Gl(e.backgroundColor):e.backgroundColor),s;case"arrow":return s;default:throw new Error(`Unimplemented type ${e.type}`)}},TI=(e,o,t)=>Ef(e)&&(o||lI(e)&&t?.get(e.id)!==!0)&&Hl(e.backgroundColor)&&Hl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:cI(e)?{...e,strokeColor:Hl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Hl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,zl=(e,o,t)=>{if(o===null)return[];let[,,n,r,i,a]=o;return[e.line(n,r,i,a,t)]},Fm=(e,o,t)=>{if(o===null)return[];let[n,r,i,a,s,l]=o;return[e.line(i,a,n,r,t),e.line(s,l,n,r,t)]},ci=(e,o)=>{let t={...o},n=o.strokeWidth??e.strokeWidth;if(e.strokeStyle==="dotted"){let r=SI(n-1);t.strokeLineDash=[r[0],r[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Pf=(e,o,t,n,r,i=1)=>{if(n===null)return[];let[a,s,l]=n,c={...o,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,o.roughness||0)};return delete c.strokeLineDash,[e.circle(a,s,l*i,c)]},II=(e,o,t,n,r,i,a,s)=>{if(n===null)return[];let l=i.strokeWidth??e.strokeWidth,c=(f,h=0)=>kI(e,o,t,f,h,l),d=s?Gl(e.strokeColor):e.strokeColor,p=s?Gl(a):a,m=-.25,u=.8;switch(n){case"circle":case"circle_outline":return Pf(r,i,d,c(n),n==="circle_outline"?p:d);case"triangle":case"triangle_outline":{let f=c(n);if(f===null)return[];let[h,x,E,w,y,v]=f,T={...i,fill:n==="triangle_outline"?p:d,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete T.strokeLineDash,[r.polygon([[h,x],[E,w],[y,v],[h,x]],T)]}case"diamond":case"diamond_outline":{let f=c(n);if(f===null)return[];let[h,x,E,w,y,v,T,I]=f,M={...i,fill:n==="diamond_outline"?p:d,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete M.strokeLineDash,[r.polygon([[h,x],[E,w],[y,v],[T,I],[h,x]],M)]}case"cardinality_one":return zl(r,c(n),ci(e,i));case"cardinality_many":return Fm(r,c(n),ci(e,i));case"cardinality_one_or_many":{let f=ci(e,i);return[...Fm(r,c("cardinality_many"),f),...zl(r,c("cardinality_one",m),f)]}case"cardinality_exactly_one":{let f=ci(e,i);return[...zl(r,c("cardinality_one",-.5),f),...zl(r,c("cardinality_one"),f)]}case"cardinality_zero_or_one":{let f=ci(e,i);return[...Pf(r,i,d,c("circle_outline",1.5),p,u),...zl(r,c("cardinality_one",-.5),f)]}case"cardinality_zero_or_many":{let f=ci(e,i);return[...Fm(r,c("cardinality_many"),f),...Pf(r,i,d,c("circle_outline",1.5),p,u)]}case"bar":case"arrow":default:return Fm(r,c(n),ci(e,i))}};var Y9=(e,o,{isExporting:t,canvasBackgroundColor:n,embedsValidationStatus:r,theme:i,zoom:a,renderScale:s})=>{let l=a??1,c=s??l,d=i===Af.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let p;if(e.roundness){let m=e.width,u=e.height,f=_n(Math.min(m,u),e);p=o.path(`M ${f} 0 L ${m-f} 0 Q ${m} 0, ${m} ${f} L ${m} ${u-f} Q ${m} ${u}, ${m-f} ${u} L ${f} ${u} Q 0 ${u}, 0 ${u-f} L 0 ${f} Q 0 0, ${f} 0`,Do(TI(e,t,r),!0,d,l,c))}else p=o.rectangle(0,0,e.width,e.height,Do(TI(e,t,r),!1,d,l,c));return p}case"diamond":{let p,[m,u,f,h,x,E,w,y]=Bm(e);if(e.roundness){let v=_n(Math.abs(m-w),e),T=_n(Math.abs(h-u),e);p=o.path(`M ${m+v} ${u+T} L ${f-v} ${h-T}
@@ -23,7 +23,7 @@ ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipbo
23
23
  `).filter(l=>l.trim().length>0).map(l=>l.split(s).map(c=>c.trim())),t=[" ",",",";"].map(s=>{let l=o(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)?fS(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as rs}from"@nous-excalidraw/math";import{FONT_FAMILY as Yz,FONT_SIZES as Vz,getFontString as Xz,getLineHeight as Kz,ROUGHNESS as bS}from"@nous-excalidraw/common";import{measureText as $z,newLinearElement as gb,newTextElement as Zz}from"@nous-excalidraw/element";var xS=(e,o,t,n)=>{if(!Ja(e,"radar"))return null;let r=e.labels??e.series[0].values.map((W,Y)=>`Value ${Y+1}`),i=e.series,{normalize:a,renderSteps:s}=dS(i,r.length),l=ts(n),c=os(l),d=es(i.length,l),{chartWidth:p,chartHeight:m}=cS(),u=o+p/2,f=t-m/2,h=$a/2,x=r.map((W,Y)=>-Math.PI/2+Math.PI*2*Y/r.length),{axisLabels:E,axisLabelTopY:w,axisLabelBottomY:y}=mS(r,x,u,f,h,c),v=Yz["Lilita One"],T=Vz.xl,I=Kz(v),M=Xz({fontFamily:v,fontSize:T}),S=e.title?op(e.title,M,p+Za*2):null,_=S?$z(S,M,I):null,A=S?Zz({backgroundColor:c,...Oe,text:S,originalText:e.title??S,x:o+p/2,y:w-Za-_.height/2,fontFamily:v,fontSize:T,lineHeight:I,textAlign:"center"}):null,P=s?Array.from({length:ib},(W,Y)=>{let G=(Y+1)/ib,J=h*G,$=x.map(ee=>rs(Math.cos(ee)*J,Math.sin(ee)*J));return $.push(rs($[0][0],$[0][1])),gb({backgroundColor:"transparent",...Oe,type:"line",x:u,y:f,width:J*2,height:J*2,strokeStyle:"solid",roughness:bS.architect,opacity:pi,polygon:!0,points:$})}):[],D=x.map(W=>{let Y=Math.cos(W)*h,G=Math.sin(W)*h;return gb({backgroundColor:"transparent",...Oe,type:"line",x:u,y:f,width:Math.abs(Y),height:Math.abs(G),strokeStyle:"solid",roughness:bS.architect,opacity:pi,points:[rs(0,0),rs(Y,G)]})}),z=i.map((W,Y)=>{let G=x.map((J,$)=>{let ee=W.values[$]??0,R=a(ee,$)*h;return rs(Math.cos(J)*R,Math.sin(J)*R)});return G.push(rs(G[0][0],G[0][1])),gb({backgroundColor:"transparent",...Oe,type:"line",x:u,y:f,width:h*2,height:h*2,strokeColor:d[Y],strokeWidth:2,polygon:!0,points:G})}),K=ns(i,d,u,y,t+cn*5,c);return[...A?[A]:[],...E,...P,...D,...z,...K]};var fb=(e,o,t,n,r)=>e==="line"?gS(o,t,n,r):e==="radar"?xS(o,t,n,r):uS(o,t,n,r);import{jsx as po,jsxs as ES}from"react/jsx-runtime";var jz=()=>ES("div",{"data-testid":"brave-measure-text-error",children:[po("p",{children:po(Rt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>po("span",{style:{fontWeight:600},children:e})})}),po("p",{children:po(Rt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>po("span",{style:{fontWeight:600},children:e})})}),po("p",{children:po(Rt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>po("a",{href:"http://docs.excalidraw.com/docs/@nous-excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),po("p",{children:po(Rt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>po("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>ES("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),yS=jz;import nH from"clsx";import rH from"react";import{useLayoutEffect as qz,useRef as wS,useEffect as vS}from"react";import{unstable_batchedUpdates as Jz}from"react-dom";import{KEYS as Qz,queryFocusableElements as eH}from"@nous-excalidraw/common";import tH from"clsx";import{jsx as oH}from"react/jsx-runtime";var TS=({children:e,left:o,top:t,onCloseRequest:n,fitInViewport:r=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:s=window.innerWidth,viewportHeight:l=window.innerHeight,className:c})=>{let d=wS(null);vS(()=>{let m=d.current;if(!m)return;m.contains(document.activeElement)||m.focus();let u=f=>{if(f.key===Qz.TAB){let h=eH(m),{activeElement:x}=document,E=h.findIndex(w=>w===x);x===m?(f.shiftKey?h[h.length-1]?.focus():h[0].focus(),f.preventDefault(),f.stopImmediatePropagation()):E===0&&f.shiftKey?(h[h.length-1]?.focus(),f.preventDefault(),f.stopImmediatePropagation()):E===h.length-1&&!f.shiftKey&&(h[0]?.focus(),f.preventDefault(),f.stopImmediatePropagation())}};return m.addEventListener("keydown",u),()=>m.removeEventListener("keydown",u)},[]);let p=wS(null);return qz(()=>{if(r&&d.current&&t!=null&&o!=null){let m=d.current,{width:u,height:f}=m.getBoundingClientRect();if(p.current?.top===t&&p.current?.left===o)return;p.current={top:t,left:o},u>=s?(m.style.width=`${s}px`,m.style.left="0px",m.style.overflowX="scroll"):o+u-i>s?m.style.left=`${s-u-10}px`:m.style.left=`${o}px`,f>=l?(m.style.height=`${l-20}px`,m.style.top="10px",m.style.overflowY="scroll"):t+f-a>l?m.style.top=`${l-f}px`:m.style.top=`${t}px`}},[t,o,r,s,l,i,a]),vS(()=>{if(n){let m=u=>{d.current?.contains(u.target)||Jz(()=>n(u))};return document.addEventListener("pointerdown",m,!1),()=>document.removeEventListener("pointerdown",m,!1)}},[n]),oH("div",{className:tH("popover",c),ref:d,tabIndex:-1,children:e})};import{jsx as is,jsxs as iH}from"react/jsx-runtime";var rt="separator",IS=rH.memo(({actionManager:e,items:o,top:t,left:n,onClose:r})=>{let i=jo(),a=Qn(),s=o.reduce((l,c)=>(c&&(c===rt||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l),[]);return is(TS,{onCloseRequest:()=>{r()},top:t,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:is("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===rt)return!s[c-1]||s[c-1]===rt?null:is("hr",{className:"context-menu-item-separator"},c);let d=l.name,p="";return l.label&&(typeof l.label=="function"?p=g(l.label(a,i,e.app)):p=g(l.label)),is("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:iH("button",{type:"button",className:nH("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[is("div",{className:"context-menu-item__label",children:p}),is("kbd",{className:"context-menu-item__shortcut",children:d?De(d):""})]})},c)})})})});import{jsx as bb,jsxs as CS}from"react/jsx-runtime";var aH=({height:e,width:o,userToFollow:t,onDisconnect:n})=>bb("div",{className:"follow-mode",style:{width:o,height:e},children:CS("div",{className:"follow-mode__badge",children:[CS("div",{className:"follow-mode__badge__label",children:["Following"," ",bb("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),bb("button",{type:"button",onClick:n,className:"follow-mode__disconnect-btn",children:oo})]})}),SS=aH;import wi from"clsx";import EV from"react";import{CLASSES as yV,DEFAULT_SIDEBAR as R1,TOOL_TYPE as Uk,arrayToMap as wV,capitalizeString as vV,isShallowEqual as $p}from"@nous-excalidraw/common";import{mutateElement as TV}from"@nous-excalidraw/element";import{showSelectedShapeActions as IV}from"@nous-excalidraw/element";import{ShapeCache as CV}from"@nous-excalidraw/element";import sH from"clsx";import{jsx as MS,jsxs as cH}from"react/jsx-runtime";var lH="medium",kS={CHECKED:Bi,UNCHECKED:Wr},PS=e=>cH("label",{className:sH("ToolIcon ToolIcon__lock",`ToolIcon_size_${lH}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[MS("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),MS("div",{className:"ToolIcon__icon",children:e.checked?kS.CHECKED:kS.UNCHECKED})]});import{useState as ap,useEffect as _S}from"react";import as from"clsx";import{KEYS as xb,capitalizeString as ot}from"@nous-excalidraw/common";import dH from"clsx";import{KEYS as AS}from"@nous-excalidraw/common";import{jsx as mH}from"react/jsx-runtime";var LS=e=>mH(q,{className:dH("Shape",{fillable:!1,active:e.checked}),type:"radio",icon:Ki,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:AS.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":AS.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{Fragment as pH,jsx as tt,jsxs as vb}from"react/jsx-runtime";var Eb=[{type:"rectangle",icon:Oi,title:ot(g("toolBar.rectangle"))},{type:"diamond",icon:Fi,title:ot(g("toolBar.diamond"))},{type:"triangle",icon:zi,title:ot(g("toolBar.triangle"))},{type:"ellipse",icon:Hi,title:ot(g("toolBar.ellipse"))}],yb=[{type:"selection",icon:Yr,title:ot(g("toolBar.selection"))},{type:"lasso",icon:$n,title:ot(g("toolBar.lasso"))}],wb=[{type:"arrow",icon:Yc,title:ot(g("toolBar.arrow"))},{type:"line",icon:Gi,title:ot(g("toolBar.line"))}],DS=({app:e,onHandToolToggle:o,setAppState:t})=>{let n=e.state.activeTool,[r,i]=ap(!1),[a,s]=ap("rectangle"),[l,c]=ap("arrow");_S(()=>{(n.type==="rectangle"||n.type==="diamond"||n.type==="triangle"||n.type==="ellipse")&&s(n.type)},[n.type]),_S(()=>{(n.type==="arrow"||n.type==="line")&&c(n.type)},[n.type]);let d=n.type==="frame",p=n.type==="laser",m=n.type==="embeddable",{TTDDialogTriggerTunnel:u}=Re(),f=(D,z)=>{e.state.activeTool.type!==D&&me("toolbar",D,"ui"),D==="selection"?e.state.activeTool.type==="selection"||e.setActiveTool({type:"selection"}):e.setActiveTool({type:D})},[h,x]=ap(0),E=36,w=4,y=7,v=y*E+(y-1)*w,T=E+w,I=h>=v+1*T,M=h>=v+2*T,S=h>=v+3*T,A=["text","frame","embeddable","laser","magicframe"].filter(D=>!(I&&D==="text"||M&&D==="image"||S&&D==="frame")).includes(n.type),P=A?n.type==="text"?$o:n.type==="image"?Ui:n.type==="frame"?Co:n.type==="embeddable"?Wi:n.type==="laser"?Zo:n.type==="magicframe"?Kr:Vs:Vs;return vb("div",{className:"mobile-toolbar",ref:D=>{D&&x(D.getBoundingClientRect().width)},children:[tt(LS,{checked:wn(e.state),onChange:o,title:g("toolBar.hand"),isMobile:!0}),tt(Oa,{app:e,options:yb,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,namePrefix:"selectionType",title:ot(g("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:D=>{(D==="selection"||D==="lasso")&&(e.setActiveTool({type:D}),t({preferredSelectionTool:{type:D,initialized:!0}}))},displayedOption:yb.find(D=>D.type===e.state.preferredSelectionTool.type)||yb[0]}),tt(q,{className:as({active:n.type==="freedraw"}),type:"radio",icon:Ko,checked:n.type==="freedraw",name:"editor-current-shape",title:`${ot(g("toolBar.freedraw"))}`,"aria-label":ot(g("toolBar.freedraw")),"data-testid":"toolbar-freedraw",onChange:()=>f("freedraw")}),tt(q,{className:as({active:n.type==="eraser"}),type:"radio",icon:Vc,checked:n.type==="eraser",name:"editor-current-shape",title:`${ot(g("toolBar.eraser"))}`,"aria-label":ot(g("toolBar.eraser")),"data-testid":"toolbar-eraser",onChange:()=>f("eraser")}),tt(Oa,{app:e,options:Eb,activeTool:n,defaultOption:a,namePrefix:"shapeType",title:ot(g(a==="rectangle"?"toolBar.rectangle":a==="diamond"?"toolBar.diamond":a==="triangle"?"toolBar.triangle":a==="ellipse"?"toolBar.ellipse":"toolBar.rectangle")),"data-testid":"toolbar-rectangle",onToolChange:D=>{(D==="rectangle"||D==="diamond"||D==="triangle"||D==="ellipse")&&(s(D),e.setActiveTool({type:D}))},displayedOption:Eb.find(D=>D.type===a)||Eb[0]}),tt(Oa,{app:e,options:wb,activeTool:n,defaultOption:l,namePrefix:"linearElementType",title:ot(g(l==="arrow"?"toolBar.arrow":"toolBar.line")),"data-testid":"toolbar-arrow",fillable:!0,onToolChange:D=>{(D==="arrow"||D==="line")&&(c(D),e.setActiveTool({type:D}))},displayedOption:wb.find(D=>D.type===l)||wb[0]}),I&&tt(q,{className:as({active:n.type==="text"}),type:"radio",icon:$o,checked:n.type==="text",name:"editor-current-shape",title:`${ot(g("toolBar.text"))}`,"aria-label":ot(g("toolBar.text")),"data-testid":"toolbar-text",onChange:()=>f("text")}),M&&tt(q,{className:as({active:n.type==="image"}),type:"radio",icon:Ui,checked:n.type==="image",name:"editor-current-shape",title:`${ot(g("toolBar.image"))}`,"aria-label":ot(g("toolBar.image")),"data-testid":"toolbar-image",onChange:()=>f("image")}),S&&tt(q,{className:as({active:d}),type:"radio",icon:Co,checked:d,name:"editor-current-shape",title:`${ot(g("toolBar.frame"))}`,"aria-label":ot(g("toolBar.frame")),"data-testid":"toolbar-frame",onChange:()=>f("frame")}),vb(ce,{open:r,children:[tt(ce.Trigger,{className:as("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":A||r}),onToggle:()=>{i(!r),t({openMenu:null,openPopup:null})},title:g("toolBar.extraTools"),style:{width:E,height:E,display:"flex",alignItems:"center",justifyContent:"center"},children:P}),vb(ce.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[!I&&tt(ce.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:$o,shortcut:xb.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:n.type==="text",children:g("toolBar.text")}),!M&&tt(ce.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Ui,"data-testid":"toolbar-image",selected:n.type==="image",children:g("toolBar.image")}),!S&&tt(ce.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Co,shortcut:xb.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:d,children:g("toolBar.frame")}),tt(ce.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Wi,"data-testid":"toolbar-embeddable",selected:m,children:g("toolBar.embeddable")}),tt(ce.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Zo,"data-testid":"toolbar-laser",selected:p,shortcut:xb.K.toLocaleUpperCase(),children:g("toolBar.laser")}),tt("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),e.props.aiEnabled!==!1&&tt(u.Out,{}),tt(ce.Item,{onSelect:()=>e.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Zi,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),e.props.aiEnabled!==!1&&e.plugins.diagramToCode&&tt(pH,{children:tt(ce.Item,{onSelect:()=>e.onMagicframeToolSelect(),icon:Kr,"data-testid":"toolbar-magicframe",badge:tt(ce.Item.Badge,{children:"AI"}),children:g("toolBar.magicframe")})})]})]})]})};import uH from"clsx";import{jsx as hH}from"react/jsx-runtime";var sp=({children:e,side:o,className:t})=>hH("div",{className:uH("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import gH from"clsx";import{jsx as RS,jsxs as bH}from"react/jsx-runtime";var fH="medium",lp=e=>e.penDetected?bH("label",{className:gH("ToolIcon ToolIcon__penMode",`ToolIcon_size_${fH}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[RS("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),RS("div",{className:"ToolIcon__icon",children:D0})]}):null;import{Fragment as NS,jsx as dn,jsxs as hi}from"react/jsx-runtime";var BS=({appState:e,elements:o,actionManager:t,setAppState:n,onHandToolToggle:r,renderTopLeftUI:i,renderTopRightUI:a,renderSidebars:s,renderWelcomeScreen:l,UIOptions:c,app:d,onPenModeToggle:p})=>{let{WelcomeScreenCenterTunnel:m,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:f}=Re(),h=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let E=hi("div",{className:"excalidraw-ui-top-right",children:[a?.(!0,e)??(!e.viewModeEnabled&&hi(NS,{children:[dn(lp,{checked:e.penMode,onChange:()=>p(null),title:g("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),dn(f.Out,{})]})),e.viewModeEnabled&&dn(eI,{actionManager:t})]}),w=hi("div",{className:"excalidraw-ui-top-left",children:[i?.(!0,e),dn(u.Out,{})]});return hi("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[w,E]})},x=()=>dn(DS,{app:d,onHandToolToggle:r,setAppState:n});return hi(NS,{children:[s(),dn("div",{className:"App-welcome-screen",children:l&&dn(m.Out,{})}),!e.viewModeEnabled&&hi("div",{className:"App-bottom-bar",style:{marginBottom:mo+Nn},children:[dn(ZT,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:n}),hi(Ze,{className:"App-toolbar",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&x(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&dn("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(E=>({...Hr(o,E)}))},children:g("buttons.scrollBackToContent")})]})]}),dn(sp,{side:"top",className:"App-top-bar",children:h()})]})};import HS,{useLayoutEffect as GS,useRef as US,useState as WS}from"react";import{newTextElement as YS}from"@nous-excalidraw/element";import{arrayToMap as xH}from"@nous-excalidraw/common";import{getElementBounds as EH}from"@nous-excalidraw/element";import{isArrowElement as yH,isExcalidrawElement as wH,isFreeDrawElement as vH,isLinearElement as TH,isTextElement as IH}from"@nous-excalidraw/element";import{rangeIncludesValue as cp,pointFrom as uo,pointRotateRads as CH,rangeInclusive as dp}from"@nous-excalidraw/math";var SH=e=>e.type==="diamond"?[uo(e.width/2,0),uo(e.width,e.height/2),uo(e.width/2,e.height),uo(0,e.height/2)]:e.type==="triangle"?[uo(e.width/2,0),uo(0,e.height),uo(e.width,e.height)]:[uo(0,0),uo(0+e.width,0),uo(0+e.width,e.height),uo(0,e.height)],kH=e=>TH(e)||vH(e)?e.points:SH(e),OS=e=>{let o=e.reduce((t,[n,r])=>(t.minY=Math.min(t.minY,r),t.minX=Math.min(t.minX,n),t.maxX=Math.max(t.maxX,n),t.maxY=Math.max(t.maxY,r),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},FS=e=>{let o=kH(e),{cx:t,cy:n}=OS(o),r=uo(t,n),i=o.map(d=>CH(d,r,e.angle)),{minX:a,minY:s,maxX:l,maxY:c}=OS(i);return[a+e.x,s+e.y,l+e.x,c+e.y]},Tb=(e,o,t=!1)=>{let n=FS(e),r=o[0]<=n[0]&&o[2]>=n[2]&&o[1]<=n[1]&&o[3]>=n[3];return t?r?!0:n[0]<=o[0]&&n[2]>=o[2]&&n[1]<=o[1]&&n[3]>=o[3]:r},zS=(e,o)=>{let t=FS(e);return(cp(t[0],dp(o[0],o[2]))||cp(o[0],dp(t[0],t[2])))&&(cp(t[1],dp(o[1],o[3]))||cp(o[1],dp(t[1],t[3])))},MH=({elements:e,bounds:o,type:t,errorMargin:n=0})=>{wH(o)&&(o=EH(o,xH(e)));let r=[o[0]-n,o[1]-n,o[2]+n,o[3]+n],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?zS(a,r):t==="inside"?Tb(a,r):Tb(a,r,!0)){if(i.add(a.id),a.boundElements)for(let l of a.boundElements)i.add(l.id);IH(a)&&a.containerId&&i.add(a.containerId),yH(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};import{getCommonBounds as mp}from"@nous-excalidraw/element";import{jsx as Bn,jsxs as pp}from"react/jsx-runtime";var PH=e=>{switch(e){case"bar":return g("labels.chartType_bar");case"line":return g("labels.chartType_line");case"radar":return g("labels.chartType_radar");default:return e}},AH=e=>{let o=US(null),[t,n]=WS(null),{theme:r}=se();GS(()=>{if(!e.spreadsheet){n(null);return}let a=fb(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!a){n(null),o.current?.replaceChildren();return}n(a);let s,l=o.current;return(async()=>(s=await Pn({elements:a,appState:{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},files:null,exportPadding:0}),s.querySelector(".style-fonts")?.remove(),l.replaceChildren(),l.appendChild(s)))(),()=>{l.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=PH(e.chartType);return pp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[Bn("div",{className:"ChartPreview__canvas",ref:o}),Bn("div",{className:"ChartPreview__label",children:i})]})},LH=e=>{let o=US(null),{theme:t}=se();return GS(()=>{if(!e.rawText)return;let n=YS({text:e.rawText,x:0,y:0}),r=o.current;return(async()=>{let i=await Pn({elements:[n],appState:{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:t==="dark"},files:null,exportPadding:0});i.querySelector(".style-fonts")?.remove(),r.replaceChildren(),r.appendChild(i)})(),()=>{r.replaceChildren()}},[e.rawText,t]),pp("button",{type:"button",className:"ChartPreview","aria-label":g("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Bn("div",{className:"ChartPreview__canvas",ref:o}),Bn("div",{className:"ChartPreview__label",children:g("labels.chartType_plaintext")})]})},VS=({data:e,rawText:o,onClose:t})=>{let{onInsertElements:n,focusContainer:r}=He(),[i,a]=WS(Math.random()),s=HS.useCallback(()=>{a(Math.random())},[]),l=HS.useCallback(()=>{t&&t()},[t]),c=(p,m)=>{n(m),me("paste","chart",p),t(),r()},d=p=>{let m=YS({text:p,x:0,y:0});n([m]),me("paste","chart","plaintext"),t(),r()};return Bn(qe,{size:"regular",onCloseRequest:l,title:pp("div",{className:"PasteChartDialog__title",children:[Bn("div",{className:"PasteChartDialog__titleText",children:g("labels.pasteCharts")}),Bn("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),s())},children:Xi})]}),className:"PasteChartDialog",autofocus:!1,children:pp("div",{className:"container",children:[["bar","line","radar"].map(p=>Ja(e,p)?Bn(AH,{chartType:p,spreadsheet:e,colorSeed:i,onClick:c},p):null),o&&Bn(LH,{rawText:o,onClick:d})]})})};import{Fragment as _H,jsx as XS,jsxs as DH}from"react/jsx-runtime";var Jl=({heading:e,children:o,...t})=>{let{id:n}=Ne(),r=XS("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:g(`headings.${e}`)});return XS("section",{...t,"aria-labelledby":`${n}-${e}-title`,children:typeof o=="function"?o(r):DH(_H,{children:[r,o]})})};import{Popover as up}from"radix-ui";import KS from"clsx";import hp,{useLayoutEffect as RH}from"react";import{supportsResizeObserver as NH,isShallowEqual as BH}from"@nous-excalidraw/common";import{Fragment as GH,jsx as mn,jsxs as gp}from"react/jsx-runtime";var OH=4,FH=8,zH=({shouldWrap:e,children:o,username:t})=>e?mn($t,{label:t||"Unknown user",children:o}):mn(GH,{children:o}),Ib=({actionManager:e,collaborator:o,socketId:t,withName:n=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:n,isBeingFollowed:i},s=e.renderAction("goToCollaborator",a);return mn(zH,{username:o.username,shouldWrap:r,children:s},t)},HH=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],fp=hp.memo(({className:e,mobile:o,collaborators:t,userToFollow:n})=>{let r=Be(),i=new Map;t.forEach((h,x)=>{let E=h.id||x;i.set(E,{...h,socketId:x})});let a=Array.from(i.values()).filter(h=>h.username?.trim()),[s,l]=hp.useState(""),c=a.filter(h=>h.username?.toLowerCase().includes(s)),d=hp.useRef(null);RH(()=>{if(d.current){let h=E=>{let w=Math.max(1,Math.min(8,Math.floor(E/38)));m(w)};if(h(d.current.clientWidth),!NH)return;let x=new ResizeObserver(E=>{for(let w of E){let{width:y}=w.contentRect;h(y)}});return x.observe(d.current),()=>{x.disconnect()}}},[]);let[p,m]=hp.useState(OH),f=a.slice(0,p-1).map(h=>Ib({actionManager:r,collaborator:h,socketId:h.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:h.socketId===n}));return o?mn("div",{className:KS("UserList UserList_mobile",e),children:a.map(h=>Ib({actionManager:r,collaborator:h,socketId:h.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:h.socketId===n}))}):mn("div",{className:"UserList__wrapper",ref:d,children:gp("div",{className:KS("UserList",e),style:{"--max-avatars":p},children:[f,a.length>p-1&&gp(up.Root,{children:[gp(up.Trigger,{className:"UserList__more",children:["+",a.length-p+1]}),mn(up.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:gp(Ze,{padding:2,children:[a.length>=FH&&mn(xd,{placeholder:g("quickSearch.placeholder"),onChange:l}),mn(Ed,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:c.length>0?[mn("div",{className:"hint",children:g("userList.hint.text")}),c.map(h=>Ib({actionManager:r,collaborator:h,socketId:h.socketId,withName:!0,isBeingFollowed:h.socketId===n}))]:[]}),mn(up.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[n,r]of e.collaborators){let i=o.collaborators.get(n);if(!i||n!==t.next().value||!BH(r,i,HH))return!1}return!0});import Cb from"clsx";import{jsx as UH}from"react/jsx-runtime";var $S=e=>UH("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:Yi});import{jsx as On,jsxs as Sb}from"react/jsx-runtime";var ZS=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i}=Re();return Sb("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[On("div",{className:Cb("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:On(Tt.Col,{gap:2,children:Sb(Jl,{heading:"canvasActions",children:[On(qT,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&On(JT,{renderAction:o.renderAction,className:Cb("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),On(r.Out,{}),On("div",{className:Cb("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Sb("div",{style:{position:"relative"},children:[n&&On(i.Out,{}),On($S,{onClick:()=>o.executeAction(ei)})]})}),On(QT,{actionManager:o,showExitZenModeBtn:t})]})},jS=ZS;ZS.displayName="Footer";import eG from"clsx";import{useEffect as n3,useLayoutEffect as r3,useRef as Nb,useState as tG,forwardRef as i3,useImperativeHandle as oG,useCallback as e3}from"react";import{CLASSES as nG,EVENT as t3,isDevEnv as rG,KEYS as iG,updateObject as aG}from"@nous-excalidraw/common";import YH from"clsx";import{useContext as VH}from"react";import WH from"react";var bp=WH.createContext({});import{jsx as kb,jsxs as qS}from"react/jsx-runtime";var Mb=({children:e,className:o})=>{let t=be(),n=VH(bp),r=!!(t.canFitSidebar&&n.shouldRenderDockButton);return qS("div",{className:YH("sidebar__header",o),"data-testid":"sidebar-header",children:[e,qS("div",{className:"sidebar__header__buttons",children:[r&&kb($t,{label:g("labels.sidebarLock"),children:kb(Et,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:M0})}),kb(Et,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":g("buttons.close"),children:oo})]})]})};Mb.displayName="SidebarHeader";import{Tabs as XH}from"radix-ui";import{jsx as JS}from"react/jsx-runtime";var Pb=({children:e,tab:o,onSelect:t,...n})=>JS(XH.Trigger,{value:o,asChild:!0,onSelect:t,children:JS("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...n,children:e})});Pb.displayName="SidebarTabTrigger";import{Tabs as KH}from"radix-ui";import{jsx as $H}from"react/jsx-runtime";var Ab=({children:e,...o})=>$H(KH.List,{className:"sidebar-triggers",...o,children:e});Ab.displayName="SidebarTabTriggers";import ZH from"clsx";import{jsx as Lb,jsxs as QS}from"react/jsx-runtime";var _b=({name:e,tab:o,icon:t,title:n,children:r,onToggle:i,className:a,style:s})=>{let l=he(),c=se();return QS("label",{title:n,className:"sidebar-trigger__label-element",children:[Lb("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:d=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let p=d.target.checked;l({openSidebar:p?{name:e,tab:o}:null,openMenu:null,openPopup:null}),i?.(p)},checked:c.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),QS("div",{className:ZH("sidebar-trigger",a),style:s,children:[t&&Lb("div",{children:t}),r&&Lb("div",{className:"sidebar-trigger__label",children:r})]})]})};_b.displayName="SidebarTrigger";import{Tabs as jH}from"radix-ui";import{jsx as qH}from"react/jsx-runtime";var Db=({children:e,...o})=>{let t=se(),n=he();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return qH(jH.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>n(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...o,children:e})};Db.displayName="SidebarTabs";import{Tabs as JH}from"radix-ui";import{jsx as QH}from"react/jsx-runtime";var Rb=({tab:e,children:o,...t})=>QH(JH.Content,{...t,value:e,"data-testid":e,children:o});Rb.displayName="SidebarTab";import{jsx as o3}from"react/jsx-runtime";import{createElement as sG}from"react";var Ql=fe(!1),a3=i3(({name:e,children:o,onDock:t,docked:n,className:r,...i},a)=>{rG()&&t&&n==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=he(),l=Vo(Ql);r3(()=>(l(!!n),()=>{l(!1)}),[l,n]);let c=Nb({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=aG(c.current,{docked:n,shouldRenderDockButton:!!t&&n!=null});let d=Nb(null);oG(a,()=>d.current);let p=be(),m=e3(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return na(d,e3(u=>{u.target.closest(".sidebar-trigger")||(!n||!p.canFitSidebar)&&m()},[m,n,p.canFitSidebar])),n3(()=>{let u=f=>{f.key===iG.ESCAPE&&(!n||!p.canFitSidebar)&&m()};return document.addEventListener(t3.KEYDOWN,u),()=>{document.removeEventListener(t3.KEYDOWN,u)}},[m,n,p.canFitSidebar]),o3(Ze,{...i,className:eG(nG.SIDEBAR,{"sidebar--docked":n},r),ref:d,children:o3(bp.Provider,{value:c.current,children:o})})});a3.displayName="SidebarInner";var ho=Object.assign(i3((e,o)=>{let t=se(),{onStateChange:n}=e,r=Nb(t.openSidebar);n3(()=>{(!t.openSidebar&&r?.current?.name===e.name||t.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&t.openSidebar!==r.current&&n?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,n,e.name]);let[i,a]=tG(!1);return r3(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?sG(a3,{...e,ref:o,key:e.name}):null}),{Header:Mb,TabTriggers:Ab,TabTrigger:Pb,Tabs:Db,Tab:Rb,Trigger:_b});ho.displayName="Sidebar";import{composeEventHandlers as gG}from"@nous-excalidraw/common";import{useLayoutEffect as lG,useRef as cG}from"react";import{jsx as dG}from"react/jsx-runtime";var Fn=(e,o)=>{let t=fe(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=Re(),[,a]=i(t),s=cG({preferHost:!1,counter:0});return lG(()=>{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:dG(o,{...r})};return n.displayName=e,n};var Hb={};jx(Hb,{ChangeCanvasBackground:()=>E3,ClearCanvas:()=>b3,CommandPalette:()=>h3,Export:()=>y3,Help:()=>f3,LiveCollaborationTrigger:()=>v3,LoadScene:()=>m3,Preferences:()=>No,PreferencesToggleGridModeItem:()=>Fb,PreferencesToggleZenModeItem:()=>zb,SaveAsImage:()=>u3,SaveToActiveFile:()=>p3,SearchMenu:()=>g3,Socials:()=>w3,ToggleTheme:()=>x3});import hG from"clsx";import{THEME as Tr}from"@nous-excalidraw/common";var Bb=fe({active:!1});async function s3({title:e,description:o,actionLabel:t,color:n}){return new Promise(r=>{nt.set(Bb,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:o,actionLabel:t,color:n})})}import mG from"clsx";import{jsx as l3,jsxs as pG}from"react/jsx-runtime";var xp=function({onChange:e,value:o,choices:t,name:n}){return l3("div",{className:"RadioGroup",children:t.map(r=>pG("div",{className:mG("RadioGroup__choice",{active:r.value===o}),title:r.ariaLabel,children:[l3("input",{name:n,type:"radio",checked:r.value===o,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as uG,jsx as ec,jsxs as c3}from"react/jsx-runtime";var d3=({value:e,shortcut:o,onChange:t,choices:n,children:r,name:i,icon:a})=>{let s=be();return c3(uG,{children:[c3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&ec("div",{className:"dropdown-menu-item__icon",children:a}),ec("label",{className:"dropdown-menu-item__text",children:ec($r,{children:r})}),ec(xp,{name:i,value:e,onChange:t,choices:n})]}),o&&s.formFactor!=="phone"&&ec("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};d3.displayName="DropdownMenuItemContentRadio";var Ob=d3;import{Fragment as A3,jsx as ye,jsxs as tc}from"react/jsx-runtime";var m3=()=>{let{t:e}=Ie(),o=Be(),t=Qn();return o.isActionEnabled(xa)?ye(Pt,{icon:Vi,onSelect:async()=>{(!t.length||await s3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:ye(Rt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>ye("strong",{children:r}),br:()=>ye("br",{})})}))&&o.executeAction(xa)},"data-testid":"load-button",shortcut:De("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};m3.displayName="LoadScene";var p3=()=>{let{t:e}=Ie(),o=Be();return o.isActionEnabled(Qr)?ye(Pt,{shortcut:De("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(Qr),icon:H0,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};p3.displayName="SaveToActiveFile";var u3=()=>{let e=he(),{t:o}=Ie();return ye(Pt,{icon:$c,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:De("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};u3.displayName="SaveAsImage";var h3=e=>{let o=he(),{t}=Ie();return ye(Pt,{icon:Xs,"data-testid":"command-palette-button",onSelect:()=>{me("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:De("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};h3.displayName="CommandPalette";var g3=e=>{let{t:o}=Ie(),t=Be();return ye(Pt,{icon:Kt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Nl)},shortcut:De("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};g3.displayName="SearchMenu";var f3=()=>{let{t:e}=Ie(),o=Be();return ye(Pt,{"data-testid":"help-menu-item",icon:Yi,onSelect:()=>o.executeAction(ei),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};f3.displayName="Help";var b3=()=>{let{t:e}=Ie(),o=Vo(ii);return Be().isActionEnabled(Mn)?ye(Pt,{icon:ft,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};b3.displayName="ClearCanvas";var x3=e=>{let{t:o}=Ie(),t=se(),n=Be(),r=De("toggleTheme");return n.isActionEnabled(jr)?e?.allowSystemTheme?ye(Ob,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:Tr.LIGHT,label:Us,ariaLabel:`${o("buttons.lightMode")} - ${r}`},{value:Tr.DARK,label:Gs,ariaLabel:`${o("buttons.darkMode")} - ${r}`},{value:"system",label:ay,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):ye(Pt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===Tr.DARK?Tr.LIGHT:Tr.DARK);else return n.executeAction(jr)},icon:t.theme===Tr.DARK?Us:Gs,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===Tr.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===Tr.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};x3.displayName="ToggleTheme";var E3=()=>{let{t:e}=Ie(),o=se(),t=Be(),n=qo();return o.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:tc("div",{style:{marginTop:"0.75rem"},children:[ye("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),ye("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};E3.displayName="ChangeCanvasBackground";var y3=()=>{let{t:e}=Ie(),o=he();return ye(Pt,{icon:Vr,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};y3.displayName="Export";var w3=()=>{let{t:e}=Ie();return tc(A3,{children:[ye(Na,{icon:Xc,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),ye(Na,{icon:z0,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),ye(Na,{icon:F0,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};w3.displayName="Socials";var v3=({onSelect:e,isCollaborating:o})=>{let{t}=Ie();return ye(Pt,{"data-testid":"collab-button",icon:Zc,className:hG({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};v3.displayName="LiveCollaborationTrigger";var T3=()=>{let{t:e}=Ie(),o=He(),t=se();return ye(Ao,{checked:t.activeTool.locked,shortcut:De("toolLock"),onSelect:n=>{o.toggleLock(),n.preventDefault()},children:e("labels.preferences_toolLock")})},I3=()=>{let{t:e}=Ie(),o=se(),t=he();return ye(Ob,{name:"boxSelectionMode",icon:od,value:o.boxSelectionMode,onChange:n=>{t({boxSelectionMode:n})},choices:[{value:"contain",label:e("labels.boxSelectionContain"),ariaLabel:e("labels.boxSelectionContain")},{value:"overlap",label:e("labels.boxSelectionOverlap"),ariaLabel:e("labels.boxSelectionOverlap")}],children:e("labels.boxSelectionMode")})},C3=()=>{let{t:e}=Ie(),o=Be(),t=se();return ye(Ao,{checked:t.objectsSnapModeEnabled,shortcut:De("objectsSnapMode"),onSelect:n=>{o.executeAction(gl),n.preventDefault()},children:e("buttons.objectsSnapMode")})},S3=()=>{let{t:e}=Ie(),o=Be(),t=se();return ye(Ao,{checked:t.bindingPreference==="enabled",onSelect:n=>{o.executeAction(fl),n.preventDefault()},children:e("labels.arrowBinding")})},k3=()=>{let{t:e}=Ie(),o=Be(),t=se();return ye(Ao,{checked:t.isMidpointSnappingEnabled,onSelect:n=>{o.executeAction(bl),n.preventDefault()},children:e("labels.midpointSnapping")})},Fb=()=>{let{t:e}=Ie(),o=Be(),t=se();return ye(Ao,{checked:t.gridModeEnabled,shortcut:De("gridMode"),onSelect:n=>{o.executeAction(Ca),n.preventDefault()},children:e("labels.toggleGrid")})},zb=()=>{let{t:e}=Ie(),o=Be(),t=se();return ye(Ao,{checked:t.zenModeEnabled,shortcut:De("zenMode"),onSelect:n=>{o.executeAction(lr),n.preventDefault()},children:e("buttons.zenMode")})},M3=()=>{let{t:e}=Ie(),o=Be(),t=se();return ye(Ao,{checked:t.viewModeEnabled,shortcut:De("viewMode"),onSelect:n=>{o.executeAction(ri),n.preventDefault()},children:e("labels.viewMode")})},P3=()=>{let{t:e}=Ie(),o=Be(),t=se();return ye(Ao,{checked:t.stats.open,shortcut:De("stats"),onSelect:n=>{o.executeAction(cr),n.preventDefault()},children:e("stats.fullTitle")})},No=({children:e,additionalItems:o})=>{let{t}=Ie();return tc(pr,{children:[ye(pr.Trigger,{icon:by,children:t("labels.preferences")}),tc(pr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||tc(A3,{children:[ye(I3,{}),ye(T3,{}),ye(C3,{}),ye(Fb,{}),ye(zb,{}),ye(M3,{}),ye(P3,{}),ye(S3,{}),ye(k3,{})]}),o]})]})};No.ToggleToolLock=T3;No.BoxSelectionMode=I3;No.ToggleSnapMode=C3;No.ToggleArrowBinding=S3;No.ToggleMidpointSnapping=k3;No.ToggleGridMode=Fb;No.ToggleZenMode=zb;No.ToggleViewMode=M3;No.ToggleElementProperties=P3;No.displayName="Preferences";import{jsx as Ep,jsxs as Gb}from"react/jsx-runtime";var fG=Object.assign(Fn("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Re(),n=be(),r=se(),i=he();return Ep(t.In,{children:Gb(ce,{open:r.openMenu==="canvas",children:[Ep(ce.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:B0}),Gb(ce.Content,{onClickOutside:()=>i({openMenu:null}),onSelect:gG(o,()=>{i({openMenu:null})}),className:"main-menu",align:"start",children:[e,n.formFactor==="phone"&&r.collaborators.size>0&&Gb("fieldset",{className:"UserList-Wrapper",children:[Ep("legend",{children:g("labels.collaborators")}),Ep(fp,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:ce.Trigger,Item:ce.Item,ItemLink:ce.ItemLink,ItemCustom:ce.ItemCustom,Group:ce.Group,Separator:ce.Separator,Sub:pr,DefaultItems:Hb}),It=fG;import bG from"clsx";import{forwardRef as xG,useState as EG}from"react";import{isPromiseLike as yG}from"@nous-excalidraw/common";import{jsx as yp,jsxs as wG}from"react/jsx-runtime";var go=xG(({children:e,icon:o,onClick:t,label:n,variant:r="filled",color:i="primary",size:a="medium",fullWidth:s,className:l,status:c,disabled:d},p)=>{let[m,u]=EG(!1),f=async x=>{let E=t?.(x);if(yG(E)){let w=window.setTimeout(()=>{u(!0)},50);try{await E}catch(y){if(y instanceof Pi)console.warn(y);else throw y}finally{clearTimeout(w),u(!1)}}},h=m?"loading":c;return i=h==="success"?"success":i,yp("button",{className:bG("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${h}`,{"ExcButton--fullWidth":s},l),onClick:f,type:"button","aria-label":n,ref:p,disabled:d||h==="loading"||h==="success",children:wG("div",{className:"ExcButton__contents",children:[h==="loading"?yp(bt,{className:"ExcButton__statusIcon"}):h==="success"&&yp("div",{className:"ExcButton__statusIcon",children:HE}),o&&yp("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),r!=="icon"&&(e??n)]})})});import{jsx as ss,jsxs as IG}from"react/jsx-runtime";var wp=({title:e,children:o,actionLabel:t,onClick:n})=>IG("div",{className:"OverwriteConfirm__Actions__Action",children:[ss("h4",{children:e}),ss("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),ss(go,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:n})]}),vG=()=>{let{t:e}=Ie(),o=Be(),t=he();return ss(wp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Ud,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},TG=()=>{let{t:e}=Ie(),o=Be();return ss(wp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(ul,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Ub=Object.assign(({children:e})=>ss("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:vG,SaveToDisk:TG});import{jsx as Ir,jsxs as L3}from"react/jsx-runtime";var vp=Object.assign(Fn("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Re(),[t,n]=Q(Bb);if(!t.active)return null;let r=()=>{t.onClose(),n(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),n(a=>({...a,active:!1}))};return Ir(o.In,{children:Ir(qe,{onCloseRequest:r,title:!1,size:916,children:L3("div",{className:"OverwriteConfirm",children:[Ir("h3",{children:t.title}),L3("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Ir("div",{className:"OverwriteConfirm__Description__icon",children:Jc}),Ir("div",{children:t.description}),Ir("div",{className:"OverwriteConfirm__Description__spacer"}),Ir(go,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Ir(Ub,{children:e})]})})})}),{Actions:Ub,Action:wp});import XG from"clsx";import{CANVAS_SEARCH_TAB as Kb,DEFAULT_SIDEBAR as KG,LIBRARY_SIDEBAR_TAB as G3,composeEventHandlers as $G}from"@nous-excalidraw/common";import{round as CG}from"@nous-excalidraw/math";import SG from"clsx";import kG from"lodash.debounce";import{Fragment as MG,memo as PG,useEffect as oc,useMemo as _3,useRef as Wb,useState as D3}from"react";import{CLASSES as AG,EVENT as LG,FONT_FAMILY as Yb,FRAME_STYLE as Vb,getLineHeight as _G}from"@nous-excalidraw/common";import{isElementCompletelyInViewport as DG}from"@nous-excalidraw/element";import{measureText as nc}from"@nous-excalidraw/element";import{KEYS as ls,randomInteger as R3,addEventListener as RG,getFontString as Tp}from"@nous-excalidraw/common";import{newTextElement as NG}from"@nous-excalidraw/element";import{isTextElement as F3,isFrameLikeElement as Ip}from"@nous-excalidraw/element";import{getDefaultFrameName as z3}from"@nous-excalidraw/element/frame";import{Fragment as VG,jsx as ut,jsxs as pn}from"react/jsx-runtime";var BG=fe(""),Xb=fe(null),OG=350,H3=()=>{let e=He(),o=he(),t=Wb(null),[n,r]=Q(BG),i=n.trim(),[a,s]=D3(!1),[l,c]=D3({nonce:null,items:[]}),d=Wb(null),p=Wb(void 0),[m,u]=Q(Xb),f=e.scene.getNonDeletedElementsMap();oc(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==p.current)&&(d.current=null,O3(i,e,(y,v)=>{c({nonce:R3(),items:y}),d.current=i,p.current=e.scene.getSceneNonce(),o({searchMatches:y.length?{focusedId:null,matches:y.map(T=>({id:T.element.id,focus:!1,matchedLines:T.matchedLines}))}:null})}))},[a,i,f,e,o,u,p]);let h=()=>{l.items.length>0&&u(y=>y===null?0:(y+1)%l.items.length)},x=()=>{l.items.length>0&&u(y=>y===null?0:y-1<0?l.items.length-1:y-1)};oc(()=>{o(y=>y.searchMatches?{searchMatches:{focusedId:m!==null&&y.searchMatches?.matches[m]?.id||null,matches:y.searchMatches.matches.map((T,I)=>I===m?{...T,focus:!0}:{...T,focus:!1})}}:null)},[m,o]),oc(()=>{if(l.items.length>0&&m!==null){let y=l.items[m];if(y){let v=e.state.zoom.value,T=NG({text:y.searchQuery,x:y.element.x+(y.matchedLines[0]?.offsetX??0),y:y.element.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:Ip(y.element)?Vb.nameFontSize:y.element.fontSize,fontFamily:Ip(y.element)?Yb.Assistant:y.element.fontFamily}),I=14,M=T.fontSize,S=M*v<I;if(!DG([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.getEditorUIOffsets())||S){let _;S?M>=I?_={fitToContent:!0}:_={fitToViewport:!0,maxZoom:CG(I/M,1)}:_={fitToContent:!0},e.scrollToContent(T,{animate:!0,duration:300,..._,canvasOffsets:e.getEditorUIOffsets()})}}}},[m,l,e]),oc(()=>()=>{u(null),d.current=null,p.current=void 0,o({searchMatches:null}),s(!1)},[o,u]);let E=jn({goToNextItem:h,goToPreviousItem:x,searchMatches:l});oc(()=>{let y=v=>{if(v.key===ls.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[ls.CTRL_OR_CMD]&&v.key===ls.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&E.searchMatches.items.length&&(v.key===ls.ENTER&&(v.stopPropagation(),E.goToNextItem()),v.key===ls.ARROW_UP?(v.stopPropagation(),E.goToPreviousItem()):v.key===ls.ARROW_DOWN&&(v.stopPropagation(),E.goToNextItem()))};return RG(window,LG.KEYDOWN,y,{capture:!0,passive:!1})},[o,E,e]);let w=`${l.items.length} ${l.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return pn("div",{className:"layer-ui__search",children:[ut("div",{className:"layer-ui__search-header",children:ut(ur,{className:AG.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:t,placeholder:g("search.placeholder"),icon:Kt,onChange:y=>{r(y),s(!0);let v=y.trim();O3(v,e,(T,I)=>{c({nonce:R3(),items:T}),u(I),d.current=v,p.current=e.scene.getSceneNonce(),o({searchMatches:T.length?{focusedId:null,matches:T.map(M=>({id:M.element.id,focus:!1,matchedLines:M.matchedLines}))}:null}),s(!1)})},selectOnRender:!0})}),pn("div",{className:"layer-ui__search-count",children:[l.items.length>0&&pn(VG,{children:[m!==null&&m>-1?pn("div",{children:[m+1," / ",w]}):ut("div",{children:w}),pn("div",{className:"result-nav",children:[ut(Et,{onSelect:()=>{h()},className:"result-nav-btn",children:ed}),ut(Et,{onSelect:()=>{x()},className:"result-nav-btn",children:my})]})]}),l.items.length===0&&i&&d.current&&ut("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),ut(HG,{matches:l,onItemClick:u,focusIndex:m,searchQuery:i})]})},N3=e=>{let o=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return ut("div",{tabIndex:-1,className:SG("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ut("div",{className:"preview-text",children:o.flatMap((t,n)=>ut(MG,{children:n===2?ut("b",{children:t}):t},n))})})},FG=e=>{let o=_3(()=>e.matches.items.filter(n=>Ip(n.element)),[e.matches]),t=_3(()=>e.matches.items.filter(n=>F3(n.element)),[e.matches]);return pn("div",{children:[o.length>0&&pn("div",{className:"layer-ui__search-result-container",children:[pn("div",{className:"layer-ui__search-result-title",children:[ut("div",{className:"title-icon",children:Co}),ut("div",{children:g("search.frames")})]}),o.map((n,r)=>ut(N3,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),t.length>0&&ut("div",{className:"layer-ui__divider"})]}),t.length>0&&pn("div",{className:"layer-ui__search-result-container",children:[pn("div",{className:"layer-ui__search-result-title",children:[ut("div",{className:"title-icon",children:$o}),ut("div",{children:g("search.texts")})]}),t.map((n,r)=>ut(N3,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+o.length===e.focusIndex,onClick:()=>e.onItemClick(r+o.length)},n.element.id+n.index))]})]})},zG=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,HG=PG(FG,zG),B3=(e,o,t)=>{let i=e.slice(0,o),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(o+t.length),m=p.split(/\s+/),u=!p.startsWith(" "),f=u?6:5,h=(u?"":" ")+m.slice(0,f).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+h,moreBefore:l>0,moreAfter:m.length>f}},GG=(e,o)=>{let t=e.split(`
24
24
  `),n=[],r=0;for(let i=0;i<t.length;i++){let a=t[i],s=t[i+1];if(s){let l=o.indexOf(s,r);if(l>a.length+r){let c=l-(a.length+r);for(;c>0;)a+=" ",c--}}n.push(a),r=r+a.length}return n.join(`
25
25
  `)},UG=(e,o,t)=>{let r=GG(e.text,e.originalText).split(`
26
- `),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+o.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),f=c.slice(0,m);c=c.slice(m);let h=nc(u,Tp(e),e.lineHeight);if(u===""&&(h.width=0),e.textAlign!=="left"&&p.line.length>0){let v=nc(p.line,Tp(e),e.lineHeight),T=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;h.width+=T}let{width:x,height:E}=nc(f,Tp(e),e.lineHeight),w=h.width,y=p.lineNumber*h.height;d.push({offsetX:w,offsetY:y,width:x,height:E,showOnCanvas:!0}),l+=m}}return d},WG=(e,o,t,n)=>{let r=e.name??z3(e),i=r.slice(t,t+o.length),a=r.slice(0,t),s=Tp({fontSize:Vb.nameFontSize,fontFamily:Yb.Assistant}),l=_G(Yb.Assistant),c=nc(a,s,l);a===""&&(c.width=0);let d=nc(i,s,l),p=c.width,m=-c.height-Vb.strokeWidth,u=d.width;return[{offsetX:p,offsetY:m,width:u,height:d.height,showOnCanvas:p+u<=e.width*n}]},YG=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),O3=kG((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements(),r=n.filter(m=>F3(m)),i=n.filter(m=>Ip(m));r.sort((m,u)=>m.y-u.y),i.sort((m,u)=>m.y-u.y);let a=[],s=new RegExp(YG(e),"gi");for(let m of r){let u=null,f=m.originalText;for(;(u=s.exec(f))!==null;){let h=B3(f,u.index,e),x=UG(m,e,u.index);x.length>0&&a.push({element:m,searchQuery:e,preview:h,index:u.index,matchedLines:x})}}let l=[];for(let m of i){let u=null,f=m.name??z3(m);for(;(u=s.exec(f))!==null;){let h=B3(f,u.index,e),x=WG(m,e,u.index,o.state.zoom.value);x.length>0&&l.push({element:m,searchQuery:e,preview:h,index:u.index,matchedLines:x})}}let c=new Set(o.visibleElements.map(m=>m.id)),d=[...l,...a],p=d.findIndex(m=>c.has(m.element.id))??null;t(d,p)},OG);import{jsx as Bo,jsxs as U3}from"react/jsx-runtime";import{createElement as ZG}from"react";var W3=Fn("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Re();return Bo(o.In,{children:Bo(ho.Trigger,{...e,className:"default-sidebar-trigger",name:KG.name})})});W3.displayName="DefaultSidebarTrigger";var Y3=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Re();return Bo(o.In,{children:e})};Y3.displayName="DefaultTabTriggers";var Cp=Object.assign(Fn("DefaultSidebar",({children:e,className:o,onDock:t,docked:n,...r})=>{let i=se(),a=he(),{DefaultSidebarTabTriggersTunnel:s}=Re(),l=i.openSidebar?.tab===Kb;return ZG(ho,{...r,name:"default",key:"default",className:XG("default-sidebar",o),docked:l||(n??i.defaultSidebarDockedPreference),onDock:l||t===!1||!t&&n!=null?void 0:$G(t,c=>{a({defaultSidebarDockedPreference:c})})},U3(ho.Tabs,{children:[Bo(ho.Header,{children:U3(ho.TabTriggers,{children:[Bo(ho.TabTrigger,{tab:Kb,children:Kt}),Bo(ho.TabTrigger,{tab:G3,children:Wc}),Bo(s.Out,{})]})}),Bo(ho.Tab,{tab:G3,children:Bo(MT,{})}),Bo(ho.Tab,{tab:Kb,children:Bo(H3,{})}),e]}))}),{Trigger:W3,TabTriggers:Y3});import{useEffect as aW,useState as sW}from"react";import{useState as qb,useRef as l5,useEffect as Jb,useDeferredValue as hU}from"react";import{EDITOR_LS_KEYS as gU,debounce as fU,isDevEnv as bU}from"@nous-excalidraw/common";import{useEffect as V3,useRef as X3,useState as K3}from"react";import{EVENT as $3,KEYS as Z3}from"@nous-excalidraw/common";import{jsx as Sp}from"react/jsx-runtime";var jG=300,j3=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:n,errorLine:r})=>{let i=X3(null),a=X3(n);a.current=n;let[s,l]=K3({type:"loading"}),[c,d]=K3(!1),{theme:p}=se();if(V3(()=>{let m=!1,u=setTimeout(()=>{m||d(!0)},jG);return import("./components/TTDDialog/CodeMirrorEditor-QL4RYZUZ.js").then(f=>{m||l({type:"ready",component:f.default})}).catch(()=>{m||l({type:"fallback"})}).finally(()=>{clearTimeout(u)}),()=>{m=!0,clearTimeout(u)}},[]),V3(()=>{if(s.type!=="fallback"||!a.current)return;let m=i.current;if(m){let u=f=>{f[Z3.CTRL_OR_CMD]&&f.key===Z3.ENTER&&(f.preventDefault(),a.current?.())};return m.focus(),m.addEventListener($3.KEYDOWN,u),()=>{m.removeEventListener($3.KEYDOWN,u)}}},[s.type]),s.type==="ready"){let m=s.component;return Sp(m,{value:e,onChange:t,onKeyboardSubmit:n,placeholder:o,theme:p,errorLine:r})}return s.type==="fallback"?Sp("textarea",{className:"ttd-dialog-input",onChange:m=>t(m.target.value),value:e,placeholder:o,ref:i}):c?Sp("div",{className:"ttd-dialog-input ttd-dialog-input--loading",children:Sp(bt,{})}):null};import eU from"clsx";var q3=/(?:Parse|Lexical) error on line (\d+)[.:]/i,J3=/Trying to inactivate an inactive participant \((.+)\)/i,qG=/^\s*-+\^\s*$/,rc=e=>q3.test(e),kp=e=>rc(e)||J3.test(e),Q3=e=>qG.test(e),$b=e=>{let o=e.match(J3);return o?.[1]?o[1].trim():null},JG=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),QG=(e,o)=>{let t=$b(e);if(!t)return null;let n=new RegExp(`^\\s*deactivate\\s+${JG(t)}(?:\\s+%%.*)?\\s*$`),r=o.split(/\r?\n/);for(let i=r.length-1;i>=0;i--)if(n.test(r[i]))return i+1;return null},ic=(e,o)=>{let t=e.match(q3);return t?Number.parseInt(t[1],10):o?QG(e,o):null},Cr=(e,o)=>(e.match(o)||[]).length,e5=(e,o)=>{if(!rc(e))return null;let t=ic(e,o),n=t?`Syntax error near line ${t}.`:"Syntax error in Mermaid diagram.",r=[];if(o){let i=Cr(o,/\[/g),a=Cr(o,/\]/g);i!==a&&r.push("Unbalanced square brackets in a node label.");let s=Cr(o,/\(/g),l=Cr(o,/\)/g);s!==l&&r.push("Unbalanced parentheses in a node shape.");let c=Cr(o,/\{/g),d=Cr(o,/\}/g);c!==d&&r.push("Unbalanced braces in a decision node.");let p=Cr(o,/^\s*subgraph\b/gm),m=Cr(o,/^\s*end\s*$/gm);p>m&&r.push("A block is missing an `end` statement.")}return(/got 'NODE_STRING'/.test(e)||/got 'PS'/.test(e))&&r.push("An extra character/token may appear after a node or label definition."),r.length===0&&(r.push("A node or edge line is malformed (missing/extra delimiters)."),r.push("A block (`subgraph`, `class`, etc.) may be incomplete.")),{summary:n,likelyCauses:[...new Set(r)]}},t5=e=>rc(e)?e.replace(/\n\s*Expecting[\s\S]*$/,"").trimEnd():e;import{jsx as fo,jsxs as Mp}from"react/jsx-runtime";var Pp=({error:e,canvasRef:o,loaded:t,hideErrorDetails:n,sourceText:r,autoFixAvailable:i,onApplyAutoFix:a})=>{let s=e?n?g("chat.errors.mermaidParseError"):t5(e.message):null,l=e&&!n?e5(e.message,r):null,c=!!i&&!!a&&!n,d=s?.split(/\r?\n/)??[];return Mp("div",{className:`ttd-dialog-output-wrapper ${e?"ttd-dialog-output-wrapper--error":""}`,children:[e&&fo("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:Mp("div",{className:"ttd-dialog-output-error-content",children:[fo("div",{className:"ttd-dialog-output-error-icon",children:Jc}),l&&Mp("div",{className:"ttd-dialog-output-error-summary",children:[fo("div",{className:"ttd-dialog-output-error-summary__headline",children:l.summary}),fo("div",{className:"ttd-dialog-output-error-summary__label",children:"Likely causes:"}),fo("ul",{className:"ttd-dialog-output-error-summary__causes",children:l.likelyCauses.map(p=>fo("li",{children:p},p))})]}),fo("div",{className:"ttd-dialog-output-error-message",children:d.map((p,m)=>Mp("span",{className:Q3(p)?"ttd-dialog-output-error-message__caret":void 0,children:[p,m<d.length-1?`
26
+ `),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+o.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),f=c.slice(0,m);c=c.slice(m);let h=nc(u,Tp(e),e.lineHeight);if(u===""&&(h.width=0),e.textAlign!=="left"&&p.line.length>0){let v=nc(p.line,Tp(e),e.lineHeight),T=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;h.width+=T}let{width:x,height:E}=nc(f,Tp(e),e.lineHeight),w=h.width,y=p.lineNumber*h.height;d.push({offsetX:w,offsetY:y,width:x,height:E,showOnCanvas:!0}),l+=m}}return d},WG=(e,o,t,n)=>{let r=e.name??z3(e),i=r.slice(t,t+o.length),a=r.slice(0,t),s=Tp({fontSize:Vb.nameFontSize,fontFamily:Yb.Assistant}),l=_G(Yb.Assistant),c=nc(a,s,l);a===""&&(c.width=0);let d=nc(i,s,l),p=c.width,m=-c.height-Vb.strokeWidth,u=d.width;return[{offsetX:p,offsetY:m,width:u,height:d.height,showOnCanvas:p+u<=e.width*n}]},YG=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),O3=kG((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements(),r=n.filter(m=>F3(m)),i=n.filter(m=>Ip(m));r.sort((m,u)=>m.y-u.y),i.sort((m,u)=>m.y-u.y);let a=[],s=new RegExp(YG(e),"gi");for(let m of r){let u=null,f=m.originalText;for(;(u=s.exec(f))!==null;){let h=B3(f,u.index,e),x=UG(m,e,u.index);x.length>0&&a.push({element:m,searchQuery:e,preview:h,index:u.index,matchedLines:x})}}let l=[];for(let m of i){let u=null,f=m.name??z3(m);for(;(u=s.exec(f))!==null;){let h=B3(f,u.index,e),x=WG(m,e,u.index,o.state.zoom.value);x.length>0&&l.push({element:m,searchQuery:e,preview:h,index:u.index,matchedLines:x})}}let c=new Set(o.visibleElements.map(m=>m.id)),d=[...l,...a],p=d.findIndex(m=>c.has(m.element.id))??null;t(d,p)},OG);import{jsx as Bo,jsxs as U3}from"react/jsx-runtime";import{createElement as ZG}from"react";var W3=Fn("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Re();return Bo(o.In,{children:Bo(ho.Trigger,{...e,className:"default-sidebar-trigger",name:KG.name})})});W3.displayName="DefaultSidebarTrigger";var Y3=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Re();return Bo(o.In,{children:e})};Y3.displayName="DefaultTabTriggers";var Cp=Object.assign(Fn("DefaultSidebar",({children:e,className:o,onDock:t,docked:n,...r})=>{let i=se(),a=he(),{DefaultSidebarTabTriggersTunnel:s}=Re(),l=i.openSidebar?.tab===Kb;return ZG(ho,{...r,name:"default",key:"default",className:XG("default-sidebar",o),docked:l||(n??i.defaultSidebarDockedPreference),onDock:l||t===!1||!t&&n!=null?void 0:$G(t,c=>{a({defaultSidebarDockedPreference:c})})},U3(ho.Tabs,{children:[Bo(ho.Header,{children:U3(ho.TabTriggers,{children:[Bo(ho.TabTrigger,{tab:Kb,children:Kt}),Bo(ho.TabTrigger,{tab:G3,children:Wc}),Bo(s.Out,{})]})}),Bo(ho.Tab,{tab:G3,children:Bo(MT,{})}),Bo(ho.Tab,{tab:Kb,children:Bo(H3,{})}),e]}))}),{Trigger:W3,TabTriggers:Y3});import{useEffect as aW,useState as sW}from"react";import{useState as qb,useRef as l5,useEffect as Jb,useDeferredValue as hU}from"react";import{EDITOR_LS_KEYS as gU,debounce as fU,isDevEnv as bU}from"@nous-excalidraw/common";import{useEffect as V3,useRef as X3,useState as K3}from"react";import{EVENT as $3,KEYS as Z3}from"@nous-excalidraw/common";import{jsx as Sp}from"react/jsx-runtime";var jG=300,j3=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:n,errorLine:r})=>{let i=X3(null),a=X3(n);a.current=n;let[s,l]=K3({type:"loading"}),[c,d]=K3(!1),{theme:p}=se();if(V3(()=>{let m=!1,u=setTimeout(()=>{m||d(!0)},jG);return import("./components/TTDDialog/CodeMirrorEditor-PQAT7WNN.js").then(f=>{m||l({type:"ready",component:f.default})}).catch(()=>{m||l({type:"fallback"})}).finally(()=>{clearTimeout(u)}),()=>{m=!0,clearTimeout(u)}},[]),V3(()=>{if(s.type!=="fallback"||!a.current)return;let m=i.current;if(m){let u=f=>{f[Z3.CTRL_OR_CMD]&&f.key===Z3.ENTER&&(f.preventDefault(),a.current?.())};return m.focus(),m.addEventListener($3.KEYDOWN,u),()=>{m.removeEventListener($3.KEYDOWN,u)}}},[s.type]),s.type==="ready"){let m=s.component;return Sp(m,{value:e,onChange:t,onKeyboardSubmit:n,placeholder:o,theme:p,errorLine:r})}return s.type==="fallback"?Sp("textarea",{className:"ttd-dialog-input",onChange:m=>t(m.target.value),value:e,placeholder:o,ref:i}):c?Sp("div",{className:"ttd-dialog-input ttd-dialog-input--loading",children:Sp(bt,{})}):null};import eU from"clsx";var q3=/(?:Parse|Lexical) error on line (\d+)[.:]/i,J3=/Trying to inactivate an inactive participant \((.+)\)/i,qG=/^\s*-+\^\s*$/,rc=e=>q3.test(e),kp=e=>rc(e)||J3.test(e),Q3=e=>qG.test(e),$b=e=>{let o=e.match(J3);return o?.[1]?o[1].trim():null},JG=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),QG=(e,o)=>{let t=$b(e);if(!t)return null;let n=new RegExp(`^\\s*deactivate\\s+${JG(t)}(?:\\s+%%.*)?\\s*$`),r=o.split(/\r?\n/);for(let i=r.length-1;i>=0;i--)if(n.test(r[i]))return i+1;return null},ic=(e,o)=>{let t=e.match(q3);return t?Number.parseInt(t[1],10):o?QG(e,o):null},Cr=(e,o)=>(e.match(o)||[]).length,e5=(e,o)=>{if(!rc(e))return null;let t=ic(e,o),n=t?`Syntax error near line ${t}.`:"Syntax error in Mermaid diagram.",r=[];if(o){let i=Cr(o,/\[/g),a=Cr(o,/\]/g);i!==a&&r.push("Unbalanced square brackets in a node label.");let s=Cr(o,/\(/g),l=Cr(o,/\)/g);s!==l&&r.push("Unbalanced parentheses in a node shape.");let c=Cr(o,/\{/g),d=Cr(o,/\}/g);c!==d&&r.push("Unbalanced braces in a decision node.");let p=Cr(o,/^\s*subgraph\b/gm),m=Cr(o,/^\s*end\s*$/gm);p>m&&r.push("A block is missing an `end` statement.")}return(/got 'NODE_STRING'/.test(e)||/got 'PS'/.test(e))&&r.push("An extra character/token may appear after a node or label definition."),r.length===0&&(r.push("A node or edge line is malformed (missing/extra delimiters)."),r.push("A block (`subgraph`, `class`, etc.) may be incomplete.")),{summary:n,likelyCauses:[...new Set(r)]}},t5=e=>rc(e)?e.replace(/\n\s*Expecting[\s\S]*$/,"").trimEnd():e;import{jsx as fo,jsxs as Mp}from"react/jsx-runtime";var Pp=({error:e,canvasRef:o,loaded:t,hideErrorDetails:n,sourceText:r,autoFixAvailable:i,onApplyAutoFix:a})=>{let s=e?n?g("chat.errors.mermaidParseError"):t5(e.message):null,l=e&&!n?e5(e.message,r):null,c=!!i&&!!a&&!n,d=s?.split(/\r?\n/)??[];return Mp("div",{className:`ttd-dialog-output-wrapper ${e?"ttd-dialog-output-wrapper--error":""}`,children:[e&&fo("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:Mp("div",{className:"ttd-dialog-output-error-content",children:[fo("div",{className:"ttd-dialog-output-error-icon",children:Jc}),l&&Mp("div",{className:"ttd-dialog-output-error-summary",children:[fo("div",{className:"ttd-dialog-output-error-summary__headline",children:l.summary}),fo("div",{className:"ttd-dialog-output-error-summary__label",children:"Likely causes:"}),fo("ul",{className:"ttd-dialog-output-error-summary__causes",children:l.likelyCauses.map(p=>fo("li",{children:p},p))})]}),fo("div",{className:"ttd-dialog-output-error-message",children:d.map((p,m)=>Mp("span",{className:Q3(p)?"ttd-dialog-output-error-message__caret":void 0,children:[p,m<d.length-1?`
27
27
  `:""]},`error-line-${m}`))}),!n&&fo("div",{className:"ttd-dialog-output-error-autofix-slot",children:c?fo(Et,{className:"ttd-dialog-panel-button ttd-dialog-output-error-autofix",onSelect:a,children:g("mermaid.autoFixAvailable")}):null})]})},"error"),t?fo("div",{className:eU("ttd-dialog-output-canvas-container",{invisible:!!e}),children:fo("div",{ref:o,className:"ttd-dialog-output-canvas-content"})},"canvas"):fo(bt,{size:"2rem"})]})};import cs from"clsx";import{Fragment as tU}from"react";import{jsx as ds,jsxs as ms}from"react/jsx-runtime";var gi=({label:e,children:o,panelActions:t=[],onTextSubmitInProgess:n,renderTopRight:r,renderSubmitShortcut:i,className:a,panelActionJustifyContent:s="flex-start"})=>{let l=c=>{if(c?.variant==="link")return ms("button",{className:cs("ttd-dialog-panel-action-link",c.className),onClick:c.action,disabled:c?.disabled||n,type:"button",children:[c.label,c.icon&&ds("span",{className:"ttd-dialog-panel-action-link__icon",children:c.icon})]});if(c?.variant==="button")return ms(Et,{className:cs("ttd-dialog-panel-button",c.className),onSelect:c.action?c.action:()=>{},disabled:c?.disabled||n,children:[ms("div",{className:cs({invisible:n}),children:[c?.label,c?.icon&&ds("span",{children:c.icon})]}),n&&ds(bt,{})]});if(c?.variant==="rateLimit")return ds("div",{className:cs("ttd-dialog-panel__rate-limit",c.className),children:c.label})};return ms("div",{className:cs("ttd-dialog-panel",a),children:[(e||r)&&ms("div",{className:"ttd-dialog-panel__header",children:[typeof e=="string"?ds("label",{children:e}):e,r?.()]}),o,ms("div",{className:cs("ttd-dialog-panel-button-container",{invisible:!t.length}),style:{justifyContent:s},children:[t.filter(Boolean).map(c=>ds(tU,{children:l(c)},c.label)),!n&&i?.()]})]})};import{jsx as oU}from"react/jsx-runtime";var o5=({children:e})=>oU("div",{className:"ttd-dialog-panels",children:e});import{jsx as n5,jsxs as nU}from"react/jsx-runtime";var r5=()=>nU("div",{className:"ttd-dialog-submit-shortcut",children:[n5("div",{className:"ttd-dialog-submit-shortcut__key",children:B("CtrlOrCmd")}),n5("div",{className:"ttd-dialog-submit-shortcut__key",children:B("Enter")})]});var rU=(e,o)=>{let t=ic(e,o);return t==null?null:t-1},i5=(e,o,t)=>{if(o<0||o>=e.length)return null;let n=t(e[o]);if(n===e[o])return null;let r=[...e];return r[o]=n,r.join(`
28
28
  `)},iU=e=>{let o=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([A-Za-z]+)\s*$/);if(o)return o[1];let t=e.match(/^(.*(?:\[[^\]]*]|\([^)]*\)|\{[^}]*}|"(?:[^"]*)"|'(?:[^']*)'))([,;:])\s*$/);return t?t[1]:e},a5=e=>e.replace(/(\|[^|\n]+\|)\s*>\s*(?=[A-Za-z0-9_("[{'`])/g,"$1 "),s5=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),aU=(e,o)=>{let t=new RegExp(`^\\s*deactivate\\s+${s5(o)}(?:\\s+%%.*)?\\s*$`),n=e.split(/\r?\n/);for(let r=n.length-1;r>=0;r--)if(t.test(n[r]))return n.filter((i,a)=>a!==r).join(`
29
29
  `);return null},sU=(e,o)=>{let t=new RegExp(`^\\s*deactivate\\s+${s5(o)}(?:\\s+%%.*)?\\s*$`),n=e.split(/\r?\n/),r=!1,i=n.filter(a=>t.test(a)?(r=!0,!1):!0);return r?i.join(`
@@ -45,7 +45,7 @@ The exception/error is: ${$}
45
45
 
46
46
  Please fix the Mermaid syntax and regenerate a valid diagram.`;await E({prompt:ee,isRepairFlow:!0})},z=async G=>{let J=d.messages.findIndex($=>$.id===G.id);if(J>0){let $=d.messages[J-1];$.type==="user"&&typeof $.content=="string"&&(h(),await E({prompt:$.content,isRepairFlow:!0}))}},K=()=>{ac({app:i,data:x})},W=G=>{let J=d.messages.findIndex(ee=>ee.id===G&&ee.type==="assistant"),$=d.messages.slice(0,J-1);p({...d,messages:$})},Y=G=>{p(J=>({...J,currentPrompt:G}))};return qU("div",{className:`ttd-dialog-layout ${m?"ttd-dialog-layout--split":"ttd-dialog-layout--chat-only"}`,children:[l1(S5,{chatId:d.id,messages:d.messages,currentPrompt:d.currentPrompt,onPromptChange:Y,onGenerate:E,isGenerating:f?.isGenerating??!1,generatedResponse:f?.content,isMenuOpen:y,onMenuToggle:M,onMenuClose:S,onNewChat:I,onRestoreChat:v,onDeleteChat:T,savedChats:u,activeSessionId:d.id,onAbort:w,onMermaidTabClick:A,onAiRepairClick:D,onDeleteMessage:W,onInsertMessage:P,onRetry:z,onViewAsMermaid:_,renderWarning:n,renderWelcomeScreen:t}),m&&l1(M5,{canvasRef:s,hideErrorDetails:f?.errorType==="parse",error:l,loaded:e.loaded,onInsert:K})]})},jU=({mermaidToExcalidrawLib:e,onTextSubmit:o,renderWelcomeScreen:t,renderWarning:n,persistenceAdapter:r})=>l1(ZU,{mermaidToExcalidrawLib:e,onTextSubmit:o,renderWelcomeScreen:t,renderWarning:n,persistenceAdapter:r}),P5=jU;import{Tabs as JU}from"radix-ui";import{useRef as A5}from"react";import{isMemberOf as QU}from"@nous-excalidraw/common";import{jsx as eW}from"react/jsx-runtime";var L5=e=>{let o=he(),t=A5(null),n=A5(0);return eW(JU.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:r=>{if(!r)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>n.current&&(n.current=a,i.style.minHeight=`min(${n.current}px, 100%)`)}e.dialog==="ttd"&&QU(["text-to-diagram","mermaid"],r)&&o({openDialog:{name:e.dialog,tab:r}})},children:e.children})};L5.displayName="TTDDialogTabs";var _5=L5;import{Tabs as tW}from"radix-ui";import{jsx as oW}from"react/jsx-runtime";var c1=({children:e,...o})=>oW(tW.List,{className:"ttd-dialog-triggers",...o,children:e});c1.displayName="TTDDialogTabTriggers";import{Tabs as nW}from"radix-ui";import{jsx as D5}from"react/jsx-runtime";var Np=({children:e,tab:o,onSelect:t,...n})=>D5(nW.Trigger,{value:o,asChild:!0,onSelect:t,children:D5("button",{type:"button",className:"ttd-dialog-tab-trigger",...n,children:e})});Np.displayName="TTDDialogTabTrigger";import{Tabs as rW}from"radix-ui";import{jsx as iW}from"react/jsx-runtime";var Bp=({tab:e,children:o,...t})=>iW(rW.Content,{...t,value:e,children:o});Bp.displayName="TTDDialogTab";import{jsx as un,jsxs as d1}from"react/jsx-runtime";var Op=e=>{let o=se();return o.openDialog?.name!=="ttd"?null:un(lW,{...e,tab:o.openDialog.tab})};Op.WelcomeMessage=Ap;var lW=Fn("TTDDialogBase",({tab:e,...o})=>{let t=He(),[n,r]=sW({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});return aW(()=>{(async()=>{await n.api,r(a=>({...a,loaded:!0}))})()},[n.api]),un(qe,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1520,title:!1,...o,autofocus:!1,children:d1(_5,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?un("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):d1(c1,{children:[un(Np,{tab:"text-to-diagram",children:d1("div",{className:"ttd-dialog-tab-trigger__content",children:[g("labels.textToDiagram"),un("div",{className:"ttd-dialog-tab-trigger__badge",children:g("chat.aiBeta")})]})}),un(Np,{tab:"mermaid",children:g("mermaid.label")})]}),!("__fallback"in o)&&un(Bp,{className:"ttd-dialog-content",tab:"text-to-diagram",children:un(P5,{mermaidToExcalidrawLib:n,onTextSubmit:o.onTextSubmit,renderWelcomeScreen:o.renderWelcomeScreen,renderWarning:o.renderWarning,persistenceAdapter:o.persistenceAdapter})}),un(Bp,{className:"ttd-dialog-content",tab:"mermaid",children:un(m5,{mermaidToExcalidrawLib:n,isActive:e==="mermaid"})})]})})});import{round as yk}from"@nous-excalidraw/math";import vY from"clsx";import TY from"lodash.throttle";import{useEffect as wk,useMemo as I1,useState as IY,memo as CY}from"react";import{STATS_PANELS as Yp}from"@nous-excalidraw/common";import{getCommonBounds as SY}from"@nous-excalidraw/element";import{getUncroppedWidthAndHeight as kY}from"@nous-excalidraw/element";import{isImageElement as C1}from"@nous-excalidraw/element";import{frameAndChildrenSelectedTogether as MY}from"@nous-excalidraw/element";import{elementsAreInSameGroup as PY}from"@nous-excalidraw/element";import{degreesToRadians as G5,radiansToDegrees as V5}from"@nous-excalidraw/math";import{getBoundTextElement as U5}from"@nous-excalidraw/element";import{isArrowElement as W5,isElbowArrow as wW}from"@nous-excalidraw/element";import{updateBindings as Y5}from"@nous-excalidraw/element";import gW from"clsx";import{useEffect as z5,useRef as zp,useState as fW}from"react";import{EVENT as bs,KEYS as bW,cloneJSON as m1}from"@nous-excalidraw/common";import{deepCopyElement as xW}from"@nous-excalidraw/element";import{CaptureUpdateAction as H5}from"@nous-excalidraw/element";import{pointFrom as Pr,pointRotateRads as Fp}from"@nous-excalidraw/math";import{getBoundTextElement as cW,isBindingElement as dW,unbindBindingElement as R5}from"@nous-excalidraw/element";import{isFrameLikeElement as O5}from"@nous-excalidraw/element";import{getSelectedGroupIds as mW,getElementsInGroup as pW,isInGroup as uW}from"@nous-excalidraw/element";import{getFrameChildren as hW}from"@nous-excalidraw/element";import{updateBindings as N5}from"@nous-excalidraw/element";import{DRAGGING_THRESHOLD as B5}from"@nous-excalidraw/common";var F5=.01,dc=10,Gt=(e,o)=>!(o==="angle"&&O5(e)),Ve=(e,o)=>{let t=e+o/2;return t-t%o},gs=(e,o,t)=>Object.keys(e).map(n=>({original:(t??o).get(n),latest:o.get(n)})).filter(n=>n.original!==void 0&&n.latest!==void 0);var Ei=(e,o,t,n,r,i,a=!0)=>{if(dW(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<B5&&Math.abs(o-t.y)<B5)return;R5(t,"start",n),R5(t,"end",n)}let s=n.getNonDeletedElementsMap(),l=s.get(t.id);if(!l)return;let[c,d]=[t.x+t.width/2,t.y+t.height/2],[p,m]=Fp(Pr(t.x,t.y),Pr(c,d),t.angle),u=e-p,f=o-m,[h,x]=Fp(Pr(e,o),Pr(c+u,d+f),-t.angle);n.mutateElement(l,{x:h,y:x},{informMutation:a,isDragging:!1}),N5(l,n,r);let E=cW(t,i);if(E){let w=s.get(E.id);w&&n.mutateElement(w,{x:E.x+u,y:E.y+f},{informMutation:a,isDragging:!1})}if(O5(t)){let w=hW(i,t.id);w.forEach(y=>{let v=s.get(y.id);if(!v)return;let[T,I]=[y.x+y.width/2,y.y+y.height/2],[M,S]=Fp(Pr(y.x,y.y),Pr(T,I),y.angle),_=Math.round(M+u),A=Math.round(S+f),[P,D]=Fp(Pr(_,A),Pr(T+u,I+f),-y.angle);n.mutateElement(v,{x:P,y:D},{informMutation:a,isDragging:!1}),N5(v,n,r,{simultaneouslyUpdated:w})})}},fs=(e,o)=>{let n=mW(o).map(r=>pW(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!uW(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as p1,jsxs as yW}from"react/jsx-runtime";var EW=({label:e,icon:o,dragInputCallback:t,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:s,scene:l,appState:c,sensitivity:d=1,dragFinishedCallback:p})=>{let m=He(),u=he(),f=zp(null),h=zp(null),[x,E]=fW(n.toString()),w=zp(null);w.current||(w.current={originalAppState:m1(c),originalElements:r,lastUpdatedValue:x,updatePending:!1}),z5(()=>{let T=n.toString();E(T),w.current.lastUpdatedValue=T},[n]);let y=(T,I,M)=>{if(!w.current.updatePending)return!1;w.current.updatePending=!1;let S=Number(T);if(isNaN(S)){E(n.toString());return}let _=Number(S.toFixed(2)),A=Number(n);(isNaN(A)||Math.abs(_-A)>=F5)&&(w.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:I,originalElementsMap:m.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:_,property:s,originalAppState:M,setInputValue:P=>E(String(P)),app:m,setAppState:u}),m.syncActionResult({captureUpdate:H5.IMMEDIATELY}))},v=zp({});return v.current.handleInputValue=y,z5(()=>{let T=f.current,I=v.current;return()=>{let M=T?.value;M&&I.handleInputValue?.(M,w.current.originalElements,w.current.originalAppState),window.removeEventListener(bs.POINTER_MOVE,I.onPointerMove,!1),window.removeEventListener(bs.POINTER_UP,I.onPointerUp,!1)}},[i]),i?yW("div",{className:gW("drag-input-container",!i&&"disabled"),"data-testid":e,children:[p1("div",{className:"drag-input-label",ref:h,onPointerDown:T=>{if(f.current&&i){document.body.classList.add("excalidraw-cursor-resize");let I=Number(f.current.value);isNaN(I)&&(I=0);let M=null,S=m.scene.getNonDeletedElements().reduce((W,Y)=>(W.set(Y.id,xW(Y)),W),new Map),_=r.map(W=>S.get(W.id)),A=m1(c),P=0,D=0,z=W=>{if(M&&S!==null&&_!==null){let Y=W.clientX-M.x;Y!==0&&(D+=Y,Math.abs(D)>=d&&(D=Math.sign(D)*Math.floor(Math.abs(D)/d),P+=D,t({accumulatedChange:P,instantChange:D,originalElements:_,originalElementsMap:S,shouldKeepAspectRatio:a,shouldChangeByStepSize:W.shiftKey,property:s,scene:l,originalAppState:A,setInputValue:G=>E(String(G)),app:m,setAppState:u}),D=0))}M={x:W.clientX,y:W.clientY}},K=()=>{window.removeEventListener(bs.POINTER_MOVE,z,!1),m.syncActionResult({captureUpdate:H5.IMMEDIATELY}),p?.({app:m,setAppState:u,originalElements:_,originalAppState:A}),M=null,P=0,D=0,_=null,S=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(bs.POINTER_UP,K,!1)};v.current.onPointerMove=z,v.current.onPointerUp=K,window.addEventListener(bs.POINTER_MOVE,z,!1),window.addEventListener(bs.POINTER_UP,K,!1)}},onPointerEnter:()=>{h.current&&(h.current.style.cursor="ew-resize")},children:o?p1(Jo,{icon:o}):e}),p1("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let I=T.target;I instanceof HTMLInputElement&&T.key===bW.ENTER&&(y(I.value,r,c),m.focusContainer())}},ref:f,value:x,onChange:T=>{w.current.updatePending=!0,E(T.target.value)},onFocus:T=>{T.target.select(),w.current.originalElements=r,w.current.originalAppState=m1(c)},onBlur:T=>{x?i&&y(T.target.value,w.current.originalElements,w.current.originalAppState):E(n.toString())},disabled:!i})]}):null},ht=EW;import{jsx as CW}from"react/jsx-runtime";var vW=15,TW=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=o[0];if(s&&!wW(s)){let l=a.get(s.id);if(!l)return;if(n!==void 0){let f=G5(n);r.mutateElement(l,{angle:f}),Y5(l,r,i.state);let h=U5(l,a);h&&!W5(l)&&r.mutateElement(h,{angle:f});return}let c=Math.round(V5(s.angle)*100)/100,d=Math.round(e),p=(c+d)%360;t&&(p=Ve(p,vW)),p=p<0?p+360:p;let m=G5(p);r.mutateElement(l,{angle:m}),Y5(l,r,i.state);let u=U5(l,a);u&&!W5(l)&&r.mutateElement(u,{angle:m})}},IW=({element:e,scene:o,appState:t,property:n})=>CW(ht,{label:"A",icon:qc,value:Math.round(V5(e.angle)%360*100)/100,elements:[e],dragInputCallback:TW,editable:Gt(e,"angle"),scene:o,appState:t,property:n}),X5=IW;import{jsx as kW}from"react/jsx-runtime";var K5=5,SW=({property:e,scene:o,appState:t,setAppState:n})=>kW(ht,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:s})=>{n(l=>{let c;return r?c=r:i&&(c=a?Ve(l.gridStep+K5*Math.sign(i),K5):l.gridStep+i),c?(c=Qx(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),$5=SW;import{clamp as Hp,round as u1}from"@nous-excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Gp}from"@nous-excalidraw/common";import{MINIMAL_CROP_SIZE as Z5,getUncroppedWidthAndHeight as J5}from"@nous-excalidraw/element";import{resizeSingleElement as j5}from"@nous-excalidraw/element";import{isImageElement as Q5,shouldForceMaintainAspectRatio as MW}from"@nous-excalidraw/element";import{isFrameLikeElement as h1}from"@nous-excalidraw/element";import{getElementsInResizingFrame as g1}from"@nous-excalidraw/element";import{replaceAllElementsInFrame as ek}from"@nous-excalidraw/element";import{jsx as _W}from"react/jsx-runtime";var q5=10,PW=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:s,instantChange:l,scene:c,app:d,setAppState:p})=>{let m=c.getNonDeletedElementsMap(),u=o[0],f=m.get(u.id);if(u&&f){let h=n||MW(u),x=u.width/u.height;if(s.croppingElementId===u.id){let E=m.get(u.id);if(!E||!Q5(E)||!E.crop)return;let w=E.crop,y={...w},v=E.scale[0]===-1,T=E.scale[1]===-1,{width:I,height:M}=J5(E),S=w.naturalWidth/I,_=w.naturalHeight/M,A=v?w.width+w.x:w.naturalWidth-w.x,P=T?w.height+w.y:w.naturalHeight-w.y,D=Z5*S,z=Z5*_;if(i!==void 0){if(a==="width"){let J=i*S,$=Hp(J,D,A);y={...y,width:$,x:v?w.x+w.width-$:w.x}}else if(a==="height"){let J=i*_,$=Hp(J,z,P);y={...y,height:$,y:T?w.y+w.height-$:w.y}}c.mutateElement(E,{crop:y,width:y.width/(w.naturalWidth/I),height:y.height/(w.naturalHeight/M)});return}let K=a==="width"?l:0,W=a==="height"?l:0,Y=Hp(w.width+K,D,A),G=Hp(w.height+W,D,P);y={...w,x:v?w.x+w.width-Y:w.x,y:T?w.y+w.height-G:w.y,width:Y,height:G},c.mutateElement(E,{crop:y,width:y.width/(w.naturalWidth/I),height:y.height/(w.naturalHeight/M)});return}if(i!==void 0){let E=Math.max(a==="width"?i:h?i*x:u.width,Gp),w=Math.max(a==="height"?i:h?i/x:u.height,Gp);if(j5(E,w,f,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:h}),h1(f)){let y=g1(c.getElementsIncludingDeleted(),f,s,c.getNonDeletedElementsMap()),v=ek(c.getElementsIncludingDeleted(),y,f,d);c.replaceAllElements(v)}return}{let E=a==="width"?e:0,w=a==="height"?e:0,y=Math.max(0,u.width+E);a==="width"&&(r?y=Ve(y,q5):y=Math.round(y));let v=Math.max(0,u.height+w);if(a==="height"&&(r?v=Ve(v,q5):v=Math.round(v)),h&&(a==="width"?v=Math.round(y/x*100)/100:y=Math.round(v*x*100)/100),v=Math.max(Gp,v),y=Math.max(Gp,y),j5(y,v,f,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:h}),h1(f)){let T=g1(c.getElementsIncludingDeleted(),f,s,c.getNonDeletedElementsMap());p({elementsToHighlight:T})}}}},AW=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&h1(a)){let s=g1(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),l=ek(o.scene.getElementsIncludingDeleted(),s,a,o);o.scene.replaceAllElements(l),e({elementsToHighlight:null})}},LW=({property:e,element:o,scene:t,appState:n})=>{let r=u1(e==="width"?o.width:o.height,2);if(n.croppingElementId&&n.croppingElementId===o.id&&Q5(o)&&o.crop){let{width:i,height:a}=J5(o);if(e==="width"){let s=i/o.crop.naturalWidth;r=u1(o.crop.width*s,2)}if(e==="height"){let s=a/o.crop.naturalHeight;r=u1(o.crop.height*s,2)}}return _W(ht,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:PW,value:r,editable:Gt(o,e),scene:t,appState:n,property:e,dragFinishedCallback:AW})},f1=LW;import{getBoundTextElement as DW,redrawTextBoundingBox as RW}from"@nous-excalidraw/element";import{hasBoundTextElement as NW,isTextElement as ok}from"@nous-excalidraw/element";import{jsx as zW}from"react/jsx-runtime";var tk=4,BW=4,OW=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o[0];if(a){let s=i.get(a.id);if(!s||!ok(s))return;let l;if(n!==void 0)l=Math.max(Math.round(n),tk);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,tk),t&&(l=Ve(l,BW))}l&&(r.mutateElement(s,{fontSize:l}),RW(s,r.getContainerElement(s),r))}},FW=({element:e,scene:o,appState:t,property:n})=>{let r=ok(e)?e:NW(e)?DW(e,o.getNonDeletedElementsMap()):null;return r?zW(ht,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:OW,icon:Xr,appState:t,scene:o,property:n}):null},nk=FW;import{degreesToRadians as rk,radiansToDegrees as sk}from"@nous-excalidraw/math";import{getBoundTextElement as ik}from"@nous-excalidraw/element";import{isArrowElement as ak}from"@nous-excalidraw/element";import{isInGroup as b1}from"@nous-excalidraw/element";import{jsx as WW}from"react/jsx-runtime";var HW=15,GW=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),s=o.map(c=>a.get(c.id)).filter(c=>c&&!b1(c)&&Gt(c,r)),l=o.filter(c=>!b1(c)&&Gt(c,r));if(n!==void 0){let c=rk(n);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let p=ik(d,a);p&&!ak(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(sk(p.angle)*100)/100,u=Math.round(e),f=(m+u)%360;t&&(f=Ve(f,HW)),f=f<0?f+360:f;let h=rk(f);i.mutateElement(d,{angle:h});let x=ik(d,a);x&&!ak(d)&&i.mutateElement(x,{angle:h})}i.triggerUpdate()},UW=({elements:e,scene:o,appState:t,property:n})=>{let r=e.filter(l=>!b1(l)&&Gt(l,"angle")),i=r.map(l=>Math.round(sk(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>Gt(l,"angle"));return WW(ht,{label:"A",icon:qc,value:a,elements:e,dragInputCallback:GW,editable:s,appState:t,scene:o,property:n})},lk=UW;import{pointFrom as ck}from"@nous-excalidraw/math";import{useMemo as YW}from"react";import{MIN_WIDTH_OR_HEIGHT as Ar}from"@nous-excalidraw/common";import{getElementsInResizingFrame as x1,isFrameLikeElement as E1,replaceAllElementsInFrame as pk,updateBoundElements as VW}from"@nous-excalidraw/element";import{rescalePointsInElement as XW,resizeSingleElement as dk}from"@nous-excalidraw/element";import{getBoundTextElement as KW,handleBindTextResize as $W}from"@nous-excalidraw/element";import{isTextElement as uk}from"@nous-excalidraw/element";import{jsx as eY}from"react/jsx-runtime";var xs=10,ZW=(e,o,t,n)=>{let r=n.x-e,i=n.y-o,a=n.width*t,s=n.height*t,l=e+r*t,c=o+i*t;return{width:a,height:s,x:l,y:c,...XW(n,a,s,!1),...uk(n)?{fontSize:n.fontSize*t}:{}}},jW=(e,o,t,n,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=ZW(e,o,n,i);s.mutateElement(r,c);let d=KW(i,a);if(d){let p=d.fontSize*n;VW(r,s);let m=l.get(d.id);m&&uk(m)&&(s.mutateElement(m,{fontSize:p}),$W(r,s,t==="width"?"e":"s",!0))}},mk=(e,o,t,n,r,i,a,s,l,c)=>{i==="width"?o=Math.round(e/n*100)/100:e=Math.round(o*n*100)/100;let d=o/t;for(let p=0;p<s.length;p++){let m=s[p],u=a[p];jW(r[0],r[1],i,d,u,m,l,c)}},qW=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:a,property:s,setAppState:l,app:c})=>{let d=a.getNonDeletedElementsMap(),p=fs(o,n);if(i!==void 0){for(let h of p){let x=gs(h,d,t);if(x.length>1){let E=x.map(D=>D.latest),w=x.map(D=>D.original),[y,v,T,I]=mp(w),M=T-y,S=I-v,_=M/S,A=Math.max(Ar,s==="width"?Math.max(0,i):M),P=Math.max(Ar,s==="height"?Math.max(0,i):S);mk(A,P,S,_,ck(y,v),s,E,w,t,a)}else{let[E]=x,w=E?.latest,y=E?.original;if(w&&y&&Gt(w,s)){let v=s==="width"?Math.max(0,i):w.width;s==="width"&&(r?v=Ve(v,xs):v=Math.round(v));let T=s==="height"?Math.max(0,i):w.height;if(s==="height"&&(r?T=Ve(T,xs):T=Math.round(T)),v=Math.max(Ar,v),T=Math.max(Ar,T),dk(v,T,w,y,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),E1(w)){let I=x1(a.getElementsIncludingDeleted(),w,n,a.getNonDeletedElementsMap()),M=pk(a.getElementsIncludingDeleted(),I,w,c);a.replaceAllElements(M)}}}}a.triggerUpdate();return}let m=s==="width"?e:0,u=s==="height"?e:0,f=[];for(let h of p){let x=gs(h,d,t);if(x.length>1){let E=x.map(D=>D.latest),w=x.map(D=>D.original),[y,v,T,I]=mp(w),M=T-y,S=I-v,_=M/S,A=Math.max(0,M+m);s==="width"&&(r?A=Ve(A,xs):A=Math.round(A));let P=Math.max(0,S+u);s==="height"&&(r?P=Ve(P,xs):P=Math.round(P)),A=Math.max(Ar,A),P=Math.max(Ar,P),mk(A,P,S,_,ck(y,v),s,E,w,t,a)}else{let[E]=x,w=E?.latest,y=E?.original;if(w&&y&&Gt(w,s)){let v=Math.max(0,y.width+m);s==="width"&&(r?v=Ve(v,xs):v=Math.round(v));let T=Math.max(0,y.height+u);if(s==="height"&&(r?T=Ve(T,xs):T=Math.round(T)),v=Math.max(Ar,v),T=Math.max(Ar,T),dk(v,T,w,y,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),E1(w)){let I=x1(a.getElementsIncludingDeleted(),w,n,a.getNonDeletedElementsMap());f.push(...I)}}}}l({elementsToHighlight:f}),a.triggerUpdate()},JW=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&E1(a)){let s=x1(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),l=pk(o.scene.getElementsIncludingDeleted(),s,a,o);o.scene.replaceAllElements(l),e({elementsToHighlight:null})}},QW=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=YW(()=>n.map(c=>{let d=gs(c,t);if(d.length>1){let[m,u,f,h]=mp(d.map(x=>x.latest));return Math.round((e==="width"?f-m:h-u)*100)/100}let[p]=d;return Math.round((e==="width"?p.latest.width:p.latest.height)*100)/100}),[t,n,e]),s=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",l=a.length>0;return eY(ht,{label:e==="width"?"W":"H",elements:o,dragInputCallback:qW,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:JW})},y1=QW;import{getBoundTextElement as tY,redrawTextBoundingBox as hk}from"@nous-excalidraw/element";import{hasBoundTextElement as oY,isTextElement as nY}from"@nous-excalidraw/element";import{isInGroup as rY}from"@nous-excalidraw/element";import{jsx as cY}from"react/jsx-runtime";var gk=4,iY=4,aY=(e,o)=>e.reduce((t,n)=>{if(!n||rY(n))return t;if(nY(n))return t.push(n),t;if(oY(n)){let r=tY(n,o);if(r)return t.push(r),t}return t},[]),sY=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o.map(l=>i.get(l.id)),s;if(n){s=Math.max(Math.round(n),gk);for(let l of a)r.mutateElement(l,{fontSize:s}),hk(l,r.getContainerElement(l),r);r.triggerUpdate()}else{let l=o;for(let c=0;c<a.length;c++){let d=a[c],p=l[c],m=Math.round(p.fontSize),u=Math.round(e),f=Math.max(m+u,gk);t&&(f=Ve(f,iY)),r.mutateElement(d,{fontSize:f}),hk(d,r.getContainerElement(d),r)}r.triggerUpdate()}},lY=({elements:e,scene:o,appState:t,property:n,elementsMap:r})=>{let i=aY(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 cY(ht,{label:"F",icon:Xr,elements:i,dragInputCallback:sY,value:s,editable:l,scene:o,property:n,appState:t})},fk=lY;import{pointFrom as Lr,pointRotateRads as Up}from"@nous-excalidraw/math";import{useMemo as dY}from"react";import{isTextElement as mY}from"@nous-excalidraw/element";import{getCommonBounds as w1}from"@nous-excalidraw/element";import{jsx as fY}from"react/jsx-runtime";var pY=(e,o,t,n,r,i,a)=>{for(let s=0;s<n.length;s++){let l=n[s],[c,d]=[l.x+l.width/2,l.y+l.height/2],[p,m]=Up(Lr(l.x,l.y),Lr(c,d),l.angle),u=e==="x"?Math.round(p+o):p,f=e==="y"?Math.round(m+t):m;Ei(u,f,l,i,a,r,!1)}},uY=(e,o,t,n,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=w1(t),c=e-s,d=o-l;for(let p=0;p<t.length;p++){let m=t[p],u=a.get(m.id);if(u&&(!mY(u)||!u.containerId)){let[f,h]=[u.x+u.width/2,u.y+u.height/2],[x,E]=Up(Lr(u.x,u.y),Lr(f,h),u.angle);Ei(x+c,E+d,m,r,i,n,!1)}}},hY=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a,originalAppState:s,app:l})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of fs(o,s)){let f=gs(u,c,t);if(f.length>1){let[h,x,,]=w1(f.map(y=>y.latest));uY(i==="x"?r:h,i==="y"?r:x,f.map(y=>y.original),t,a,l.state)}else{let h=f[0]?.original,x=f[0]?.latest;if(h&&x&&Gt(x,i)){let[E,w]=[h.x+h.width/2,h.y+h.height/2],[y,v]=Up(Lr(h.x,h.y),Lr(E,w),h.angle);Ei(i==="x"?r:y,i==="y"?r:v,h,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=n?Ve(e,dc):e;pY(i,i==="x"?d:0,i==="y"?d:0,o,t,a,l.state),a.triggerUpdate()},gY=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=dY(()=>n.map(l=>{let c=Object.keys(l).map(h=>t.get(h)).filter(h=>h!==void 0);if(c.length>1){let[h,x]=w1(c);return Math.round((e==="x"?h:x)*100)/100}let[d]=c,[p,m]=[d.x+d.width/2,d.y+d.height/2],[u,f]=Up(Lr(d.x,d.y),Lr(p,m),d.angle);return Math.round((e==="x"?u:f)*100)/100}),[n,t,e]),s=new Set(a).size===1?a[0]:"Mixed";return fY(ht,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:hY,value:s,property:e,scene:r,appState:i})},v1=gY;import{clamp as mc,pointFrom as Wp,pointRotateRads as xk,round as bk}from"@nous-excalidraw/math";import{getFlipAdjustedCropPosition as bY,getUncroppedWidthAndHeight as xY}from"@nous-excalidraw/element";import{isImageElement as Ek}from"@nous-excalidraw/element";import{jsx as wY}from"react/jsx-runtime";var EY=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:n,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],[f,h]=xk(Wp(p.x,p.y),Wp(m,u),p.angle);if(l.croppingElementId===p.id){let v=d.get(p.id);if(!v||!Ek(v)||!v.crop)return;let T=v.crop,I=T,M=v.scale[0]===-1,S=v.scale[1]===-1,{width:_,height:A}=xY(v);if(i!==void 0){if(a==="x"){let z=i*(T.naturalWidth/_);M?I={...T,x:mc(T.naturalWidth-z-T.width,0,T.naturalWidth-T.width)}:I={...T,x:mc(i*(T.naturalWidth/_),0,T.naturalWidth-T.width)}}a==="y"&&(I={...T,y:mc(i*(T.naturalHeight/A),0,T.naturalHeight-T.height)}),s.mutateElement(v,{crop:I});return}let P=(a==="x"?o:0)*(M?-1:1),D=(a==="y"?o:0)*(S?-1:1);I={...T,x:mc(T.x+P,0,T.naturalWidth-T.width),y:mc(T.y+D,0,T.naturalHeight-T.height)},s.mutateElement(v,{crop:I});return}if(i!==void 0){Ei(a==="x"?i:f,a==="y"?i:h,p,s,c.state,n);return}let x=a==="x"?e:0,E=a==="y"?e:0,w=a==="x"?Math.round(r?Ve(p.x+x,dc):f+x):f,y=a==="y"?Math.round(r?Ve(p.y+E,dc):h+E):h;Ei(w,y,p,s,c.state,n)},yY=({property:e,element:o,elementsMap:t,scene:n,appState:r})=>{let[i,a]=xk(Wp(o.x,o.y),Wp(o.x+o.width/2,o.y+o.height/2),o.angle),s=bk(e==="x"?i:a,2);if(r.croppingElementId===o.id&&Ek(o)&&o.crop){let l=bY(o);l&&(s=bk(e==="x"?l.x:l.y,2))}return wY(ht,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:EY,scene:n,value:s,property:e,appState:r})},T1=yY;import{Fragment as S1,jsx as ae,jsxs as Ut}from"react/jsx-runtime";var AY=50,pc=e=>{let o=jo(),t=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),r=yr(e.app);return ae(LY,{...e,appState:o,sceneNonce:t,selectedElements:n,gridModeEnabled:r})},Ge=({children:e,columns:o=1,heading:t,style:n,...r})=>ae("div",{className:vY("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...n},...r,children:e});Ge.displayName="StatsRow";var Vp=({children:e,order:o,style:t,...n})=>ae("div",{className:"exc-stats__rows",style:{order:o,...t},...n,children:e});Vp.displayName="StatsRows";pc.StatsRow=Ge;pc.StatsRows=Vp;var LY=CY(({app:e,onClose:o,renderCustomStats:t,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let s=e.scene,l=s.getNonDeletedElements(),c=s.getNonDeletedElementsMap(),d=he(),p=n.length===1?n[0]:null,m=n.length>1?n:null,u=r.croppingElementId&&C1(p),f=u?kY(p):null,[h,x]=IY({width:0,height:0}),E=I1(()=>TY(v=>{let T=SY(v);x({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},AY),[]);wk(()=>{E(l)},[i,l,E]),wk(()=>()=>E.cancel(),[E]);let w=I1(()=>fs(n,r),[n,r]),y=I1(()=>MY(n),[n]);return ae("div",{className:"exc-stats",children:Ut(Ze,{padding:3,children:[Ut("div",{className:"title",children:[ae("h2",{children:g("stats.title")}),ae("div",{className:"close",onClick:o,children:oo})]}),Ut(il,{label:ae("h3",{children:g("stats.generalStats")}),open:!!(r.stats.panels&Yp.generalStats),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^Yp.generalStats}})),children:[Ut(Vp,{children:[ae(Ge,{heading:!0,children:g("stats.scene")}),Ut(Ge,{columns:2,children:[ae("div",{children:g("stats.shapes")}),ae("div",{children:l.length})]}),Ut(Ge,{columns:2,children:[ae("div",{children:g("stats.width")}),ae("div",{children:h.width})]}),Ut(Ge,{columns:2,children:[ae("div",{children:g("stats.height")}),ae("div",{children:h.height})]}),a&&Ut(S1,{children:[ae(Ge,{heading:!0,children:"Canvas"}),ae(Ge,{children:ae($5,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!y&&n.length>0&&ae("div",{id:"elementStats",style:{marginTop:12},children:ae(il,{label:ae("h3",{children:g("stats.elementProperties")}),open:!!(r.stats.panels&Yp.elementProperties),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^Yp.elementProperties}})),children:Ut(Vp,{children:[p&&Ut(S1,{children:[u&&ae(Ge,{heading:!0,children:g("labels.unCroppedDimension")}),r.croppingElementId&&C1(p)&&f&&Ut(Ge,{columns:2,children:[ae("div",{children:g("stats.width")}),ae("div",{children:yk(f.width,2)})]}),r.croppingElementId&&C1(p)&&f&&Ut(Ge,{columns:2,children:[ae("div",{children:g("stats.height")}),ae("div",{children:yk(f.height,2)})]}),ae(Ge,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?g("labels.imageCropping"):g(`element.${p.type}`)}),ae(Ge,{children:ae(T1,{element:p,property:"x",elementsMap:c,scene:s,appState:r})}),ae(Ge,{children:ae(T1,{element:p,property:"y",elementsMap:c,scene:s,appState:r})}),ae(Ge,{children:ae(f1,{property:"width",element:p,scene:s,appState:r})}),ae(Ge,{children:ae(f1,{property:"height",element:p,scene:s,appState:r})}),ae(Ge,{children:ae(X5,{property:"angle",element:p,scene:s,appState:r})}),ae(Ge,{children:ae(nk,{property:"fontSize",element:p,scene:s,appState:r})})]}),m&&Ut(S1,{children:[PY(m)&&ae(Ge,{heading:!0,children:g("element.group")}),Ut(Ge,{columns:2,style:{margin:"0.3125rem 0"},children:[ae("div",{children:g("stats.shapes")}),ae("div",{children:n.length})]}),ae(Ge,{children:ae(v1,{property:"x",elements:m,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ae(Ge,{children:ae(v1,{property:"y",elements:m,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ae(Ge,{children:ae(y1,{property:"width",elements:m,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ae(Ge,{children:ae(y1,{property:"height",elements:m,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ae(Ge,{children:ae(lk,{property:"angle",elements:m,scene:s,appState:r})}),ae(Ge,{children:ae(fk,{property:"fontSize",elements:m,scene:s,appState:r,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as _Y,useEffect as vk,useState as Tk}from"react";import{normalizeLink as DY,KEYS as k1}from"@nous-excalidraw/common";import{defaultGetElementLinkFromSelection as RY,getLinkIdAndTypeFromSelection as NY}from"@nous-excalidraw/element";import{jsx as Es,jsxs as Xp}from"react/jsx-runtime";var BY=({sourceElementId:e,onClose:o,appState:t,scene:n,generateLinkForSelection:r=RY})=>{let i=n.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=Tk(a),[c,d]=Tk(!1);vk(()=>{let m=ie(i,t),u=a;if(m.length>0&&r){let f=NY(m,t);f&&(u=DY(r(f.id,f.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let p=_Y(()=>{if(s&&s!==i.get(e)?.link){let m=i.get(e);m&&n.mutateElement(m,{link:s})}if(!s&&c&&e){let m=i.get(e);m&&n.mutateElement(m,{link:null})}o?.()},[e,s,i,c,n,o]);return vk(()=>{let m=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===k1.ENTER&&p(),t.openDialog?.name==="elementLinkSelector"&&u.key===k1.ESCAPE&&o?.()};return window.addEventListener("keydown",m),()=>{window.removeEventListener("keydown",m)}},[t,o,p]),Xp("div",{className:"ElementLinkDialog",children:[Xp("div",{className:"ElementLinkDialog__header",children:[Es("h2",{children:g("elementLink.title")}),Es("p",{children:g("elementLink.desc")})]}),Xp("div",{className:"ElementLinkDialog__input",children:[Es(ur,{value:s??"",onChange:m=>{c||d(!0),l(m)},onKeyDown:m=>{m.key===k1.ENTER&&p()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&Es(q,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:ft})]}),Xp("div",{className:"ElementLinkDialog__actions",children:[Es(Ln,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Es(Ln,{label:g("buttons.confirm"),onClick:p,actionType:"primary"})]})]})},Ik=BY;import OY,{useState as FY}from"react";import{Fragment as zY,jsx as M1}from"react/jsx-runtime";var Ck=({children:e,onClose:o})=>{let[t,n]=FY(!!e),{container:r}=Ne(),i=OY.useCallback(()=>{n(!1),o&&o(),r?.focus()},[o,r]);return M1(zY,{children:t&&M1(qe,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:M1("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import HY from"react";import{isDarwin as Sk,isFirefox as kk,isWindows as GY}from"@nous-excalidraw/common";import{KEYS as Xe}from"@nous-excalidraw/common";import{Fragment as Pk,jsx as U,jsxs as eo}from"react/jsx-runtime";var UY=()=>eo("div",{className:"HelpDialog__header",children:[eo("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[U("div",{className:"HelpDialog__link-icon",children:Du}),g("helpDialog.documentation")]}),eo("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[U("div",{className:"HelpDialog__link-icon",children:Du}),g("helpDialog.blog")]}),eo("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[U("div",{className:"HelpDialog__link-icon",children:Xc}),g("helpDialog.github")]}),eo("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[U("div",{className:"HelpDialog__link-icon",children:sy}),"YouTube"]})]}),WY=e=>eo(Pk,{children:[U("h3",{children:e.title}),U("div",{className:"HelpDialog__islands-container",children:e.children})]}),P1=e=>eo("div",{className:`HelpDialog__island ${e.className}`,children:[U("h4",{className:"HelpDialog__island-title",children:e.caption}),U("div",{className:"HelpDialog__island-content",children:e.children})]});function*YY(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var VY=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),X=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>U(XY,{children:VY(a)},a)));return eo("div",{className:"HelpDialog__shortcut",children:[U("div",{children:e}),U("div",{className:"HelpDialog__key-container",children:[...YY(n,t?g("helpDialog.or"):null)]})]})},XY=e=>U("kbd",{className:"HelpDialog__key",...e}),Mk=({onClose:e})=>{let o=HY.useCallback(()=>{e&&e()},[e]);return U(Pk,{children:eo(qe,{onCloseRequest:o,title:g("helpDialog.title"),className:"HelpDialog",children:[U(UY,{}),eo(WY,{title:g("helpDialog.shortcuts"),children:[eo(P1,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[U(X,{label:g("toolBar.hand"),shortcuts:[Xe.H]}),U(X,{label:g("toolBar.selection"),shortcuts:[Xe.V,Xe[1]]}),U(X,{label:g("toolBar.rectangle"),shortcuts:[Xe.R,Xe[2]]}),U(X,{label:g("toolBar.diamond"),shortcuts:[Xe.D,Xe[3]]}),U(X,{label:g("toolBar.triangle"),shortcuts:[Xe.G]}),U(X,{label:g("toolBar.ellipse"),shortcuts:[Xe.O,Xe[4]]}),U(X,{label:g("toolBar.arrow"),shortcuts:[Xe.A,Xe[5]]}),U(X,{label:g("toolBar.line"),shortcuts:[Xe.L,Xe[6]]}),U(X,{label:g("toolBar.freedraw"),shortcuts:[Xe.P,Xe[7]]}),U(X,{label:g("toolBar.text"),shortcuts:[Xe.T,Xe[8]]}),U(X,{label:g("toolBar.image"),shortcuts:[Xe[9]]}),U(X,{label:g("toolBar.eraser"),shortcuts:[Xe.E,Xe[0]]}),U(X,{label:g("toolBar.frame"),shortcuts:[Xe.F]}),U(X,{label:g("toolBar.laser"),shortcuts:[Xe.K]}),U(X,{label:g("labels.eyeDropper"),shortcuts:[Xe.I,"Shift+S","Shift+G"]}),U(X,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[B("CtrlOrCmd+Enter")]}),U(X,{label:g("helpDialog.editText"),shortcuts:[B("Enter")]}),U(X,{label:g("helpDialog.textNewLine"),shortcuts:[B("Enter"),B("Shift+Enter")]}),U(X,{label:g("helpDialog.textFinish"),shortcuts:[B("Esc"),B("CtrlOrCmd+Enter")]}),U(X,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),U(X,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),U(X,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),B("Enter")],isOr:!0}),U(X,{label:g("helpDialog.cropFinish"),shortcuts:[B("Enter"),B("Escape")],isOr:!0}),U(X,{label:g("toolBar.lock"),shortcuts:[Xe.Q]}),U(X,{label:g("helpDialog.preventBinding"),shortcuts:[B("CtrlOrCmd")]}),U(X,{label:g("toolBar.link"),shortcuts:[B("CtrlOrCmd+K")]}),U(X,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),eo(P1,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[U(X,{label:g("buttons.zoomIn"),shortcuts:[B("CtrlOrCmd++")]}),U(X,{label:g("buttons.zoomOut"),shortcuts:[B("CtrlOrCmd+-")]}),U(X,{label:g("buttons.resetZoom"),shortcuts:[B("CtrlOrCmd+0")]}),U(X,{label:g("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),U(X,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),U(X,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),U(X,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),U(X,{label:g("buttons.zenMode"),shortcuts:[B("Alt+Z")]}),U(X,{label:g("buttons.objectsSnapMode"),shortcuts:[B("Alt+S")]}),U(X,{label:g("labels.toggleGrid"),shortcuts:[B("CtrlOrCmd+'")]}),U(X,{label:g("labels.viewMode"),shortcuts:[B("Alt+R")]}),U(X,{label:g("labels.toggleTheme"),shortcuts:[B("Alt+Shift+D")]}),U(X,{label:g("stats.fullTitle"),shortcuts:[B("Alt+/")]}),U(X,{label:g("search.title"),shortcuts:[De("searchMenu")]}),U(X,{label:g("commandPalette.title"),shortcuts:kk?[De("commandPalette")]:[De("commandPalette"),De("commandPalette",1)]})]}),eo(P1,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[U(X,{label:g("helpDialog.createFlowchart"),shortcuts:[B("CtrlOrCmd+Arrow Key")],isOr:!0}),U(X,{label:g("helpDialog.navigateFlowchart"),shortcuts:[B("Alt+Arrow Key")],isOr:!0}),U(X,{label:g("labels.moveCanvas"),shortcuts:[B(`Space+${g("helpDialog.drag")}`),B(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),U(X,{label:g("buttons.clearReset"),shortcuts:[B("CtrlOrCmd+Delete")]}),U(X,{label:g("labels.delete"),shortcuts:[B("Delete")]}),U(X,{label:g("labels.cut"),shortcuts:[B("CtrlOrCmd+X")]}),U(X,{label:g("labels.copy"),shortcuts:[B("CtrlOrCmd+C")]}),U(X,{label:g("labels.paste"),shortcuts:[B("CtrlOrCmd+V")]}),U(X,{label:g("labels.pasteAsPlaintext"),shortcuts:[B("CtrlOrCmd+Shift+V")]}),U(X,{label:g("labels.selectAll"),shortcuts:[B("CtrlOrCmd+A")]}),U(X,{label:g("labels.multiSelect"),shortcuts:[B(`Shift+${g("helpDialog.click")}`)]}),U(X,{label:g("helpDialog.deepSelect"),shortcuts:[B(`CtrlOrCmd+${g("helpDialog.click")}`)]}),U(X,{label:g("helpDialog.deepBoxSelect"),shortcuts:[B(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(ha||kk)&&U(X,{label:g("labels.copyAsPng"),shortcuts:[B("Shift+Alt+C")]}),U(X,{label:g("labels.copyStyles"),shortcuts:[B("CtrlOrCmd+Alt+C")]}),U(X,{label:g("labels.pasteStyles"),shortcuts:[B("CtrlOrCmd+Alt+V")]}),U(X,{label:g("labels.sendToBack"),shortcuts:[Sk?B("CtrlOrCmd+Alt+["):B("CtrlOrCmd+Shift+[")]}),U(X,{label:g("labels.bringToFront"),shortcuts:[Sk?B("CtrlOrCmd+Alt+]"):B("CtrlOrCmd+Shift+]")]}),U(X,{label:g("labels.sendBackward"),shortcuts:[B("CtrlOrCmd+[")]}),U(X,{label:g("labels.bringForward"),shortcuts:[B("CtrlOrCmd+]")]}),U(X,{label:g("labels.alignTop"),shortcuts:[B("CtrlOrCmd+Shift+Up")]}),U(X,{label:g("labels.alignBottom"),shortcuts:[B("CtrlOrCmd+Shift+Down")]}),U(X,{label:g("labels.alignLeft"),shortcuts:[B("CtrlOrCmd+Shift+Left")]}),U(X,{label:g("labels.alignRight"),shortcuts:[B("CtrlOrCmd+Shift+Right")]}),U(X,{label:g("labels.duplicateSelection"),shortcuts:[B("CtrlOrCmd+D"),B(`Alt+${g("helpDialog.drag")}`)]}),U(X,{label:g("helpDialog.toggleElementLock"),shortcuts:[B("CtrlOrCmd+Shift+L")]}),U(X,{label:g("buttons.undo"),shortcuts:[B("CtrlOrCmd+Z")]}),U(X,{label:g("buttons.redo"),shortcuts:GY?[B("CtrlOrCmd+Y"),B("CtrlOrCmd+Shift+Z")]:[B("CtrlOrCmd+Shift+Z")]}),U(X,{label:g("labels.group"),shortcuts:[B("CtrlOrCmd+G")]}),U(X,{label:g("labels.ungroup"),shortcuts:[B("CtrlOrCmd+Shift+G")]}),U(X,{label:g("labels.flipHorizontal"),shortcuts:[B("Shift+H")]}),U(X,{label:g("labels.flipVertical"),shortcuts:[B("Shift+V")]}),U(X,{label:g("labels.showStroke"),shortcuts:[B("S")]}),U(X,{label:g("labels.showBackground"),shortcuts:[B("G")]}),U(X,{label:g("labels.showFonts"),shortcuts:[B("Shift+F")]}),U(X,{label:g("labels.decreaseFontSize"),shortcuts:[B("CtrlOrCmd+Shift+<")]}),U(X,{label:g("labels.increaseFontSize"),shortcuts:[B("CtrlOrCmd+Shift+>")]})]})]})]})})};import{CANVAS_SEARCH_TAB as KY,DEFAULT_SIDEBAR as $Y}from"@nous-excalidraw/common";import{isFlowchartNodeElement as ZY,isImageElement as Ak,isLinearElement as Lk,isLineElement as jY,isTextBindableContainer as qY,isTextElement as JY}from"@nous-excalidraw/element";import{isNodeInFlowchart as QY}from"@nous-excalidraw/element";import{jsx as A1}from"react/jsx-runtime";var ke=e=>Array.isArray(e)?`<kbd>${e.map(B).join(" + ")}</kbd>`:`<kbd>${B(e)}</kbd>`,eV=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar?.name===$Y.name&&e.openSidebar.tab===KY&&e.searchMatches?.matches.length)return g("hints.dismissSearch",{shortcut:ke("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(Ot(e))return g("hints.eraserRevert",{shortcut:ke("Alt")});let c=n.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return g("hints.arrowBindModifiers",{shortcut_1:ke("Ctrl"),shortcut_2:ke("Alt")});if(r.type==="arrow"||r.type==="line")return l?g("hints.linearElementMulti",{shortcut_1:ke("Escape"),shortcut_2:ke("Enter")}):r.type==="arrow"?g("hints.arrowTool",{shortcut:ke("A")}):g("hints.linearElement");if(r.type==="freedraw")return g("hints.freeDraw");if(r.type==="text")return g("hints.text");if(r.type==="embeddable")return g("hints.embeddable");if(i&&s==="mouse"&&c.length===1){let d=c[0];return Lk(d)&&d.points.length===2?g("hints.lockAngle",{shortcut:ke("Shift")}):Ak(d)?g("hints.resizeImage",{shortcut_1:ke("Shift"),shortcut_2:ke("Alt")}):g("hints.resize",{shortcut_1:ke("Shift"),shortcut_2:ke("Alt")})}if(a&&s==="mouse")return g("hints.rotate",{shortcut:ke("Shift")});if(c.length===1&&JY(c[0]))return g("hints.text_selected",{shortcut:ke("Enter")});if(e.editingTextElement)return g("hints.text_editing",{shortcut_1:ke("Escape"),shortcut_2:ke(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return g("hints.leaveCropEditor",{shortcut_1:ke("Enter"),shortcut_2:ke("Escape")});if(c.length===1&&Ak(c[0]))return g("hints.enterCropEditor",{shortcut:ke("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return g("hints.deepBoxSelect",{shortcut:ke("CtrlOrCmd")});if(yr(n)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping",{shortcut:ke("CtrlOrCmd")});if(!c.length&&!o)return g("hints.canvasPanning",{shortcut_1:ke(g("keys.mmb")),shortcut_2:ke("Space")});if(c.length===1){if(Lk(c[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected",{shortcut_1:ke("Delete"),shortcut_2:ke(["CtrlOrCmd","D"])}):g("hints.lineEditor_nothingSelected",{shortcut_1:ke("Shift"),shortcut_2:ke("Alt")}):jY(c[0])?g("hints.lineEditor_line_info",{shortcut:ke("Enter")}):g("hints.lineEditor_info",{shortcut_1:ke("CtrlOrCmd"),shortcut_2:ke(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&qY(c[0])){let d=g("hints.bindTextToElement",{shortcut:ke("Enter")}),p=g("hints.createFlowchart",{shortcut:ke(["CtrlOrCmd","\u2191\u2193"])});return ZY(c[0])?QY(c[0],n.scene.getNonDeletedElementsMap())?[d,p]:[d,p]:d}}}return null},_k=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let r=eV({appState:e,isMobile:o,editorInterface:t,app:n});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 A1("kbd",{children:c?c[1]:s},l)}return s});return A1("div",{className:"HintViewer",children:A1("span",{children:a})})};import{useEffect as Nk,useRef as Bk,useState as yi}from"react";import{DEFAULT_EXPORT_PADDING as aV,EXPORT_IMAGE_TYPES as L1,isFirefox as sV,EXPORT_SCALES as lV,cloneJSON as Ok}from"@nous-excalidraw/common";import{useCallback as tV,useRef as oV,useState as nV}from"react";var rV=2e3,Dk=()=>{let[e,o]=nV(null),t=oV(0),n=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},rV)},r=tV(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import iV from"clsx";import{jsx as Rk}from"react/jsx-runtime";var uc=({title:e,name:o,checked:t,onChange:n,disabled:r=!1})=>Rk("div",{className:iV("Switch",{toggled:t,disabled:r}),children:Rk("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>n(!t),onKeyDown:i=>{i.key===" "&&n(!t)}})});import{jsx as Ue,jsxs as _r}from"react/jsx-runtime";var cV=()=>_r("div",{children:[Ue("h3",{children:g("canvasError.cannotShowPreview")}),Ue("p",{children:Ue("span",{children:g("canvasError.canvasTooBig")})}),_r("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),dV=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:n,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=Ae(o,e),[l,c]=yi(i),[d,p]=yi(s),[m,u]=yi(e.exportBackground),[f,h]=yi(e.exportEmbedScene),[x,E]=yi(e.exportScale),w=Bk(null),y=Bk(0),[v,T]=yi(null),{onCopy:I,copyStatus:M,resetCopyStatus:S}=Dk();Nk(()=>{S()},[l,m,a,x,f,S]);let{exportedElements:_,exportingFrame:A}=qr(o,e,d);return Nk(()=>{let P=w.current;if(!P)return;let D=P.offsetWidth,z=P.offsetHeight;if(!D)return;let K=++y.current,W=()=>K!==y.current;return dr({elements:_,appState:{...e,name:l,exportBackground:m,exportWithDarkMode:a,exportScale:x,exportEmbedScene:f},files:t,exportPadding:aV,maxWidthOrHeight:Math.max(D,z),exportingFrame:A}).then(async Y=>{if(!W()){try{await Ur(Y)}catch(G){throw G.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):G}W()||(T(null),P.replaceChildren(Y))}}).catch(Y=>{W()||(console.error(Y),T(Y))}),()=>{y.current+=1}},[e,t,_,A,l,m,a,x,f]),_r("div",{className:"ImageExportModal",children:[Ue("h3",{children:g("imageExportDialog.header")}),_r("div",{className:"ImageExportModal__preview",children:[Ue("div",{className:"ImageExportModal__preview__canvas",ref:w,children:v&&Ue(cV,{})}),Ue("div",{className:"ImageExportModal__preview__filename",children:!Ai&&Ue("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:P=>{c(P.target.value),n.executeAction(jh,"ui",P.target.value)}})})]}),_r("div",{className:"ImageExportModal__settings",children:[Ue("h3",{children:g("imageExportDialog.header")}),s&&Ue(hc,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ue(uc,{name:"exportOnlySelected",checked:d,onChange:P=>{p(P)}})}),Ue(hc,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ue(uc,{name:"exportBackgroundSwitch",checked:m,onChange:P=>{u(P),n.executeAction(qh,"ui",P)}})}),Ue(hc,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ue(uc,{name:"exportDarkModeSwitch",checked:a,onChange:P=>{n.executeAction(cv,"ui",P)}})}),Ue(hc,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ue(uc,{name:"exportEmbedSwitch",checked:f,onChange:P=>{h(P),n.executeAction(Ud,"ui",P)}})}),Ue(hc,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Ue(xp,{name:"exportScale",value:x,onChange:P=>{E(P),n.executeAction(sv,"ui",P)},choices:lV.map(P=>({value:P,label:`${P}\xD7`}))})}),_r("div",{className:"ImageExportModal__settings__buttons",children:[Ue(go,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>r(L1.png,_,{exportingFrame:A}),icon:ju,children:g("imageExportDialog.button.exportToPng")}),Ue(go,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>r(L1.svg,_,{exportingFrame:A}),icon:ju,children:g("imageExportDialog.button.exportToSvg")}),(ha||sV)&&Ue(go,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:M,onClick:async()=>{await r(L1.clipboard,_,{exportingFrame:A}),I()},icon:$i,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},hc=({label:e,children:o,tooltip:t,name:n})=>_r("div",{className:"ImageExportModal__settings__setting",title:e,children:[_r("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ue($t,{label:t,long:!0,children:zE})]}),Ue("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),Fk=({elements:e,appState:o,files:t,actionManager:n,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=yi(()=>({appStateSnapshot:Ok(o),elementsSnapshot:Ok(e)}));return Ue(qe,{onCloseRequest:i,size:"wide",title:!1,children:Ue(dV,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:n,onExportImage:r,name:a,exportWithDarkMode:o.exportWithDarkMode})})};import pV from"react";import{getFrame as uV}from"@nous-excalidraw/common";import{jsx as mV}from"react/jsx-runtime";var _1={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"}},D1=({children:e,color:o})=>mV("div",{className:"Card",style:{"--card-color":_1[o].base,"--card-color-darker":_1[o].darker,"--card-color-darkest":_1[o].darkest},children:e});import{Fragment as gV,jsx as Fo,jsxs as Kp}from"react/jsx-runtime";var hV=({elements:e,appState:o,setAppState:t,files:n,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return Fo("div",{className:"ExportDialog ExportDialog--json",children:Kp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Kp(D1,{color:"lime",children:[Fo("div",{className:"Card-icon",children:W0}),Fo("h2",{children:g("exportDialog.disk_title")}),Kp("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!Ai&&r.renderAction("changeProjectName")]}),Fo(q,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(ul,"ui")}})]}),l&&Kp(D1,{color:"pink",children:[Fo("div",{className:"Card-icon",children:Ws}),Fo("h2",{children:g("exportDialog.link_title")}),Fo("div",{className:"Card-details",children:g("exportDialog.link_details")}),Fo(q,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{me("export","link",`ui (${uV()})`),await l(e,o,n),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,n,a)]})})},zk=({elements:e,appState:o,files:t,actionManager:n,exportOpts:r,canvas:i,setAppState:a})=>{let s=pV.useCallback(()=>{a({openDialog:null})},[a]);return Fo(gV,{children:o.openDialog?.name==="jsonExport"&&Fo(qe,{onCloseRequest:s,title:g("buttons.export"),children:Fo(hV,{elements:e,appState:o,setAppState:a,files:t,actionManager:n,onCloseRequest:s,exportOpts:r,canvas:i})})})};import fV from"clsx";import{jsx as Hk,jsxs as xV}from"react/jsx-runtime";var bV="small",Gk=e=>xV("label",{className:fV("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${bV}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Hk("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),Hk("div",{className:"ToolIcon__icon",children:Zo})]});import{Fragment as Yk,jsx as te,jsxs as Wt}from"react/jsx-runtime";var SV=({UIOptions:e})=>Wt(It,{__fallback:!0,children:[te(It.DefaultItems.LoadScene,{}),te(It.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&te(It.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&te(It.DefaultItems.SaveAsImage,{}),te(It.DefaultItems.SearchMenu,{}),te(It.DefaultItems.Help,{}),te(It.DefaultItems.ClearCanvas,{}),te(It.Separator,{}),te(It.Group,{title:"Excalidraw links",children:te(It.DefaultItems.Socials,{})}),te(It.Separator,{}),te(It.DefaultItems.ToggleTheme,{}),te(It.DefaultItems.ChangeCanvasBackground,{})]}),kV=()=>Wt(vp,{__fallback:!0,children:[te(vp.Actions.SaveToDisk,{}),te(vp.Actions.ExportToImage,{})]}),MV=({actionManager:e,appState:o,files:t,setAppState:n,elements:r,canvas:i,onLockToggle:a,onHandToolToggle:s,onPenModeToggle:l,showExitZenModeBtn:c,renderTopLeftUI:d,renderTopRightUI:p,renderCustomStats:m,UIOptions:u,onExportImage:f,renderWelcomeScreen:h,children:x,app:E,isCollaborating:w,generateLinkForSelection:y})=>{let v=be(),I=dt()==="compact",M=DT(),S=I?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},_=M.tunnelsJotai.Provider,[A,P]=Q(Jn),D=()=>u.canvasActions.export?te(zk,{elements:r,appState:o,files:t,actionManager:e,exportOpts:u.canvasActions.export,canvas:i,setAppState:n}):null,z=()=>!u.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:te(Fk,{elements:r,appState:o,files:t,actionManager:e,onExportImage:f,onCloseRequest:()=>n({openDialog:null}),name:E.getName()}),K=()=>Wt("div",{style:{position:"relative"},children:[te(M.MainMenuTunnel.Out,{}),h&&te(M.WelcomeScreenMenuHintTunnel.Out,{})]}),W=()=>{let ee=I;return te(Jl,{heading:"selectedShapeActions",className:wi("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:ee?te(Ze,{className:wi("compact-shape-actions-island"),padding:0,style:{maxHeight:`${o.height-166}px`},children:te($T,{appState:o,elementsMap:E.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:E,setAppState:n})}):te(Ze,{className:yV.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:te(WT,{appState:o,elementsMap:E.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:E})})})},Y=()=>{let ee=IV(o,r),R=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return te(sp,{side:"top",children:Wt("div",{className:"App-menu App-menu_top",children:[Wt(Tt.Col,{gap:S.menuTopGap,className:wi("App-menu_top__left"),children:[K(),te("div",{className:wi("selected-shape-actions-container",{"selected-shape-actions-container--compact":I}),children:ee&&W()})]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&te(Jl,{heading:"shapes",className:"shapes-section",children:F=>Wt("div",{style:{position:"relative"},children:[h&&te(M.WelcomeScreenToolbarHintTunnel.Out,{}),te(Tt.Col,{gap:S.toolbarColGap,align:"start",children:Wt(Tt.Row,{gap:S.toolbarRowGap,className:wi("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Wt(Ze,{padding:S.islandPadding,className:wi("App-toolbar",{"zen-mode":o.zenModeEnabled,"App-toolbar--compact":I}),children:[te(_k,{appState:o,isMobile:v.formFactor==="phone",editorInterface:v,app:E}),F,Wt(Tt.Row,{gap:S.toolbarInnerRowGap,children:[te(lp,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>l(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),te(PS,{checked:o.activeTool.locked,onChange:a,title:g("toolBar.lock")}),te("div",{className:"App-toolbar__divider"}),te(jT,{setAppState:n,activeTool:o.activeTool,UIOptions:u,app:E})]})]}),w&&te(Ze,{style:{marginLeft:S.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:te(Gk,{title:g("toolBar.laser"),checked:o.activeTool.type===Uk.laser,onChange:()=>E.setActiveTool({type:Uk.laser}),isMobile:!0})})]})})]})}),Wt("div",{className:wi("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled,"layer-ui__wrapper__top-right--compact":I}),children:[o.collaborators.size>0&&te(fp,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),p?.(v.formFactor==="phone",o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!J||o.openSidebar?.name!==R1.name)&&te(M.DefaultSidebarTriggerTunnel.Out,{}),R&&te(pc,{app:E,onClose:()=>{e.executeAction(cr)},renderCustomStats:m})]})]})})},G=()=>te(Cp,{__fallback:!0,onDock:ee=>{me("sidebar",`toggleDock (${ee?"dock":"undock"})`,`(${v.formFactor==="phone"?"mobile":"desktop"})`)}}),J=Di(Ql),$=Wt(Yk,{children:[x,te(SV,{UIOptions:u}),te(Cp.Trigger,{__fallback:!0,icon:gy,title:vV(g("toolBar.library")),onToggle:ee=>{ee&&me("sidebar",`${R1.name} (open)`,`button (${v.formFactor==="phone"?"mobile":"desktop"})`)},tab:R1.defaultTab}),te(kV,{}),o.openDialog?.name==="ttd"&&te(Op,{__fallback:!0}),o.errorMessage&&te(Ck,{onClose:()=>n({errorMessage:null}),children:o.errorMessage}),A&&v.formFactor!=="phone"&&te(_y,{colorPickerType:A.colorPickerType,onCancel:()=>{P(null)},onChange:(ee,R,F,{altKey:ne})=>{if(!(ee!=="elementBackground"&&ee!=="elementStroke"))if(F.length){for(let ue of F)TV(ue,wV(r),{[ne&&A.swapPreviewOnAlt?ee==="elementBackground"?"strokeColor":"backgroundColor":ee==="elementBackground"?"backgroundColor":"strokeColor"]:R}),CV.delete(ue);E.scene.triggerUpdate()}else n(ee==="elementBackground"?{currentItemBackgroundColor:R}:{currentItemStrokeColor:R})},onSelect:(ee,R)=>{P(F=>F?.keepOpenOnAlt&&R.altKey?F:null),A?.onSelect?.(ee,R)}}),o.openDialog?.name==="help"&&te(Mk,{onClose:()=>{n({openDialog:null})}}),te(tI,{}),o.openDialog?.name==="elementLinkSelector"&&te(Ik,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:E.scene,appState:o,generateLinkForSelection:y}),te(M.OverwriteConfirmDialogTunnel.Out,{}),z(),D(),o.openDialog?.name==="charts"&&te(VS,{data:o.openDialog.data,rawText:o.openDialog.rawText,onClose:()=>n({openDialog:null})}),v.formFactor==="phone"&&te(BS,{app:E,appState:o,elements:r,actionManager:e,renderJSONExportDialog:D,renderImageExportDialog:z,setAppState:n,onHandToolToggle:s,onPenModeToggle:l,renderTopLeftUI:d,renderTopRightUI:p,renderSidebars:G,renderWelcomeScreen:h,UIOptions:u}),v.formFactor!=="phone"&&Wt(Yk,{children:[Wt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&J&&v.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[h&&te(M.WelcomeScreenCenterTunnel.Out,{}),Y(),te(jS,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:h}),(o.toast||o.scrolledOutside)&&Wt("div",{className:"floating-status-stack",children:[o.toast&&te(Bd,{message:o.toast.message,onClose:()=>n({toast:null}),duration:o.toast.duration,closable:o.toast.closable}),!o.toast&&o.scrolledOutside&&te("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(ee=>({...Hr(r,ee)}))},children:g("buttons.scrollBackToContent")})]})]}),G()]})]});return te(mh.Provider,{value:o,children:te(_,{children:te(mf.Provider,{value:M,children:$})})})},Wk=e=>{let{startBoundElement:o,cursorButton:t,scrollX:n,scrollY:r,...i}=e;return i},PV=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:n,...r}=e,{canvas:i,appState:a,...s}=o;return $p(Wk(n),Wk(a),{selectedElementIds:$p,selectedGroupIds:$p})&&$p(r,s)},Vk=EV.memo(MV,PV);import AV from"clsx";import{jsx as Xk,jsxs as _V}from"react/jsx-runtime";var LV="small",Zp=e=>_V("label",{className:AV("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${LV}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Xk("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),Xk("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as DV,useRef as RV}from"react";import{jsx as Kk}from"react/jsx-runtime";var $k=({trails:e})=>{let o=RV(null);return DV(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),Kk("div",{className:"SVGLayer",children:Kk("svg",{ref:o})})};import _X,{useEffect as DX,useRef as bM}from"react";import{CURSOR_TYPE as xM,isShallowEqual as RX,sceneCoordsToViewportCoords as NX}from"@nous-excalidraw/common";import{clamp as F1,pointFrom as Je,pointsEqual as GV,bezierEquation as jp,pointRotateRads as wt,pointDistance as UV}from"@nous-excalidraw/math";import{arrayToMap as WV,BIND_MODE_TIMEOUT as gc,DEFAULT_TRANSFORM_HANDLE_SPACING as iM,FRAME_STYLE as to,getFontString as YV,getFeatureFlag as VV,getVerticalOffset as XV,invariant as Qk,THEME as Dr}from"@nous-excalidraw/common";import{deconstructDiamondElement as z1,deconstructTriangleElement as H1,deconstructRectanguloidElement as aM,elementCenterPoint as Rr,getDiamondBaseCorners as KV,getTriangleBaseCorners as $V,FOCUS_POINT_SIZE as ZV,getOmitSidesForEditorInterface as G1,getTransformHandles as jV,getTransformHandlesFromCoords as qV,getCornerRadius as JV,getDiamondPoints as QV,getTrianglePoints as eX,getFreedrawOutlinePoints as tX,getLineHeightInPx as oX,hasBoundingBox as U1,hitElementItself as nX,isHoverNativeOutlineShapeElement as rX,isArrowElement as iX,isBindableElement as sM,isElbowArrow as ys,isEmbeddableElement as qp,isFrameLikeElement as hn,isImageElement as W1,isLinearElement as Y1,isLineElement as aX,maxBindingDistance_simple as sX,isTextElement as V1,LinearElementEditor as zo,getActiveTextElement as lX}from"@nous-excalidraw/element";import{renderSelectionElement as cX}from"@nous-excalidraw/element";import{getElementsInGroup as X1,getSelectedGroupIds as dX,isSelectedViaGroup as lM,selectGroupsFromGivenElements as mX}from"@nous-excalidraw/element";import{getCommonBounds as K1,getElementAbsoluteCoords as fc}from"@nous-excalidraw/element";import{getGlobalFixedPointForBindableElement as eM,isFocusPointVisible as pX}from"@nous-excalidraw/element";import{pointFrom as Ct}from"@nous-excalidraw/math";import{THEME as NV}from"@nous-excalidraw/common";var BV="#ff6b6b",OV="#ff0000",Zk=1,jk=2,qk=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===NV.LIGHT||o.zenModeEnabled?BV:OV,n=(o.zenModeEnabled?Zk*1.5:Zk)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let r of o.snapLines)r.type==="pointer"?(e.lineWidth=n,e.strokeStyle=t,zV(r,e,o)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=t,HV(r.points[0],r.points[1],r.direction,o,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=t,FV(r,e,o));e.restore()},FV=(e,o,t)=>{if(!t.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];Eo(n,r,o)}for(let n of e.points)Jk(n,t,o)},zV=(e,o,t)=>{Jk(e.points[0],t,o),t.zenModeEnabled||Eo(e.points[0],e.points[1],o)},Jk=([e,o],t,n)=>{n.save();let r=(t.zenModeEnabled?jk*1.5:jk)/t.zoom.value;n.beginPath(),n.moveTo(e-r,o-r),n.lineTo(e+r,o+r),n.moveTo(e+r,o-r),n.lineTo(e-r,o+r),n.stroke(),n.restore()},Eo=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},HV=(e,o,t,n,r)=>{let i=8/n.zoom.value,a=i/2,s=i/4;if(t==="horizontal"){let l=[(e[0]+o[0])/2,e[1]];n.zenModeEnabled||Eo(Ct(e[0],e[1]-i),Ct(e[0],e[1]+i),r),Eo(Ct(l[0]-s,l[1]-a),Ct(l[0]-s,l[1]+a),r),Eo(Ct(l[0]+s,l[1]-a),Ct(l[0]+s,l[1]+a),r),n.zenModeEnabled||(Eo(Ct(o[0],o[1]-i),Ct(o[0],o[1]+i),r),Eo(e,o,r))}else{let l=[e[0],(e[1]+o[1])/2];n.zenModeEnabled||Eo(Ct(e[0]-i,e[1]),Ct(e[0]+i,e[1]),r),Eo(Ct(l[0]-a,l[1]-s),Ct(l[0]+a,l[1]-s),r),Eo(Ct(l[0]-a,l[1]+s),Ct(l[0]+a,l[1]+s),r),n.zenModeEnabled||(Eo(Ct(o[0]-i,o[1]),Ct(o[0]+i,o[1]),r),Eo(e,o,r))}};var uX=(e,o)=>{Qk(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;Qk(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),$1(t,e,o),e.restore()},hX=(e,o,t)=>{let{elementId:n,hoverPointIndex:r}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(r)||o.selectedLinearElement?.isDragging)return;let i=zo.getElement(n,t);if(!i)return;let a=zo.getPointAtIndexGlobalCoordinates(i,r,t);e.save(),e.translate(o.scrollX,o.scrollY),$1(a,e,o),e.restore()},$1=(e,o,t)=>{o.fillStyle="rgba(143, 106, 239, 0.4)",Ns(o,e[0],e[1],zo.POINT_HANDLE_SIZE/t.zoom.value,!1)},gX=(e,o,t)=>{e.save(),e.translate(o.scrollX,o.scrollY),$1(t,e,o),e.restore()},N1=(e,o,t,n,r,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",r?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Ns(e,t[0],t[1],(a?n*(o.selectedLinearElement?.isEditing?1.5:2):n)/o.zoom.value,!i,!a||r)},fX=(e,o,t,n,r)=>{let i=o.element.frameId&&t.get(o.element.frameId);switch(i&&hn(i)&&(e.translate(i.x,i.y),e.beginPath(),to.radius&&e.roundRect?e.roundRect(-1,-1,i.width+1,i.height+1,to.radius/n.zoom.value):e.rect(-1,-1,i.width+1,i.height+1),e.clip(),e.translate(-i.x,-i.y)),o.element.type){case"magicframe":case"frame":e.save(),e.translate(o.element.x,o.element.y),e.lineWidth=to.strokeWidth/n.zoom.value,e.strokeStyle=n.theme===Dr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",to.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,o.element.width,o.element.height,to.radius/n.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,o.element.width,o.element.height),e.restore();break;default:e.save();let a=Rr(o.element,t);switch(e.translate(a[0],a[1]),e.rotate(o.element.angle),e.translate(-a[0],-a[1]),e.translate(o.element.x,o.element.y),e.lineWidth=F1(1.75,o.element.strokeWidth,4)/Math.max(.25,n.zoom.value),e.strokeStyle=n.theme===Dr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",o.element.type){case"ellipse":e.beginPath(),e.ellipse(o.element.width/2,o.element.height/2,o.element.width/2,o.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":case"triangle":{let[s,l]=o.element.type==="diamond"?z1(o.element):H1(o.element);s.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-o.element.x,c[0][1]-o.element.y),e.lineTo(c[1][0]-o.element.x,c[1][1]-o.element.y),e.stroke()}),l.forEach(c=>{let[d,p,m,u]=c;e.beginPath(),e.moveTo(d[0]-o.element.x,d[1]-o.element.y),e.bezierCurveTo(p[0]-o.element.x,p[1]-o.element.y,m[0]-o.element.x,m[1]-o.element.y,u[0]-o.element.x,u[1]-o.element.y),e.stroke()})}break;default:{let[s,l]=aM(o.element);s.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-o.element.x,c[0][1]-o.element.y),e.lineTo(c[1][0]-o.element.x,c[1][1]-o.element.y),e.stroke()}),l.forEach(c=>{let[d,p,m,u]=c;e.beginPath(),e.moveTo(d[0]-o.element.x,d[1]-o.element.y),e.bezierCurveTo(p[0]-o.element.x,p[1]-o.element.y,m[0]-o.element.x,m[1]-o.element.y,u[0]-o.element.x,u[1]-o.element.y),e.stroke()})}break}e.restore();break}if(n.isMidpointSnappingEnabled&&(hn(o.element)||sM(o.element))){let a=n.selectedLinearElement,s=a?.elementId&&zo.getElement(a?.elementId,t),l=r&&nX({point:r,element:o.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),c=s&&ys(s)||n.activeTool.type==="arrow"&&n.currentItemArrowType==="elbow";if(!l||c){e.save();let d=Rr(o.element,t),p;if(o.element.type==="diamond"){let h=Rr(o.element,t);p=KV(o.element).map(x=>{let E=jp(x,.5),w=wt(E,h,o.element.angle);return Je(w[0],w[1])})}else if(o.element.type==="triangle"){let h=Rr(o.element,t);p=$V(o.element).map(x=>{let E=jp(x,.5),w=wt(E,h,o.element.angle);return Je(w[0],w[1])})}else p=[{x:o.element.width,y:o.element.height/2},{x:o.element.width/2,y:o.element.height},{x:0,y:o.element.height/2},{x:o.element.width/2,y:0}].map(x=>{let E=Je(x.x+o.element.x,x.y+o.element.y),w=wt(E,d,o.element.angle);return Je(w[0],w[1])});let m=r&&p.reduce((h,x,E)=>{let w=UV(x,r);return E===-1||w<h.distance?{idx:E,distance:w}:h},{idx:-1,distance:1/0}),u=4/n.zoom.value,f=sX(n.zoom)+o.element.strokeWidth/2;p.forEach((h,x)=>{let E=(!l||c)&&m?.idx===x&&m.distance<=f,w=!E&&(c||x===m?.idx&&m.distance<=f*2);E?(e.fillStyle=n.theme===Dr.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(h[0],h[1],u,0,2*Math.PI),e.fill()):w&&(e.fillStyle=n.theme===Dr.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(h[0],h[1],u,0,2*Math.PI),e.fill())}),e.restore()}}},bX=(e,o,t,n,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=gc-(a?.runtime??(s?0:gc)),c=F1(1/gc*l,1e-4,1),d=t.strokeWidth/2,p=t.frameId&&n.get(t.frameId);switch(p&&hn(p)&&(o.translate(p.x,p.y),o.beginPath(),to.radius&&o.roundRect?o.roundRect(-1,-1,p.width+1,p.height+1,to.radius/r.zoom.value):o.rect(-1,-1,p.width+1,p.height+1),o.clip(),o.translate(-p.x,-p.y)),t.type){case"magicframe":case"frame":o.save(),o.translate(t.x,t.y),o.lineWidth=to.strokeWidth/r.zoom.value,o.strokeStyle=r.theme===Dr.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,to.radius&&o.roundRect?(o.beginPath(),o.roundRect(0,0,t.width,t.height,to.radius/r.zoom.value),o.stroke(),o.closePath()):o.strokeRect(0,0,t.width,t.height),o.restore();break;default:o.save();let u=Rr(t,n),f=u[0]+r.scrollX,h=u[1]+r.scrollY;switch(o.translate(f,h),o.rotate(t.angle),o.translate(-f,-h),o.translate(t.x+r.scrollX-d,t.y+r.scrollY-d),o.lineWidth=F1(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),o.strokeStyle=r.theme===Dr.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":o.beginPath(),o.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),o.closePath(),o.stroke();break;case"diamond":case"triangle":{let[x,E]=t.type==="diamond"?z1(t,d):H1(t,d);x.forEach(w=>{o.beginPath(),o.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),o.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),o.stroke()}),E.forEach(w=>{let[y,v,T,I]=w;o.beginPath(),o.moveTo(y[0]-t.x+d,y[1]-t.y+d),o.bezierCurveTo(v[0]-t.x+d,v[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,I[0]-t.x+d,I[1]-t.y+d),o.stroke()})}break;default:{let[x,E]=aM(t,d);x.forEach(w=>{o.beginPath(),o.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),o.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),o.stroke()}),E.forEach(w=>{let[y,v,T,I]=w;o.beginPath(),o.moveTo(y[0]-t.x+d,y[1]-t.y+d),o.bezierCurveTo(v[0]-t.x+d,v[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,I[0]-t.x+d,I[1]-t.y+d),o.stroke()})}break}o.restore();break}if(!s||(a?.runtime??0)>gc)return;let m=.5*(Math.min(t.width,t.height)/2);if(!hn(t)){o.save(),o.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/gc*l;if(o.strokeStyle="rgba(0, 0, 0, 0.2)",o.lineWidth=1/r.zoom.value,o.setLineDash([4/r.zoom.value,4/r.zoom.value]),o.lineDashOffset=-u*10/r.zoom.value,o.beginPath(),o.ellipse(t.width/2,t.height/2,m,m,0,0,2*Math.PI),o.stroke(),o.fillStyle="rgba(0, 0, 0, 0.04)",o.beginPath(),o.ellipse(t.width/2,t.height/2,m*(1-c),m*(1-c),0,0,2*Math.PI),o.fill(),o.restore(),r.isMidpointSnappingEnabled){o.save(),o.translate(t.x+r.scrollX,t.y+r.scrollY);let f=5/r.zoom.value,h=5/r.zoom.value,x=f+h,E;if(t.type==="diamond"){let[,w]=z1(t),y=Rr(t,n);E=w.map(v=>{let T=jp(v,.5),I=wt(T,y,t.angle);return{x:I[0]-t.x,y:I[1]-t.y}})}else if(t.type==="triangle"){let[,w]=H1(t),y=Rr(t,n);E=w.map(v=>{let T=jp(v,.5),I=wt(T,y,t.angle);return{x:I[0]-t.x,y:I[1]-t.y}})}else{let w=Rr(t,n);E=[{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=Je(v.x+t.x,v.y+t.y),I=wt(T,w,t.angle);return{x:I[0]-t.x,y:I[1]-t.y}})}E.forEach(w=>{o.clearRect(w.x-x,w.y-x,x*2,x*2)}),o.fillStyle=r.theme===Dr.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,E.forEach(w=>{o.beginPath(),o.arc(w.x,w.y,f,0,2*Math.PI),o.fill()}),o.restore()}}return{runtime:(a?.runtime??0)+i}},xX=(e,o,t,n,r,i,a)=>{if(t===null)return;if(VV("COMPLEX_BINDINGS"))return bX(e,o,t.element,n,r,i,a);o.save(),o.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Je(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null;fX(o,t,n,r,s),o.restore()},Z1=(e,o,t)=>{let{angle:n,x1:r,y1:i,x2:a,y2:s,selectionColors:l,cx:c,cy:d,dashed:p}=t,m=a-r,u=s-i,h=(t.padding??iM*2)/o.zoom.value,x=8/o.zoom.value,E=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=cM/o.zoom.value;let w=l.length;for(let y=0;y<w;++y)e.strokeStyle=l[y],p&&e.setLineDash([x,E+(x+E)*(w-1)]),e.lineDashOffset=(x+E)*y,Li(e,r-h,i-h,m+h*2,u+h*2,c,d,n);e.restore()},EX=3,yX=2,Qp="#8F6AEF",cM=2,Jp="#8F6AEF",dM=e=>hn(e)||W1(e)||qp(e)||rX(e)||V1(e),wX=1,B1=null,vX=(e,o,t)=>{if(typeof document>"u")return t*.22;B1||(B1=document.createElement("canvas"));let n=B1.getContext("2d");if(!n)return t*.22;n.font=e;let r=n.measureText(o.length?o:" ");return typeof r.actualBoundingBoxDescent=="number"&&Number.isFinite(r.actualBoundingBoxDescent)&&r.actualBoundingBoxDescent>0?r.actualBoundingBoxDescent:t*.22},TX=(e,o)=>{let t=e.text.replace(/\r\n?/g,`
47
47
  `).split(`
48
- `),n=oX(e.fontSize,e.lineHeight),r=XV(e.fontFamily,e.fontSize,n),i=Math.max(0,t.length-1),a=i*n+r,s=vX(YV(e),t[i]??"",e.fontSize);return a+s+wX/o.value},mM=(e,o,t,n)=>{let i=(hn(t)?EX:yX)/o.zoom.value,[a,s,l,c,d,p]=fc(t,n,!0),m=l-a,u=c-s;if(e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle=Qp,e.lineWidth=i,e.setLineDash([]),e.lineJoin="round",e.lineCap="round",t.type==="ellipse"){e.beginPath(),e.ellipse(d,p,m/2,u/2,t.angle,0,Math.PI*2),e.stroke(),e.restore();return}if(t.type==="diamond"){let[h,x,E,w,y,v,T,I]=QV(t),M=Je(d,p),S=[wt(Je(t.x+h,t.y+x),M,t.angle),wt(Je(t.x+E,t.y+w),M,t.angle),wt(Je(t.x+y,t.y+v),M,t.angle),wt(Je(t.x+T,t.y+I),M,t.angle)];e.beginPath(),e.moveTo(S[0][0],S[0][1]);for(let _=1;_<S.length;_++)e.lineTo(S[_][0],S[_][1]);e.closePath(),e.stroke(),e.restore();return}if(t.type==="triangle"){let[h,x,E,w,y,v]=eX(t),T=Je(d,p),I=[wt(Je(t.x+h,t.y+x),T,t.angle),wt(Je(t.x+E,t.y+w),T,t.angle),wt(Je(t.x+y,t.y+v),T,t.angle)];e.beginPath(),e.moveTo(I[0][0],I[0][1]);for(let M=1;M<I.length;M++)e.lineTo(I[M][0],I[M][1]);e.closePath(),e.stroke(),e.restore();return}if(Y1(t)){let h=zo.getPointsGlobalCoordinates(t,n);if(h.length>=2){e.beginPath(),e.moveTo(h[0][0],h[0][1]);for(let x=1;x<h.length;x++)e.lineTo(h[x][0],h[x][1]);e.stroke()}e.restore();return}if(t.type==="freedraw"){let x=tX(t,o.zoom.value);if(x.length>=2){let E=Je(d,p);e.beginPath();let w=wt(Je(t.x+x[0][0],t.y+x[0][1]),E,t.angle);e.moveTo(w[0],w[1]);for(let y=1;y<x.length;y++){let v=wt(Je(t.x+x[y][0],t.y+x[y][1]),E,t.angle);e.lineTo(v[0],v[1])}e.stroke()}e.restore();return}if(V1(t)){let h=TX(t,o.zoom),x=Je(d,p),E=wt(Je(t.x,t.y+h),x,t.angle),w=wt(Je(t.x+t.width,t.y+h),x,t.angle);e.lineJoin="miter",e.lineCap="butt",e.beginPath(),e.moveTo(E[0],E[1]),e.lineTo(w[0],w[1]),e.stroke(),e.restore();return}t.type==="rectangle"&&(e.lineJoin="miter");let f=hn(t)?to.radius/o.zoom.value:qp(t)||t.type==="rectangle"?0:JV(Math.min(t.width,t.height),t)/o.zoom.value;Li(e,a,s,m,u,d,p,t.angle,!1,f),e.restore()},pM=({elementsMap:e,selectedElements:o,appState:t,editorInterface:n,renderConfig:r})=>{let i=WV(o),a=[],s=o.length===1&&Y1(o[0]);for(let c of e.values()){let d=[],p=r.remoteSelectedElementIds.get(c.id);if(s&&ys(c)&&(c.startBinding||c.endBinding)||(i.has(c.id)&&!lM(t,c)&&d.push(r.selectionColor||Jp),p&&d.push(...p.map(m=>ti(m,t.collaborators.get(m))))),d.length){let[m,u,f,h,x,E]=fc(c,e,!0);a.push({angle:c.angle,x1:m,y1:u,x2:f,y2:h,selectionColors:c.locked?["#ced4da"]:d,dashed:!!p||c.locked,cx:x,cy:E,activeEmbeddable:!qp(c)&&t.activeEmbeddable?.element===c&&t.activeEmbeddable.state==="active",padding:c.id===t.croppingElementId||W1(c)||qp(c)||hn(c)?0:void 0})}}let l=c=>{let d=X1(e,c),[p,m,u,f]=K1(d);a.push({angle:0,x1:p,x2:u,y1:m,y2:f,selectionColors:d.some(h=>h.locked)?["#ced4da"]:[r.selectionColor||Jp],dashed:!0,cx:p+(u-p)/2,cy:m+(f-m)/2,activeEmbeddable:!1})};for(let c of dX(t))l(c);return t.editingGroupId&&l(t.editingGroupId),a},uM=e=>e.selectedElementsAreBeingDragged,hM=(e,o)=>!e.selectedElementIds[o.id]&&!lM(e,o),IX=({context:e,appState:o,allElementsMap:t,elementsMap:n,selectedElements:r,renderConfig:i,editorInterface:a})=>{if(o.hoverOutlineElementId){let s=t.get(o.hoverOutlineElementId);s&&!s.isDeleted&&hM(o,s)&&dM(s)&&mM(e,o,s,n)}!o.multiElement&&!o.newElement&&!o.selectedLinearElement?.isEditing&&U1(r,o,a)&&!uM(o)&&pM({elementsMap:n,selectedElements:r,appState:o,editorInterface:a,renderConfig:i}).forEach(c=>Z1(e,o,c))},CX=(e,o,t,n)=>{let[r,i,a,s]=fc(t,n),l=a-r,c=s-i;e.strokeStyle=Qp,e.lineWidth=to.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Li(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,to.radius/o.zoom.value),e.restore()},tM=(e,o,t,n)=>{let{colors:r=[Qp],dashed:i=!1}=n||{},a=t.filter(d=>d.groupIds.length===0),s=t.filter(d=>d.groupIds.length>0),l=d=>{let[p,m,u,f]=K1(d);return{angle:0,x1:p,x2:u,y1:m,y2:f,selectionColors:r,dashed:i,cx:p+(u-p)/2,cy:m+(f-m)/2,activeEmbeddable:!1}},c=d=>{let p=X1(t,d);return l(p)};Object.entries(mX(s,o)).filter(([d,p])=>p).map(([d,p])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>Z1(e,o,d))},O1=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=zo.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=zo,a=o.selectedLinearElement?.isEditing?i:i/2,s=ys(t),l=aX(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)&&GV(c,d===r.length-1?r[0]:r[d-1],2/o.zoom.value),m=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(d);l&&t.polygon&&!m&&d===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(m=!0),N1(e,o,c,a,m,!1,p)}),ys(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,p)=>{zo.isSegmentTooShort(t,r[p+1],r[p],p,o.zoom,n)||N1(e,o,Je((d[0]+r[p+1][0])/2,(d[1]+r[p+1][1])/2),i/2,!1,!c.includes(p+1),!1)})}else zo.getEditorMidPoints(t,n,o).filter((d,p,m)=>d!==null&&!(ys(t)&&(p===0||p===m.length-1))).forEach(d=>{(o.selectedLinearElement?.isEditing||r.length===2)&&N1(e,o,d,i/2,!1,!0,!1)});e.restore()},SX=(e,o,t,n)=>{e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/o.zoom.value,e.setLineDash([4/o.zoom.value,4/o.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(n[0],n[1]),e.stroke(),e.restore()},kX=(e,o,t,n,r)=>{e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/o.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",Ns(e,t[0],t[1],n/o.zoom.value,!0,!0),e.restore()},oM=({arrow:e,appState:o,type:t,context:n,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,a=i?.elementId&&r.get(i.elementId);if(!a||!sM(a)||a.isDeleted)return;let s=eM(i.fixedPoint,a,r);if(!pX(s,e,a,r,o,t))return;let l=o.selectedLinearElement,c=!!l?.isDragging,d=t==="start"?0:e.points.length-1,p=!!l?.selectedPointsIndices?.includes(d);if(l?.hoveredFocusPointBinding===t&&!l.draggedFocusPointBinding&&gX(n,o,s),!(p&&c)){let m=eM(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,f=zo.getPointAtIndexGlobalCoordinates(e,d,r);SX(n,o,f,m),kX(n,o,m,ZV/1.5,u)}},nM=new Set(["nw","ne","sw","se"]),rM=(e,o,t,n,r,i,a)=>{if(r.length!==1)return;e.save(),e.translate(o.scrollX,o.scrollY),e.fillStyle="#fff";let s=jV(r[0],o.zoom,n,"mouse",G1(i));!o.viewModeEnabled&&a&&!V1(o.editingTextElement)&&!o.croppingElementId&&gM(e,t,o,s,r[0].angle),e.restore()},gM=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[s,l,c,d]=a,p=i;if(e.save(),e.lineWidth=1/t.zoom.value,p==="rotation")o.selectionColor&&(e.strokeStyle=o.selectionColor),Ns(e,s+c/2,l+d/2,c/2,!0);else if(nM.has(p)){let m=o.selectionColor||Jp,u=o.hoveredCornerTransformHandleType===p;e.fillStyle=u?m:"#ffffff",e.save(),e.translate(s+c/2,l+d/2),e.rotate(r),e.fillRect(-c/2,-d/2,c,d),e.strokeStyle=m,e.lineWidth=1/t.zoom.value,e.strokeRect(-c/2,-d/2,c,d),e.restore()}else o.selectionColor&&(e.strokeStyle=o.selectionColor);p!=="rotation"&&!nM.has(p)&&(e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/t.zoom.value),e.fill(),e.stroke()):Li(e,s,l,c,d,s+c/2,l+d/2,r,!0)),e.restore()}})},MX=(e,o,t,n,r)=>{let[i,a,,,s,l]=fc(n,r),c=3,d=20,p=c/t.zoom.value,m=p/2,u=s-i+p,f=l-a+p,h=Math.min(d/t.zoom.value,u),x=Math.min(d/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=p,[[[-u,-f],[0,m],[h,m],[m,0],[m,x]],[[u-m,-f],[m,m],[-h+m,m],[0,0],[0,x]],[[-u,f],[0,-m],[h,-m],[m,0],[m,-x]],[[u-m,f],[m,-m],[-h+m,-m],[0,0],[0,-x]]].forEach(w=>{let[[y,v],[T,I],[M,S],[_,A],[P,D]]=w;e.save(),e.translate(s,l),e.rotate(n.angle),e.beginPath(),e.moveTo(y+T,v+I),e.lineTo(y+M,v+S),e.stroke(),e.beginPath(),e.moveTo(y+_,v+A),e.lineTo(y+P,v+D),e.stroke(),e.restore()}),e.restore()},PX=(e,o,t,n)=>{o.save();let r=jf(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);o.translate(s+t.scrollX,l+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=n,o.globalAlpha=.5,o.setLineDash([6/t.zoom.value,4/t.zoom.value]),o.strokeRect(c,d,i,a),o.restore()},AX=(e,o,t,n,r)=>{let i=qf(e,t.zoom.value,r);i&&(o.save(),o.globalAlpha=.5,o.lineWidth=1.5/t.zoom.value,o.lineCap="round",o.strokeStyle=n,o.beginPath(),o.moveTo(i.start[0]+t.scrollX,i.start[1]+t.scrollY),o.lineTo(i.end[0]+t.scrollX,i.end[1]+t.scrollY),o.stroke(),o.restore())},LX=({app:e,canvas:o,outlineOverlayCanvas:t,elementsMap:n,visibleElements:r,selectedElements:i,allElementsMap:a,scale:s,appState:l,renderConfig:c,editorInterface:d,animationState:p,deltaTime:m})=>{if(o===null)return{atLeastOneVisibleElement:!1,elementsMap:n};let u=uM(l),[f,h]=Bs(o,s),x=p,E=Os({canvas:o,scale:s,normalizedWidth:f,normalizedHeight:h});E.save(),E.scale(l.zoom.value,l.zoom.value);let w;if(r.forEach(S=>{l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===S.id&&S&&(w=S)}),w&&O1(E,l,w,n),l.selectionElement&&!l.isCropping)try{cX(l.selectionElement,E,l,c.selectionColor)}catch(S){console.error(S)}let y=lX(i,l);if(y&&!y.autoResize&&AX(y,E,l,c.selectionColor,d.formFactor),l.editingTextElement){let S=a.get(l.editingTextElement.id);S&&!S.autoResize&&PX(S,E,l,c.selectionColor)}if(l.isBindingEnabled&&l.suggestedBinding?x={...p,bindingHighlight:xX(e,E,l.suggestedBinding,a,l,m,p?.bindingHighlight)}:x={...p,bindingHighlight:void 0},l.frameToHighlight&&CX(E,l,l.frameToHighlight,n),!t&&l.hoverOutlineElementId){let S=a.get(l.hoverOutlineElementId);S&&!S.isDeleted&&hM(l,S)&&dM(S)&&mM(E,l,S,n)}if(l.elementsToHighlight&&tM(E,l,l.elementsToHighlight,{colors:[Qp]}),l.activeLockedId){let S=a.get(l.activeLockedId),_=S?[S]:X1(a,l.activeLockedId);tM(E,l,_,{colors:["#ced4da"],dashed:!0})}let v=i.some(S=>hn(S));i.length===1&&l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===i[0].id&&O1(E,l,i[0],n);let T=l.selectedLinearElement,I=T&&zo.getElement(T.elementId,a);if(I&&(l.selectedLinearElement.isDragging||(T.segmentMidPointHoveredCoords?uX(E,l):(ys(I)?T.hoverPointIndex===0||T.hoverPointIndex===I.points.length-1:T.hoverPointIndex>=0)&&hX(E,l,n)),iX(I)&&(oM({arrow:I,elementsMap:a,appState:l,context:E,type:"start"}),oM({arrow:I,elementsMap:a,appState:l,context:E,type:"end"}))),!l.multiElement&&!l.newElement&&!l.selectedLinearElement?.isEditing){let S=U1(i,l,d);i.length===1&&Y1(i[0])&&l.selectedLinearElement?.elementId===i[0].id&&!i[0].locked&&O1(E,l,i[0],n);let A=c.selectionColor||Jp;if(S&&!u){let P=pM({elementsMap:n,selectedElements:i,appState:l,editorInterface:d,renderConfig:c});t||P.forEach(D=>Z1(E,l,D))}if(E.save(),E.translate(l.scrollX,l.scrollY),i.length===1){if(!t&&!u&&rM(E,l,c,n,i,d,S),l.croppingElementId&&!l.isCropping){let P=n.get(l.croppingElementId);P&&W1(P)&&MX(E,c,l,P,n)}}else if(i.length>1&&!l.isRotating&&!u&&!i.some(P=>P.locked)){let P=iM*2/l.zoom.value;E.fillStyle="#fff";let[D,z,K,W]=K1(i,n),Y=E.getLineDash();E.setLineDash([2/l.zoom.value]);let G=E.lineWidth;E.lineWidth=cM/l.zoom.value,E.strokeStyle=A,Li(E,D-P,z-P,K-D+P*2,W-z+P*2,(D+K)/2,(z+W)/2,0),E.lineWidth=G,E.setLineDash(Y);let J=qV([D,z,K,W,(D+K)/2,(z+W)/2],0,l.zoom,"mouse",v?{...G1(d),rotation:!0}:G1(d));i.some($=>!$.locked)&&gM(E,c,l,J,0)}E.restore()}l.searchMatches?.matches.forEach(({id:S,focus:_,matchedLines:A})=>{let P=n.get(S);if(P){let[D,z,,,K,W]=fc(P,n,!0);E.save(),l.theme===Dr.LIGHT?_?E.fillStyle="rgba(255, 124, 0, 0.4)":E.fillStyle="rgba(255, 226, 0, 0.4)":_?E.fillStyle="rgba(229, 82, 0, 0.4)":E.fillStyle="rgba(99, 52, 0, 0.4)";let Y=hn(P)?l.zoom.value:1;E.translate(l.scrollX,l.scrollY),E.translate(K,W),E.rotate(P.angle),A.forEach(G=>{(G.showOnCanvas||_)&&E.fillRect(D+G.offsetX/Y-K,z+G.offsetY/Y-W,G.width/Y,G.height/Y)}),E.restore()}}),qk(E,l),E.restore(),wv({context:E,renderConfig:c,appState:l,normalizedWidth:f,normalizedHeight:h});let M;if(c.renderScrollbars&&(M=kC(n,f,h,l),E.save(),E.fillStyle=SC,E.strokeStyle="rgba(255,255,255,0.8)",[M.horizontal,M.vertical].forEach(S=>{S&&Kd(E,S.x,S.y,S.width,S.height,mo/2)}),E.restore()),t){let[S,_]=Bs(t,s),A=Os({canvas:t,scale:s,normalizedWidth:S,normalizedHeight:_});if(A.save(),A.scale(l.zoom.value,l.zoom.value),IX({context:A,appState:l,allElementsMap:a,elementsMap:n,selectedElements:i,renderConfig:c,editorInterface:d}),!l.multiElement&&!l.newElement&&!l.selectedLinearElement?.isEditing&&!u){let P=U1(i,l,d);rM(A,l,c,n,i,d,P)}A.restore()}return{scrollBars:M,atLeastOneVisibleElement:r.length>0,elementsMap:n,animationState:x}},fM=e=>{let o=LX(e);return e.callback(o),o};var gt=class gt{static start(o,t){let n=t({deltaTime:0,state:void 0});n&&(gt.animations.set(o,{animation:t,lastTime:0,state:n}),gt.isRunning||(gt.isRunning=!0,Xl()?requestAnimationFrame(gt.tick):setTimeout(gt.tick,0)))}static tick(){if(gt.animations.size>0){for(let[o,t]of gt.animations){let n=performance.now(),r=t.lastTime===0?0:n-t.lastTime,i=t.animation({deltaTime:r,state:t.state});if(i)t.lastTime=n,t.state=i;else if(gt.animations.delete(o),gt.animations.size===0){gt.isRunning=!1;return}}Xl()?requestAnimationFrame(gt.tick):setTimeout(gt.tick,0)}}static running(o){return gt.animations.has(o)}static cancel(o){gt.animations.delete(o)}};k(gt,"isRunning",!1),k(gt,"animations",new Map);var bc=gt;import{jsx as FX}from"react/jsx-runtime";var EM="animateInteractiveScene",BX=e=>{let o=bM(!1),t=bM(null);return DX(()=>{if(!o.current){o.current=!0;return}let n=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,NX({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),n.set(d,c.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#8F6AEF";t.current={app:e.app,canvas:e.canvas,outlineOverlayCanvas:e.outlineOverlayCanvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:n,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:s,selectionColor:l,hoveredCornerTransformHandleType:e.app.hoveredCornerTransformHandleType,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.lastViewportPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},bc.running(EM)||bc.start(EM,({deltaTime:c,state:d})=>{let p=fM({...t.current,deltaTime:c,animationState:d}).animationState;if(p){for(let m in p)if(p[m]!==void 0)return p}})}),FX("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled&&e.appState.activeTool.type!=="laser"?xM.GRAB:xM.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:g("labels.drawingCanvas")})},yM=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,hoverOutlineElementId:e.hoverOutlineElementId,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,suggestedBinding:e.suggestedBinding,isRotating:e.isRotating,isResizing:e.isResizing,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,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged}),OX=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:RX(yM(e.appState),yM(o.appState)),j1=_X.memo(BX,OX);import zX,{useEffect as wM,useRef as vM}from"react";import{isShallowEqual as TM}from"@nous-excalidraw/common";import{jsx as UX}from"react/jsx-runtime";var HX=e=>{let o=vM(null),t=vM(!1);return wM(()=>{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]),wM(()=>{let n=o.current;if(!n)return;let r=e.canvas;t.current||(t.current=!0,n.replaceChildren(r),r.classList.add("excalidraw__canvas","static")),a0({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Xl())}),UX("div",{className:"excalidraw__canvas-wrapper",ref:o})},IM=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}),GX=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:TM(IM(e.appState),IM(o.appState))&&TM(e.renderConfig,o.renderConfig),q1=zX.memo(HX,GX);import{useLayoutEffect as ZX,useRef as jX}from"react";import{throttleRAF as WX}from"@nous-excalidraw/common";import{getTargetFrame as YX,isInvisiblySmallElement as VX,renderElement as XX,shouldApplyFrameClip as KX}from"@nous-excalidraw/element";var CM=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=Bs(e,i),d=Os({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(VX(t)){d.restore();return}if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let m=YX(t,n,a);m&&KX(t,m,a,n)&&r0(m,d,s,a)}XX(t,n,r,o,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},$X=WX(e=>{CM(e)}),SM=(e,o)=>{if(o){$X(e);return}CM(e)};import{jsx as JX}from"react/jsx-runtime";var qX=e=>{let o=jX(null);return ZX(()=>{o.current&&SM({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},!1)}),JX("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},kM=qX;var eu=class{constructor(o){this.getState=o;k(this,"listeners",[]);k(this,"onStateChange",(o,t,n)=>{let{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}=this.normalize(o,t,n);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(o){return typeof o=="object"&&!Array.isArray(o)&&"predicate"in o}subscribe(o){return this.listeners.push(o),()=>{this.listeners=this.listeners.filter(t=>t!==o)}}normalize(o,t,n){let r,i,a=t,s=n?.once??!1,l=!1;if(this.isStateChangePredicateOptions(o)){let{predicate:c,callback:d,once:p}=o;r=c,i=m=>m,a=d?(m,u)=>d(u):void 0,s=p??!1,l=c(this.getState())}else if(typeof o=="function"){let c=o;r=(d,p)=>c(d)!==c(p),i=d=>c(d)}else if(Array.isArray(o)){let c=o;r=(d,p)=>c.some(m=>d[m]!==p[m]),i=d=>d}else{let c=o;r=(d,p)=>d[c]!==p[c],i=d=>d[c]}return{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}}flush(o){if(!this.listeners.length)return;let t=this.getState(),n=[];for(let r of this.listeners)r.predicate(t,o)?(r.callback(r.getValue(t),t),r.once||n.push(r)):n.push(r);this.listeners=n}clear(){this.listeners=[]}};import{getCommonBounds as QX,getElementsInGroup as eK,selectGroupsFromGivenElements as tK}from"@nous-excalidraw/element";import{sceneCoordsToViewportCoords as oK}from"@nous-excalidraw/common";import{flushSync as nK}from"react-dom";import{jsx as iK}from"react/jsx-runtime";var rK=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:eK(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=QX(n),{x:a,y:s}=oK({sceneX:r,sceneY:i},e.state);return iK("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-s+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{nK(()=>{let l=tK(n,e.state);e.setState({selectedElementIds:n.reduce((c,d)=>({...c,[d.id]:!0}),{}),selectedGroupIds:l,activeLockedId:null})}),e.actionManager.executeAction(wl)},title:g("labels.elementLock.unlock"),children:P0})},MM=rK;import{sceneCoordsToViewportCoords as aK}from"@nous-excalidraw/common";import{getElementAbsoluteCoords as sK}from"@nous-excalidraw/element";import{jsxs as lK}from"react/jsx-runtime";var PM=({element:e,elementsMap:o,appState:t})=>{let[n,,r,i]=sK(e,o,!0),a=(n+r)/2,{x:s,y:l}=aK({sceneX:a,sceneY:i},t),c=s-t.offsetLeft,d=l-t.offsetTop+6,p=Math.round(e.width),m=Math.round(e.height);return lK("div",{className:"excalidraw-frame-resize-dimensions",style:{left:c,top:d,transform:"translateX(-50%)"},children:[p," x ",m]})};import{Fragment as dZ,jsx as we,jsxs as pu}from"react/jsx-runtime";var YP=wo.createContext(null),VP=wo.createContext(null),Px={formFactor:"desktop",desktopUIMode:"full",userAgent:UP(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},Lx=wo.createContext(Px);Lx.displayName="EditorInterfaceContext";var lZ={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},_x=wo.createContext({container:null,id:null});_x.displayName="ExcalidrawContainerContext";var Dx=wo.createContext([]);Dx.displayName="ExcalidrawElementsContext";var Rx=wo.createContext({...Yo(),width:0,height:0,offsetLeft:0,offsetTop:0});Rx.displayName="ExcalidrawAppStateContext";var Nx=wo.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Nx.displayName="ExcalidrawSetAppStateContext";var Bx=wo.createContext(null);Bx.displayName="ExcalidrawActionManagerContext";var Ms=wo.createContext(null);Ms.displayName="ExcalidrawAPIContext";var hu=wo.createContext(null);hu.displayName="ExcalidrawAPISetContext";var He=()=>Yn(YP),qo=()=>Yn(VP),be=()=>Yn(Lx),dt=()=>uu(be()),Ne=()=>Yn(_x),Qn=()=>Yn(Dx),jo=()=>Yn(Rx),he=()=>Yn(Nx),Be=()=>Yn(Bx),gu=()=>Yn(Ms),Tc=!1,Cx=0,Ic=null,Or=!1,Cc=!1,Sx=!1,Sc={horizontal:null,vertical:null},Fr=0,kc=!1,kx=new Map,Mx=!1,FP=0,zP=!1,Mc=null,Ce={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Ci=class Ci extends wo.Component{constructor(t){super(t);k(this,"canvas");k(this,"interactiveCanvas",null);k(this,"outlineOverlayCanvas",null);k(this,"sessionExportThemeOverride");k(this,"rc");k(this,"unmounted",!1);k(this,"actionManager");k(this,"editorInterface",Px);k(this,"stylesPanelMode",uu(Px));k(this,"excalidrawContainerRef",wo.createRef());k(this,"scene");k(this,"fonts");k(this,"renderer");k(this,"visibleElements");k(this,"resizeObserver");k(this,"library");k(this,"libraryItemsFromStorage");k(this,"id");k(this,"store");k(this,"history");k(this,"excalidrawContainerValue");k(this,"files",{});k(this,"imageCache",new Map);k(this,"iFrameRefs",new Map);k(this,"embedsValidationStatus",new Map);k(this,"initializedEmbeds",new Set);k(this,"elementsPendingErasure",new Set);k(this,"_initialized",!1);k(this,"editorLifecycleEvents",new UK(lZ));k(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));k(this,"appStateObserver",new eu(()=>this.state));k(this,"onStateChange",this.appStateObserver.onStateChange);k(this,"flowChartCreator",new P$);k(this,"flowChartNavigator",new A$);k(this,"bindModeHandler",null);k(this,"hitLinkElement");k(this,"lastPointerDownEvent",null);k(this,"lastPointerUpEvent",null);k(this,"lastPointerUpIsDoubleClick",!1);k(this,"lastPointerMoveEvent",null);k(this,"lastPointerMoveCoords",null);k(this,"hoveredCornerTransformHandleType",null);k(this,"lastCompletedCanvasClicks",[]);k(this,"previousPointerMoveCoords",null);k(this,"lastViewportPosition",{x:0,y:0});k(this,"animationFrameHandler",new Um);k(this,"laserTrails",new Xm(this.animationFrameHandler,this));k(this,"eraserTrail",new Jm(this.animationFrameHandler,this));k(this,"lassoTrail",new qm(this.animationFrameHandler,this));k(this,"onChangeEmitter",new vi);k(this,"onPointerDownEmitter",new vi);k(this,"onPointerUpEmitter",new vi);k(this,"onUserFollowEmitter",new vi);k(this,"onScrollChangeEmitter",new vi);k(this,"missingPointerEventCleanupEmitter",new vi);k(this,"onRemoveEventListenersEmitter",new vi);k(this,"api");k(this,"updateEditorAtom",(t,...n)=>{let r=nt.set(t,...n);return this.triggerRender(),r});k(this,"previousHoveredBindableElement",null);k(this,"getEffectiveGridSize",()=>yr(this)?this.state.gridSize:null);k(this,"getTextCreationGridPoint",(t,n)=>{let r=this.getEffectiveGridSize();if(r===null)return null;let i=a=>Math.floor(a/r)*r;return{x:i(t),y:i(n)}});k(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:n,moveEvent:r})=>t&&dx(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,n.x,n.y))?(ve(this.interactiveCanvas,Fe.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));k(this,"isDoubleClick",(t,n)=>t!=null&&n.timeStamp-t.timeStamp<=WM);k(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),vc.delete(t)});k(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(Go(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=hx(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else Ss(r)&&t.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});k(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);k(this,"frameNameBoundsCache",{get:t=>{let n=this.frameNameBoundsCache._cache.get(t.id);if(!n||n.zoom!==this.state.zoom.value||n.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=ze({clientX:i.x,clientY:i.y},this.state),s=ze({clientX:i.right,clientY:i.bottom},this.state);return n={x:a.x,y:a.y,width:s.x-a.x,height:s.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,n),n}return null}return n},_cache:new Map});k(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});k(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===ws.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&Qe(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!dP(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}=ru({sceneX:i.x,sceneY:i.y},this.state),l=6,c,d=T$(i),p=t?Nr.nameColorDarkTheme:Nr.nameColorLightTheme,m=this.state.hoveredFrameId===i.id&&!this.state.selectedElementIds[i.id],x=!!this.state.selectedElementIds[i.id]?"#8F6AEF":m?"#C6A6FF":p;if(i.id===this.state.editingFrame){let E=d;c=we("input",{autoFocus:!0,value:E,onChange:w=>{this.scene.mutateElement(i,{name:w.target.value})},onFocus:w=>w.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:w=>{(w.key===Z.ESCAPE||w.key===Z.ENTER)&&this.resetEditingFrame(i)},style:{background:t?GK(this.state.viewBackgroundColor):this.state.viewBackgroundColor,zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Nr.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:x,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-l}px`},size:E.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return we("div",{id:this.getFrameNameDOMId(i),className:sx.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+Nr.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Nr.nameFontSize,color:x,lineHeight:Nr.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:Fe.MOVE,pointerEvents:this.state.viewModeEnabled?vs.disabled:vs.enabled},onPointerMove:E=>{if(this.state.viewModeEnabled)return;let w=ze(E,this.state);this.updateFrameHoverStateFromSceneCoords(w.x,w.y)},onPointerDown:E=>this.handleCanvasPointerDown(E),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});k(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});k(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());k(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());k(this,"getSceneElements",()=>this.scene.getNonDeletedElements());k(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});k(this,"onExportImage",async(t,n,r)=>{me("export",t,"ui");let i=await Jr(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(FK).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Fc(i)&&this.setState({fileHandle:i})});k(this,"magicGenerations",new Map);k(this,"updateMagicGeneration",({frameElement:t,data:n})=>{n.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:n}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,n),this.triggerRender()});k(this,"plugins",{});k(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:fn.magicframe}),me("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&mx(t[0])&&t[0];if(!n&&t.some(i=>Qe(i)||i.frameId)){this.setActiveTool({type:fn.magicframe});return}me("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,s,l]=Ti(t),c=50;r=rP({...Nr,x:i-c,y:a-c,width:s-i+c*2,height:l-a+c*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let d of t)this.scene.mutateElement(d,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});k(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(Jn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(n,r)=>{let i=t==="background"&&r.altKey||t==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:n},captureUpdate:Xt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:Xt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(s=>this.state.selectedElementIds[s.id]?Wn(s,{[i?"strokeColor":"backgroundColor"]:n}):s),captureUpdate:Xt.IMMEDIATELY})},keepOpenOnAlt:!1})});k(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});k(this,"syncActionResult",$e(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let n=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),n=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,s=t?.appState?.theme||this.props.theme||ws.LIGHT,l=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r&&t.elements.forEach(d=>{r?.id===d.id&&r!==d&&AP(d)&&kt(d)&&(r=d)}),r?.isDeleted&&(r=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}}),n=!0}n||this.scene.triggerUpdate()}));k(this,"onBlur",$e(()=>{Or=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));k(this,"onUnload",()=>{this.onBlur()});k(this,"disableEvent",t=>{t.preventDefault()});k(this,"resetHistory",()=>{this.history.clear()});k(this,"resetStore",()=>{this.store.clear()});k(this,"resetScene",$e(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...Yo(),isLoading:t?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));k(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async p=>{if(!p.files.length)return;let m=p.files[0],u=await m.getFile();this.loadFileToCanvas(new File([u],u.name||"",{type:u.type}),m)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(p=>{console.error(p)})}catch(p){console.error(p),t={appState:{errorMessage:p.message||"Encountered an error during importing or restoring scene data"}}}let n=Gr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=_i(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r={...r,...Hr(n,{...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})});let a=To(CK),s=n.filter(p=>!p.isDeleted),l=r.zoom.value,c=a;if(s.length){let{appState:p}=ua({targetElements:s,appState:{...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft,zoom:{value:a}},fitToViewport:!1,maxZoom:a,canvasOffsets:this.getEditorUIOffsets()});c=p.zoom.value,r={...r,scrollX:p.scrollX,scrollY:p.scrollY,zoom:p.zoom,currentItemFontSize:ox(r.currentItemFontSize,l,c)}}else r={...r,zoom:{value:a},currentItemFontSize:ox(r.currentItemFontSize,l,a)};r={...r,currentItemStrokeWidthCustom:!1,currentItemStrokeWidth:XM(c)};let d=n.map(p=>{if(!kt(p))return p;let m=ox(p.fontSize,l,c);return m===p.fontSize?p:Wn(p,{fontSize:m})});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:d,appState:r,files:t?.files,captureUpdate:Xt.NEVER});for(let p of this.scene.getNonDeletedElements())kt(p)&&bP(p,this.scene.getContainerElement(p),this.scene);this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(p=>{this.fonts.onLoaded(p)}),yx(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});k(this,"getFormFactor",(t,n)=>this.props.UIOptions.getFormFactor?.(t,n)??XK(t,n));k(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=jK(),a=UP(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:EK,l=ax(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(n,r),userAgent:a,canFitSidebar:n>s,isLandscape:n>r});this.editorInterface=l,this.reconcileStylesPanelMode(l)});k(this,"reconcileStylesPanelMode",t=>{let n=uu(t);if(n===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=n,r!=="full"&&n==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});k(this,"setDesktopUIMode",t=>{let n=qK(t);this.editorInterface=ax(this.editorInterface,{desktopUIMode:n}),this.reconcileStylesPanelMode(this.editorInterface)});k(this,"onResize",$e(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>vc.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));k(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});k(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:n,elementsMap:r})=>{n&&(Sc=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});k(this,"onScroll",ZM(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},yK));k(this,"onCut",$e(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||xc(t.target)||(this.actionManager.executeAction(jd,"keyboard",t),t.preventDefault(),t.stopPropagation())}));k(this,"onCopy",$e(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||xc(t.target)||(this.actionManager.executeAction(Ia,"keyboard",t),t.preventDefault(),t.stopPropagation())}));k(this,"onTouchStart",t=>{if(KK&&t.preventDefault(),!Tc){Tc=!0,t.touches.length===1&&(Ic={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Cx),Cx=window.setTimeout(Ci.resetTapTwice,WM);return}if(Tc&&t.touches.length===1&&Ic){let n=t.touches[0];Hn(oe(n.clientX,n.clientY),oe(Ic.x,Ic.y))<=QM&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),Tc=!1,clearTimeout(Cx)}t.touches.length===2&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null})});k(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}):Ce.pointers.clear()});k(this,"pasteFromClipboard",$e(async t=>{let n=!!Mx,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||xc(r)))return;let s=await ga(t),l=s.getFiles(),c=await Hd(s,n);if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(c,l,n),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t?.preventDefault()}));k(this,"addElementsFromPasteOrLibrary",t=>{let n=Gr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=Ti(n),l=Ts(r,a)/2,c=Ts(i,s)/2,d=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,p=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:m,y:u}=ze({clientX:d,clientY:p},this.state),f=m-l,h=u-c,[x,E]=St(f,h,this.getEffectiveGridSize()),{duplicatedElements:w}=lx({type:"everything",elements:n.map(S=>Wn(S,{x:S.x+x-r,y:S.y+E-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...w];v=this.props.onDuplicate?.(v,y)||v,CP(v,iu(w));let I=this.getTopLayerFrameAtSceneCoords({x:m,y:u});if(I){let S=C$(w,I);Ex(v,S,I,this.state)}this.scene.replaceAllElements(v),w.forEach(S=>{if(kt(S)&&cx(S)){let _=gP(S,this.scene.getElementsMapIncludingDeleted());bP(S,_,this.scene)}}),ZK&&yn.loadElementsFonts(w).then(S=>{this.fonts.onLoaded(S)}),t.files&&this.addMissingFiles(t.files);let M=Y$(w);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&nt.get(Ql)?this.state.openSidebar:null,...yo({editingGroupId:null,selectedElementIds:M.reduce((S,_)=>(cx(_)||(S[_.id]=!0),S),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t.fitToContent&&this.scrollToContent(w,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});k(this,"setAppState",(t,n)=>{this.setState(t,n)});k(this,"removePointer",t=>{Fr&&this.resetContextMenuTimer(),Ce.pointers.delete(t.pointerId)});k(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||me("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...bn(this.state,n.activeTool.locked?{type:this.state.preferredSelectionTool.type}:n.activeTool),locked:!n.activeTool.locked}}))});k(this,"updateFrameRendering",t=>{this.setState(n=>{let r=typeof t=="function"?t(n.frameRendering):t;return{frameRendering:{enabled:r?.enabled??n.frameRendering.enabled,clip:r?.clip??n.frameRendering.clip,name:r?.name??n.frameRendering.name,outline:r?.outline??n.frameRendering.outline}}})});k(this,"togglePenMode",t=>{this.setState(n=>({penMode:t??!n.penMode,penDetected:!0}))});k(this,"onHandToolToggle",()=>{this.actionManager.executeAction(Nw)});k(this,"zoomCanvas",t=>{let n=Sn({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:To(t)},this.state);this.syncSceneStrokeWidthsForZoom(n.zoom.value),this.setState(n)});k(this,"syncSceneStrokeWidthsForZoom",(t,n=this.state.zoom.value)=>{t!==n&&this.scene.replaceAllElements(sZ(this.scene.getElementsIncludingDeleted(),n,t))});k(this,"cancelInProgressAnimation",null);k(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let l;if(yx(t)?l=D$(t):l=t,l){let c=this.scene.getElementsFromId(l);c?.length?this.scrollToContent(c,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):yx(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let r=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,s=this.state.scrollY;if(n?.fitToContent||n?.fitToViewport){let{appState:l}=ua({canvasOffsets:n.canvasOffsets,fitCanvasOffsets:n.fitCanvasOffsets,scrollCanvasOffsets:n.scrollCanvasOffsets,targetElements:r,appState:this.state,fitToViewport:!!n?.fitToViewport,viewportZoomFactor:n?.viewportZoomFactor,minZoom:n?.minZoom,maxZoom:n?.maxZoom});if(i=l.zoom,a=l.scrollX,s=l.scrollY,n?.clampHostStylebarAboveElement){let d=(n.fitCanvasOffsets??n.canvasOffsets)?.top??0,[,p]=Ti(r),m=(d+Ci.HOST_STYLEBAR_GAP_ABOVE_ELEMENT)/i.value-p;s<m&&(s=m)}}else{let l=Hr(r,this.state);a=l.scrollX,s=l.scrollY}if(n?.animate){let l=this.state.scrollX,c=this.state.scrollY,d=this.state.zoom.value,p=this.state.currentItemStrokeWidth,m=this.state.currentItemStrokeWidthCustom,u=this.state.currentItemFontSize,f=OK({fromValues:{scrollX:l,scrollY:c,zoom:d},toValues:{scrollX:a,scrollY:s,zoom:i.value},interpolateValue:(h,x,E,w)=>{if(w==="zoom")return h*Math.pow(x/h,zK(E))},onStep:({scrollX:h,scrollY:x,zoom:E})=>{this.syncSceneStrokeWidthsForZoom(E),this.setState({scrollX:h,scrollY:x,zoom:{value:E},currentItemStrokeWidth:VM(p,d,E,m),currentItemFontSize:YM(u,d,E)})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:n?.duration??500});this.cancelInProgressAnimation=()=>{f(),this.cancelInProgressAnimation=null}}else this.syncSceneStrokeWidthsForZoom(i.value),this.setState({scrollX:a,scrollY:s,zoom:i,currentItemStrokeWidth:VM(this.state.currentItemStrokeWidth,this.state.zoom.value,i.value,this.state.currentItemStrokeWidthCustom),currentItemFontSize:YM(this.state.currentItemFontSize,this.state.zoom.value,i.value)})});k(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});k(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser();let n=(r,i)=>{let a=r?.zoom?.value;a!=null&&a!==i&&this.syncSceneStrokeWidthsForZoom(a)};typeof t=="function"?this.setState((r,i)=>{let a=t(r,i);return n(a,r.zoom.value),a}):(n(t,this.state.zoom.value),this.setState(t))});k(this,"setToast",t=>{this.setState({toast:t})});k(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),n=await t.match("shared-file");if(n){let r=await n.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,uK,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});k(this,"addFiles",$e(t=>{let{addedFiles:n}=this.addMissingFiles(t);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));k(this,"addMissingFiles",(t,n=!1)=>{let r=n?{}:{...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===gn.svg))try{let l=g0(hP(f0(s.dataURL)),gn.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});k(this,"updateScene",$e(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=n||void 0,l=r?JK({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:s,appState:l})}r&&this.setState(r),n&&this.scene.replaceAllElements(n),i&&this.setState({collaborators:i})}));k(this,"applyDeltas",(t,n)=>{let r=_P.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return _P.applyTo(r,a,i,n)});k(this,"mutateElement",(t,n,r=!0)=>this.scene.mutateElement(t,n,{informMutation:r,isDragging:!1}));k(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});k(this,"toggleSidebar",({name:t,tab:n,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===n?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&n&&(a.tab=n),this.setState({openSidebar:a}),!!i});k(this,"updateCurrentCursorPosition",$e(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));k(this,"getHostUiBottomRelativeToContainer",(t,n)=>{let r=document.querySelector(t)?.getBoundingClientRect();return!r||r.width<=0||r.height<=0?0:Math.max(r.bottom-n,0)});k(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current,n=t?.getBoundingClientRect()?.top??0,r=t?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,i=this.getHostUiBottomRelativeToContainer(Ci.HOST_TOOLBAR_SELECTOR,n),a=Math.max(r-n,i,0),s=t?.querySelector(".sidebar")?.getBoundingClientRect(),l=t?.querySelector(".App-menu__left")?.getBoundingClientRect(),c=16;return vn().rtl?{top:a+c,right:Math.max(this.state.width-(l?.left??this.state.width),0)+c,bottom:c,left:Math.max(s?.right??0,0)+c}:{top:a+c,right:Math.max(this.state.width-(s?.left??this.state.width)+c,0),bottom:c,left:Math.max(l?.right??0,0)+c}});k(this,"onKeyDown",$e(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(s,l){let c=s[l];return typeof c=="function"?c.bind(s):l==="key"?t.shiftKey?s.key.toUpperCase():s.key.toLowerCase():c}})),!jM(t.target)){if((t.key===Z.ESCAPE||t.key===Z.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let s=ie(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&Cs(s[0])&&t.key===Z.ENTER){this.startImageCropping(s[0]);return}if(t.key===Z.ESCAPE)this.updateEditorAtom(Po,null);else if(t.key===Z.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(sx.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=Aa(s);nt.get(Po)?.type==="panel"&&Og(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(Po,{type:"panel"})}if(t.key===Z.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=tu(t.key);if(t[Z.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let c=ie(this.scene.getNonDeletedElementsMap(),this.state);c.length===1&&p$(c[0])&&this.flowChartCreator.createNodes(c[0],this.state,wP(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!ux(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let c=ie(this.scene.getNonDeletedElementsMap(),this.state);if(c.length===1&&l){t.preventDefault();let d=this.flowChartNavigator.exploreByDirection(c[0],this.scene.getNonDeletedElementsMap(),wP(t.key));if(d){this.setState(m=>({selectedElementIds:Me({[d]:!0},m)}));let p=this.scene.getNonDeletedElementsMap().get(d);p&&!ux([p],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(p,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[Z.CTRL_OR_CMD]&&t.key===Z.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:De("commandPalette")})}),t.preventDefault();return}if(t[Z.CTRL_OR_CMD]&&t.key.toLowerCase()===Z.V&&(Mx=t.shiftKey,clearTimeout(FP),FP=window.setTimeout(()=>{Mx=!1},100)),t[Z.CTRL_OR_CMD]&&xc(t.target)&&(t.code===BM.MINUS||t.code===BM.EQUAL)){t.preventDefault();return}if(xc(t.target)&&t.key!==Z.ESCAPE||tu(t.key)&&jM(t.target))return;if(t.key===Z.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===Z.E&&t.shiftKey&&t[Z.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===Z.PAGE_UP||t.key===Z.PAGE_DOWN){let s=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===Z.PAGE_DOWN&&(s=-s),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+s})):this.translateCanvas(l=>({scrollY:l.scrollY+s}))}if(this.state.openDialog?.name==="elementLinkSelector"||(t.key===Z.ALT&&(Un("COMPLEX_BINDINGS")?this.handleSkipBindMode():mu({app:this,event:t})),this.actionManager.handleKeyDown(t)))return;let n=this.props.viewModeEnabled===!0;if(!n&&this.state.viewModeEnabled&&t.key===Z.ESCAPE){this.setActiveTool({type:"selection"});return}if(!n&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let s=_T(t.key,this);if(this.state.viewModeEnabled&&!eP(s,["laser","hand"]))return;if(s){this.state.activeTool.type!==s&&me("toolbar",s,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),s==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===Br.sharp?Br.round:l.currentItemArrowType===Br.round?Br.elbow:Br.sharp})),s==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:s}),t.stopPropagation();return}else if(t.key===Z.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[Z.CTRL_OR_CMD]&&!t.repeat&&(Un("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Yt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),mu({app:this,event:t})),tu(t.key)){let s=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=new Set;s.filter(m=>En(m)).filter(m=>{let u=m.startBinding&&!s.some(h=>h.id===m.startBinding?.elementId),f=m.endBinding&&!s.some(h=>h.id===m.endBinding?.elementId);return u||f}).forEach(m=>l.add(m.id)),s=s.filter(m=>!l.has(m.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?GM:this.getEffectiveGridSize())||(t.shiftKey?fK:GM),d=0,p=0;t.key===Z.ARROW_LEFT?d=-c:t.key===Z.ARROW_RIGHT?d=c:t.key===Z.ARROW_UP?p=-c:t.key===Z.ARROW_DOWN&&(p=c),s.forEach(m=>{this.scene.mutateElement(m,{x:m.x+d,y:m.y+p},{informMutation:!1,isDragging:!1}),su(m,this.scene,{simultaneouslyUpdated:s})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===Z.ENTER){let s=this.scene.getSelectedElements(this.state);if(s.length===1){let l=s[0];if(t[Z.CTRL_OR_CMD]||wx(l))Bt(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),Vt(l)||this.actionManager.executeAction(Va));else if(kt(l)||fP(l)){let c;kt(l)||(c=l);let d=fx(l,this.state,this.scene.getNonDeletedElementsMap()),p=d.x,m=d.y;this.startTextEditing({sceneX:p,sceneY:m,container:c}),t.preventDefault();return}else Qe(l)&&this.setState({editingFrame:l.id})}}if(t.key===Z.SPACE&&Ce.pointers.size===0&&(Or=!0,ve(this.interactiveCanvas,Fe.GRAB),t.preventDefault()),(t.key===Z.G||t.key===Z.S)&&!t.altKey&&!t[Z.CTRL_OR_CMD]){let s=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!s.length)return;t.key===Z.G&&(Uo(this.state.activeTool.type)||s.some(l=>Uo(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===Z.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[Z.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===Z.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=>kt(l)||gx(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}t[Z.CTRL_OR_CMD]&&(t.key===Z.BACKSPACE||t.key===Z.DELETE)&&this.updateEditorAtom(ii,"clearCanvas");let r=t.key.toLocaleLowerCase(),i=r===Z.S&&t.shiftKey&&!t[Z.CTRL_OR_CMD],a=t.key===Z.I||r===Z.G&&t.shiftKey;(i||a)&&this.openEyeDropper({type:i?"stroke":"background"})}));k(this,"onKeyUp",$e(t=>{if(t.key===Z.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?ve(this.interactiveCanvas,Fe.GRAB):au(this.state.activeTool.type)?Zt(this.interactiveCanvas):(jt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Or=!1),t.key===Z.ALT&&mu({app:this,event:t}),(t.key===Z.ALT&&this.state.bindMode==="skip"||!t[Z.CTRL_OR_CMD]&&!yc(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Un("COMPLEX_BINDINGS"))){let n=ze({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Ho(oe(n.x,n.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=Ee.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());En(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[Z.CTRL_OR_CMD]){let n=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==n&&Yt(()=>{this.setState({isBindingEnabled:n})}),mu({app:this,event:t})}if(tu(t.key)){oP(this.scene.getSelectedElements(this.state).filter(Is),this.scene,this.state);let n=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(vx).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...RP(r,n.get(r.startBinding.elementId),"start",n)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...RP(r,n.get(r.endBinding.elementId),"end",n)}})}),this.setState({suggestedBinding:null})}if(t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:Xt.IMMEDIATELY})),!t[Z.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:Me({[n.id]:!0},r)})),ux([n],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(n,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:Xt.IMMEDIATELY})}}));k(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);k(this,"setActiveTool",(t,n=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=bn(this.state,t);r.type==="hand"?ve(this.interactiveCanvas,Fe.GRAB):Or||jt(this.interactiveCanvas,{...this.state,activeTool:r}),RK(document.activeElement)&&this.focusContainer(),d$(r.type)||this.setState({suggestedBinding:null}),r.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:au(r.type)?i.selectedLinearElement:null};return r.type==="freedraw"&&this.store.scheduleCapture(),r.type==="lasso"?{...i,...a,activeTool:r,...n?{}:{selectedElementIds:Me({},i),selectedGroupIds:Me({},i),editingGroupId:null,multiElement:null}}:r.type!=="selection"?{...i,...a,activeTool:r,selectedElementIds:Me({},i),selectedGroupIds:Me({},i),editingGroupId:null,multiElement:null}:{...i,...a,activeTool:r}})});k(this,"setOpenDialog",t=>{this.setState({openDialog:t})});k(this,"setCursor",t=>{ve(this.interactiveCanvas,t)});k(this,"resetCursor",()=>{Zt(this.interactiveCanvas)});k(this,"isTouchScreenMultiTouchGesture",()=>Ce.pointers.size>=2);k(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${qM()}`);k(this,"onGestureStart",$e(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null}),Ce.initialScale=this.state.zoom.value}));k(this,"onGestureChange",$e(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=Ce.initialScale;n&&this.setState(r=>{let i=Sn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:To(n*t.scale)},r);return i.zoom.value!==r.zoom.value&&this.syncSceneStrokeWidthsForZoom(i.zoom.value),i})}));k(this,"onGestureEnd",$e(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}),Ce.initialScale=null}));k(this,"isHittingTextAutoResizeHandle",(t,n)=>{let r=OP(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&uC(n,r,this.state.zoom.value,this.editorInterface.formFactor))});k(this,"handleTextAutoResizeHandlePointerDown",(t,n)=>{let r=OP(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,n)?!1:(this.actionManager.executeAction(Hf,"ui",r),this.resetCursor(),!0)});k(this,"startTextEditing",({sceneX:t,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:s})=>{let l=!1,c=r&&this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i);i&&c&&(gx(i,this.scene.getNonDeletedElementsMap())||(l=!0));let d=this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,n),p=d?.fontFamily||this.state.currentItemFontFamily,m=d?.lineHeight||$M(p),u=d?.fontSize??kK(this.state.zoom.value);if(!d&&l&&i&&!Is(i)){let y=B$(rx({fontSize:u,fontFamily:p}),m),v=O$(u,m),T=Math.max(i.height,v),I=Math.max(i.width,y);this.scene.mutateElement(i,{height:T,width:I}),t=i.x+I/2,n=i.y+T/2,c&&(c=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:n}),h=this.getTextCreationGridPoint(t,n),x=c?{x:c.elementCenterX,y:c.elementCenterY}:d?{x:t,y:n}:{x:h?.x??t,y:h===null?n-TP(u,m)/2:h.y},E=d||iP({x:x.x,y:x.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:p,textAlign:c?"center":this.state.currentItemTextAlign,verticalAlign:c?TK.MIDDLE:zM,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:m,angle:i?Is(i)?0:i.angle:0,frameId:f?f.id:null});if(!d&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:E.id})}),this.setState({editingTextElement:E}),!d)if(i&&l){let w=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(E,w+1)}else this.scene.insertElement(E);a||d||i?this.handleTextWysiwyg(E,{isExistingElement:!!d,initialCaretSceneCoords:d?s:null}):this.setState({newElement:E,multiElement:null})});k(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});k(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});k(this,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[n,r]=this.lastCompletedCanvasClicks;return Hn(oe(n.x,n.y),oe(r.x,r.y))<=QM});k(this,"handleCanvasDoubleClick",t=>{if(this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=ze(t,this.state),a=this.getElementAtPosition(r,i);if(a&&(Cs(a)||Qe(a)||Go(a))){this.scrollToContent(a,{animate:!0,duration:500,fitToViewport:!0,viewportZoomFactor:.9,fitCanvasOffsets:this.getEditorUIOffsets(),scrollCanvasOffsets:this.getEditorUIOffsets(),clampHostStylebarAboveElement:!0});return}if(a)return;if(n.length===1&&Bt(n[0])){let l=n[0];if((t[Z.CTRL_OR_CMD]&&vx(l)||wx(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(Va);return}else if(this.state.selectedLinearElement&&Vt(n[0])){let c=Ee.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=c?Ee.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):-1;if(d&&d>-1){this.store.scheduleCapture(),Ee.deleteFixedSegment(n[0],this.scene,d);let p=Ee.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=p?Ee.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,p,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:m,value:c,added:!1}},segmentMidPointHoveredCoords:p}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&wx(l))return}if(Zt(this.interactiveCanvas),U$(this.state).length>0){let l=this.getElementAtPosition(r,i),c=l&&G$(l,this.state.selectedGroupIds);if(c){this.store.scheduleCapture(),this.setState(d=>({...d,...yo({editingGroupId:c,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),d,this)}));return}}if(Zt(this.interactiveCanvas),!t[Z.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(dx(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let c=this.getTextBindableContainerAtPosition(r,i);if(c&&(sP(c)||!BK(c.backgroundColor)||ks({point:oe(r,i),element:c,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(c)}))){let d=fx(c,this.state,this.scene.getNonDeletedElementsMap());r=d.x,i=d.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:c})}}});k(this,"handleCanvasClick",t=>{if(t.button!==Gn.MAIN){this.lastCompletedCanvasClicks=[];return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:t.clientX,y:t.clientY}]});k(this,"getElementLinkAtPosition",(t,n)=>{if(n&&n.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let s=r[a];if(n&&s.id===n.id&&(i=a),s.link&&a>=i&&Nc(s,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});k(this,"handleElementLinkClick",t=>{let n=Hn(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>HM)return;let r=ze(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=Nc(this.hitLinkElement,i,this.state,oe(r.x,r.y),this.editorInterface.formFactor==="phone"),s=ze(this.lastPointerUpEvent,this.state),l=Nc(this.hitLinkElement,i,this.state,oe(s.x,s.y),this.editorInterface.formFactor==="phone");if(a&&l){Ig();let c=this.hitLinkElement.link;if(c){c=nx(c);let d;if(this.props.onLinkOpen&&(d=NK(le.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let p=LK(c)?"_self":"_blank",m=window.open(void 0,p);m&&(m.opener=null,m.location=c)}}}});k(this,"getTopLayerFrameAtSceneCoords",t=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&xx(t,i,n));return r.length?r[r.length-1]:null});k(this,"getHoveredCornerTransformHandleType",t=>t==="nw"||t==="ne"||t==="sw"||t==="se"?t:null);k(this,"syncHoveredCornerTransformHandleType",t=>{let n=this.getHoveredCornerTransformHandleType(t);n!==this.hoveredCornerTransformHandleType&&(this.hoveredCornerTransformHandleType=n,this.triggerRender(!0))});k(this,"clearHoveredCornerTransformHandleType",()=>{this.hoveredCornerTransformHandleType!==null&&(this.hoveredCornerTransformHandleType=null,this.triggerRender(!0))});k(this,"clearHoverOutlineIfNeeded",()=>{(this.state.hoverOutlineElementId!=null||this.state.hoveredFrameId!=null)&&this.setState({hoverOutlineElementId:null,hoveredFrameId:null})});k(this,"computeHoveredFrameId",(t,n,r)=>{let i=this.scene.getNonDeletedElementsMap(),a=this.scene.getNonDeletedFramesLikes();for(let s=a.length-1;s>=0;s--){let l=a[s];if(l.locked)continue;let c=this.frameNameBoundsCache.get(l);if(c&&t>=c.x&&t<=c.x+c.width&&n>=c.y&&n<=c.y+c.height)return l.id}if(r&&!r.isDeleted){if(Qe(r))return r.id;let s=cu(r,i);if(s&&!s.isDeleted&&!s.locked)return s.id}for(let s=a.length-1;s>=0;s--){let l=a[s];if(!l.locked&&xx({x:t,y:n},l,i))return l.id}return null});k(this,"updateFrameHoverAndOutline",(t,n,r)=>{let i=this.computeHoveredFrameId(t,n,r),a=null;if(!this.state.selectedElementsAreBeingDragged){let c=r;if(c&&!c.isDeleted&&(Qe(c)||Cs(c)||Go(c)||c$(c)||kt(c))&&!this.state.selectedElementIds[c.id])a=c.id;else if(i){let d=this.scene.getElement(i);d&&!d.isDeleted&&Qe(d)&&(a=i)}}let s=i!==this.state.hoveredFrameId,l=a!==this.state.hoverOutlineElementId;!s&&!l||(s&&l?this.setState({hoveredFrameId:i,hoverOutlineElementId:a}):s?this.setState({hoveredFrameId:i}):this.setState({hoverOutlineElementId:a}))});k(this,"updateFrameHoverStateFromSceneCoords",(t,n)=>{let r=this.getElementAtPosition(t,n,{preferSelected:!1,includeLockedElements:!0}),i=null;r&&r.locked?i=null:i=r,this.updateFrameHoverAndOutline(t,n,i)});k(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let n=ze(t,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i},Ce.pointers.has(t.pointerId)&&Ce.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let a=Ce.initialScale;if(Ce.pointers.size===2&&Ce.lastCenter&&a&&Ce.initialDistance){let h=Uf(Ce.pointers),x=h.x-Ce.lastCenter.x,E=h.y-Ce.lastCenter.y;Ce.lastCenter=h;let w=Wf(Array.from(Ce.pointers.values())),y=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/Ce.initialDistance,v=y?To(a*y):this.state.zoom.value;this.setState(T=>{let I=Sn({viewportX:h.x,viewportY:h.y,nextZoom:v},T);return this.translateCanvas({zoom:I.zoom,scrollX:I.scrollX+2*(x/v),scrollY:I.scrollY+2*(E/v),shouldCacheIgnoreZoom:!0}),null}),this.resetShouldCacheIgnoreZoomDebounced()}else Ce.lastCenter=Ce.initialDistance=Ce.initialScale=null;if(Or||Cc||Sx||wn(this.state)){this.clearHoverOutlineIfNeeded(),this.clearHoveredCornerTransformHandleType();return}let l=ob(Sc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(l?Zt(this.interactiveCanvas):jt(this.interactiveCanvas,this.state)),!this.state.newElement&&cC(this.state.activeTool.type)){let{originOffset:h,snapLines:x}=lC(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(E=>{let w=Ec(E.snapLines,x),y=E.originSnapOffset?Ec(E.originSnapOffset,h):h;return E.snapLines===w&&E.originSnapOffset===y?null:{snapLines:w,originSnapOffset:y}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(h=>h.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let h=this.state.newElement?null:Ee.handlePointerMoveInEditMode(t,r,i,this);h&&h!==this.state.selectedLinearElement&&Yt(()=>{this.setState({selectedLinearElement:h})})}if(l$(this.state.activeTool.type)){let{newElement:h}=this.state;if(!h&&yc(this.state)){let x=oe(r,i),E=this.scene.getNonDeletedElementsMap(),w=Ho(x,this.scene.getNonDeletedElements(),E,Tx(this.state.zoom));w?this.setState({suggestedBinding:{element:w,midPoint:Ix(x,w,E,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:h,selectedLinearElement:x}=this.state,{x:E,y:w,points:y}=h,v=y[y.length-1],{lastCommittedPoint:T}=x;if(jt(this.interactiveCanvas,this.state),v===T)Is(this.state.newElement)&&yc(this.state)&&Ho(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),Tx(this.state.zoom))?(this.actionManager.executeAction(_t,"ui",{event:t.nativeEvent,sceneCoords:{x:r,y:i}}),this.setState({suggestedBinding:null,startBoundElement:null}),this.state.activeTool.locked||(Zt(this.interactiveCanvas),this.setState(M=>({newElement:null,activeTool:bn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Me({...M.selectedElementIds,[h.id]:!0},M),selectedLinearElement:new Ee(h,this.scene.getNonDeletedElementsMap())})))):Hn(oe(r-E,i-w),v)>=tx?(this.scene.mutateElement(h,{points:[...y,oe(r-E,i-w)]},{informMutation:!1,isDragging:!1}),xn(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:y[y.length-1],selectedPointsIndices:[h.points.length-1],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:h.points.length-1}}})):ve(this.interactiveCanvas,Fe.POINTER);else if(y.length>2&&T&&Hn(oe(r-E,i-w),T)<tx){ve(this.interactiveCanvas,Fe.POINTER),this.scene.mutateElement(h,{points:y.slice(0,-1)},{informMutation:!1,isDragging:!1});let I=h.points.length-1;this.setState({selectedLinearElement:{...x,selectedPointsIndices:x.selectedPointsIndices?[...new Set(x.selectedPointsIndices.map(M=>Math.min(M,I)))]:x.selectedPointsIndices,lastCommittedPoint:h.points[I],initialState:{...x.initialState,lastClickedPoint:I}}})}else{pP(y,this.state.zoom.value)&&ve(this.interactiveCanvas,Fe.POINTER);let I=this.scene.getNonDeletedElementsMap();if(vx(h)){let S=Ho(oe(r,i),this.scene.getNonDeletedElements(),I);Un("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(h,S)}xn(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let M=Ee.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);M&&this.setState(M)}this.clearHoverOutlineIfNeeded(),this.clearHoveredCornerTransformHandleType();return}if(this.state.activeTool.type==="arrow"){let h=Ho(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),Tx(this.state.zoom)),x=oe(r,i),E=this.scene.getNonDeletedElementsMap();h&&!tZ(x,h,E)&&this.setState({suggestedBinding:{element:h,midPoint:Ix(x,h,E,this.state.zoom)}})}let c=!!t.buttons,d=this.state.activeTool.type==="laser";if(c||!d&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser"){this.clearHoverOutlineIfNeeded(),this.clearHoveredCornerTransformHandleType();return}let p=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,n)){ve(this.interactiveCanvas,Fe.POINTER),this.clearHoverOutlineIfNeeded(),this.clearHoveredCornerTransformHandleType();return}if(m.length===1&&!l&&!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&&Vt(m[0]))&&!(Bt(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let h=kP(p,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(h&&h.transformHandleType){ve(this.interactiveCanvas,SP(h)),this.clearHoverOutlineIfNeeded(),this.syncHoveredCornerTransformHandleType(h.transformHandleType);return}}}else if(m.length>1&&!l&&this.state.openDialog?.name!=="elementLinkSelector"){let h=MP(Ti(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(h){ve(this.interactiveCanvas,SP({transformHandleType:h})),this.clearHoverOutlineIfNeeded(),this.syncHoveredCornerTransformHandleType(h);return}}if(this.clearHoveredCornerTransformHandleType(),Ot(this.state)){this.clearHoverOutlineIfNeeded();return}let u=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),f=null;if(u&&u.locked?f=null:f=u,this.updateFrameHoverStateFromSceneCoords(r,i),this.handleIframeLikeElementHover({hitElement:f,scenePointer:n,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(n,u)),this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id])ve(this.interactiveCanvas,Fe.POINTER),n2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap());else{if(Ig(),d)return;f&&(f.link||Go(f))&&this.state.selectedElementIds[f.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?ve(this.interactiveCanvas,kt(f)?Fe.TEXT:Fe.CROSSHAIR):!t[Z.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(n,m)?ve(this.interactiveCanvas,Fe.MOVE):this.state.viewModeEnabled?ve(this.interactiveCanvas,Fe.GRAB):this.state.openDialog?.name==="elementLinkSelector"?ve(this.interactiveCanvas,Fe.AUTO):l?ve(this.interactiveCanvas,Fe.AUTO):!t[Z.CTRL_OR_CMD]&&f?.id!==this.state.editingTextElement?.id?(f||this.isHittingCommonBoundingBoxOfSelectedElements(n,m))&&!f?.locked&&(!f||!Vt(f)||!(f.startBinding||f.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&ve(this.interactiveCanvas,Fe.MOVE):ve(this.interactiveCanvas,Fe.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&f?this.setState(h=>({hoveredElementIds:Ec(h.hoveredElementIds,yo({editingGroupId:h.editingGroupId,selectedElementIds:{[f.id]:!0}},this.scene.getNonDeletedElements(),h,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!f&&this.setState(h=>({hoveredElementIds:Ec(h.hoveredElementIds,{})}))});k(this,"handleEraser",(t,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});k(this,"handleTouchMove",t=>{kc=!0});k(this,"handleCanvasPointerDown",t=>{let n=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let h=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==h&&this.setState({isBindingEnabled:h})}let r=ze(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.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(h=>({searchMatches:h.searchMatches&&{focusedId:null,matches:h.searchMatches.matches.map(x=>({...x,focus:!1}))}})),this.updateEditorAtom(Xb,null)),nt.get(Po)&&this.updateEditorAtom(Po,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 h=this.state.newElement;this.updateScene({...h.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==h.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:Me(Object.keys(this.state.selectedElementIds).filter(x=>x!==h.id).reduce((x,E)=>(x[E]=this.state.selectedElementIds[E],x),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Xt.EVENTUALLY:Xt.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(h=>({penMode:!0,penDetected:!0})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=ax(this.editorInterface,{isTouchScreen:!0})),Cc||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Gn.ERASER&&this.state.activeTool.type!==fn.eraser){this.setState({activeTool:bn(this.state,{type:fn.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let h=()=>{x(),E?.(),Ot(this.state)&&this.setState({activeTool:bn(this.state,{...this.state.activeTool.lastActiveTool||{type:fn.selection},lastActiveToolBeforeEraser:null})})},x=je(window,le.POINTER_UP,h,{once:!0}),E;requestAnimationFrame(()=>{E=this.missingPointerEventCleanupEmitter.once(h)})});return}if(t.button!==Gn.MAIN&&t.button!==Gn.TOUCH&&t.button!==Gn.ERASER||Ce.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(n,c.origin)||this.handleDraggingScrollBar(t,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,c))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let h=c.hit.element&&this.isASelectedElement(c.hit.element);(t.altKey&&t[Z.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!h)&&(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&&!h&&(this.setState(w=>{let y={...w.selectedElementIds,[c.hit.element.id]:!0},v=[];Object.keys(w.selectedElementIds).forEach(I=>{let M=this.scene.getElement(I);M&&v.push(M)});let T=c.hit.element;if(Qe(T))bx(v,T.id).forEach(I=>{delete y[I.id]});else if(T.frameId)y[T.frameId]&&delete y[T.id];else{let I=T.groupIds,M=new Set(I.flatMap(S=>Ii(this.scene.getNonDeletedElements(),S)).filter(S=>Qe(S)).map(S=>S.id));M.size>0&&v.forEach(S=>{S.frameId&&M.has(S.frameId)&&(delete y[S.id],S.groupIds.flatMap(_=>Ii(this.scene.getNonDeletedElements(),_)).forEach(_=>{delete y[_.id]}))})}return{...yo({editingGroupId:w.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),w,this),showHyperlinkPopup:T.link||Go(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"?jt(this.interactiveCanvas,this.state):this.state.activeTool.type===fn.frame||this.state.activeTool.type===fn.magicframe?this.createFrameElementOnPointerDown(c,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(c.lastCoords.x,c.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,c);this.props?.onPointerDown?.(this.state.activeTool,c),this.onPointerDownEmitter.trigger(this.state.activeTool,c,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(c.lastCoords.x,c.lastCoords.y);let p=this.onPointerMoveFromPointerDownHandler(c),m=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),f=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(h=>m(h||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(le.POINTER_MOVE,p),window.addEventListener(le.POINTER_UP,m),window.addEventListener(le.KEYDOWN,u),window.addEventListener(le.KEYUP,f),c.eventListeners.onMove=p,c.eventListeners.onUp=m,c.eventListeners.onKeyUp=f,c.eventListeners.onKeyDown=u)});k(this,"handleCanvasPointerUp",t=>{if(Un("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,t),this.lastPointerUpEvent=t,!t.ctrlKey){let a=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==a&&this.setState({isBindingEnabled:a})}let n=ze({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=n;if(this.lastPointerMoveCoords={x:r,y:i},!this.handleIframeLikeCenterClick()){if(this.editorInterface.isTouchScreen){let a=this.getElementAtPosition(n.x,n.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(n,a)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?this.handleElementLinkClick(t):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})}});k(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(kc=!1,Fr?kc=!0:Fr=window.setTimeout(()=>{Fr=0,kc||this.handleCanvasContextMenu(t)},vK))});k(this,"resetContextMenuTimer",()=>{clearTimeout(Fr),Fr=0,kc=!1});k(this,"maybeCleanupAfterMissingPointerUp",t=>{Mc?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});k(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(Ce.pointers.size<=1&&(t.button===Gn.WHEEL||t.button===Gn.MAIN&&Or||wn(this.state)||this.state.viewModeEnabled&&this.state.activeTool.type!=="laser")))return!1;Cc=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);ve(this.interactiveCanvas,Fe.GRABBING);let{clientX:i,clientY:a}=t,s=Km(c=>{let d=i-c.clientX,p=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!n&&(Math.abs(d)>1||Math.abs(p)>1)){n=!0;let m=f=>{document.body.removeEventListener(le.PASTE,m),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(le.PASTE,m),window.removeEventListener(le.POINTER_UP,u)},100)};document.body.addEventListener(le.PASTE,m),window.addEventListener(le.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-d/this.state.zoom.value,scrollY:this.state.scrollY-p/this.state.zoom.value})}),l=$e(Mc=()=>{Mc=null,Cc=!1,Or||(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"?ve(this.interactiveCanvas,Fe.GRAB):jt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(le.POINTER_MOVE,s),window.removeEventListener(le.POINTER_UP,l),window.removeEventListener(le.BLUR,l),s.flush()});return window.addEventListener(le.BLUR,l),window.addEventListener(le.POINTER_MOVE,s,{passive:!0}),window.addEventListener(le.POINTER_UP,l),!0});k(this,"clearSelectionIfNotUsingSelection",()=>{au(this.state.activeTool.type)||this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});k(this,"handleSelectionOnPointerDown",(t,n)=>{if(au(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&&!Vt(a[0])&&!(Bt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=kP(r,this.state,n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);s!=null&&(s.transformHandleType==="rotation"?(this.setState({resizingElement:s.element}),n.resize.handleType=s.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:s.element}),n.resize.handleType=s.transformHandleType))}else a.length>1&&(n.resize.handleType=MP(Ti(a),n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=ix(X$(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&Bt(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=K$(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let m=this.state.selectedLinearElement,u=Ee.handlePointerDown(t,this,this.store,n.origin,m,this.scene);if(u.hitElement&&(n.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let f=this.scene.getNonDeletedElementsMap(),h=Ee.getElement(m.elementId,f);if(h&&En(h)){let{hitFocusPoint:x,pointerOffset:E}=rZ(h,n,f,this.state);if(x)return this.setState({selectedLinearElement:{...m,hoveredFocusPointBinding:x,draggedFocusPointBinding:x,pointerOffset:E}}),!1}}let s=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),l=s.filter(m=>!m.locked),c=this.getElementAtPosition(n.origin.x,n.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])?n.hit.element=null:n.hit.element=n.hit.element??this.getElementAtPosition(n.origin.x,n.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(n.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&n.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),n.hit.element&&this.getElementLinkAtPosition({x:n.origin.x,y:n.origin.y},n.hit.element))return!1;n.hit.allHitElements=l;let d=n.hit.element,p=n.hit.allHitElements.some(m=>this.isASelectedElement(m));if((d===null||!p)&&!t.shiftKey&&!n.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?Me({[m.selectedLinearElement.elementId]:!0},this.state):Me({},m)}));else if(d!=null){if(t[Z.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(n.origin.x,n.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(n.hit.wasAddedToSelection=!0),this.setState(m=>({...H$(m,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!IP(d,this.state.editingGroupId)&&this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!p&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(m=>{let u={...m.selectedElementIds,[d.id]:!0},f=[];if(Object.keys(m.selectedElementIds).forEach(h=>{let x=this.scene.getElement(h);x&&f.push(x)}),Qe(d))bx(f,d.id).forEach(h=>{delete u[h.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let h=d.groupIds,x=new Set(h.flatMap(E=>Ii(this.scene.getNonDeletedElements(),E)).filter(E=>Qe(E)).map(E=>E.id));x.size>0&&f.forEach(E=>{E.frameId&&x.has(E.frameId)&&(delete u[E.id],E.groupIds.flatMap(w=>Ii(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete u[w.id]}))})}return m.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(h=>m.selectedGroupIds[h])||(u={[d.id]:!0})),{...yo({editingGroupId:m.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),m,this),showHyperlinkPopup:d.link||Go(d)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});k(this,"handleTextOnPointerDown",(t,n)=>{if(this.state.editingTextElement)return;let r=n.origin.x,i=n.origin.y,a=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),s=this.getTextBindableContainerAtPosition(r,i);sP(a)&&(s=a,r=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s,autoEdit:!1,initialCaretSceneCoords:{x:r,y:i}}),Zt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:bn(this.state,{type:this.state.preferredSelectionTool.type})})});k(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,a]=St(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=t$({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:l,locked:!1,frameId:s?s.id:null,points:[oe(0,0)],pressures:l?[]:[t.pressure]});this.scene.insertElement(c),this.setState(p=>{let m={...p.selectedElementIds};return delete m[c.id],{selectedElementIds:Me(m,p)}});let d=Ho(oe(r.origin.x,r.origin.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.setState({newElement:c,startBoundElement:d,suggestedBinding:null})});k(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[a,s]=St(t,n,this.lastPointerDownEvent?.[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=o$({type:"iframe",x:a,y:s,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.scene.insertElement(l),l});k(this,"insertEmbeddableElement",({sceneX:t,sceneY:n,link:r})=>{let[i,a]=St(t,n,this.lastPointerDownEvent?.[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=lu(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let l=nP({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),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.scene.insertElement(l),l});k(this,"newImagePlaceholder",({sceneX:t,sceneY:n,addToFrameUnderCursor:r=!0})=>{let[i,a]=St(t,n,this.lastPointerDownEvent?.[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=r?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,l=100/this.state.zoom.value;return i$({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),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})});k(this,"handleLinearElementOnPointerDown",(t,n,r)=>{if(t.ctrlKey&&Yt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(xn(a,"selectedLinearElement is expected to be set"),i.type==="line"&&pP(i.points,this.state.zoom.value)){Yt(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(_t);return}if(Vt(i)&&i.points.length>1){this.actionManager.executeAction(_t,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=yc(this.state)&&Ho(oe(this.lastPointerMoveCoords?.x??s+i.points[i.points.length-1][0],this.lastPointerMoveCoords?.y??l+i.points[i.points.length-1][1]),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(En(i)&&d||i.points.length>1&&c&&Hn(oe(r.origin.x-s,r.origin.y-l),c)<tx){this.actionManager.executeAction(_t,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(p=>({selectedElementIds:Me({...p.selectedElementIds,[i.id]:!0},p)})),ve(this.interactiveCanvas,Fe.POINTER)}else{let[i,a]=St(r.origin.x,r.origin.y,t[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,p]=n==="arrow"?[l,c]:[null,null],m=n==="arrow"?n$({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Br.round?{type:ou.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:p,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===Br.elbow,fixedSegments:this.state.currentItemArrowType===Br.elbow?[]:null}):a$({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:ou.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=oe(r.origin.x,r.origin.y),f=this.scene.getNonDeletedElementsMap(),h=yc(this.state)?Ho(u,this.scene.getNonDeletedElements(),f):null;this.scene.mutateElement(m,{points:[oe(0,0),oe(0,0)]}),this.scene.insertElement(m),En(m)&&Q$(m,new Map([[0,{point:oe(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:FM(t.nativeEvent)}),Yt(()=>{this.setState(x=>{let E=null,w=x.selectedElementIds;if(Bt(m)){E=new Ee(m,this.scene.getNonDeletedElementsMap());let y=m.points.length-1;E={...E,selectedPointsIndices:[y],initialState:{...E.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:y,origin:oe(r.origin.x,r.origin.y)}}}return w=this.state.activeTool.locked?x.selectedElementIds:Me({[m.id]:!0},x),{...x,bindMode:"orbit",newElement:m,startBoundElement:h,suggestedBinding:h&&En(m)?{element:h,midPoint:Ix(u,h,f,this.state.zoom)}:null,selectedElementIds:w,selectedLinearElement:E}})}),En(m)&&Un("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(m,h)}});k(this,"getNewElementStrokeProps",()=>this.state.currentItemStrokeWidthCustom?{strokeWidth:this.state.currentItemStrokeWidth,customData:{[SK]:!0}}:{strokeWidth:XM(this.state.zoom.value)});k(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=St(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[Z.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,...this.getNewElementStrokeProps(),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=nP({type:"embeddable",...s}):l=r$({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.scene.insertElement(l),this.setState({multiElement:null,newElement:l}))});k(this,"createFrameElementOnPointerDown",(t,n)=>{let[r,i]=St(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Nr},s=n===fn.magicframe?rP(a):e$(a);this.scene.insertElement(s),this.setState({multiElement:null,newElement:s})});k(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});k(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(En(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);du(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);du(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else px(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&du(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&du(s,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||cx(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,Wn(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});k(this,"initializeImage",async(t,n)=>{if(!Cu(n))throw new Error(g("errors.unsupportedFileType"));let r=n.type;if(ve(this.interactiveCanvas,"wait"),r===gn.svg)try{n=Pu(hP(await n.text()),n.name)}catch(l){throw console.warn(l),new Error(g("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(n)||h0(n));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{n=await zc(n,{maxWidthOrHeight:gK})}catch(l){console.error("Error trying to resizing image file on insertion",l)}if(n.size>UM)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(UM/1024/1024)}MB`}))}let s=this.files[i]?.dataURL||await Mu(n);return new Promise(async(l,c)=>{try{let d=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:s,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(g("errors.imageInsertError")))}})});k(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return Wn(r,{fileId:n})});k(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:r,y:i}=ze({clientX:t,clientY:n},this.state),a=await Dc({description:"Image",extensions:Object.keys(bK),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:bn(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(_t)})}});k(this,"getImageNaturalDimensions",(t,n)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(n.naturalHeight,i),s=a*(n.naturalWidth/n.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}});k(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await b$({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(Xt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>wc(a)&&i.has(a.fileId)?Wn(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});k(this,"addNewImagesToImageCache",async(t=f$(this.scene.getNonDeletedElements()),n=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,n);if(i.size)for(let a of r)i.has(a.fileId)&&vc.delete(a);i.size&&this.scene.triggerUpdate()}});k(this,"scheduleImageRefresh",cK(()=>{this.addNewImagesToImageCache()},xK));k(this,"handleOutlineOverlayCanvasRef",t=>{this.outlineOverlayCanvas=t});k(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(le.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(le.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(le.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(le.TOUCH_END,this.onTouchEnd))});k(this,"insertImages",async(t,n,r)=>{let i=50/this.state.zoom.value,a=DP(t.map(()=>this.newImagePlaceholder({sceneX:n,sceneY:r})),n,r,i);a.forEach(m=>this.scene.insertElement(m));let s=await Promise.all(a.map(async(m,u)=>{try{return await this.initializeImage(m,await zs(t[u]))}catch(f){return this.setState({errorMessage:f.message||g("errors.imageInsertError")}),Wn(m,{isDeleted:!0})}})),l=iu(s),c=DP(s.filter(m=>!m.isDeleted),n,r,i),d=iu(c),p=this.scene.getElementsIncludingDeleted().map(m=>d.get(m.id)??l.get(m.id)??m);this.updateScene({appState:{selectedElementIds:Me(Object.fromEntries(c.map(m=>[m.id,!0])),this.state)},elements:p,captureUpdate:Xt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(_t)})});k(this,"handleAppOnDrop",async t=>{let{x:n,y:r}=ze(t,this.state),i=await ga(t),a=i.getFiles();if(a.length>0){let d=a.map(u=>u.file).filter(u=>u!=null),p=d.length===1&&(d[0].type===gn.png||d[0].type===gn.svg),m=d.some(u=>Cu(u));if(m||!p&&!m)return}let s=i.getData(gn.excalidrawlibIds),l=i.getData(gn.excalidrawlib);if(s||l){try{let d=null;if(s){let{itemIds:p}=JSON.parse(s);d=(await this.library.getLatestLibrary()).filter(u=>p.includes(u.id))}else l&&(d=u0(l));d?.length&&(d=d.map(p=>({...p,elements:lx({type:"everything",elements:p.elements,randomizeSeed:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:Da(d),position:t,files:null}))}catch(d){this.setState({errorMessage:d.message})}return}if(a.length>0){let{file:d,fileHandle:p}=a[0];d&&await this.loadFileToCanvas(d,p)}let c=i.findByType(gn.text);if(c){let d=c.value;if(d&&hx(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||lu(d)?.type==="video")){let p=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:nx(d)});p&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[p.id]:!0}}))}}});k(this,"loadFileToCanvas",async(t,n)=>{t=await zs(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Su(t,this.state,r,n)}catch(a){let s=a instanceof t0;if(s&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:g("errors.imageToolNotSupported")});return}let l=s?g("alerts.cannotRestoreFromImage"):g("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:l})}if(!i)return;i.type===gn.excalidraw?(WP(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:Xt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Xt.IMMEDIATELY})):i.type===gn.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});k(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Gn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let{x:n,y:r}=ze(t,this.state),i=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),s=this.isHittingCommonBoundingBoxOfSelectedElements({x:n,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;me("contextMenu","openContextMenu",l),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...yo({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Bt(i)?new Ee(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:m,items:this.getContextMenuItems(l)}})})});k(this,"maybeDragNewGenericElement",(t,n,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){PP({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Ts(t.origin.x,a.x),height:Ts(t.origin.y,a.y),shouldMaintainAspectRatio:ex(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let s=this.state.newElement;if(!s)return;let[l,c]=St(a.x,a.y,n[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=wc(s)&&this.imageCache.get(s.fileId)?.image,p=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:m,snapLines:u}=sC(s,this,n,{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}),En(s)||PP({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:Ts(t.originInGrid.x,l),height:Ts(t.originInGrid.y,c),shouldMaintainAspectRatio:lP(s)?!0:ex(n),shouldResizeFromCenter:OM(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:p,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:s}),(this.state.activeTool.type===fn.frame||this.state.activeTool.type===fn.magicframe)&&this.setState({elementsToHighlight:xP(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})});k(this,"maybeHandleCrop",(t,n)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,s]=St(i.x-t.resize.offset.x,i.y-t.resize.offset.y,n[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&Cs(l)){let c=t.originalElements.get(l.id),d=wc(l)&&this.imageCache.get(l.fileId)?.image;if(c&&Cs(c)&&d&&!(d instanceof Promise)){let[p,m]=St(i.x,i.y,n[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:m-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:f,snapLines:h}=Kf([l],[c],this,n,u,r);this.scene.mutateElement(l,L$(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+f.x,s+f.y,n.shiftKey?c.width/c.height:void 0)),su(l,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:h})}return!0}return!1});k(this,"maybeHandleResize",(t,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(p=>Qe(p)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Vt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=St(s.x-t.resize.offset.x,s.y-t.resize.offset.y,n[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(p=>{bx(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]=St(s.x,s.y,n[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:m-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:h,snapLines:x}=Kf(r,ie(f,this.state),this,n,u,a);l+=h.x,c+=h.y,this.setState({snapLines:x})}return $$(t.originalElements,a,r,this.scene,FM(n),OM(n),r.some(lP)?!0:ex(n),l,c,t.resize.center.x,t.resize.center.y)?(this.setState({elementsToHighlight:i.length>0?null:[]}),!0):!1});k(this,"getContextMenuItems",t=>{let n=[];if(t==="canvas")return this.state.viewModeEnabled?[...n,Ca,lr,ri,cr]:[mg,rt,qd,rt,lh,c2,rt,Ca,gl,fl,bl,lr,ri,cr];if(n.push(qd),this.state.viewModeEnabled)return[Ia,...n];let r=this.editorInterface.formFactor!=="phone"?[rt,rh,ih,ah,sh]:[];return[rt,jd,Ia,mg,rt,HI,GI,UI,rt,Nf,rt,...n,rt,tg,og,rt,rg,Hf,hg,gg,$v,ig,rt,lg,...r,rt,cg,dg,rt,Va,rt,yl,nm,rt,ch,wl,rt,Zs]});k(this,"handleWheel",$e(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&t.target.classList.contains(sx.FRAME_NAME))){t[Z.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Cc)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(r),a=IK(this.state.zoom.value,i>0?"out":"in")*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),this.translateCanvas(d=>({...Sn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:To(c)},d),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(r||n)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:s})=>({scrollX:a-n/i.value,scrollY:s-r/i.value}))}));k(this,"savePointer",(t,n,r)=>{if(!t||!n)return;let{x:i,y:a}=ze({clientX:t,clientY:n},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:Ce.pointers})});k(this,"resetShouldCacheIgnoreZoomDebounced",ZM(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));k(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let n=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:s}=n.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()})}});k(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});k(this,"watchState",()=>{});let n=Yo(),{viewModeEnabled:r=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=n.theme,name:c=`${g("labels.untitled")}-${qM()}`}=t;this.state={...n,theme:l,exportWithDarkMode:l===ws.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:r,zenModeEnabled:i,objectsSnapModeEnabled:s,gridModeEnabled:a??n.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight},this.refreshEditorInterface(),this.stylesPanelMode=uu(this.editorInterface),this.id=mK(),this.library=new R2(this),this.actionManager=new Gm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new LP,this.canvas=document.createElement("canvas"),this.rc=dK.canvas(this.canvas),this.renderer=new Vl(this.scene),this.visibleElements=[],this.store=new q$(this),this.history=new Ul(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new yn(this.scene),this.history=new Ul(this.store),this.actionManager.registerAll(nd),this.actionManager.registerAction(XI(this.history)),this.actionManager.registerAction(KI(this.history)),this.api=this.createExcalidrawAPI()}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:n=>{this.actionManager.registerAction(n)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:n=>this.onChangeEmitter.on(n),onIncrement:n=>this.store.onStoreIncrementEmitter.on(n),onPointerDown:n=>this.onPointerDownEmitter.on(n),onPointerUp:n=>this.onPointerUpEmitter.on(n),onScrollChange:n=>this.onScrollChangeEmitter.on(n),onUserFollow:n=>this.onUserFollowEmitter.on(n),onStateChange:this.onStateChange,onEvent:this.onEvent}}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let n=null;try{n=JSON.parse(t.data)}catch{}if(n)switch(t.origin){case"https://player.vimeo.com":if(n.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:n.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(n.event==="infoDelivery"&&n.info&&n.id&&typeof n.info.playerState=="number"){let r=n.id,i=n.info.playerState;Object.values(nu).includes(i)&&kx.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){xn(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),n=Ho(oe(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=Ee.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&n?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),Yt(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:n}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;xn(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=n-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?Ee.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):Ee.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,n){if(t.isDeleted||Vt(t))return;let r=()=>{if(this.bindModeHandler=null,xn(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 f=this.state.selectedLinearElement.selectedPointsIndices.includes(0),h=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!f&&!h||f&&h)return}let{x:p,y:m}=this.lastPointerMoveCoords,u=Ho(oe(p,m),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){xn(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let f=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Yt(()=>{xn(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:f}}})});let h=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;xn(h,"Last event must exist");let x=p-this.state.selectedLinearElement.pointerOffset.x,E=m-this.state.selectedLinearElement.pointerOffset.y,w=this.state.multiElement?Ee.handlePointerMove(h,this,x,E,this.state.selectedLinearElement):Ee.handlePointDragging(h,this,x,E,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),f=m?n:t.startBinding&&p.get(t.startBinding.elementId),h=u?n:t.endBinding&&p.get(t.endBinding.elementId),x=f&&NP(f,p),E=h&&NP(h,p);i=!!(x&&E&&f.id!==h.id&&eZ(x,E))}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===n?.id||l&&t[l]?.mode==="inside"&&n?.id===t[l]?.elementId;l&&c&&t[l]?.mode==="inside"&&n?.id!==t[l]?.elementId&&t[c]?.elementId!==t[l]?.elementId&&this.scene.mutateElement(t,{[l]:{...t[l],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!n||this.previousHoveredBindableElement&&n.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Yt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,VK)),this.previousHoveredBindableElement=n}cacheEmbeddableRef(t,n){n&&this.iFrameRefs.set(t.id,n)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==Gn.MAIN||Or||!eP(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(ze({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),n=oe(ze({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(Hn(t,n)>HM)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&Ce.pointers.size<2&&dx(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,n[0],n[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),Ss(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let c=kx.get(s.id);switch(c||(kx.set(s.id,nu.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case nu.PLAYING:case nu.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,n,r,i){return t&&!n.altKey&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=t.x+t.width/3&&r<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,n=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Go(a)&&this.embedsValidationStatus.get(a.id)===!0||Ss(a));return we(dZ,{children:i.map(a=>{let{x:s,y:l}=ru({sceneX:a.x,sceneY:a.y},this.state),c=dP(a,n,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;if(Ss(a)){m=null;let h=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(h.status==="done"){let x=h.html;m={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>x}}else if(h.status==="pending")m={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>uP(`
48
+ `),n=oX(e.fontSize,e.lineHeight),r=XV(e.fontFamily,e.fontSize,n),i=Math.max(0,t.length-1),a=i*n+r,s=vX(YV(e),t[i]??"",e.fontSize);return a+s+wX/o.value},mM=(e,o,t,n)=>{let i=(hn(t)?EX:yX)/o.zoom.value,[a,s,l,c,d,p]=fc(t,n,!0),m=l-a,u=c-s;if(e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle=Qp,e.lineWidth=i,e.setLineDash([]),e.lineJoin="round",e.lineCap="round",t.type==="ellipse"){e.beginPath(),e.ellipse(d,p,m/2,u/2,t.angle,0,Math.PI*2),e.stroke(),e.restore();return}if(t.type==="diamond"){let[h,x,E,w,y,v,T,I]=QV(t),M=Je(d,p),S=[wt(Je(t.x+h,t.y+x),M,t.angle),wt(Je(t.x+E,t.y+w),M,t.angle),wt(Je(t.x+y,t.y+v),M,t.angle),wt(Je(t.x+T,t.y+I),M,t.angle)];e.beginPath(),e.moveTo(S[0][0],S[0][1]);for(let _=1;_<S.length;_++)e.lineTo(S[_][0],S[_][1]);e.closePath(),e.stroke(),e.restore();return}if(t.type==="triangle"){let[h,x,E,w,y,v]=eX(t),T=Je(d,p),I=[wt(Je(t.x+h,t.y+x),T,t.angle),wt(Je(t.x+E,t.y+w),T,t.angle),wt(Je(t.x+y,t.y+v),T,t.angle)];e.beginPath(),e.moveTo(I[0][0],I[0][1]);for(let M=1;M<I.length;M++)e.lineTo(I[M][0],I[M][1]);e.closePath(),e.stroke(),e.restore();return}if(Y1(t)){let h=zo.getPointsGlobalCoordinates(t,n);if(h.length>=2){e.beginPath(),e.moveTo(h[0][0],h[0][1]);for(let x=1;x<h.length;x++)e.lineTo(h[x][0],h[x][1]);e.stroke()}e.restore();return}if(t.type==="freedraw"){let x=tX(t,o.zoom.value);if(x.length>=2){let E=Je(d,p);e.beginPath();let w=wt(Je(t.x+x[0][0],t.y+x[0][1]),E,t.angle);e.moveTo(w[0],w[1]);for(let y=1;y<x.length;y++){let v=wt(Je(t.x+x[y][0],t.y+x[y][1]),E,t.angle);e.lineTo(v[0],v[1])}e.stroke()}e.restore();return}if(V1(t)){let h=TX(t,o.zoom),x=Je(d,p),E=wt(Je(t.x,t.y+h),x,t.angle),w=wt(Je(t.x+t.width,t.y+h),x,t.angle);e.lineJoin="miter",e.lineCap="butt",e.beginPath(),e.moveTo(E[0],E[1]),e.lineTo(w[0],w[1]),e.stroke(),e.restore();return}t.type==="rectangle"&&(e.lineJoin="miter");let f=hn(t)?to.radius/o.zoom.value:qp(t)||t.type==="rectangle"?0:JV(Math.min(t.width,t.height),t)/o.zoom.value;Li(e,a,s,m,u,d,p,t.angle,!1,f),e.restore()},pM=({elementsMap:e,selectedElements:o,appState:t,editorInterface:n,renderConfig:r})=>{let i=WV(o),a=[],s=o.length===1&&Y1(o[0]);for(let c of e.values()){let d=[],p=r.remoteSelectedElementIds.get(c.id);if(s&&ys(c)&&(c.startBinding||c.endBinding)||(i.has(c.id)&&!lM(t,c)&&d.push(r.selectionColor||Jp),p&&d.push(...p.map(m=>ti(m,t.collaborators.get(m))))),d.length){let[m,u,f,h,x,E]=fc(c,e,!0);a.push({angle:c.angle,x1:m,y1:u,x2:f,y2:h,selectionColors:c.locked?["#ced4da"]:d,dashed:!!p||c.locked,cx:x,cy:E,activeEmbeddable:!qp(c)&&t.activeEmbeddable?.element===c&&t.activeEmbeddable.state==="active",padding:c.id===t.croppingElementId||W1(c)||qp(c)||hn(c)?0:void 0})}}let l=c=>{let d=X1(e,c),[p,m,u,f]=K1(d);a.push({angle:0,x1:p,x2:u,y1:m,y2:f,selectionColors:d.some(h=>h.locked)?["#ced4da"]:[r.selectionColor||Jp],dashed:!0,cx:p+(u-p)/2,cy:m+(f-m)/2,activeEmbeddable:!1})};for(let c of dX(t))l(c);return t.editingGroupId&&l(t.editingGroupId),a},uM=e=>e.selectedElementsAreBeingDragged,hM=(e,o)=>!e.selectedElementIds[o.id]&&!lM(e,o),IX=({context:e,appState:o,allElementsMap:t,elementsMap:n,selectedElements:r,renderConfig:i,editorInterface:a})=>{if(o.hoverOutlineElementId){let s=t.get(o.hoverOutlineElementId);s&&!s.isDeleted&&hM(o,s)&&dM(s)&&mM(e,o,s,n)}!o.multiElement&&!o.newElement&&!o.selectedLinearElement?.isEditing&&U1(r,o,a)&&!uM(o)&&pM({elementsMap:n,selectedElements:r,appState:o,editorInterface:a,renderConfig:i}).forEach(c=>Z1(e,o,c))},CX=(e,o,t,n)=>{let[r,i,a,s]=fc(t,n),l=a-r,c=s-i;e.strokeStyle=Qp,e.lineWidth=to.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Li(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,to.radius/o.zoom.value),e.restore()},tM=(e,o,t,n)=>{let{colors:r=[Qp],dashed:i=!1}=n||{},a=t.filter(d=>d.groupIds.length===0),s=t.filter(d=>d.groupIds.length>0),l=d=>{let[p,m,u,f]=K1(d);return{angle:0,x1:p,x2:u,y1:m,y2:f,selectionColors:r,dashed:i,cx:p+(u-p)/2,cy:m+(f-m)/2,activeEmbeddable:!1}},c=d=>{let p=X1(t,d);return l(p)};Object.entries(mX(s,o)).filter(([d,p])=>p).map(([d,p])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>Z1(e,o,d))},O1=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=zo.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=zo,a=o.selectedLinearElement?.isEditing?i:i/2,s=ys(t),l=aX(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)&&GV(c,d===r.length-1?r[0]:r[d-1],2/o.zoom.value),m=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(d);l&&t.polygon&&!m&&d===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(m=!0),N1(e,o,c,a,m,!1,p)}),ys(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,p)=>{zo.isSegmentTooShort(t,r[p+1],r[p],p,o.zoom,n)||N1(e,o,Je((d[0]+r[p+1][0])/2,(d[1]+r[p+1][1])/2),i/2,!1,!c.includes(p+1),!1)})}else zo.getEditorMidPoints(t,n,o).filter((d,p,m)=>d!==null&&!(ys(t)&&(p===0||p===m.length-1))).forEach(d=>{(o.selectedLinearElement?.isEditing||r.length===2)&&N1(e,o,d,i/2,!1,!0,!1)});e.restore()},SX=(e,o,t,n)=>{e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/o.zoom.value,e.setLineDash([4/o.zoom.value,4/o.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(n[0],n[1]),e.stroke(),e.restore()},kX=(e,o,t,n,r)=>{e.save(),e.translate(o.scrollX,o.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/o.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",Ns(e,t[0],t[1],n/o.zoom.value,!0,!0),e.restore()},oM=({arrow:e,appState:o,type:t,context:n,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,a=i?.elementId&&r.get(i.elementId);if(!a||!sM(a)||a.isDeleted)return;let s=eM(i.fixedPoint,a,r);if(!pX(s,e,a,r,o,t))return;let l=o.selectedLinearElement,c=!!l?.isDragging,d=t==="start"?0:e.points.length-1,p=!!l?.selectedPointsIndices?.includes(d);if(l?.hoveredFocusPointBinding===t&&!l.draggedFocusPointBinding&&gX(n,o,s),!(p&&c)){let m=eM(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,f=zo.getPointAtIndexGlobalCoordinates(e,d,r);SX(n,o,f,m),kX(n,o,m,ZV/1.5,u)}},nM=new Set(["nw","ne","sw","se"]),rM=(e,o,t,n,r,i,a)=>{if(r.length!==1)return;e.save(),e.translate(o.scrollX,o.scrollY),e.fillStyle="#fff";let s=jV(r[0],o.zoom,n,"mouse",G1(i));!o.viewModeEnabled&&a&&!V1(o.editingTextElement)&&!o.croppingElementId&&gM(e,t,o,s,r[0].angle),e.restore()},gM=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[s,l,c,d]=a,p=i;if(e.save(),e.lineWidth=1/t.zoom.value,p==="rotation")o.selectionColor&&(e.strokeStyle=o.selectionColor),Ns(e,s+c/2,l+d/2,c/2,!0);else if(nM.has(p)){let m=o.selectionColor||Jp;e.fillStyle="#ffffff",e.save(),e.translate(s+c/2,l+d/2),e.rotate(r),e.fillRect(-c/2,-d/2,c,d),e.strokeStyle=m,e.lineWidth=1/t.zoom.value,e.strokeRect(-c/2,-d/2,c,d),e.restore()}else o.selectionColor&&(e.strokeStyle=o.selectionColor);p!=="rotation"&&!nM.has(p)&&(e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/t.zoom.value),e.fill(),e.stroke()):Li(e,s,l,c,d,s+c/2,l+d/2,r,!0)),e.restore()}})},MX=(e,o,t,n,r)=>{let[i,a,,,s,l]=fc(n,r),c=3,d=20,p=c/t.zoom.value,m=p/2,u=s-i+p,f=l-a+p,h=Math.min(d/t.zoom.value,u),x=Math.min(d/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=p,[[[-u,-f],[0,m],[h,m],[m,0],[m,x]],[[u-m,-f],[m,m],[-h+m,m],[0,0],[0,x]],[[-u,f],[0,-m],[h,-m],[m,0],[m,-x]],[[u-m,f],[m,-m],[-h+m,-m],[0,0],[0,-x]]].forEach(w=>{let[[y,v],[T,I],[M,S],[_,A],[P,D]]=w;e.save(),e.translate(s,l),e.rotate(n.angle),e.beginPath(),e.moveTo(y+T,v+I),e.lineTo(y+M,v+S),e.stroke(),e.beginPath(),e.moveTo(y+_,v+A),e.lineTo(y+P,v+D),e.stroke(),e.restore()}),e.restore()},PX=(e,o,t,n)=>{o.save();let r=jf(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);o.translate(s+t.scrollX,l+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=n,o.globalAlpha=.5,o.setLineDash([6/t.zoom.value,4/t.zoom.value]),o.strokeRect(c,d,i,a),o.restore()},AX=(e,o,t,n,r)=>{let i=qf(e,t.zoom.value,r);i&&(o.save(),o.globalAlpha=.5,o.lineWidth=1.5/t.zoom.value,o.lineCap="round",o.strokeStyle=n,o.beginPath(),o.moveTo(i.start[0]+t.scrollX,i.start[1]+t.scrollY),o.lineTo(i.end[0]+t.scrollX,i.end[1]+t.scrollY),o.stroke(),o.restore())},LX=({app:e,canvas:o,outlineOverlayCanvas:t,elementsMap:n,visibleElements:r,selectedElements:i,allElementsMap:a,scale:s,appState:l,renderConfig:c,editorInterface:d,animationState:p,deltaTime:m})=>{if(o===null)return{atLeastOneVisibleElement:!1,elementsMap:n};let u=uM(l),[f,h]=Bs(o,s),x=p,E=Os({canvas:o,scale:s,normalizedWidth:f,normalizedHeight:h});E.save(),E.scale(l.zoom.value,l.zoom.value);let w;if(r.forEach(S=>{l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===S.id&&S&&(w=S)}),w&&O1(E,l,w,n),l.selectionElement&&!l.isCropping)try{cX(l.selectionElement,E,l,c.selectionColor)}catch(S){console.error(S)}let y=lX(i,l);if(y&&!y.autoResize&&AX(y,E,l,c.selectionColor,d.formFactor),l.editingTextElement){let S=a.get(l.editingTextElement.id);S&&!S.autoResize&&PX(S,E,l,c.selectionColor)}if(l.isBindingEnabled&&l.suggestedBinding?x={...p,bindingHighlight:xX(e,E,l.suggestedBinding,a,l,m,p?.bindingHighlight)}:x={...p,bindingHighlight:void 0},l.frameToHighlight&&CX(E,l,l.frameToHighlight,n),!t&&l.hoverOutlineElementId){let S=a.get(l.hoverOutlineElementId);S&&!S.isDeleted&&hM(l,S)&&dM(S)&&mM(E,l,S,n)}if(l.elementsToHighlight&&tM(E,l,l.elementsToHighlight,{colors:[Qp]}),l.activeLockedId){let S=a.get(l.activeLockedId),_=S?[S]:X1(a,l.activeLockedId);tM(E,l,_,{colors:["#ced4da"],dashed:!0})}let v=i.some(S=>hn(S));i.length===1&&l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===i[0].id&&O1(E,l,i[0],n);let T=l.selectedLinearElement,I=T&&zo.getElement(T.elementId,a);if(I&&(l.selectedLinearElement.isDragging||(T.segmentMidPointHoveredCoords?uX(E,l):(ys(I)?T.hoverPointIndex===0||T.hoverPointIndex===I.points.length-1:T.hoverPointIndex>=0)&&hX(E,l,n)),iX(I)&&(oM({arrow:I,elementsMap:a,appState:l,context:E,type:"start"}),oM({arrow:I,elementsMap:a,appState:l,context:E,type:"end"}))),!l.multiElement&&!l.newElement&&!l.selectedLinearElement?.isEditing){let S=U1(i,l,d);i.length===1&&Y1(i[0])&&l.selectedLinearElement?.elementId===i[0].id&&!i[0].locked&&O1(E,l,i[0],n);let A=c.selectionColor||Jp;if(S&&!u){let P=pM({elementsMap:n,selectedElements:i,appState:l,editorInterface:d,renderConfig:c});t||P.forEach(D=>Z1(E,l,D))}if(E.save(),E.translate(l.scrollX,l.scrollY),i.length===1){if(!t&&!u&&rM(E,l,c,n,i,d,S),l.croppingElementId&&!l.isCropping){let P=n.get(l.croppingElementId);P&&W1(P)&&MX(E,c,l,P,n)}}else if(i.length>1&&!l.isRotating&&!u&&!i.some(P=>P.locked)){let P=iM*2/l.zoom.value;E.fillStyle="#fff";let[D,z,K,W]=K1(i,n),Y=E.getLineDash();E.setLineDash([2/l.zoom.value]);let G=E.lineWidth;E.lineWidth=cM/l.zoom.value,E.strokeStyle=A,Li(E,D-P,z-P,K-D+P*2,W-z+P*2,(D+K)/2,(z+W)/2,0),E.lineWidth=G,E.setLineDash(Y);let J=qV([D,z,K,W,(D+K)/2,(z+W)/2],0,l.zoom,"mouse",v?{...G1(d),rotation:!0}:G1(d));i.some($=>!$.locked)&&gM(E,c,l,J,0)}E.restore()}l.searchMatches?.matches.forEach(({id:S,focus:_,matchedLines:A})=>{let P=n.get(S);if(P){let[D,z,,,K,W]=fc(P,n,!0);E.save(),l.theme===Dr.LIGHT?_?E.fillStyle="rgba(255, 124, 0, 0.4)":E.fillStyle="rgba(255, 226, 0, 0.4)":_?E.fillStyle="rgba(229, 82, 0, 0.4)":E.fillStyle="rgba(99, 52, 0, 0.4)";let Y=hn(P)?l.zoom.value:1;E.translate(l.scrollX,l.scrollY),E.translate(K,W),E.rotate(P.angle),A.forEach(G=>{(G.showOnCanvas||_)&&E.fillRect(D+G.offsetX/Y-K,z+G.offsetY/Y-W,G.width/Y,G.height/Y)}),E.restore()}}),qk(E,l),E.restore(),wv({context:E,renderConfig:c,appState:l,normalizedWidth:f,normalizedHeight:h});let M;if(c.renderScrollbars&&(M=kC(n,f,h,l),E.save(),E.fillStyle=SC,E.strokeStyle="rgba(255,255,255,0.8)",[M.horizontal,M.vertical].forEach(S=>{S&&Kd(E,S.x,S.y,S.width,S.height,mo/2)}),E.restore()),t){let[S,_]=Bs(t,s),A=Os({canvas:t,scale:s,normalizedWidth:S,normalizedHeight:_});if(A.save(),A.scale(l.zoom.value,l.zoom.value),IX({context:A,appState:l,allElementsMap:a,elementsMap:n,selectedElements:i,renderConfig:c,editorInterface:d}),!l.multiElement&&!l.newElement&&!l.selectedLinearElement?.isEditing&&!u){let P=U1(i,l,d);rM(A,l,c,n,i,d,P)}A.restore()}return{scrollBars:M,atLeastOneVisibleElement:r.length>0,elementsMap:n,animationState:x}},fM=e=>{let o=LX(e);return e.callback(o),o};var gt=class gt{static start(o,t){let n=t({deltaTime:0,state:void 0});n&&(gt.animations.set(o,{animation:t,lastTime:0,state:n}),gt.isRunning||(gt.isRunning=!0,Xl()?requestAnimationFrame(gt.tick):setTimeout(gt.tick,0)))}static tick(){if(gt.animations.size>0){for(let[o,t]of gt.animations){let n=performance.now(),r=t.lastTime===0?0:n-t.lastTime,i=t.animation({deltaTime:r,state:t.state});if(i)t.lastTime=n,t.state=i;else if(gt.animations.delete(o),gt.animations.size===0){gt.isRunning=!1;return}}Xl()?requestAnimationFrame(gt.tick):setTimeout(gt.tick,0)}}static running(o){return gt.animations.has(o)}static cancel(o){gt.animations.delete(o)}};k(gt,"isRunning",!1),k(gt,"animations",new Map);var bc=gt;import{jsx as FX}from"react/jsx-runtime";var EM="animateInteractiveScene",BX=e=>{let o=bM(!1),t=bM(null);return DX(()=>{if(!o.current){o.current=!0;return}let n=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,NX({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),n.set(d,c.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#8F6AEF";t.current={app:e.app,canvas:e.canvas,outlineOverlayCanvas:e.outlineOverlayCanvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:n,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:s,selectionColor:l,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.lastViewportPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},bc.running(EM)||bc.start(EM,({deltaTime:c,state:d})=>{let p=fM({...t.current,deltaTime:c,animationState:d}).animationState;if(p){for(let m in p)if(p[m]!==void 0)return p}})}),FX("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled&&e.appState.activeTool.type!=="laser"?xM.GRAB:xM.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:g("labels.drawingCanvas")})},yM=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,hoverOutlineElementId:e.hoverOutlineElementId,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,suggestedBinding:e.suggestedBinding,isRotating:e.isRotating,isResizing:e.isResizing,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,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged}),OX=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:RX(yM(e.appState),yM(o.appState)),j1=_X.memo(BX,OX);import zX,{useEffect as wM,useRef as vM}from"react";import{isShallowEqual as TM}from"@nous-excalidraw/common";import{jsx as UX}from"react/jsx-runtime";var HX=e=>{let o=vM(null),t=vM(!1);return wM(()=>{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]),wM(()=>{let n=o.current;if(!n)return;let r=e.canvas;t.current||(t.current=!0,n.replaceChildren(r),r.classList.add("excalidraw__canvas","static")),a0({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Xl())}),UX("div",{className:"excalidraw__canvas-wrapper",ref:o})},IM=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}),GX=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:TM(IM(e.appState),IM(o.appState))&&TM(e.renderConfig,o.renderConfig),q1=zX.memo(HX,GX);import{useLayoutEffect as ZX,useRef as jX}from"react";import{throttleRAF as WX}from"@nous-excalidraw/common";import{getTargetFrame as YX,isInvisiblySmallElement as VX,renderElement as XX,shouldApplyFrameClip as KX}from"@nous-excalidraw/element";var CM=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=Bs(e,i),d=Os({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(VX(t)){d.restore();return}if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let m=YX(t,n,a);m&&KX(t,m,a,n)&&r0(m,d,s,a)}XX(t,n,r,o,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},$X=WX(e=>{CM(e)}),SM=(e,o)=>{if(o){$X(e);return}CM(e)};import{jsx as JX}from"react/jsx-runtime";var qX=e=>{let o=jX(null);return ZX(()=>{o.current&&SM({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},!1)}),JX("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},kM=qX;var eu=class{constructor(o){this.getState=o;k(this,"listeners",[]);k(this,"onStateChange",(o,t,n)=>{let{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}=this.normalize(o,t,n);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(o){return typeof o=="object"&&!Array.isArray(o)&&"predicate"in o}subscribe(o){return this.listeners.push(o),()=>{this.listeners=this.listeners.filter(t=>t!==o)}}normalize(o,t,n){let r,i,a=t,s=n?.once??!1,l=!1;if(this.isStateChangePredicateOptions(o)){let{predicate:c,callback:d,once:p}=o;r=c,i=m=>m,a=d?(m,u)=>d(u):void 0,s=p??!1,l=c(this.getState())}else if(typeof o=="function"){let c=o;r=(d,p)=>c(d)!==c(p),i=d=>c(d)}else if(Array.isArray(o)){let c=o;r=(d,p)=>c.some(m=>d[m]!==p[m]),i=d=>d}else{let c=o;r=(d,p)=>d[c]!==p[c],i=d=>d[c]}return{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}}flush(o){if(!this.listeners.length)return;let t=this.getState(),n=[];for(let r of this.listeners)r.predicate(t,o)?(r.callback(r.getValue(t),t),r.once||n.push(r)):n.push(r);this.listeners=n}clear(){this.listeners=[]}};import{getCommonBounds as QX,getElementsInGroup as eK,selectGroupsFromGivenElements as tK}from"@nous-excalidraw/element";import{sceneCoordsToViewportCoords as oK}from"@nous-excalidraw/common";import{flushSync as nK}from"react-dom";import{jsx as iK}from"react/jsx-runtime";var rK=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:eK(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=QX(n),{x:a,y:s}=oK({sceneX:r,sceneY:i},e.state);return iK("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-s+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{nK(()=>{let l=tK(n,e.state);e.setState({selectedElementIds:n.reduce((c,d)=>({...c,[d.id]:!0}),{}),selectedGroupIds:l,activeLockedId:null})}),e.actionManager.executeAction(wl)},title:g("labels.elementLock.unlock"),children:P0})},MM=rK;import{sceneCoordsToViewportCoords as aK}from"@nous-excalidraw/common";import{getElementAbsoluteCoords as sK}from"@nous-excalidraw/element";import{jsxs as lK}from"react/jsx-runtime";var PM=({element:e,elementsMap:o,appState:t})=>{let[n,,r,i]=sK(e,o,!0),a=(n+r)/2,{x:s,y:l}=aK({sceneX:a,sceneY:i},t),c=s-t.offsetLeft,d=l-t.offsetTop+6,p=Math.round(e.width),m=Math.round(e.height);return lK("div",{className:"excalidraw-frame-resize-dimensions",style:{left:c,top:d,transform:"translateX(-50%)"},children:[p," x ",m]})};import{Fragment as dZ,jsx as we,jsxs as pu}from"react/jsx-runtime";var YP=wo.createContext(null),VP=wo.createContext(null),Px={formFactor:"desktop",desktopUIMode:"full",userAgent:UP(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},Lx=wo.createContext(Px);Lx.displayName="EditorInterfaceContext";var lZ={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},_x=wo.createContext({container:null,id:null});_x.displayName="ExcalidrawContainerContext";var Dx=wo.createContext([]);Dx.displayName="ExcalidrawElementsContext";var Rx=wo.createContext({...Yo(),width:0,height:0,offsetLeft:0,offsetTop:0});Rx.displayName="ExcalidrawAppStateContext";var Nx=wo.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Nx.displayName="ExcalidrawSetAppStateContext";var Bx=wo.createContext(null);Bx.displayName="ExcalidrawActionManagerContext";var Ms=wo.createContext(null);Ms.displayName="ExcalidrawAPIContext";var hu=wo.createContext(null);hu.displayName="ExcalidrawAPISetContext";var He=()=>Yn(YP),qo=()=>Yn(VP),be=()=>Yn(Lx),dt=()=>uu(be()),Ne=()=>Yn(_x),Qn=()=>Yn(Dx),jo=()=>Yn(Rx),he=()=>Yn(Nx),Be=()=>Yn(Bx),gu=()=>Yn(Ms),Tc=!1,Cx=0,Ic=null,Or=!1,Cc=!1,Sx=!1,Sc={horizontal:null,vertical:null},Fr=0,kc=!1,kx=new Map,Mx=!1,FP=0,zP=!1,Mc=null,Ce={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Ci=class Ci extends wo.Component{constructor(t){super(t);k(this,"canvas");k(this,"interactiveCanvas",null);k(this,"outlineOverlayCanvas",null);k(this,"sessionExportThemeOverride");k(this,"rc");k(this,"unmounted",!1);k(this,"actionManager");k(this,"editorInterface",Px);k(this,"stylesPanelMode",uu(Px));k(this,"excalidrawContainerRef",wo.createRef());k(this,"scene");k(this,"fonts");k(this,"renderer");k(this,"visibleElements");k(this,"resizeObserver");k(this,"library");k(this,"libraryItemsFromStorage");k(this,"id");k(this,"store");k(this,"history");k(this,"excalidrawContainerValue");k(this,"files",{});k(this,"imageCache",new Map);k(this,"iFrameRefs",new Map);k(this,"embedsValidationStatus",new Map);k(this,"initializedEmbeds",new Set);k(this,"elementsPendingErasure",new Set);k(this,"_initialized",!1);k(this,"editorLifecycleEvents",new UK(lZ));k(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));k(this,"appStateObserver",new eu(()=>this.state));k(this,"onStateChange",this.appStateObserver.onStateChange);k(this,"flowChartCreator",new P$);k(this,"flowChartNavigator",new A$);k(this,"bindModeHandler",null);k(this,"hitLinkElement");k(this,"lastPointerDownEvent",null);k(this,"lastPointerUpEvent",null);k(this,"lastPointerUpIsDoubleClick",!1);k(this,"lastPointerMoveEvent",null);k(this,"lastPointerMoveCoords",null);k(this,"lastCompletedCanvasClicks",[]);k(this,"previousPointerMoveCoords",null);k(this,"lastViewportPosition",{x:0,y:0});k(this,"animationFrameHandler",new Um);k(this,"laserTrails",new Xm(this.animationFrameHandler,this));k(this,"eraserTrail",new Jm(this.animationFrameHandler,this));k(this,"lassoTrail",new qm(this.animationFrameHandler,this));k(this,"onChangeEmitter",new vi);k(this,"onPointerDownEmitter",new vi);k(this,"onPointerUpEmitter",new vi);k(this,"onUserFollowEmitter",new vi);k(this,"onScrollChangeEmitter",new vi);k(this,"missingPointerEventCleanupEmitter",new vi);k(this,"onRemoveEventListenersEmitter",new vi);k(this,"api");k(this,"updateEditorAtom",(t,...n)=>{let r=nt.set(t,...n);return this.triggerRender(),r});k(this,"previousHoveredBindableElement",null);k(this,"getEffectiveGridSize",()=>yr(this)?this.state.gridSize:null);k(this,"getTextCreationGridPoint",(t,n)=>{let r=this.getEffectiveGridSize();if(r===null)return null;let i=a=>Math.floor(a/r)*r;return{x:i(t),y:i(n)}});k(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:n,moveEvent:r})=>t&&dx(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,n.x,n.y))?(ve(this.interactiveCanvas,Fe.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));k(this,"isDoubleClick",(t,n)=>t!=null&&n.timeStamp-t.timeStamp<=WM);k(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),vc.delete(t)});k(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(Go(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=hx(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else Ss(r)&&t.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});k(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);k(this,"frameNameBoundsCache",{get:t=>{let n=this.frameNameBoundsCache._cache.get(t.id);if(!n||n.zoom!==this.state.zoom.value||n.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=ze({clientX:i.x,clientY:i.y},this.state),s=ze({clientX:i.right,clientY:i.bottom},this.state);return n={x:a.x,y:a.y,width:s.x-a.x,height:s.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,n),n}return null}return n},_cache:new Map});k(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});k(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===ws.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&Qe(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!dP(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}=ru({sceneX:i.x,sceneY:i.y},this.state),l=6,c,d=T$(i),p=t?Nr.nameColorDarkTheme:Nr.nameColorLightTheme,m=this.state.hoveredFrameId===i.id&&!this.state.selectedElementIds[i.id],x=!!this.state.selectedElementIds[i.id]?"#8F6AEF":m?"#C6A6FF":p;if(i.id===this.state.editingFrame){let E=d;c=we("input",{autoFocus:!0,value:E,onChange:w=>{this.scene.mutateElement(i,{name:w.target.value})},onFocus:w=>w.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:w=>{(w.key===Z.ESCAPE||w.key===Z.ENTER)&&this.resetEditingFrame(i)},style:{background:t?GK(this.state.viewBackgroundColor):this.state.viewBackgroundColor,zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Nr.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:x,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-l}px`},size:E.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return we("div",{id:this.getFrameNameDOMId(i),className:sx.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+Nr.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Nr.nameFontSize,color:x,lineHeight:Nr.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:Fe.MOVE,pointerEvents:this.state.viewModeEnabled?vs.disabled:vs.enabled},onPointerMove:E=>{if(this.state.viewModeEnabled)return;let w=ze(E,this.state);this.updateFrameHoverStateFromSceneCoords(w.x,w.y)},onPointerDown:E=>this.handleCanvasPointerDown(E),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});k(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});k(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());k(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());k(this,"getSceneElements",()=>this.scene.getNonDeletedElements());k(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});k(this,"onExportImage",async(t,n,r)=>{me("export",t,"ui");let i=await Jr(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(FK).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Fc(i)&&this.setState({fileHandle:i})});k(this,"magicGenerations",new Map);k(this,"updateMagicGeneration",({frameElement:t,data:n})=>{n.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:n}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,n),this.triggerRender()});k(this,"plugins",{});k(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:fn.magicframe}),me("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&mx(t[0])&&t[0];if(!n&&t.some(i=>Qe(i)||i.frameId)){this.setActiveTool({type:fn.magicframe});return}me("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,s,l]=Ti(t),c=50;r=rP({...Nr,x:i-c,y:a-c,width:s-i+c*2,height:l-a+c*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let d of t)this.scene.mutateElement(d,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});k(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(Jn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(n,r)=>{let i=t==="background"&&r.altKey||t==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:n},captureUpdate:Xt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:Xt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(s=>this.state.selectedElementIds[s.id]?Wn(s,{[i?"strokeColor":"backgroundColor"]:n}):s),captureUpdate:Xt.IMMEDIATELY})},keepOpenOnAlt:!1})});k(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});k(this,"syncActionResult",$e(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let n=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),n=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,s=t?.appState?.theme||this.props.theme||ws.LIGHT,l=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r&&t.elements.forEach(d=>{r?.id===d.id&&r!==d&&AP(d)&&kt(d)&&(r=d)}),r?.isDeleted&&(r=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}}),n=!0}n||this.scene.triggerUpdate()}));k(this,"onBlur",$e(()=>{Or=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));k(this,"onUnload",()=>{this.onBlur()});k(this,"disableEvent",t=>{t.preventDefault()});k(this,"resetHistory",()=>{this.history.clear()});k(this,"resetStore",()=>{this.store.clear()});k(this,"resetScene",$e(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...Yo(),isLoading:t?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));k(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async p=>{if(!p.files.length)return;let m=p.files[0],u=await m.getFile();this.loadFileToCanvas(new File([u],u.name||"",{type:u.type}),m)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(p=>{console.error(p)})}catch(p){console.error(p),t={appState:{errorMessage:p.message||"Encountered an error during importing or restoring scene data"}}}let n=Gr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=_i(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r={...r,...Hr(n,{...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})});let a=To(CK),s=n.filter(p=>!p.isDeleted),l=r.zoom.value,c=a;if(s.length){let{appState:p}=ua({targetElements:s,appState:{...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft,zoom:{value:a}},fitToViewport:!1,maxZoom:a,canvasOffsets:this.getEditorUIOffsets()});c=p.zoom.value,r={...r,scrollX:p.scrollX,scrollY:p.scrollY,zoom:p.zoom,currentItemFontSize:ox(r.currentItemFontSize,l,c)}}else r={...r,zoom:{value:a},currentItemFontSize:ox(r.currentItemFontSize,l,a)};r={...r,currentItemStrokeWidthCustom:!1,currentItemStrokeWidth:XM(c)};let d=n.map(p=>{if(!kt(p))return p;let m=ox(p.fontSize,l,c);return m===p.fontSize?p:Wn(p,{fontSize:m})});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:d,appState:r,files:t?.files,captureUpdate:Xt.NEVER});for(let p of this.scene.getNonDeletedElements())kt(p)&&bP(p,this.scene.getContainerElement(p),this.scene);this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(p=>{this.fonts.onLoaded(p)}),yx(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});k(this,"getFormFactor",(t,n)=>this.props.UIOptions.getFormFactor?.(t,n)??XK(t,n));k(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=jK(),a=UP(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:EK,l=ax(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(n,r),userAgent:a,canFitSidebar:n>s,isLandscape:n>r});this.editorInterface=l,this.reconcileStylesPanelMode(l)});k(this,"reconcileStylesPanelMode",t=>{let n=uu(t);if(n===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=n,r!=="full"&&n==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});k(this,"setDesktopUIMode",t=>{let n=qK(t);this.editorInterface=ax(this.editorInterface,{desktopUIMode:n}),this.reconcileStylesPanelMode(this.editorInterface)});k(this,"onResize",$e(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>vc.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));k(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});k(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:n,elementsMap:r})=>{n&&(Sc=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});k(this,"onScroll",ZM(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},yK));k(this,"onCut",$e(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||xc(t.target)||(this.actionManager.executeAction(jd,"keyboard",t),t.preventDefault(),t.stopPropagation())}));k(this,"onCopy",$e(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||xc(t.target)||(this.actionManager.executeAction(Ia,"keyboard",t),t.preventDefault(),t.stopPropagation())}));k(this,"onTouchStart",t=>{if(KK&&t.preventDefault(),!Tc){Tc=!0,t.touches.length===1&&(Ic={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Cx),Cx=window.setTimeout(Ci.resetTapTwice,WM);return}if(Tc&&t.touches.length===1&&Ic){let n=t.touches[0];Hn(oe(n.clientX,n.clientY),oe(Ic.x,Ic.y))<=QM&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),Tc=!1,clearTimeout(Cx)}t.touches.length===2&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null})});k(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}):Ce.pointers.clear()});k(this,"pasteFromClipboard",$e(async t=>{let n=!!Mx,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||xc(r)))return;let s=await ga(t),l=s.getFiles(),c=await Hd(s,n);if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(c,l,n),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t?.preventDefault()}));k(this,"addElementsFromPasteOrLibrary",t=>{let n=Gr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=Ti(n),l=Ts(r,a)/2,c=Ts(i,s)/2,d=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,p=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:m,y:u}=ze({clientX:d,clientY:p},this.state),f=m-l,h=u-c,[x,E]=St(f,h,this.getEffectiveGridSize()),{duplicatedElements:w}=lx({type:"everything",elements:n.map(S=>Wn(S,{x:S.x+x-r,y:S.y+E-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...w];v=this.props.onDuplicate?.(v,y)||v,CP(v,iu(w));let I=this.getTopLayerFrameAtSceneCoords({x:m,y:u});if(I){let S=C$(w,I);Ex(v,S,I,this.state)}this.scene.replaceAllElements(v),w.forEach(S=>{if(kt(S)&&cx(S)){let _=gP(S,this.scene.getElementsMapIncludingDeleted());bP(S,_,this.scene)}}),ZK&&yn.loadElementsFonts(w).then(S=>{this.fonts.onLoaded(S)}),t.files&&this.addMissingFiles(t.files);let M=Y$(w);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&nt.get(Ql)?this.state.openSidebar:null,...yo({editingGroupId:null,selectedElementIds:M.reduce((S,_)=>(cx(_)||(S[_.id]=!0),S),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t.fitToContent&&this.scrollToContent(w,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});k(this,"setAppState",(t,n)=>{this.setState(t,n)});k(this,"removePointer",t=>{Fr&&this.resetContextMenuTimer(),Ce.pointers.delete(t.pointerId)});k(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||me("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...bn(this.state,n.activeTool.locked?{type:this.state.preferredSelectionTool.type}:n.activeTool),locked:!n.activeTool.locked}}))});k(this,"updateFrameRendering",t=>{this.setState(n=>{let r=typeof t=="function"?t(n.frameRendering):t;return{frameRendering:{enabled:r?.enabled??n.frameRendering.enabled,clip:r?.clip??n.frameRendering.clip,name:r?.name??n.frameRendering.name,outline:r?.outline??n.frameRendering.outline}}})});k(this,"togglePenMode",t=>{this.setState(n=>({penMode:t??!n.penMode,penDetected:!0}))});k(this,"onHandToolToggle",()=>{this.actionManager.executeAction(Nw)});k(this,"zoomCanvas",t=>{let n=Sn({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:To(t)},this.state);this.syncSceneStrokeWidthsForZoom(n.zoom.value),this.setState(n)});k(this,"syncSceneStrokeWidthsForZoom",(t,n=this.state.zoom.value)=>{t!==n&&this.scene.replaceAllElements(sZ(this.scene.getElementsIncludingDeleted(),n,t))});k(this,"cancelInProgressAnimation",null);k(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let l;if(yx(t)?l=D$(t):l=t,l){let c=this.scene.getElementsFromId(l);c?.length?this.scrollToContent(c,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):yx(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let r=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,s=this.state.scrollY;if(n?.fitToContent||n?.fitToViewport){let{appState:l}=ua({canvasOffsets:n.canvasOffsets,fitCanvasOffsets:n.fitCanvasOffsets,scrollCanvasOffsets:n.scrollCanvasOffsets,targetElements:r,appState:this.state,fitToViewport:!!n?.fitToViewport,viewportZoomFactor:n?.viewportZoomFactor,minZoom:n?.minZoom,maxZoom:n?.maxZoom});if(i=l.zoom,a=l.scrollX,s=l.scrollY,n?.clampHostStylebarAboveElement){let d=(n.fitCanvasOffsets??n.canvasOffsets)?.top??0,[,p]=Ti(r),m=(d+Ci.HOST_STYLEBAR_GAP_ABOVE_ELEMENT)/i.value-p;s<m&&(s=m)}}else{let l=Hr(r,this.state);a=l.scrollX,s=l.scrollY}if(n?.animate){let l=this.state.scrollX,c=this.state.scrollY,d=this.state.zoom.value,p=this.state.currentItemStrokeWidth,m=this.state.currentItemStrokeWidthCustom,u=this.state.currentItemFontSize,f=OK({fromValues:{scrollX:l,scrollY:c,zoom:d},toValues:{scrollX:a,scrollY:s,zoom:i.value},interpolateValue:(h,x,E,w)=>{if(w==="zoom")return h*Math.pow(x/h,zK(E))},onStep:({scrollX:h,scrollY:x,zoom:E})=>{this.syncSceneStrokeWidthsForZoom(E),this.setState({scrollX:h,scrollY:x,zoom:{value:E},currentItemStrokeWidth:VM(p,d,E,m),currentItemFontSize:YM(u,d,E)})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:n?.duration??500});this.cancelInProgressAnimation=()=>{f(),this.cancelInProgressAnimation=null}}else this.syncSceneStrokeWidthsForZoom(i.value),this.setState({scrollX:a,scrollY:s,zoom:i,currentItemStrokeWidth:VM(this.state.currentItemStrokeWidth,this.state.zoom.value,i.value,this.state.currentItemStrokeWidthCustom),currentItemFontSize:YM(this.state.currentItemFontSize,this.state.zoom.value,i.value)})});k(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});k(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser();let n=(r,i)=>{let a=r?.zoom?.value;a!=null&&a!==i&&this.syncSceneStrokeWidthsForZoom(a)};typeof t=="function"?this.setState((r,i)=>{let a=t(r,i);return n(a,r.zoom.value),a}):(n(t,this.state.zoom.value),this.setState(t))});k(this,"setToast",t=>{this.setState({toast:t})});k(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),n=await t.match("shared-file");if(n){let r=await n.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,uK,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});k(this,"addFiles",$e(t=>{let{addedFiles:n}=this.addMissingFiles(t);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));k(this,"addMissingFiles",(t,n=!1)=>{let r=n?{}:{...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===gn.svg))try{let l=g0(hP(f0(s.dataURL)),gn.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});k(this,"updateScene",$e(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=n||void 0,l=r?JK({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:s,appState:l})}r&&this.setState(r),n&&this.scene.replaceAllElements(n),i&&this.setState({collaborators:i})}));k(this,"applyDeltas",(t,n)=>{let r=_P.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return _P.applyTo(r,a,i,n)});k(this,"mutateElement",(t,n,r=!0)=>this.scene.mutateElement(t,n,{informMutation:r,isDragging:!1}));k(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});k(this,"toggleSidebar",({name:t,tab:n,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===n?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&n&&(a.tab=n),this.setState({openSidebar:a}),!!i});k(this,"updateCurrentCursorPosition",$e(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));k(this,"getHostUiBottomRelativeToContainer",(t,n)=>{let r=document.querySelector(t)?.getBoundingClientRect();return!r||r.width<=0||r.height<=0?0:Math.max(r.bottom-n,0)});k(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current,n=t?.getBoundingClientRect()?.top??0,r=t?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,i=this.getHostUiBottomRelativeToContainer(Ci.HOST_TOOLBAR_SELECTOR,n),a=Math.max(r-n,i,0),s=t?.querySelector(".sidebar")?.getBoundingClientRect(),l=t?.querySelector(".App-menu__left")?.getBoundingClientRect(),c=16;return vn().rtl?{top:a+c,right:Math.max(this.state.width-(l?.left??this.state.width),0)+c,bottom:c,left:Math.max(s?.right??0,0)+c}:{top:a+c,right:Math.max(this.state.width-(s?.left??this.state.width)+c,0),bottom:c,left:Math.max(l?.right??0,0)+c}});k(this,"onKeyDown",$e(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(s,l){let c=s[l];return typeof c=="function"?c.bind(s):l==="key"?t.shiftKey?s.key.toUpperCase():s.key.toLowerCase():c}})),!jM(t.target)){if((t.key===Z.ESCAPE||t.key===Z.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let s=ie(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&Cs(s[0])&&t.key===Z.ENTER){this.startImageCropping(s[0]);return}if(t.key===Z.ESCAPE)this.updateEditorAtom(Po,null);else if(t.key===Z.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(sx.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=Aa(s);nt.get(Po)?.type==="panel"&&Og(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(Po,{type:"panel"})}if(t.key===Z.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=tu(t.key);if(t[Z.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let c=ie(this.scene.getNonDeletedElementsMap(),this.state);c.length===1&&p$(c[0])&&this.flowChartCreator.createNodes(c[0],this.state,wP(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!ux(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let c=ie(this.scene.getNonDeletedElementsMap(),this.state);if(c.length===1&&l){t.preventDefault();let d=this.flowChartNavigator.exploreByDirection(c[0],this.scene.getNonDeletedElementsMap(),wP(t.key));if(d){this.setState(m=>({selectedElementIds:Me({[d]:!0},m)}));let p=this.scene.getNonDeletedElementsMap().get(d);p&&!ux([p],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(p,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[Z.CTRL_OR_CMD]&&t.key===Z.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:De("commandPalette")})}),t.preventDefault();return}if(t[Z.CTRL_OR_CMD]&&t.key.toLowerCase()===Z.V&&(Mx=t.shiftKey,clearTimeout(FP),FP=window.setTimeout(()=>{Mx=!1},100)),t[Z.CTRL_OR_CMD]&&xc(t.target)&&(t.code===BM.MINUS||t.code===BM.EQUAL)){t.preventDefault();return}if(xc(t.target)&&t.key!==Z.ESCAPE||tu(t.key)&&jM(t.target))return;if(t.key===Z.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===Z.E&&t.shiftKey&&t[Z.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===Z.PAGE_UP||t.key===Z.PAGE_DOWN){let s=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===Z.PAGE_DOWN&&(s=-s),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+s})):this.translateCanvas(l=>({scrollY:l.scrollY+s}))}if(this.state.openDialog?.name==="elementLinkSelector"||(t.key===Z.ALT&&(Un("COMPLEX_BINDINGS")?this.handleSkipBindMode():mu({app:this,event:t})),this.actionManager.handleKeyDown(t)))return;let n=this.props.viewModeEnabled===!0;if(!n&&this.state.viewModeEnabled&&t.key===Z.ESCAPE){this.setActiveTool({type:"selection"});return}if(!n&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let s=_T(t.key,this);if(this.state.viewModeEnabled&&!eP(s,["laser","hand"]))return;if(s){this.state.activeTool.type!==s&&me("toolbar",s,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),s==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===Br.sharp?Br.round:l.currentItemArrowType===Br.round?Br.elbow:Br.sharp})),s==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:s}),t.stopPropagation();return}else if(t.key===Z.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[Z.CTRL_OR_CMD]&&!t.repeat&&(Un("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Yt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),mu({app:this,event:t})),tu(t.key)){let s=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=new Set;s.filter(m=>En(m)).filter(m=>{let u=m.startBinding&&!s.some(h=>h.id===m.startBinding?.elementId),f=m.endBinding&&!s.some(h=>h.id===m.endBinding?.elementId);return u||f}).forEach(m=>l.add(m.id)),s=s.filter(m=>!l.has(m.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?GM:this.getEffectiveGridSize())||(t.shiftKey?fK:GM),d=0,p=0;t.key===Z.ARROW_LEFT?d=-c:t.key===Z.ARROW_RIGHT?d=c:t.key===Z.ARROW_UP?p=-c:t.key===Z.ARROW_DOWN&&(p=c),s.forEach(m=>{this.scene.mutateElement(m,{x:m.x+d,y:m.y+p},{informMutation:!1,isDragging:!1}),su(m,this.scene,{simultaneouslyUpdated:s})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===Z.ENTER){let s=this.scene.getSelectedElements(this.state);if(s.length===1){let l=s[0];if(t[Z.CTRL_OR_CMD]||wx(l))Bt(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),Vt(l)||this.actionManager.executeAction(Va));else if(kt(l)||fP(l)){let c;kt(l)||(c=l);let d=fx(l,this.state,this.scene.getNonDeletedElementsMap()),p=d.x,m=d.y;this.startTextEditing({sceneX:p,sceneY:m,container:c}),t.preventDefault();return}else Qe(l)&&this.setState({editingFrame:l.id})}}if(t.key===Z.SPACE&&Ce.pointers.size===0&&(Or=!0,ve(this.interactiveCanvas,Fe.GRAB),t.preventDefault()),(t.key===Z.G||t.key===Z.S)&&!t.altKey&&!t[Z.CTRL_OR_CMD]){let s=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!s.length)return;t.key===Z.G&&(Uo(this.state.activeTool.type)||s.some(l=>Uo(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===Z.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[Z.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===Z.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=>kt(l)||gx(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}t[Z.CTRL_OR_CMD]&&(t.key===Z.BACKSPACE||t.key===Z.DELETE)&&this.updateEditorAtom(ii,"clearCanvas");let r=t.key.toLocaleLowerCase(),i=r===Z.S&&t.shiftKey&&!t[Z.CTRL_OR_CMD],a=t.key===Z.I||r===Z.G&&t.shiftKey;(i||a)&&this.openEyeDropper({type:i?"stroke":"background"})}));k(this,"onKeyUp",$e(t=>{if(t.key===Z.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?ve(this.interactiveCanvas,Fe.GRAB):au(this.state.activeTool.type)?Zt(this.interactiveCanvas):(jt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Or=!1),t.key===Z.ALT&&mu({app:this,event:t}),(t.key===Z.ALT&&this.state.bindMode==="skip"||!t[Z.CTRL_OR_CMD]&&!yc(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Un("COMPLEX_BINDINGS"))){let n=ze({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Ho(oe(n.x,n.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=Ee.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());En(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[Z.CTRL_OR_CMD]){let n=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==n&&Yt(()=>{this.setState({isBindingEnabled:n})}),mu({app:this,event:t})}if(tu(t.key)){oP(this.scene.getSelectedElements(this.state).filter(Is),this.scene,this.state);let n=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(vx).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...RP(r,n.get(r.startBinding.elementId),"start",n)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...RP(r,n.get(r.endBinding.elementId),"end",n)}})}),this.setState({suggestedBinding:null})}if(t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:Xt.IMMEDIATELY})),!t[Z.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:Me({[n.id]:!0},r)})),ux([n],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(n,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:Xt.IMMEDIATELY})}}));k(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);k(this,"setActiveTool",(t,n=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=bn(this.state,t);r.type==="hand"?ve(this.interactiveCanvas,Fe.GRAB):Or||jt(this.interactiveCanvas,{...this.state,activeTool:r}),RK(document.activeElement)&&this.focusContainer(),d$(r.type)||this.setState({suggestedBinding:null}),r.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:au(r.type)?i.selectedLinearElement:null};return r.type==="freedraw"&&this.store.scheduleCapture(),r.type==="lasso"?{...i,...a,activeTool:r,...n?{}:{selectedElementIds:Me({},i),selectedGroupIds:Me({},i),editingGroupId:null,multiElement:null}}:r.type!=="selection"?{...i,...a,activeTool:r,selectedElementIds:Me({},i),selectedGroupIds:Me({},i),editingGroupId:null,multiElement:null}:{...i,...a,activeTool:r}})});k(this,"setOpenDialog",t=>{this.setState({openDialog:t})});k(this,"setCursor",t=>{ve(this.interactiveCanvas,t)});k(this,"resetCursor",()=>{Zt(this.interactiveCanvas)});k(this,"isTouchScreenMultiTouchGesture",()=>Ce.pointers.size>=2);k(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${qM()}`);k(this,"onGestureStart",$e(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null}),Ce.initialScale=this.state.zoom.value}));k(this,"onGestureChange",$e(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=Ce.initialScale;n&&this.setState(r=>{let i=Sn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:To(n*t.scale)},r);return i.zoom.value!==r.zoom.value&&this.syncSceneStrokeWidthsForZoom(i.zoom.value),i})}));k(this,"onGestureEnd",$e(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}),Ce.initialScale=null}));k(this,"isHittingTextAutoResizeHandle",(t,n)=>{let r=OP(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&uC(n,r,this.state.zoom.value,this.editorInterface.formFactor))});k(this,"handleTextAutoResizeHandlePointerDown",(t,n)=>{let r=OP(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,n)?!1:(this.actionManager.executeAction(Hf,"ui",r),this.resetCursor(),!0)});k(this,"startTextEditing",({sceneX:t,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:s})=>{let l=!1,c=r&&this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i);i&&c&&(gx(i,this.scene.getNonDeletedElementsMap())||(l=!0));let d=this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,n),p=d?.fontFamily||this.state.currentItemFontFamily,m=d?.lineHeight||$M(p),u=d?.fontSize??kK(this.state.zoom.value);if(!d&&l&&i&&!Is(i)){let y=B$(rx({fontSize:u,fontFamily:p}),m),v=O$(u,m),T=Math.max(i.height,v),I=Math.max(i.width,y);this.scene.mutateElement(i,{height:T,width:I}),t=i.x+I/2,n=i.y+T/2,c&&(c=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:n}),h=this.getTextCreationGridPoint(t,n),x=c?{x:c.elementCenterX,y:c.elementCenterY}:d?{x:t,y:n}:{x:h?.x??t,y:h===null?n-TP(u,m)/2:h.y},E=d||iP({x:x.x,y:x.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:p,textAlign:c?"center":this.state.currentItemTextAlign,verticalAlign:c?TK.MIDDLE:zM,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:m,angle:i?Is(i)?0:i.angle:0,frameId:f?f.id:null});if(!d&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:E.id})}),this.setState({editingTextElement:E}),!d)if(i&&l){let w=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(E,w+1)}else this.scene.insertElement(E);a||d||i?this.handleTextWysiwyg(E,{isExistingElement:!!d,initialCaretSceneCoords:d?s:null}):this.setState({newElement:E,multiElement:null})});k(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});k(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});k(this,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[n,r]=this.lastCompletedCanvasClicks;return Hn(oe(n.x,n.y),oe(r.x,r.y))<=QM});k(this,"handleCanvasDoubleClick",t=>{if(this.state.editingTextElement||!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=ze(t,this.state),a=this.getElementAtPosition(r,i);if(a&&(Cs(a)||Qe(a)||Go(a))){this.scrollToContent(a,{animate:!0,duration:500,fitToViewport:!0,viewportZoomFactor:.9,fitCanvasOffsets:this.getEditorUIOffsets(),scrollCanvasOffsets:this.getEditorUIOffsets(),clampHostStylebarAboveElement:!0});return}if(a)return;if(n.length===1&&Bt(n[0])){let l=n[0];if((t[Z.CTRL_OR_CMD]&&vx(l)||wx(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(Va);return}else if(this.state.selectedLinearElement&&Vt(n[0])){let c=Ee.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=c?Ee.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):-1;if(d&&d>-1){this.store.scheduleCapture(),Ee.deleteFixedSegment(n[0],this.scene,d);let p=Ee.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=p?Ee.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,p,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:m,value:c,added:!1}},segmentMidPointHoveredCoords:p}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&wx(l))return}if(Zt(this.interactiveCanvas),U$(this.state).length>0){let l=this.getElementAtPosition(r,i),c=l&&G$(l,this.state.selectedGroupIds);if(c){this.store.scheduleCapture(),this.setState(d=>({...d,...yo({editingGroupId:c,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),d,this)}));return}}if(Zt(this.interactiveCanvas),!t[Z.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(dx(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let c=this.getTextBindableContainerAtPosition(r,i);if(c&&(sP(c)||!BK(c.backgroundColor)||ks({point:oe(r,i),element:c,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(c)}))){let d=fx(c,this.state,this.scene.getNonDeletedElementsMap());r=d.x,i=d.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:c})}}});k(this,"handleCanvasClick",t=>{if(t.button!==Gn.MAIN){this.lastCompletedCanvasClicks=[];return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:t.clientX,y:t.clientY}]});k(this,"getElementLinkAtPosition",(t,n)=>{if(n&&n.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let s=r[a];if(n&&s.id===n.id&&(i=a),s.link&&a>=i&&Nc(s,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});k(this,"handleElementLinkClick",t=>{let n=Hn(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>HM)return;let r=ze(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=Nc(this.hitLinkElement,i,this.state,oe(r.x,r.y),this.editorInterface.formFactor==="phone"),s=ze(this.lastPointerUpEvent,this.state),l=Nc(this.hitLinkElement,i,this.state,oe(s.x,s.y),this.editorInterface.formFactor==="phone");if(a&&l){Ig();let c=this.hitLinkElement.link;if(c){c=nx(c);let d;if(this.props.onLinkOpen&&(d=NK(le.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let p=LK(c)?"_self":"_blank",m=window.open(void 0,p);m&&(m.opener=null,m.location=c)}}}});k(this,"getTopLayerFrameAtSceneCoords",t=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&xx(t,i,n));return r.length?r[r.length-1]:null});k(this,"clearHoverOutlineIfNeeded",()=>{(this.state.hoverOutlineElementId!=null||this.state.hoveredFrameId!=null)&&this.setState({hoverOutlineElementId:null,hoveredFrameId:null})});k(this,"computeHoveredFrameId",(t,n,r)=>{let i=this.scene.getNonDeletedElementsMap(),a=this.scene.getNonDeletedFramesLikes();for(let s=a.length-1;s>=0;s--){let l=a[s];if(l.locked)continue;let c=this.frameNameBoundsCache.get(l);if(c&&t>=c.x&&t<=c.x+c.width&&n>=c.y&&n<=c.y+c.height)return l.id}if(r&&!r.isDeleted){if(Qe(r))return r.id;let s=cu(r,i);if(s&&!s.isDeleted&&!s.locked)return s.id}for(let s=a.length-1;s>=0;s--){let l=a[s];if(!l.locked&&xx({x:t,y:n},l,i))return l.id}return null});k(this,"updateFrameHoverAndOutline",(t,n,r)=>{let i=this.computeHoveredFrameId(t,n,r),a=null;if(!this.state.selectedElementsAreBeingDragged){let c=r;if(c&&!c.isDeleted&&(Qe(c)||Cs(c)||Go(c)||c$(c)||kt(c))&&!this.state.selectedElementIds[c.id])a=c.id;else if(i){let d=this.scene.getElement(i);d&&!d.isDeleted&&Qe(d)&&(a=i)}}let s=i!==this.state.hoveredFrameId,l=a!==this.state.hoverOutlineElementId;!s&&!l||(s&&l?this.setState({hoveredFrameId:i,hoverOutlineElementId:a}):s?this.setState({hoveredFrameId:i}):this.setState({hoverOutlineElementId:a}))});k(this,"updateFrameHoverStateFromSceneCoords",(t,n)=>{let r=this.getElementAtPosition(t,n,{preferSelected:!1,includeLockedElements:!0}),i=null;r&&r.locked?i=null:i=r,this.updateFrameHoverAndOutline(t,n,i)});k(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let n=ze(t,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i},Ce.pointers.has(t.pointerId)&&Ce.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let a=Ce.initialScale;if(Ce.pointers.size===2&&Ce.lastCenter&&a&&Ce.initialDistance){let h=Uf(Ce.pointers),x=h.x-Ce.lastCenter.x,E=h.y-Ce.lastCenter.y;Ce.lastCenter=h;let w=Wf(Array.from(Ce.pointers.values())),y=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/Ce.initialDistance,v=y?To(a*y):this.state.zoom.value;this.setState(T=>{let I=Sn({viewportX:h.x,viewportY:h.y,nextZoom:v},T);return this.translateCanvas({zoom:I.zoom,scrollX:I.scrollX+2*(x/v),scrollY:I.scrollY+2*(E/v),shouldCacheIgnoreZoom:!0}),null}),this.resetShouldCacheIgnoreZoomDebounced()}else Ce.lastCenter=Ce.initialDistance=Ce.initialScale=null;if(Or||Cc||Sx||wn(this.state)){this.clearHoverOutlineIfNeeded();return}let l=ob(Sc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(l?Zt(this.interactiveCanvas):jt(this.interactiveCanvas,this.state)),!this.state.newElement&&cC(this.state.activeTool.type)){let{originOffset:h,snapLines:x}=lC(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(E=>{let w=Ec(E.snapLines,x),y=E.originSnapOffset?Ec(E.originSnapOffset,h):h;return E.snapLines===w&&E.originSnapOffset===y?null:{snapLines:w,originSnapOffset:y}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(h=>h.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let h=this.state.newElement?null:Ee.handlePointerMoveInEditMode(t,r,i,this);h&&h!==this.state.selectedLinearElement&&Yt(()=>{this.setState({selectedLinearElement:h})})}if(l$(this.state.activeTool.type)){let{newElement:h}=this.state;if(!h&&yc(this.state)){let x=oe(r,i),E=this.scene.getNonDeletedElementsMap(),w=Ho(x,this.scene.getNonDeletedElements(),E,Tx(this.state.zoom));w?this.setState({suggestedBinding:{element:w,midPoint:Ix(x,w,E,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:h,selectedLinearElement:x}=this.state,{x:E,y:w,points:y}=h,v=y[y.length-1],{lastCommittedPoint:T}=x;if(jt(this.interactiveCanvas,this.state),v===T)Is(this.state.newElement)&&yc(this.state)&&Ho(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),Tx(this.state.zoom))?(this.actionManager.executeAction(_t,"ui",{event:t.nativeEvent,sceneCoords:{x:r,y:i}}),this.setState({suggestedBinding:null,startBoundElement:null}),this.state.activeTool.locked||(Zt(this.interactiveCanvas),this.setState(M=>({newElement:null,activeTool:bn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Me({...M.selectedElementIds,[h.id]:!0},M),selectedLinearElement:new Ee(h,this.scene.getNonDeletedElementsMap())})))):Hn(oe(r-E,i-w),v)>=tx?(this.scene.mutateElement(h,{points:[...y,oe(r-E,i-w)]},{informMutation:!1,isDragging:!1}),xn(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:y[y.length-1],selectedPointsIndices:[h.points.length-1],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:h.points.length-1}}})):ve(this.interactiveCanvas,Fe.POINTER);else if(y.length>2&&T&&Hn(oe(r-E,i-w),T)<tx){ve(this.interactiveCanvas,Fe.POINTER),this.scene.mutateElement(h,{points:y.slice(0,-1)},{informMutation:!1,isDragging:!1});let I=h.points.length-1;this.setState({selectedLinearElement:{...x,selectedPointsIndices:x.selectedPointsIndices?[...new Set(x.selectedPointsIndices.map(M=>Math.min(M,I)))]:x.selectedPointsIndices,lastCommittedPoint:h.points[I],initialState:{...x.initialState,lastClickedPoint:I}}})}else{pP(y,this.state.zoom.value)&&ve(this.interactiveCanvas,Fe.POINTER);let I=this.scene.getNonDeletedElementsMap();if(vx(h)){let S=Ho(oe(r,i),this.scene.getNonDeletedElements(),I);Un("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(h,S)}xn(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let M=Ee.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);M&&this.setState(M)}this.clearHoverOutlineIfNeeded();return}if(this.state.activeTool.type==="arrow"){let h=Ho(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),Tx(this.state.zoom)),x=oe(r,i),E=this.scene.getNonDeletedElementsMap();h&&!tZ(x,h,E)&&this.setState({suggestedBinding:{element:h,midPoint:Ix(x,h,E,this.state.zoom)}})}let c=!!t.buttons,d=this.state.activeTool.type==="laser";if(c||!d&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser"){this.clearHoverOutlineIfNeeded();return}let p=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,n)){ve(this.interactiveCanvas,Fe.POINTER),this.clearHoverOutlineIfNeeded();return}if(m.length===1&&!l&&!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&&Vt(m[0]))&&!(Bt(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let h=kP(p,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(h&&h.transformHandleType){ve(this.interactiveCanvas,SP(h)),this.clearHoverOutlineIfNeeded();return}}}else if(m.length>1&&!l&&this.state.openDialog?.name!=="elementLinkSelector"){let h=MP(Ti(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(h){ve(this.interactiveCanvas,SP({transformHandleType:h})),this.clearHoverOutlineIfNeeded();return}}if(Ot(this.state)){this.clearHoverOutlineIfNeeded();return}let u=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),f=null;if(u&&u.locked?f=null:f=u,this.updateFrameHoverStateFromSceneCoords(r,i),this.handleIframeLikeElementHover({hitElement:f,scenePointer:n,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(n,u)),this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id])ve(this.interactiveCanvas,Fe.POINTER),n2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap());else{if(Ig(),d)return;f&&(f.link||Go(f))&&this.state.selectedElementIds[f.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?ve(this.interactiveCanvas,kt(f)?Fe.TEXT:Fe.CROSSHAIR):!t[Z.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(n,m)?ve(this.interactiveCanvas,Fe.MOVE):this.state.viewModeEnabled?ve(this.interactiveCanvas,Fe.GRAB):this.state.openDialog?.name==="elementLinkSelector"?ve(this.interactiveCanvas,Fe.AUTO):l?ve(this.interactiveCanvas,Fe.AUTO):!t[Z.CTRL_OR_CMD]&&f?.id!==this.state.editingTextElement?.id?(f||this.isHittingCommonBoundingBoxOfSelectedElements(n,m))&&!f?.locked&&(!f||!Vt(f)||!(f.startBinding||f.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&ve(this.interactiveCanvas,Fe.MOVE):ve(this.interactiveCanvas,Fe.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&f?this.setState(h=>({hoveredElementIds:Ec(h.hoveredElementIds,yo({editingGroupId:h.editingGroupId,selectedElementIds:{[f.id]:!0}},this.scene.getNonDeletedElements(),h,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!f&&this.setState(h=>({hoveredElementIds:Ec(h.hoveredElementIds,{})}))});k(this,"handleEraser",(t,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});k(this,"handleTouchMove",t=>{kc=!0});k(this,"handleCanvasPointerDown",t=>{let n=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let h=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==h&&this.setState({isBindingEnabled:h})}let r=ze(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.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(h=>({searchMatches:h.searchMatches&&{focusedId:null,matches:h.searchMatches.matches.map(x=>({...x,focus:!1}))}})),this.updateEditorAtom(Xb,null)),nt.get(Po)&&this.updateEditorAtom(Po,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 h=this.state.newElement;this.updateScene({...h.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==h.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:Me(Object.keys(this.state.selectedElementIds).filter(x=>x!==h.id).reduce((x,E)=>(x[E]=this.state.selectedElementIds[E],x),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Xt.EVENTUALLY:Xt.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(h=>({penMode:!0,penDetected:!0})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=ax(this.editorInterface,{isTouchScreen:!0})),Cc||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Gn.ERASER&&this.state.activeTool.type!==fn.eraser){this.setState({activeTool:bn(this.state,{type:fn.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let h=()=>{x(),E?.(),Ot(this.state)&&this.setState({activeTool:bn(this.state,{...this.state.activeTool.lastActiveTool||{type:fn.selection},lastActiveToolBeforeEraser:null})})},x=je(window,le.POINTER_UP,h,{once:!0}),E;requestAnimationFrame(()=>{E=this.missingPointerEventCleanupEmitter.once(h)})});return}if(t.button!==Gn.MAIN&&t.button!==Gn.TOUCH&&t.button!==Gn.ERASER||Ce.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(n,c.origin)||this.handleDraggingScrollBar(t,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,c))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let h=c.hit.element&&this.isASelectedElement(c.hit.element);(t.altKey&&t[Z.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!h)&&(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&&!h&&(this.setState(w=>{let y={...w.selectedElementIds,[c.hit.element.id]:!0},v=[];Object.keys(w.selectedElementIds).forEach(I=>{let M=this.scene.getElement(I);M&&v.push(M)});let T=c.hit.element;if(Qe(T))bx(v,T.id).forEach(I=>{delete y[I.id]});else if(T.frameId)y[T.frameId]&&delete y[T.id];else{let I=T.groupIds,M=new Set(I.flatMap(S=>Ii(this.scene.getNonDeletedElements(),S)).filter(S=>Qe(S)).map(S=>S.id));M.size>0&&v.forEach(S=>{S.frameId&&M.has(S.frameId)&&(delete y[S.id],S.groupIds.flatMap(_=>Ii(this.scene.getNonDeletedElements(),_)).forEach(_=>{delete y[_.id]}))})}return{...yo({editingGroupId:w.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),w,this),showHyperlinkPopup:T.link||Go(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"?jt(this.interactiveCanvas,this.state):this.state.activeTool.type===fn.frame||this.state.activeTool.type===fn.magicframe?this.createFrameElementOnPointerDown(c,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(c.lastCoords.x,c.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,c);this.props?.onPointerDown?.(this.state.activeTool,c),this.onPointerDownEmitter.trigger(this.state.activeTool,c,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(c.lastCoords.x,c.lastCoords.y);let p=this.onPointerMoveFromPointerDownHandler(c),m=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),f=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(h=>m(h||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(le.POINTER_MOVE,p),window.addEventListener(le.POINTER_UP,m),window.addEventListener(le.KEYDOWN,u),window.addEventListener(le.KEYUP,f),c.eventListeners.onMove=p,c.eventListeners.onUp=m,c.eventListeners.onKeyUp=f,c.eventListeners.onKeyDown=u)});k(this,"handleCanvasPointerUp",t=>{if(Un("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,t),this.lastPointerUpEvent=t,!t.ctrlKey){let a=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==a&&this.setState({isBindingEnabled:a})}let n=ze({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=n;if(this.lastPointerMoveCoords={x:r,y:i},!this.handleIframeLikeCenterClick()){if(this.editorInterface.isTouchScreen){let a=this.getElementAtPosition(n.x,n.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(n,a)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?this.handleElementLinkClick(t):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})}});k(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(kc=!1,Fr?kc=!0:Fr=window.setTimeout(()=>{Fr=0,kc||this.handleCanvasContextMenu(t)},vK))});k(this,"resetContextMenuTimer",()=>{clearTimeout(Fr),Fr=0,kc=!1});k(this,"maybeCleanupAfterMissingPointerUp",t=>{Mc?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});k(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(Ce.pointers.size<=1&&(t.button===Gn.WHEEL||t.button===Gn.MAIN&&Or||wn(this.state)||this.state.viewModeEnabled&&this.state.activeTool.type!=="laser")))return!1;Cc=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);ve(this.interactiveCanvas,Fe.GRABBING);let{clientX:i,clientY:a}=t,s=Km(c=>{let d=i-c.clientX,p=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!n&&(Math.abs(d)>1||Math.abs(p)>1)){n=!0;let m=f=>{document.body.removeEventListener(le.PASTE,m),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(le.PASTE,m),window.removeEventListener(le.POINTER_UP,u)},100)};document.body.addEventListener(le.PASTE,m),window.addEventListener(le.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-d/this.state.zoom.value,scrollY:this.state.scrollY-p/this.state.zoom.value})}),l=$e(Mc=()=>{Mc=null,Cc=!1,Or||(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"?ve(this.interactiveCanvas,Fe.GRAB):jt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(le.POINTER_MOVE,s),window.removeEventListener(le.POINTER_UP,l),window.removeEventListener(le.BLUR,l),s.flush()});return window.addEventListener(le.BLUR,l),window.addEventListener(le.POINTER_MOVE,s,{passive:!0}),window.addEventListener(le.POINTER_UP,l),!0});k(this,"clearSelectionIfNotUsingSelection",()=>{au(this.state.activeTool.type)||this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});k(this,"handleSelectionOnPointerDown",(t,n)=>{if(au(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&&!Vt(a[0])&&!(Bt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=kP(r,this.state,n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);s!=null&&(s.transformHandleType==="rotation"?(this.setState({resizingElement:s.element}),n.resize.handleType=s.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:s.element}),n.resize.handleType=s.transformHandleType))}else a.length>1&&(n.resize.handleType=MP(Ti(a),n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=ix(X$(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&Bt(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=K$(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let m=this.state.selectedLinearElement,u=Ee.handlePointerDown(t,this,this.store,n.origin,m,this.scene);if(u.hitElement&&(n.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let f=this.scene.getNonDeletedElementsMap(),h=Ee.getElement(m.elementId,f);if(h&&En(h)){let{hitFocusPoint:x,pointerOffset:E}=rZ(h,n,f,this.state);if(x)return this.setState({selectedLinearElement:{...m,hoveredFocusPointBinding:x,draggedFocusPointBinding:x,pointerOffset:E}}),!1}}let s=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),l=s.filter(m=>!m.locked),c=this.getElementAtPosition(n.origin.x,n.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])?n.hit.element=null:n.hit.element=n.hit.element??this.getElementAtPosition(n.origin.x,n.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(n.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&n.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),n.hit.element&&this.getElementLinkAtPosition({x:n.origin.x,y:n.origin.y},n.hit.element))return!1;n.hit.allHitElements=l;let d=n.hit.element,p=n.hit.allHitElements.some(m=>this.isASelectedElement(m));if((d===null||!p)&&!t.shiftKey&&!n.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?Me({[m.selectedLinearElement.elementId]:!0},this.state):Me({},m)}));else if(d!=null){if(t[Z.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(n.origin.x,n.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(n.hit.wasAddedToSelection=!0),this.setState(m=>({...H$(m,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!IP(d,this.state.editingGroupId)&&this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!p&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(m=>{let u={...m.selectedElementIds,[d.id]:!0},f=[];if(Object.keys(m.selectedElementIds).forEach(h=>{let x=this.scene.getElement(h);x&&f.push(x)}),Qe(d))bx(f,d.id).forEach(h=>{delete u[h.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let h=d.groupIds,x=new Set(h.flatMap(E=>Ii(this.scene.getNonDeletedElements(),E)).filter(E=>Qe(E)).map(E=>E.id));x.size>0&&f.forEach(E=>{E.frameId&&x.has(E.frameId)&&(delete u[E.id],E.groupIds.flatMap(w=>Ii(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete u[w.id]}))})}return m.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(h=>m.selectedGroupIds[h])||(u={[d.id]:!0})),{...yo({editingGroupId:m.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),m,this),showHyperlinkPopup:d.link||Go(d)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});k(this,"handleTextOnPointerDown",(t,n)=>{if(this.state.editingTextElement)return;let r=n.origin.x,i=n.origin.y,a=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),s=this.getTextBindableContainerAtPosition(r,i);sP(a)&&(s=a,r=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s,autoEdit:!1,initialCaretSceneCoords:{x:r,y:i}}),Zt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:bn(this.state,{type:this.state.preferredSelectionTool.type})})});k(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,a]=St(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=t$({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:l,locked:!1,frameId:s?s.id:null,points:[oe(0,0)],pressures:l?[]:[t.pressure]});this.scene.insertElement(c),this.setState(p=>{let m={...p.selectedElementIds};return delete m[c.id],{selectedElementIds:Me(m,p)}});let d=Ho(oe(r.origin.x,r.origin.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.setState({newElement:c,startBoundElement:d,suggestedBinding:null})});k(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[a,s]=St(t,n,this.lastPointerDownEvent?.[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=o$({type:"iframe",x:a,y:s,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.scene.insertElement(l),l});k(this,"insertEmbeddableElement",({sceneX:t,sceneY:n,link:r})=>{let[i,a]=St(t,n,this.lastPointerDownEvent?.[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=lu(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let l=nP({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),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.scene.insertElement(l),l});k(this,"newImagePlaceholder",({sceneX:t,sceneY:n,addToFrameUnderCursor:r=!0})=>{let[i,a]=St(t,n,this.lastPointerDownEvent?.[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=r?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,l=100/this.state.zoom.value;return i$({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),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})});k(this,"handleLinearElementOnPointerDown",(t,n,r)=>{if(t.ctrlKey&&Yt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(xn(a,"selectedLinearElement is expected to be set"),i.type==="line"&&pP(i.points,this.state.zoom.value)){Yt(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(_t);return}if(Vt(i)&&i.points.length>1){this.actionManager.executeAction(_t,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=yc(this.state)&&Ho(oe(this.lastPointerMoveCoords?.x??s+i.points[i.points.length-1][0],this.lastPointerMoveCoords?.y??l+i.points[i.points.length-1][1]),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(En(i)&&d||i.points.length>1&&c&&Hn(oe(r.origin.x-s,r.origin.y-l),c)<tx){this.actionManager.executeAction(_t,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(p=>({selectedElementIds:Me({...p.selectedElementIds,[i.id]:!0},p)})),ve(this.interactiveCanvas,Fe.POINTER)}else{let[i,a]=St(r.origin.x,r.origin.y,t[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,p]=n==="arrow"?[l,c]:[null,null],m=n==="arrow"?n$({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Br.round?{type:ou.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:p,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===Br.elbow,fixedSegments:this.state.currentItemArrowType===Br.elbow?[]:null}):a$({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,...this.getNewElementStrokeProps(),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:ou.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=oe(r.origin.x,r.origin.y),f=this.scene.getNonDeletedElementsMap(),h=yc(this.state)?Ho(u,this.scene.getNonDeletedElements(),f):null;this.scene.mutateElement(m,{points:[oe(0,0),oe(0,0)]}),this.scene.insertElement(m),En(m)&&Q$(m,new Map([[0,{point:oe(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:FM(t.nativeEvent)}),Yt(()=>{this.setState(x=>{let E=null,w=x.selectedElementIds;if(Bt(m)){E=new Ee(m,this.scene.getNonDeletedElementsMap());let y=m.points.length-1;E={...E,selectedPointsIndices:[y],initialState:{...E.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:y,origin:oe(r.origin.x,r.origin.y)}}}return w=this.state.activeTool.locked?x.selectedElementIds:Me({[m.id]:!0},x),{...x,bindMode:"orbit",newElement:m,startBoundElement:h,suggestedBinding:h&&En(m)?{element:h,midPoint:Ix(u,h,f,this.state.zoom)}:null,selectedElementIds:w,selectedLinearElement:E}})}),En(m)&&Un("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(m,h)}});k(this,"getNewElementStrokeProps",()=>this.state.currentItemStrokeWidthCustom?{strokeWidth:this.state.currentItemStrokeWidth,customData:{[SK]:!0}}:{strokeWidth:XM(this.state.zoom.value)});k(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=St(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[Z.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,...this.getNewElementStrokeProps(),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=nP({type:"embeddable",...s}):l=r$({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.scene.insertElement(l),this.setState({multiElement:null,newElement:l}))});k(this,"createFrameElementOnPointerDown",(t,n)=>{let[r,i]=St(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Nr},s=n===fn.magicframe?rP(a):e$(a);this.scene.insertElement(s),this.setState({multiElement:null,newElement:s})});k(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});k(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(En(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);du(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);du(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else px(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&du(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&du(s,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||cx(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,Wn(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});k(this,"initializeImage",async(t,n)=>{if(!Cu(n))throw new Error(g("errors.unsupportedFileType"));let r=n.type;if(ve(this.interactiveCanvas,"wait"),r===gn.svg)try{n=Pu(hP(await n.text()),n.name)}catch(l){throw console.warn(l),new Error(g("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(n)||h0(n));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{n=await zc(n,{maxWidthOrHeight:gK})}catch(l){console.error("Error trying to resizing image file on insertion",l)}if(n.size>UM)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(UM/1024/1024)}MB`}))}let s=this.files[i]?.dataURL||await Mu(n);return new Promise(async(l,c)=>{try{let d=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:s,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(g("errors.imageInsertError")))}})});k(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return Wn(r,{fileId:n})});k(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:r,y:i}=ze({clientX:t,clientY:n},this.state),a=await Dc({description:"Image",extensions:Object.keys(bK),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:bn(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(_t)})}});k(this,"getImageNaturalDimensions",(t,n)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(n.naturalHeight,i),s=a*(n.naturalWidth/n.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}});k(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await b$({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(Xt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>wc(a)&&i.has(a.fileId)?Wn(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});k(this,"addNewImagesToImageCache",async(t=f$(this.scene.getNonDeletedElements()),n=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,n);if(i.size)for(let a of r)i.has(a.fileId)&&vc.delete(a);i.size&&this.scene.triggerUpdate()}});k(this,"scheduleImageRefresh",cK(()=>{this.addNewImagesToImageCache()},xK));k(this,"handleOutlineOverlayCanvasRef",t=>{this.outlineOverlayCanvas=t});k(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(le.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(le.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(le.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(le.TOUCH_END,this.onTouchEnd))});k(this,"insertImages",async(t,n,r)=>{let i=50/this.state.zoom.value,a=DP(t.map(()=>this.newImagePlaceholder({sceneX:n,sceneY:r})),n,r,i);a.forEach(m=>this.scene.insertElement(m));let s=await Promise.all(a.map(async(m,u)=>{try{return await this.initializeImage(m,await zs(t[u]))}catch(f){return this.setState({errorMessage:f.message||g("errors.imageInsertError")}),Wn(m,{isDeleted:!0})}})),l=iu(s),c=DP(s.filter(m=>!m.isDeleted),n,r,i),d=iu(c),p=this.scene.getElementsIncludingDeleted().map(m=>d.get(m.id)??l.get(m.id)??m);this.updateScene({appState:{selectedElementIds:Me(Object.fromEntries(c.map(m=>[m.id,!0])),this.state)},elements:p,captureUpdate:Xt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(_t)})});k(this,"handleAppOnDrop",async t=>{let{x:n,y:r}=ze(t,this.state),i=await ga(t),a=i.getFiles();if(a.length>0){let d=a.map(u=>u.file).filter(u=>u!=null),p=d.length===1&&(d[0].type===gn.png||d[0].type===gn.svg),m=d.some(u=>Cu(u));if(m||!p&&!m)return}let s=i.getData(gn.excalidrawlibIds),l=i.getData(gn.excalidrawlib);if(s||l){try{let d=null;if(s){let{itemIds:p}=JSON.parse(s);d=(await this.library.getLatestLibrary()).filter(u=>p.includes(u.id))}else l&&(d=u0(l));d?.length&&(d=d.map(p=>({...p,elements:lx({type:"everything",elements:p.elements,randomizeSeed:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:Da(d),position:t,files:null}))}catch(d){this.setState({errorMessage:d.message})}return}if(a.length>0){let{file:d,fileHandle:p}=a[0];d&&await this.loadFileToCanvas(d,p)}let c=i.findByType(gn.text);if(c){let d=c.value;if(d&&hx(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||lu(d)?.type==="video")){let p=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:nx(d)});p&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[p.id]:!0}}))}}});k(this,"loadFileToCanvas",async(t,n)=>{t=await zs(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Su(t,this.state,r,n)}catch(a){let s=a instanceof t0;if(s&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:g("errors.imageToolNotSupported")});return}let l=s?g("alerts.cannotRestoreFromImage"):g("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:l})}if(!i)return;i.type===gn.excalidraw?(WP(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:Xt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Xt.IMMEDIATELY})):i.type===gn.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});k(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Gn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let{x:n,y:r}=ze(t,this.state),i=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),s=this.isHittingCommonBoundingBoxOfSelectedElements({x:n,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;me("contextMenu","openContextMenu",l),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...yo({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Bt(i)?new Ee(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:m,items:this.getContextMenuItems(l)}})})});k(this,"maybeDragNewGenericElement",(t,n,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){PP({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Ts(t.origin.x,a.x),height:Ts(t.origin.y,a.y),shouldMaintainAspectRatio:ex(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let s=this.state.newElement;if(!s)return;let[l,c]=St(a.x,a.y,n[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=wc(s)&&this.imageCache.get(s.fileId)?.image,p=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:m,snapLines:u}=sC(s,this,n,{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}),En(s)||PP({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:Ts(t.originInGrid.x,l),height:Ts(t.originInGrid.y,c),shouldMaintainAspectRatio:lP(s)?!0:ex(n),shouldResizeFromCenter:OM(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:p,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:s}),(this.state.activeTool.type===fn.frame||this.state.activeTool.type===fn.magicframe)&&this.setState({elementsToHighlight:xP(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})});k(this,"maybeHandleCrop",(t,n)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,s]=St(i.x-t.resize.offset.x,i.y-t.resize.offset.y,n[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&Cs(l)){let c=t.originalElements.get(l.id),d=wc(l)&&this.imageCache.get(l.fileId)?.image;if(c&&Cs(c)&&d&&!(d instanceof Promise)){let[p,m]=St(i.x,i.y,n[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:m-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:f,snapLines:h}=Kf([l],[c],this,n,u,r);this.scene.mutateElement(l,L$(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+f.x,s+f.y,n.shiftKey?c.width/c.height:void 0)),su(l,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:h})}return!0}return!1});k(this,"maybeHandleResize",(t,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(p=>Qe(p)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Vt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=St(s.x-t.resize.offset.x,s.y-t.resize.offset.y,n[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(p=>{bx(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]=St(s.x,s.y,n[Z.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:p-t.originInGrid.x,y:m-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:h,snapLines:x}=Kf(r,ie(f,this.state),this,n,u,a);l+=h.x,c+=h.y,this.setState({snapLines:x})}return $$(t.originalElements,a,r,this.scene,FM(n),OM(n),r.some(lP)?!0:ex(n),l,c,t.resize.center.x,t.resize.center.y)?(this.setState({elementsToHighlight:i.length>0?null:[]}),!0):!1});k(this,"getContextMenuItems",t=>{let n=[];if(t==="canvas")return this.state.viewModeEnabled?[...n,Ca,lr,ri,cr]:[mg,rt,qd,rt,lh,c2,rt,Ca,gl,fl,bl,lr,ri,cr];if(n.push(qd),this.state.viewModeEnabled)return[Ia,...n];let r=this.editorInterface.formFactor!=="phone"?[rt,rh,ih,ah,sh]:[];return[rt,jd,Ia,mg,rt,HI,GI,UI,rt,Nf,rt,...n,rt,tg,og,rt,rg,Hf,hg,gg,$v,ig,rt,lg,...r,rt,cg,dg,rt,Va,rt,yl,nm,rt,ch,wl,rt,Zs]});k(this,"handleWheel",$e(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&t.target.classList.contains(sx.FRAME_NAME))){t[Z.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Cc)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(r),a=IK(this.state.zoom.value,i>0?"out":"in")*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),this.translateCanvas(d=>({...Sn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:To(c)},d),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(r||n)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:s})=>({scrollX:a-n/i.value,scrollY:s-r/i.value}))}));k(this,"savePointer",(t,n,r)=>{if(!t||!n)return;let{x:i,y:a}=ze({clientX:t,clientY:n},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:Ce.pointers})});k(this,"resetShouldCacheIgnoreZoomDebounced",ZM(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));k(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let n=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:s}=n.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()})}});k(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});k(this,"watchState",()=>{});let n=Yo(),{viewModeEnabled:r=!1,zenModeEnabled:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=n.theme,name:c=`${g("labels.untitled")}-${qM()}`}=t;this.state={...n,theme:l,exportWithDarkMode:l===ws.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:r,zenModeEnabled:i,objectsSnapModeEnabled:s,gridModeEnabled:a??n.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight},this.refreshEditorInterface(),this.stylesPanelMode=uu(this.editorInterface),this.id=mK(),this.library=new R2(this),this.actionManager=new Gm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new LP,this.canvas=document.createElement("canvas"),this.rc=dK.canvas(this.canvas),this.renderer=new Vl(this.scene),this.visibleElements=[],this.store=new q$(this),this.history=new Ul(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new yn(this.scene),this.history=new Ul(this.store),this.actionManager.registerAll(nd),this.actionManager.registerAction(XI(this.history)),this.actionManager.registerAction(KI(this.history)),this.api=this.createExcalidrawAPI()}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:n=>{this.actionManager.registerAction(n)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:n=>this.onChangeEmitter.on(n),onIncrement:n=>this.store.onStoreIncrementEmitter.on(n),onPointerDown:n=>this.onPointerDownEmitter.on(n),onPointerUp:n=>this.onPointerUpEmitter.on(n),onScrollChange:n=>this.onScrollChangeEmitter.on(n),onUserFollow:n=>this.onUserFollowEmitter.on(n),onStateChange:this.onStateChange,onEvent:this.onEvent}}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let n=null;try{n=JSON.parse(t.data)}catch{}if(n)switch(t.origin){case"https://player.vimeo.com":if(n.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:n.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(n.event==="infoDelivery"&&n.info&&n.id&&typeof n.info.playerState=="number"){let r=n.id,i=n.info.playerState;Object.values(nu).includes(i)&&kx.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){xn(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),n=Ho(oe(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=Ee.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&n?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),Yt(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:n}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;xn(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=n-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?Ee.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):Ee.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,n){if(t.isDeleted||Vt(t))return;let r=()=>{if(this.bindModeHandler=null,xn(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 f=this.state.selectedLinearElement.selectedPointsIndices.includes(0),h=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!f&&!h||f&&h)return}let{x:p,y:m}=this.lastPointerMoveCoords,u=Ho(oe(p,m),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){xn(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let f=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Yt(()=>{xn(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:f}}})});let h=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;xn(h,"Last event must exist");let x=p-this.state.selectedLinearElement.pointerOffset.x,E=m-this.state.selectedLinearElement.pointerOffset.y,w=this.state.multiElement?Ee.handlePointerMove(h,this,x,E,this.state.selectedLinearElement):Ee.handlePointDragging(h,this,x,E,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),f=m?n:t.startBinding&&p.get(t.startBinding.elementId),h=u?n:t.endBinding&&p.get(t.endBinding.elementId),x=f&&NP(f,p),E=h&&NP(h,p);i=!!(x&&E&&f.id!==h.id&&eZ(x,E))}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===n?.id||l&&t[l]?.mode==="inside"&&n?.id===t[l]?.elementId;l&&c&&t[l]?.mode==="inside"&&n?.id!==t[l]?.elementId&&t[c]?.elementId!==t[l]?.elementId&&this.scene.mutateElement(t,{[l]:{...t[l],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!n||this.previousHoveredBindableElement&&n.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Yt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,VK)),this.previousHoveredBindableElement=n}cacheEmbeddableRef(t,n){n&&this.iFrameRefs.set(t.id,n)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==Gn.MAIN||Or||!eP(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(ze({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),n=oe(ze({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(Hn(t,n)>HM)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&Ce.pointers.size<2&&dx(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,n[0],n[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),Ss(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let c=kx.get(s.id);switch(c||(kx.set(s.id,nu.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case nu.PLAYING:case nu.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,n,r,i){return t&&!n.altKey&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=t.x+t.width/3&&r<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,n=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Go(a)&&this.embedsValidationStatus.get(a.id)===!0||Ss(a));return we(dZ,{children:i.map(a=>{let{x:s,y:l}=ru({sceneX:a.x,sceneY:a.y},this.state),c=dP(a,n,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;if(Ss(a)){m=null;let h=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(h.status==="done"){let x=h.html;m={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>x}}else if(h.status==="pending")m={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>uP(`
49
49
  <style>
50
50
  html, body {
51
51
  width: 100%;