@excalidraw/element 0.18.0-835eb8d → 0.18.0-8608d7b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/index.js +1 -1
- package/dist/dev/index.js.map +2 -2
- package/dist/prod/index.js +1 -1
- package/dist/types/common/src/constants.d.ts +3 -0
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +15 -3
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +65 -13
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +30 -6
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +15 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionExport.d.ts +45 -9
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionFrame.d.ts +20 -4
- package/dist/types/excalidraw/actions/actionGroup.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionLink.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionMenu.d.ts +15 -3
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +10 -2
- package/dist/types/excalidraw/actions/actionProperties.d.ts +76 -16
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionStyles.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +5 -1
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +5 -1
- package/dist/types/excalidraw/appState.d.ts +4 -1
- package/dist/types/excalidraw/components/Actions.d.ts +9 -2
- package/dist/types/excalidraw/components/App.d.ts +8 -3
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -0
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -1
- package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +1 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerTrigger.d.ts +2 -1
- package/dist/types/excalidraw/components/LayerUI.d.ts +2 -1
- package/dist/types/excalidraw/components/MobileMenu.d.ts +3 -5
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +11 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +1 -2
- package/dist/types/excalidraw/components/ToolPopover.d.ts +25 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +4 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +2 -1
- package/dist/types/excalidraw/components/icons.d.ts +0 -1
- package/dist/types/excalidraw/types.d.ts +7 -2
- package/package.json +3 -3
package/dist/prod/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var mc=Object.create;var Ss=Object.defineProperty;var fc=Object.getOwnPropertyDe
|
|
|
8
8
|
|
|
9
9
|
`)=>e.reduce((o,i)=>(oe(i)&&o.push(i.text),o),[]).join(t);P();import{curvePointDistance as cr,distanceToLineSegment as ur,pointRotateRads as pr}from"@excalidraw/math";import{ellipse as Uu,ellipseDistanceFromPoint as Xu}from"@excalidraw/math/ellipse";var Ut=(e,t,n)=>{switch(e.type){case"selection":case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return ju(e,t,n);case"diamond":return Wu(e,t,n);case"ellipse":return Vu(e,t,n);case"line":case"arrow":case"freedraw":return $u(e,n)}},ju=(e,t,n)=>{let o=he(e,t),i=pr(n,o,-e.angle),[r,s]=Mn(e);return Math.min(...r.map(a=>ur(i,a)),...s.map(a=>cr(a,i)).filter(a=>a!==null))},Wu=(e,t,n)=>{let o=he(e,t),i=pr(n,o,-e.angle),[r,s]=Tn(e);return Math.min(...r.map(a=>ur(i,a)),...s.map(a=>cr(a,i)).filter(a=>a!==null))},Vu=(e,t,n)=>{let o=he(e,t);return Xu(pr(n,o,-e.angle),Uu(o,e.width/2,e.height/2))},$u=(e,t)=>{let[n,o]=Bo(e);return Math.min(...n.map(i=>ur(t,i)),...o.map(i=>cr(i,t)))};var Wo=e=>{if(e.type==="arrow")return!1;let t=!Zu(e.backgroundColor)||st(e)||Ro(e)||oe(e);return e.type==="line"?t&&mn(e.points):e.type==="freedraw"?t&&mn(e.points):t||we(e)},op=({point:e,element:t,threshold:n,elementsMap:o,frameNameBound:i=null})=>{let r=i?Xo(Mt(i.x-n,i.y-n),e,Mt(i.x+i.width+n,i.y+i.height+n)):!1,s=pe(t,o,!0);return!Xo(Mt(s[0]-n,s[1]-n),lt(e,dt(s),-t.angle),Mt(s[2]+n,s[3]+n))&&!r?!1:Wo(t)&&Aa(e,t,o)||Pa(e,t,o,n)||r},ip=(e,t,n,o=0)=>{let[i,r,s,a]=pe(t,n);return i-=o,r-=o,s+=o,a+=o,Xo(Mt(i,r),e,Mt(s,a))},kw=(e,t)=>!op(e)&&!rp(e.point,e.element,t)&&ip(e.point,e.element,t),rp=(e,t,n)=>{let o=W(t,n);if(!o)return!1;let i=j(t)?{...o,...U.getBoundTextElementPosition(t,o,n)}:o;return Aa(e,i,n)},En=(e,t,n,o=0,i=!1)=>{let r=[Math.min(n[0][0]-o,n[1][0]-o),Math.min(n[0][1]-o,n[1][1]-o),Math.max(n[0][0]+o,n[1][0]+o),Math.max(n[0][1]+o,n[1][1]+o)],s=pe(e,t);if(!gn(r,s))return[];switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"selection":case"magicframe":return ap(e,t,n,o,i);case"diamond":return lp(e,t,n,o,i);case"ellipse":return dp(e,t,n,o);case"line":case"freedraw":case"arrow":return sp(e,n,i)}},Ma=(e,t,n,o,i,r=!1)=>{for(let s of e){let a=Vo(s[0],s[1],s[2],s[3]),l=[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])];if(!gn(a,l))continue;let d=Ia(s,t);if(d.length>0){for(let c of d)n.push(lt(c,o,i));if(r)return n}}return n},Ta=(e,t,n,o,i,r=!1)=>{for(let s of e){let a=Sa(s,t);if(a&&(n.push(lt(a,o,i)),r))return n}return n},sp=(e,t,n=!1)=>{let[o,i]=Bo(e),r=[];for(let s of o){let a=Sa(s,t);if(a&&(r.push(a),n))return r}for(let s of i){let a=Vo(s[0],s[1],s[2],s[3]),l=[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])];if(!gn(a,l))continue;let d=Ia(s,t);if(d.length>0&&(r.push(...d),n))return r}return r},ap=(e,t,n,o=0,i=!1)=>{let r=he(e,t),s=lt(n[0],r,-e.angle),a=lt(n[1],r,-e.angle),l=jo(s,a),[d,c]=Mn(e,o),u=[];return Ta(d,l,u,r,e.angle,i),i&&u.length>0||Ma(c,l,u,r,e.angle,i),u},lp=(e,t,n,o=0,i=!1)=>{let r=he(e,t),s=lt(n[0],r,-e.angle),a=lt(n[1],r,-e.angle),l=jo(s,a),[d,c]=Tn(e,o),u=[];return Ta(d,l,u,r,e.angle,i),i&&u.length>0||Ma(c,l,u,r,e.angle,i),u},dp=(e,t,n,o=0)=>{let i=he(e,t),r=lt(n[0],i,-e.angle),s=lt(n[1],i,-e.angle);return np(tp(i,e.width/2+o,e.height/2+o),jo(r,s)).map(a=>lt(a,i,e.angle))},Pa=(e,t,n,o=1)=>Ut(t,n,e)<=o,Aa=(e,t,n)=>{if((j(t)||Me(t))&&!mn(t.points))return!1;let[o,i,r,s]=pe(t,n);if(!Xo(Mt(o,i),e,Mt(r,s)))return!1;let a=Mt((o+r)/2,(i+s)/2),l=qu(ep(Ju(Qu(e,a,.1)),Math.max(t.width,t.height)*2),a),d=jo(e,l);return En(t,n,d).filter((u,p,m)=>m.findIndex(f=>Ku(f,u))===p).length%2===1};P();import{invariant as Da,isDevEnv as cp,isTestEnv as up}from"@excalidraw/common";import{pointFrom as Xt,pointFromVector as $o,pointRotateRads as Zo,pointScaleFromOrigin as qo,pointsEqual as pp,triangleIncludesPoint as mr,vectorCross as Ge,vectorFromPoint as K,vectorScale as Ko}from"@excalidraw/math";var fe=[1,0],ye=[0,1],ke=[-1,0],_e=[0,-1],Tt=e=>{let[t,n]=e,o=Math.abs(t),i=Math.abs(n);return t>i?fe:t<=-i?ke:n>o?ye:_e},Be=(e,t)=>Tt(K(e,t)),tt=(e,t)=>Oe(Be(e,t)),me=(e,t)=>e[0]===t[0]&&e[1]===t[1],Oe=e=>me(e,fe)||me(e,ke),zw=e=>!Oe(e),mp=(e,t,n)=>{let o=dt(t);(cp()||up())&&(Da(e.width>0&&e.height>0,"Diamond element has no width or height"),Da(!pp(o,n),"The point is too close to the element mid point to determine heading"));let i=.95,r=$o(Ko(K(Zo(Xt(e.x+e.width/2,e.y),o,e.angle),o),i),o),s=$o(Ko(K(Zo(Xt(e.x+e.width,e.y+e.height/2),o,e.angle),o),i),o),a=$o(Ko(K(Zo(Xt(e.x+e.width/2,e.y+e.height),o,e.angle),o),i),o),l=$o(Ko(K(Zo(Xt(e.x,e.y+e.height/2),o,e.angle),o),i),o);if(Ge(K(n,r),K(r,s))<=0&&Ge(K(n,r),K(r,l))>0)return Be(r,o);if(Ge(K(n,s),K(s,a))<=0&&Ge(K(n,s),K(s,r))>0)return Be(s,o);if(Ge(K(n,a),K(a,l))<=0&&Ge(K(n,a),K(a,s))>0)return Be(a,o);if(Ge(K(n,l),K(l,r))<=0&&Ge(K(n,l),K(l,a))>0)return Be(l,o);if(Ge(K(n,o),K(r,o))<=0&&Ge(K(n,o),K(s,o))>0){let c=e.width>e.height?r:s;return Be(c,o)}else if(Ge(K(n,o),K(s,o))<=0&&Ge(K(n,o),K(a,o))>0){let c=e.width>e.height?a:s;return Be(c,o)}else if(Ge(K(n,o),K(a,o))<=0&&Ge(K(n,o),K(l,o))>0){let c=e.width>e.height?a:l;return Be(c,o)}let d=e.width>e.height?r:l;return Be(d,o)},oo=(e,t,n)=>{let i=dt(t);if(e.type==="diamond")return mp(e,t,n);let r=qo(Xt(t[0],t[1]),i,2),s=qo(Xt(t[2],t[1]),i,2),a=qo(Xt(t[0],t[3]),i,2),l=qo(Xt(t[2],t[3]),i,2);return mr([r,s,i],n)?_e:mr([s,l,i],n)?fe:mr([l,a,i],n)?ye:ke},fr=e=>[e[0]===0?0:e[0]>0?-1:1,e[1]===0?0:e[1]>0?-1:1];P();import{getSizeFromPoints as Gp,randomInteger as Mr,getUpdatedTimestamp as Tr}from"@excalidraw/common";P();import{clamp as Qo,pointDistance as gr,pointFrom as z,pointScaleFromOrigin as fp,pointsEqual as ro,pointTranslate as Er,vector as ct,vectorCross as Jo,vectorFromPoint as xr,vectorScale as hp}from"@excalidraw/math";import{BinaryHeap as Ep,invariant as Dn,isAnyTrue as gp,tupleToCoors as xp,getSizeFromPoints as va,isDevEnv as wp,arrayToMap as yp}from"@excalidraw/common";var wr=1,ee=40,bp=(e,t)=>{let n=e.fixedSegments?e.fixedSegments.slice():null;if(n){let o=[];e.points.map(s=>z(e.x+s[0],e.y+s[1])).forEach((s,a,l)=>{if(a<2)return o.push(s);let d=Be(s,l[a-1]),c=Be(l[a-1],l[a-2]);if(me(d,c)){let u=n?.findIndex(m=>m.index===a-1)??-1,p=n?.findIndex(m=>m.index===a)??-1;p!==-1&&(n[p].start=z(l[a-2][0]-e.x,l[a-2][1]-e.y)),u!==-1&&n.splice(u,1),o.splice(-1,1),n.forEach(m=>{m.index>a-1&&(m.index-=1)})}return o.push(s)});let i=[];o.forEach((s,a,l)=>{if(a<3)return i.push(s);if(gr(l[a-2],l[a-1])<wr){let d=n?.findIndex(p=>p.index===a-2)??-1,c=n?.findIndex(p=>p.index===a-1)??-1;c!==-1&&n.splice(c,1),d!==-1&&n.splice(d,1),i.splice(-2,2),n.forEach(p=>{p.index>a-2&&(p.index-=2)});let u=tt(s,l[a-1]);return i.push(z(u?s[0]:l[a-2][0],u?l[a-2][1]:s[1]))}i.push(s)});let r=n.filter(s=>s.index!==1&&s.index!==i.length-1);return r.length===0?At(Pr(Ir(br(e,yr(e,t,i.map(s=>z(s[0]-e.x,s[1]-e.y))))??[])),r,null,null):(wp()&&Dn(Ra(i),"Invalid elbow points with fixed segments"),At(i,r,e.startIsSpecial,e.endIsSpecial))}return{x:e.x,y:e.y,points:e.points,fixedSegments:e.fixedSegments,startIsSpecial:e.startIsSpecial,endIsSpecial:e.endIsSpecial}},Pp=(e,t,n)=>{let o=t.map(T=>T.index),r=(e.fixedSegments?.map(T=>T.index)??[]).findIndex(T=>!o.includes(T));if(r===-1||!e.fixedSegments?.[r])return{points:e.points};let s=e.fixedSegments[r].index,a=e.fixedSegments[r-1],l=e.fixedSegments[r+1],d=e.x+(a?a.end[0]:0),c=e.y+(a?a.end[1]:0),u=a?null:e.startBinding,p=l?null:e.endBinding,{startHeading:m,endHeading:f,startGlobalPoint:E,endGlobalPoint:h,hoveredStartElement:g,hoveredEndElement:x,...y}=yr({x:d,y:c,startBinding:u,endBinding:p,startArrowhead:null,endArrowhead:null,points:e.points},n,[z(0,0),z(e.x+(l?.start[0]??e.points[e.points.length-1][0])-d,e.y+(l?.start[1]??e.points[e.points.length-1][1])-c)],{isDragging:!1}),{points:b}=At(Pr(Ir(br(e,{startHeading:m,endHeading:f,startGlobalPoint:E,endGlobalPoint:h,hoveredStartElement:g,hoveredEndElement:x,...y})??[])),t,null,null);if(!b||b.length<2)throw new Error("Property 'points' is required in the update returned by normalizeArrowElementUpdate()");let w=[];if(a)for(let T=0;T<a.index;T++)w.push(z(e.x+e.points[T][0],e.y+e.points[T][1]));if(b.forEach(T=>{w.push(z(e.x+(a?a.end[0]:0)+T[0],e.y+(a?a.end[1]:0)+T[1]))}),l)for(let T=l.index;T<e.points.length;T++)w.push(z(e.x+e.points[T][0],e.y+e.points[T][1]));let I=(l?.index??e.points.length)-(a?.index??0)-1,M=t.map(T=>T.index>s?{...T,index:T.index-I+(b.length-1)}:T),D=w.flatMap((T,N)=>{let C=w[N-1],R=w[N+1];if(C&&R){let L=Be(T,C),$=Be(R,T);if(me(L,$))return M.forEach(H=>{H.index>N&&(H.index-=1)}),[];if(me(L,fr($)))return M.forEach(H=>{H.index>N&&(H.index+=1)}),[T,T]}return[T]});return At(D,M,!1,!1)},Ip=(e,t,n,o,i,r)=>{let s=t.map((w,I)=>e.fixedSegments==null||e.fixedSegments[I]===void 0||e.fixedSegments[I].index!==w.index||(w.start[0]!==e.fixedSegments[I].start[0]&&w.end[0]!==e.fixedSegments[I].end[0])!=(w.start[1]!==e.fixedSegments[I].start[1]&&w.end[1]!==e.fixedSegments[I].end[1])?I:null).filter(w=>w!==null).shift();if(s==null)return{points:e.points};let a=e.fixedSegments?.findIndex(w=>w.index===1)??-1,l=e.fixedSegments?.findIndex(w=>w.index===e.points.length-1)??-1,d=gr(t[s].start,t[s].end),c=d<ee+5;if(a===-1&&t[s].index===1&&i){let w=Oe(n),M=(w?me(n,fe):me(n,ye))?c?d/2:ee:c?-d/2:-ee;t[s].start=z(t[s].start[0]+(w?M:0),t[s].start[1]+(w?0:M))}if(l===-1&&t[s].index===e.points.length-1&&r){let w=Oe(o),M=(w?me(o,fe):me(o,ye))?c?d/2:ee:c?-d/2:-ee;t[s].end=z(t[s].end[0]+(w?M:0),t[s].end[1]+(w?0:M))}let u=t.map(w=>({...w,start:z(e.x+w.start[0],e.y+w.start[1]),end:z(e.x+w.end[0],e.y+w.end[1])})),p=e.points.map((w,I)=>z(e.x+w[0],e.y+w[1])),m=u[s].index-1,f=u[s].index,E=u[s].start,h=u[s].end,g=p[m-1]&&!ro(p[m],p[m-1])?tt(p[m-1],p[m]):void 0,x=p[f+1]&&!ro(p[f],p[f+1])?tt(p[f+1],p[f]):void 0;if(g!==void 0){let w=g?1:0;p[m-1][w]=E[w]}if(p[m]=E,p[f]=h,x!==void 0){let w=x?1:0;p[f+1][w]=h[w]}let y=u.findIndex(w=>w.index===m);if(y!==-1){let w=tt(u[y].end,u[y].start)?1:0;u[y].start[w]=E[w],u[y].end=E}let b=u.findIndex(w=>w.index===f+1);if(b!==-1){let w=tt(u[b].end,u[b].start)?1:0;u[b].end[w]=h[w],u[b].start=h}if(a===-1&&m===0){let w=i?Oe(n):tt(p[1],p[0]);p.unshift(z(w?E[0]:e.x+e.points[0][0],w?e.y+e.points[0][1]:E[1])),i&&p.unshift(z(e.x+e.points[0][0],e.y+e.points[0][1]));for(let I of u)I.index+=i?2:1}if(l===-1&&f===e.points.length-1){let w=Oe(o);p.push(z(w?h[0]:e.x+e.points[e.points.length-1][0],w?e.y+e.points[e.points.length-1][1]:h[1])),r&&p.push(z(e.x+e.points[e.points.length-1][0],e.y+e.points[e.points.length-1][1]))}return At(p,u.map(w=>({...w,start:z(w.start[0]-e.x,w.start[1]-e.y),end:z(w.end[0]-e.x,w.end[1]-e.y)})),!1,!1)},Sp=(e,t,n,o,i,r,s,a,l)=>{let d=e.startIsSpecial??null,c=e.endIsSpecial??null,u=t.map((h,g)=>g===0?z(e.x+h[0],e.y+h[1]):g===t.length-1?z(e.x+h[0],e.y+h[1]):z(e.x+e.points[g][0],e.y+e.points[g][1])),p=n.map(h=>({...h,start:z(e.x+(h.start[0]-t[0][0]),e.y+(h.start[1]-t[0][1])),end:z(e.x+(h.end[0]-t[0][0]),e.y+(h.end[1]-t[0][1]))})),m=[],f=2+(d?1:0),E=2+(c?1:0);for(;m.length+f<u.length-E;)m.push(u[m.length+f]);{let h=u.at(d?2:1),g=u.at(d?3:2);if(!h||!g)throw new Error(`Second and third points must exist when handling endpoint drag (${d})`);let x=Oe(o),y=Oe(Tt(xr(h,g)));if(a&&x===y){let b=x?me(o,fe):me(o,ye);if(m.unshift(z(y?r[0]+(b?ee:-ee):g[0],y?g[1]:r[1]+(b?ee:-ee))),m.unshift(z(x?r[0]+(b?ee:-ee):r[0],x?r[1]:r[1]+(b?ee:-ee))),!d){d=!0;for(let w of p)w.index>1&&(w.index+=1)}}else if(m.unshift(z(y?r[0]:h[0],y?h[1]:r[1])),d){d=!1;for(let b of p)b.index>1&&(b.index-=1)}m.unshift(r)}{let h=u.at(u.length-(c?3:2)),g=u.at(u.length-(c?4:3));if(!h||!g)throw new Error(`Second and third to last points must exist when handling endpoint drag (${c})`);let x=Oe(i),y=tt(g,h);if(l&&x===y){let b=x?me(i,fe):me(i,ye);m.push(z(y?s[0]+(b?ee:-ee):g[0],y?g[1]:s[1]+(b?ee:-ee))),m.push(z(x?s[0]+(b?ee:-ee):s[0],x?s[1]:s[1]+(b?ee:-ee))),c||(c=!0)}else m.push(z(y?s[0]:h[0],y?h[1]:s[1])),c&&(c=!1)}return m.push(s),At(m,p.map(({index:h})=>({index:h,start:m[h-1],end:m[h]})).map(h=>({...h,start:z(h.start[0]-r[0],h.start[1]-r[1]),end:z(h.end[0]-r[0],h.end[1]-r[1])})),d,c)},jt=1e6,Ln=(e,t,n,o)=>{if(e.points.length<2)return{points:n.points??e.points};A.PROD||(Dn(!n.points||n.points.length>=2,"Updated point array length must match the arrow point length, contain exactly the new start and end points or not be specified at all (i.e. you can't add new points between start and end manually to elbow arrows)"),Dn(!e.fixedSegments||e.fixedSegments.map(w=>w.start[0]===w.end[0]||w.start[1]===w.end[1]).every(Boolean),"Fixed segments must be either horizontal or vertical"),Dn(!n.fixedSegments||n.fixedSegments.map(w=>w.start[0]===w.end[0]||w.start[1]===w.end[1]).every(Boolean),"Updates to fixed segments must be either horizontal or vertical"),Dn(e.points.slice(1).map((w,I)=>w[0]===e.points[I][0]||w[1]===e.points[I][1]),"Elbow arrow segments must be either horizontal or vertical"),Dn(n.fixedSegments?.find(w=>w.index===1&&ro(w.start,(n.points??e.points)[0]))==null&&n.fixedSegments?.find(w=>w.index===(n.points??e.points).length-1&&ro(w.end,(n.points??e.points)[(n.points??e.points).length-1]))==null,"The first and last segments cannot be fixed"));let i=n.fixedSegments??e.fixedSegments??[],r=n.points?n.points&&n.points.length===2?e.points.map((w,I)=>I===0?n.points[0]:I===e.points.length-1?n.points[1]:w):n.points.slice():e.points.slice(),{startBinding:s,endBinding:a,...l}=n,d=typeof s<"u"?s:e.startBinding,c=typeof a<"u"?a:e.endBinding,u=d&&ti(d.elementId,t),p=c&&ti(c.elementId,t),m=Ra(r);if(d&&!u&&m||c&&!p&&m||t.size===0&&m||Object.keys(l).length===0&&(u?.id!==d?.elementId||p?.id!==c?.elementId))return At(r.map(w=>z(e.x+w[0],e.y+w[1])),e.fixedSegments,e.startIsSpecial,e.endIsSpecial);let{startHeading:f,endHeading:E,startGlobalPoint:h,endGlobalPoint:g,hoveredStartElement:x,hoveredEndElement:y,...b}=yr({x:e.x,y:e.y,startBinding:d,endBinding:c,startArrowhead:e.startArrowhead,endArrowhead:e.endArrowhead,points:e.points},t,r,o);return t.size===0&&m?At(r.map(w=>z(e.x+w[0],e.y+w[1])),e.fixedSegments,e.startIsSpecial,e.endIsSpecial):!n.points&&!n.fixedSegments&&!n.startBinding&&!n.endBinding?bp(e,t):n.startBinding===e.startBinding&&n.endBinding===e.endBinding&&(n.points??[]).every((w,I)=>ro(w,e.points[I]??z(1/0,1/0)))&&m?{}:i.length===0?At(Pr(Ir(br(e,{startHeading:f,endHeading:E,startGlobalPoint:h,endGlobalPoint:g,hoveredStartElement:x,hoveredEndElement:y,...b})??[])),i,null,null):(e.fixedSegments?.length??0)>i.length?Pp(e,i,t):n.points?n.points&&n.fixedSegments?n:Sp(e,r,i,f,E,h,g,x,y):Ip(e,i,f,E,x,y)},yr=(e,t,n,o)=>{let i=Er(n[0],ct(e.x,e.y)),r=Er(n[n.length-1],ct(e.x,e.y)),s=null,a=null;if(o?.isDragging){let w=Array.from(t.values());s=Ba(i,t,w,o?.zoom)||null,a=Ba(r,t,w,o?.zoom)||null}else s=e.startBinding&&ti(e.startBinding.elementId,t)||null,a=e.endBinding&&ti(e.endBinding.elementId,t)||null;let l=Ca({...e,type:"arrow",elbowed:!0,points:n},"start",e.startBinding?.fixedPoint,i,s,t,o?.isDragging),d=Ca({...e,type:"arrow",elbowed:!0,points:n},"end",e.endBinding?.fixedPoint,r,a,t,o?.isDragging),c=Ga(l,d,s,i,t),u=Ga(d,l,a,r,t),p=[l[0]-2,l[1]-2,l[0]+2,l[1]+2],m=[d[0]-2,d[1]-2,d[0]+2,d[1]+2],f=s?$e(s,t,Wt(c,e.startArrowhead?ie*6:ie*2,1)):p,E=a?$e(a,t,Wt(u,e.endArrowhead?ie*6:ie*2,1)):m,h=vn(l,a?$e(a,t,Wt(u,ee,ee)):m)||vn(d,s?$e(s,t,Wt(c,ee,ee)):p),g=Oa(h?[p,m]:[f,E]),x=Ap(h?p:f,h?m:E,g,h?Wt(c,!s&&!a?0:ee,0):Wt(c,!s&&!a?0:ee-(e.startArrowhead?ie*6:ie*2),ee),h?Wt(u,!s&&!a?0:ee,0):Wt(u,!s&&!a?0:ee-(e.endArrowhead?ie*6:ie*2),ee),h,s&&$e(s,t),a&&$e(a,t)),y=La(x[0],c,l),b=La(x[1],u,d);return{dynamicAABBs:x,startDonglePosition:y,startGlobalPoint:l,startHeading:c,endDonglePosition:b,endGlobalPoint:d,endHeading:u,commonBounds:g,hoveredStartElement:s,hoveredEndElement:a,boundsOverlap:h,startElementBounds:f,endElementBounds:E}},br=(e,t)=>{let{dynamicAABBs:n,startDonglePosition:o,startGlobalPoint:i,startHeading:r,endDonglePosition:s,endGlobalPoint:a,endHeading:l,commonBounds:d,hoveredEndElement:c}=t,u=Dp(n,o||i,r,s||a,l,d),p=o&&ei(o,u),m=s&&ei(s,u),f=ei(a,u);f&&c&&(f.closed=!0);let E=ei(i,u);E&&e.startBinding&&(E.closed=!0);let h=p&&m&&(vn(p.pos,n[1])||vn(m.pos,n[0])),g=Mp(p||E,m||f,u,r||fe,l||fe,h?[]:n);if(g){let x=g.map(y=>[y.pos[0],y.pos[1]]);return p&&x.unshift(i),m&&x.push(a),x}return null},Wt=(e,t,n)=>{switch(e){case _e:return[t,n,n,n];case fe:return[n,t,n,n];case ye:return[n,n,t,n]}return[n,n,n,t]},Mp=(e,t,n,o,i,r)=>{let s=hr(e.pos,t.pos),a=new Ep(l=>l.f);for(a.push(e);a.size()>0;){let l=a.pop();if(!l||l.closed)continue;if(l===t)return Tp(e,l);l.closed=!0;let d=Lp(l.addr,n);for(let c=0;c<4;c++){let u=d[c];if(!u||u.closed)continue;let p=fp(u.pos,l.pos,.5);if(gp(...r.map(b=>vn(p,b))))continue;let m=Cp(c),f=l.parent?Tt(xr(l.pos,l.parent.pos)):o,E=fr(f);if(me(E,m)||ka(e.addr,u.addr)&&me(m,o)||ka(t.addr,u.addr)&&me(m,i))continue;let g=f!==m,x=l.g+hr(u.pos,l.pos)+(g?Math.pow(s,3):0),y=u.visited;if(!y||x<u.g){let b=vp(u,t,m,i);u.visited=!0,u.parent=l,u.h=hr(t.pos,u.pos)+b*Math.pow(s,2),u.g=x,u.f=u.g+u.h,y?a.rescoreElement(u):a.push(u)}}}return null},Tp=(e,t)=>{let n=t,o=[];for(;n.parent;)o.unshift(n),n=n.parent;return o.unshift(e),o},hr=(e,t)=>Math.abs(e[0]-t[0])+Math.abs(e[1]-t[1]),Ap=(e,t,n,o,i,r,s,a)=>{let l=s??e,d=a??t,[c,u,p,m]=o??[0,0,0,0],[f,E,h,g]=i??[0,0,0,0],x=[e[0]>t[2]?e[1]>t[3]||e[3]<t[1]?Math.min((l[0]+d[2])/2,e[0]-m):(l[0]+d[2])/2:e[0]>t[0]?e[0]-m:n[0]-m,e[1]>t[3]?e[0]>t[2]||e[2]<t[0]?Math.min((l[1]+d[3])/2,e[1]-c):(l[1]+d[3])/2:e[1]>t[1]?e[1]-c:n[1]-c,e[2]<t[0]?e[1]>t[3]||e[3]<t[1]?Math.max((l[2]+d[0])/2,e[2]+u):(l[2]+d[0])/2:e[2]<t[2]?e[2]+u:n[2]+u,e[3]<t[1]?e[0]>t[2]||e[2]<t[0]?Math.max((l[3]+d[1])/2,e[3]+p):(l[3]+d[1])/2:e[3]<t[3]?e[3]+p:n[3]+p],y=[t[0]>e[2]?t[1]>e[3]||t[3]<e[1]?Math.min((d[0]+l[2])/2,t[0]-g):(d[0]+l[2])/2:t[0]>e[0]?t[0]-g:n[0]-g,t[1]>e[3]?t[0]>e[2]||t[2]<e[0]?Math.min((d[1]+l[3])/2,t[1]-f):(d[1]+l[3])/2:t[1]>e[1]?t[1]-f:n[1]-f,t[2]<e[0]?t[1]>e[3]||t[3]<e[1]?Math.max((d[2]+l[0])/2,t[2]+E):(d[2]+l[0])/2:t[2]<e[2]?t[2]+E:n[2]+E,t[3]<e[1]?t[0]>e[2]||t[2]<e[0]?Math.max((d[3]+l[1])/2,t[3]+h):(d[3]+l[1])/2:t[3]<e[3]?t[3]+h:n[3]+h],b=Oa([x,y]);if(!r&&x[2]-x[0]+y[2]-y[0]>b[2]-b[0]+1e-11&&x[3]-x[1]+y[3]-y[1]>b[3]-b[1]+1e-11){let[w,I]=[(y[0]+y[2])/2,(y[1]+y[3])/2];if(t[0]>e[2]&&e[1]>t[3]){let M=x[2]+(y[0]-x[2])/2,D=y[3]+(x[1]-y[3])/2;return Jo(ct(e[2]-w,e[1]-I),ct(e[0]-w,e[3]-I))>0?[[x[0],x[1],M,x[3]],[M,y[1],y[2],y[3]]]:[[x[0],D,x[2],x[3]],[y[0],y[1],y[2],D]]}else if(e[2]<t[0]&&e[3]<t[1]){let M=x[2]+(y[0]-x[2])/2,D=x[3]+(y[1]-x[3])/2;return Jo(ct(e[0]-w,e[1]-I),ct(e[2]-w,e[3]-I))>0?[[x[0],x[1],x[2],D],[y[0],D,y[2],y[3]]]:[[x[0],x[1],M,x[3]],[M,y[1],y[2],y[3]]]}else if(e[0]>t[2]&&e[3]<t[1]){let M=y[2]+(x[0]-y[2])/2,D=x[3]+(y[1]-x[3])/2;return Jo(ct(e[2]-w,e[1]-I),ct(e[0]-w,e[3]-I))>0?[[M,x[1],x[2],x[3]],[y[0],y[1],M,y[3]]]:[[x[0],x[1],x[2],D],[y[0],D,y[2],y[3]]]}else if(e[0]>t[2]&&e[1]>t[3]){let M=y[2]+(x[0]-y[2])/2,D=y[3]+(x[1]-y[3])/2;return Jo(ct(e[0]-w,e[1]-I),ct(e[2]-w,e[3]-I))>0?[[M,x[1],x[2],x[3]],[y[0],y[1],M,y[3]]]:[[x[0],D,x[2],x[3]],[y[0],y[1],y[2],D]]}}return[x,y]},Dp=(e,t,n,o,i,r)=>{let s=new Set,a=new Set;n===ke||n===fe?a.add(t[1]):s.add(t[0]),i===ke||i===fe?a.add(o[1]):s.add(o[0]),e.forEach(c=>{s.add(c[0]),s.add(c[2]),a.add(c[1]),a.add(c[3])}),s.add(r[0]),s.add(r[2]),a.add(r[1]),a.add(r[3]);let l=Array.from(a).sort((c,u)=>c-u),d=Array.from(s).sort((c,u)=>c-u);return{row:l.length,col:d.length,data:l.flatMap((c,u)=>d.map((p,m)=>({f:0,g:0,h:0,closed:!1,visited:!1,parent:null,addr:[m,u],pos:[p,c]})))}},La=(e,t,n)=>{switch(t){case _e:return z(n[0],e[1]);case fe:return z(e[2],n[1]);case ye:return z(n[0],e[3])}return z(e[0],n[1])},vp=(e,t,n,o)=>{if(o===fe)switch(n){case fe:return e.pos[0]>=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2;case _e:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case ye:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case ke:return e.pos[1]===t.pos[1]?4:2}else if(o===ke)switch(n){case fe:return e.pos[1]===t.pos[1]?4:2;case _e:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case ye:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case ke:return e.pos[0]<=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2}else if(o===_e)switch(n){case fe:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case _e:return e.pos[1]>=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case ye:return e.pos[0]===t.pos[0]?4:2;case ke:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3}else if(o===ye)switch(n){case fe:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case _e:return e.pos[0]===t.pos[0]?4:2;case ye:return e.pos[1]<=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case ke:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3}return 0},Lp=([e,t],n)=>[io([e,t-1],n),io([e+1,t],n),io([e,t+1],n),io([e-1,t],n)],io=([e,t],n)=>e<0||e>=n.col||t<0||t>=n.row?null:n.data[t*n.col+e]??null,ei=(e,t)=>{for(let n=0;n<t.col;n++)for(let o=0;o<t.row;o++){let i=io([n,o],t);if(i&&e[0]===i.pos[0]&&e[1]===i.pos[1])return i}return null},Oa=e=>[Math.min(...e.map(t=>t[0])),Math.min(...e.map(t=>t[1])),Math.max(...e.map(t=>t[2])),Math.max(...e.map(t=>t[3]))],ti=(e,t)=>{let n=t.get(e);return n&&Le(n)?n:null},At=(e,t,n,o)=>{let i=e[0][0],r=e[0][1],s=e.map(a=>Er(a,hp(xr(e[0]),-1)));return(i<-jt||i>jt||r<-jt||r>jt||i+s[s.length-1][0]<-jt||r+s[s.length-1][0]>jt||i+s[s.length-1][1]<-jt||r+s[s.length-1][1]>jt)&&console.error("Elbow arrow normalization is outside reasonable bounds (> 1e6)",{x:i,y:r,points:s,...va(s)}),s=s.map(([a,l])=>z(Qo(a,-1e6,1e6),Qo(l,-1e6,1e6))),{points:s,x:Qo(i,-1e6,1e6),y:Qo(r,-1e6,1e6),fixedSegments:(t?.length??0)>0?t:null,...va(s),startIsSpecial:n,endIsSpecial:o}},Pr=e=>{if(e.length>1){let t=Math.abs(e[0][1]-e[1][1])<Math.abs(e[0][0]-e[1][0]);return e.filter((n,o)=>{if(o===0||o===e.length-1)return!0;let i=e[o+1],r=Math.abs(n[1]-i[1])<Math.abs(n[0]-i[0]);return t===r?(t=r,!1):(t=r,!0)})}return e},Ir=e=>e.length>=4?e.filter((t,n)=>{if(n===0||n===e.length-1)return!0;let o=e[n-1];return gr(o,t)>wr}):e,Cp=e=>{switch(e){case 0:return _e;case 1:return fe;case 2:return ye}return ke},Ca=(e,t,n,o,i,r,s)=>s?i&&r?Sr(e,i,t,r):o:i?ni(n||[0,0],i,r??yp([i])):o,Ga=(e,t,n,o,i)=>Fa(e,t,n,n&&$e(n,i,Array(4).fill(Ut(n,i,e))),o,i),Ba=(e,t,n,o)=>Vt(xp(e),n,t,o,!0,!0),ka=(e,t)=>e[0]===t[0]&&e[1]===t[1],Ra=(e,t=wr)=>e.slice(1).map((n,o)=>Math.abs(n[0]-e[o][0])<t||Math.abs(n[1]-e[o][1])<t).every(Boolean);var be=(e,t,n,o)=>{let i=!1,{points:r,fixedSegments:s,startBinding:a,endBinding:l,fileId:d}=n;B(e)&&(Object.keys(n).length===0||typeof r<"u"||typeof s<"u"||typeof a<"u"||typeof l<"u")?n={...n,angle:0,...Ln({...e,x:n.x||e.x,y:n.y||e.y},t,n,o)}:typeof r<"u"&&(n={...Gp(r),...n});for(let c in n){let u=n[c];if(typeof u<"u"){if(e[c]===u&&(typeof u!="object"||u===null||c==="groupIds"||c==="scale"))continue;if(c==="scale"){let p=e[c],m=u;if(p[0]===m[0]&&p[1]===m[1])continue}else if(c==="points"){let p=e[c],m=u;if(p.length===m.length){let f=!1,E=p.length;for(;--E;){let h=p[E],g=m[E];if(h[0]!==g[0]||h[1]!==g[1]){f=!0;break}}if(!f)continue}}e[c]=u,i=!0}}return i&&((typeof n.height<"u"||typeof n.width<"u"||typeof d<"u"||typeof r<"u")&&Pe.delete(e),e.version=n.version??e.version+1,e.versionNonce=n.versionNonce??Mr(),e.updated=Tr()),e},ge=(e,t,n=!1)=>{let o=!1;for(let i in t){let r=t[i];if(typeof r<"u"){if(e[i]===r&&(typeof r!="object"||r===null))continue;o=!0}}return!o&&!n?e:{...e,...t,version:t.version??e.version+1,versionNonce:t.versionNonce??Mr(),updated:Tr()}},Na=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=Mr(),e.updated=Tr(),e);var Ey=e=>!e[Bp.CTRL_OR_CMD],Ar=e=>e.isBindingEnabled,ie=5,zp=10,_p=(e,t)=>{let n=[];return t.forEach(o=>{let i=e.getNonDeletedElement(o);i!=null&&n.push(i)}),n},Dr=(e,t,n,o)=>{let i=o.getNonDeletedElementsMap(),r=new Set,s=new Set;_a(e,t,n,"start",r,s,o,i),_a(e,n,t,"end",r,s,o,i);let a=Array.from(s).filter(l=>!r.has(l));_p(o,a).forEach(l=>{o.mutateElement(l,{boundElements:l.boundElements?.filter(d=>d.type!=="arrow"||d.id!==e.id)})})},_a=(e,t,n,o,i,r,s,a)=>{if(t!=="keep"){if(t===null){let l=Wp(e,o,s);l!=null&&r.add(l);return}$a(e)?(n==null||(n==="keep"?!Wa(e,t,o):o==="start"||n.id!==t.id))&&(yn(e,t,o,s),i.add(t.id)):(yn(e,t,o,s),i.add(t.id))}},Xa=(e,t,n)=>["start","end"].map(o=>{let i=qa(e,o,t),r=o==="start"?e.startBinding?.elementId:e.endBinding?.elementId;if(r){let s=t.get(r);if(Le(s)&&ii(s,i,t,n))return s}return null}),Yp=(e,t,n,o,i,r)=>{let a=e.points.length-1,l=n.findIndex(p=>p===0)>-1,d=n.findIndex(p=>p===a)>-1,c=l?t?ri(e,"start",o,i,r):null:"keep",u=d?t?ri(e,"end",o,i,r):null:"keep";return[c,u]},Up=(e,t,n,o,i)=>{if(B(e))return["keep","keep"];let[r,s]=Xa(e,t,i),a=r&&o?ri(e,"start",t,n,i):null,l=s&&o?ri(e,"end",t,n,i):null;return[a,l]},Xp=(e,t,n,o,i)=>{e.forEach(r=>{let[s,a]=n?.length?Yp(r,t,n??[],o.getNonDeletedElementsMap(),o.getNonDeletedElements(),i):Up(r,o.getNonDeletedElementsMap(),o.getNonDeletedElements(),t,i);Dr(r,s,a,o)})},gy=(e,t,n)=>e.length>50?[]:e.filter(j).flatMap(o=>Xa(o,t,n)).filter(o=>o!==null).filter(o=>e.filter(i=>i.id===o?.id).length===0),ja=(e,t,n,o,i)=>Array.from(t.reduce((r,s)=>{let a=Vt(s,n.getNonDeletedElements(),n.getNonDeletedElementsMap(),o,B(e),B(e));return a!=null&&!Va(e,i?.id,a)&&r.add(a),r},new Set)),xy=(e,t,n,o)=>{let i=o.getNonDeletedElements(),r=o.getNonDeletedElementsMap();t.startBoundElement!=null&&yn(e,t.startBoundElement,"start",o);let s=Vt(n,i,r,t.zoom,B(e),B(e));s!==null&&(Wa(e,s,"end")||yn(e,s,"end",o))},jp=(e,t)=>({...e,gap:Math.min(e.gap,li(t,t.width,t.height))}),yn=(e,t,n,o)=>{if(!_(e))return;let i={elementId:t.id,...jp(Zp(e,t,n,o.getNonDeletedElementsMap()),t)};B(e)&&(i={...i,...Za(e,t,n,o.getNonDeletedElementsMap())}),o.mutateElement(e,{[n==="start"?"startBinding":"endBinding"]:i}),Ua(t.boundElements||[]).has(e.id)||o.mutateElement(t,{boundElements:(t.boundElements||[]).concat({id:e.id,type:"arrow"})})},Wa=(e,t,n)=>{let o=e[n==="start"?"endBinding":"startBinding"];return Va(e,o?.elementId,t)},Va=(e,t,n)=>t===n.id&&$a(e),$a=e=>e.points.length<3&&!B(e),Wp=(e,t,n)=>{let o=t==="start"?"startBinding":"endBinding",i=e[o];return i==null?null:(n.mutateElement(e,{[o]:null}),i.elementId)},Vt=(e,t,n,o,i,r)=>{if(r){let a=!1,l=$p(t,c=>Le(c,!1)&&ii(c,e,n,o,(i||!oi(c))&&!q(c))).filter(c=>a?!1:(oi(c)||(a=!0),!0));if(!l||l.length===0)return null;if(l.length===1)return l[0];let d=l.filter(c=>ii(c,e,n,o,!1));return d.length===1?d[0]:l.sort((c,u)=>u.width**2+u.height**2-(c.width**2+c.height**2)).pop()}return Vp(t,a=>Le(a,!1)&&ii(a,e,n,o,(i||!oi(a))&&!q(a)))},Vp=(e,t)=>{let n=null;for(let o=e.length-1;o>=0;--o){let i=e[o];if(!i.isDeleted&&t(i)){n=i;break}}return n},$p=(e,t)=>{let n=[];for(let o=e.length-1;o>=0;--o){let i=e[o];i.isDeleted||t(i)&&n.push(i)}return n},Zp=(e,t,n,o)=>{let i=n==="start"?-1:1,r=i===-1?0:e.points.length-1,s=r-i,a=U.getPointAtIndexGlobalCoordinates(e,r,o),l=U.getPointAtIndexGlobalCoordinates(e,s,o);return{focus:nm(t,o,l,a),gap:Math.max(1,Ut(t,o,a))}},Ue=(e,t,n)=>{if(!Le(e))return;let{newSize:o,simultaneouslyUpdated:i}=n??{},r=Kp(i),s=t.getNonDeletedElementsMap();n?.changedElements&&(s=new Map(s),n.changedElements.forEach(a=>{s.set(a.id,a)})),si(s,e,a=>{if(!j(a)||a.isDeleted||!qp(a,e))return;let l=a.startBinding?s.get(a.startBinding.elementId):null,d=a.endBinding?s.get(a.endBinding.elementId):null,c=null,u=null;l&&d&&(c=pe(l,s),u=pe(d,s));let p={startBinding:Ya(e,a.startBinding,o),endBinding:Ya(e,a.endBinding,o)};if(r.has(a.id)){t.mutateElement(a,p);return}let m=ai(s,a,(E,h)=>{if(E&&Le(E)&&(h==="startBinding"||h==="endBinding")&&(e.id===a[h]?.elementId||e.id===a[h==="startBinding"?"endBinding":"startBinding"]?.elementId&&!gn(c,u))){let g=tm(a,h,p[h],E,s);if(g)return[h==="startBinding"?0:a.points.length-1,{point:g}]}return null}).filter(E=>E!==null);U.movePoints(a,t,new Map(m),{...e.id===a.startBinding?.elementId?{startBinding:p.startBinding}:{},...e.id===a.endBinding?.elementId?{endBinding:p.endBinding}:{}});let f=W(a,s);f&&!f.isDeleted&&hn(a,t,!1)})},wy=(e,t,n)=>{j(e)?Xp([e],!0,[],t,n?.zoom):Ue(e,t,{...n,changedElements:new Map([[e.id,e]])})},qp=(e,t)=>e.startBinding?.elementId===t.id||e.endBinding?.elementId===t.id,Kp=e=>new Set((e||[]).map(t=>t.id)),Fa=(e,t,n,o,i,r,s)=>{let a=Tt(V(t,e));return!n||!o?a:Qp(i,n,r,s)?oo(n,o,e):Tt(V(e,he(n,r)))},Qp=(e,t,n,o)=>{let i=Ut(t,n,e),r=li(t,t.width,t.height,o);return i>r?null:i},Sr=(e,t,n,o)=>{(Rp()||Fp())&&Op(e.points.length>1,"Arrow should have at least 2 points");let i=$e(t,o),r=e.points[n==="start"?0:e.points.length-1],s=O(e.x+r[0],e.y+r[1]),a=la(t)?Jp(t,o,s):s,l=B(e),d=dt(i),c=n==="start"?1:e.points.length-2,u=ae(O(e.x+e.points[c][0],e.y+e.points[c][1]),d,e.angle??0),p=null;if(l){let m=Oe(oo(t,i,s)),f=em(t,o,a),E=O(m?d[0]:f[0],m?f[1]:d[1]),h=Re(E,xn(wn(Cn(V(f,E)),Math.max(t.width,t.height)*2),E));if(p=En(t,o,h,ie).sort(Dt)[0],!p){let g=O(m?f[0]:d[0],m?d[1]:f[1]),x=Re(g,xn(wn(Cn(V(f,g)),Math.max(t.width,t.height)*2),g));p=En(t,o,x,ie).sort(Dt)[0]}}else p=En(t,o,Re(u,xn(wn(Cn(V(a,u)),ut(a,u)+Math.max(t.width,t.height)*2),u)),ie).sort((m,f)=>Dt(m,u)-Dt(f,u))[0];return!p||Dt(a,p)<Hp?a:l?p:a},Jp=(e,t,n)=>{let o=he(e,t),i=ae(n,o,-e.angle);return i[0]<e.x&&i[1]<e.y?i[1]-e.y>-ie?ae(O(e.x-ie,e.y),o,e.angle):ae(O(e.x,e.y-ie),o,e.angle):i[0]<e.x&&i[1]>e.y+e.height?i[0]-e.x>-ie?ae(O(e.x,e.y+e.height+ie),o,e.angle):ae(O(e.x-ie,e.y+e.height),o,e.angle):i[0]>e.x+e.width&&i[1]>e.y+e.height?i[0]-e.x<e.width+ie?ae(O(e.x+e.width,e.y+e.height+ie),o,e.angle):ae(O(e.x+e.width+ie,e.y+e.height),o,e.angle):i[0]>e.x+e.width&&i[1]<e.y?i[0]-e.x<e.width+ie?ae(O(e.x+e.width,e.y-ie),o,e.angle):ae(O(e.x+e.width+ie,e.y),o,e.angle):n},em=(e,t,n,o=.05)=>{let{x:i,y:r,width:s,height:a,angle:l}=e,d=he(e,t,-.1,-.1),c=ae(n,d,-l),u=Ha(o*a,5,80),p=Ha(o*s,5,80);if(c[0]<=i+s/2&&c[1]>d[1]-u&&c[1]<d[1]+u)return ae(O(i-ie,d[1]),d,l);if(c[1]<=r+a/2&&c[0]>d[0]-p&&c[0]<d[0]+p)return ae(O(d[0],r-ie),d,l);if(c[0]>=i+s/2&&c[1]>d[1]-u&&c[1]<d[1]+u)return ae(O(i+s+ie,d[1]),d,l);if(c[1]>=r+a/2&&c[0]>d[0]-p&&c[0]<d[0]+p)return ae(O(d[0],r+a+ie),d,l);if(e.type==="diamond"){let m=ie,f=O(i+s/4-m,r+a/4-m),E=O(i+3*s/4+m,r+a/4-m),h=O(i+s/4-m,r+3*a/4+m),g=O(i+3*s/4+m,r+3*a/4+m);if(ut(f,c)<Math.max(p,u))return ae(f,d,l);if(ut(E,c)<Math.max(p,u))return ae(E,d,l);if(ut(h,c)<Math.max(p,u))return ae(h,d,l);if(ut(g,c)<Math.max(p,u))return ae(g,d,l)}return n},tm=(e,t,n,o,i)=>{if(n==null||n.elementId!==o.id&&e.points.length>2)return null;let r=t==="startBinding"?-1:1,s=r===-1?0:e.points.length-1;if(B(e)&&Jn(n)){let u=vr(n.fixedPoint)??Za(e,o,t==="startBinding"?"start":"end",i).fixedPoint,p=he(o,i),m=O(o.x+u[0]*o.width,o.y+u[1]*o.height),f=ae(m,p,o.angle);return U.pointFromAbsoluteCoords(e,f,i)}let a=s-r,l=U.getPointAtIndexGlobalCoordinates(e,a,i),d=om(o,i,n.focus,l),c;if(n.gap===0)c=d;else{let u=U.getPointAtIndexGlobalCoordinates(e,s,i),p=he(o,i),m=ut(l,u)+ut(l,p)+Math.max(o.width,o.height)*2,f=[...En(o,i,Re(l,xn(wn(Cn(V(d,l)),m),l)),n.gap).sort((E,h)=>Dt(E,l)-Dt(h,l)),xn(wn(Cn(V(d,l)),ut(l,u)),l)];f.length>1?c=f[0]:f.length===1?c=d:c=u}return U.pointFromAbsoluteCoords(e,c,i)},Za=(e,t,n,o)=>{let i=[t.x,t.y,t.x+t.width,t.y+t.height],r=Sr(e,t,n,o),s=O(i[0]+(i[2]-i[0])/2,i[1]+(i[3]-i[1])/2),a=ae(r,s,-t.angle);return{fixedPoint:vr([(a[0]-t.x)/t.width,(a[1]-t.y)/t.height])}},Ya=(e,t,n)=>{if(t==null||n==null)return t;let{width:o,height:i}=n,{width:r,height:s}=e,a=Math.max(1,Math.min(li(e,o,i),t.gap*(o<i?o/r:i/s)));return{...t,gap:a}},ri=(e,t,n,o,i)=>Vt(qa(e,t,n),o,n,i,B(e),B(e)),qa=(e,t,n)=>{let o=t==="start"?0:-1;return kp(U.getPointAtIndexGlobalCoordinates(e,o,n))},Ka=(e,t,n)=>{for(let o of e){if("boundElements"in o&&o.boundElements&&Object.assign(o,{boundElements:o.boundElements.reduce((i,r)=>{let s=t.get(r.id);return s&&i.push({...r,id:s}),i},[])}),"containerId"in o&&o.containerId&&Object.assign(o,{containerId:t.get(o.containerId)??null}),"endBinding"in o&&o.endBinding){let i=t.get(o.endBinding.elementId);Object.assign(o,{endBinding:i?{...o.endBinding,elementId:i}:null})}if("startBinding"in o&&o.startBinding){let i=t.get(o.startBinding.elementId);Object.assign(o,{startBinding:i?{...o.startBinding,elementId:i}:null})}B(o)&&Object.assign(o,Ln(o,n,{points:[o.points[0],o.points[o.points.length-1]]}))}},yy=(e,t)=>{let n=Ua(e);for(let o of t)$t.unbindAffected(n,o,(i,r)=>be(i,n,r)),Zt.unbindAffected(n,o,(i,r)=>be(i,n,r))},so=(e,t,n=[])=>{if(!e)return null;let o=e.filter(i=>!t.has(i.id));return o.push(...n.map(i=>({id:i.id,type:i.type}))),o},ii=(e,{x:t,y:n},o,i,r)=>{let s=O(t,n),a=li(e,e.width,e.height,i),l=(r||!oi(e))&&!q(e),d=[t-a,n-a,t+a,n+a],c=pe(e,o);if(!gn(d,c))return!1;let u=En(e,o,Re(he(e,o),s)),p=Ut(e,o,s);return l?u.length===0||p<=a:u.length>0&&p<=a},li=(e,t,n,o)=>{let i=o?.value&&o.value<1?o.value:1,s=(e.type==="diamond"?1/Math.sqrt(2):1)*Math.min(t,n);return Math.max(16,Math.min(.25*s,32),zp/i+ie)},nm=(e,t,n,o)=>{let i=he(e,t);if(Np(n,o))return 0;let r=ae(n,i,-e.angle),s=ae(o,i,-e.angle),a=Math.sign(Ye(V(s,n),V(s,i)))*-1,l=Re(s,xn(wn(Cn(V(s,r)),Math.max(e.width*2,e.height*2)),s)),d=e.type==="diamond"?[Re(O(e.x+e.width/2,e.y),O(e.x+e.width/2,e.y+e.height)),Re(O(e.x,e.y+e.height/2),O(e.x+e.width,e.y+e.height/2))]:[Re(O(e.x,e.y),O(e.x+e.width,e.y+e.height)),Re(O(e.x+e.width,e.y),O(e.x,e.y+e.height))],c=e.type==="diamond"?[Re(O(e.x+e.width/2,e.y-e.height),O(e.x+e.width/2,e.y+e.height*2)),Re(O(e.x-e.width,e.y+e.height/2),O(e.x+e.width*2,e.y+e.height/2))]:[Re(O(e.x-e.width,e.y-e.height),O(e.x+e.width*2,e.y+e.height*2)),Re(O(e.x+e.width*2,e.y-e.height),O(e.x-e.width,e.y+e.height*2))];return[za(l,c[0]),za(l,c[1])].filter(m=>m!==null).sort((m,f)=>Dt(m,o)-Dt(f,o)).map((m,f)=>a*ut(i,m)/(e.type==="diamond"?ut(d[f][0],d[f][1])/2:Math.sqrt(e.width**2+e.height**2)/2)).sort((m,f)=>Math.abs(m)-Math.abs(f))[0]??0},om=(e,t,n,o)=>{let i=he(e,t);if(n===0)return i;let r=(e.type==="diamond"?[O(e.x,e.y+e.height/2),O(e.x+e.width/2,e.y),O(e.x+e.width,e.y+e.height/2),O(e.x+e.width/2,e.y+e.height)]:[O(e.x,e.y),O(e.x+e.width,e.y),O(e.x+e.width,e.y+e.height),O(e.x,e.y+e.height)]).map(l=>xn(wn(V(l,i),Math.abs(n)),i)).map(l=>ae(l,i,e.angle)),s=[Ye(V(o,r[0]),V(r[1],r[0]))>0&&(n>0?Ye(V(o,r[1]),V(r[2],r[1]))<0:Ye(V(o,r[3]),V(r[0],r[3]))<0),Ye(V(o,r[1]),V(r[2],r[1]))>0&&(n>0?Ye(V(o,r[2]),V(r[3],r[2]))<0:Ye(V(o,r[0]),V(r[1],r[0]))<0),Ye(V(o,r[2]),V(r[3],r[2]))>0&&(n>0?Ye(V(o,r[3]),V(r[0],r[3]))<0:Ye(V(o,r[1]),V(r[2],r[1]))<0),Ye(V(o,r[3]),V(r[0],r[3]))>0&&(n>0?Ye(V(o,r[0]),V(r[1],r[0]))<0:Ye(V(o,r[2]),V(r[3],r[2]))<0)];return s[0]?n>0?r[1]:r[0]:s[1]?n>0?r[2]:r[1]:s[2]?n>0?r[3]:r[2]:n>0?r[0]:r[3]},Qa=new Set(["boundElements","frameId","containerId","startBinding","endBinding"]),si=(e,t,n)=>{Le(t)&&(t.boundElements?.slice()??[]).forEach(({id:i})=>{n(e.get(i),"boundElements",i)})},ai=(e,t,n)=>{let o=[];if(t.frameId){let i=t.frameId;o.push(n(e.get(i),"frameId",i))}if(ce(t)){let i=t.containerId;o.push(n(e.get(i),"containerId",i))}if(_(t)){if(t.startBinding){let i=t.startBinding.elementId;o.push(n(e.get(i),"startBinding",i))}if(t.endBinding){let i=t.endBinding.elementId;o.push(n(e.get(i),"endBinding",i))}}return o},$t=class{static unbindAffected(t,n,o){n&&ai(t,n,i=>{!i||i.isDeleted||si(t,i,(r,s,a)=>{a===n.id&&o(i,{boundElements:so(i.boundElements,new Set([a]))})})})}static rebindAffected=(t,n,o)=>{!n||n.isDeleted||ai(t,n,(i,r)=>{if(!i||i.isDeleted){o(n,{[r]:null});return}r!=="frameId"&&(i.boundElements?.find(s=>s.id===n.id)||(_(n)&&o(i,{boundElements:so(i.boundElements,new Set,new Array(n))}),oe(n)&&(i.boundElements?.find(s=>s.type==="text")?o(n,{[r]:null}):o(i,{boundElements:so(i.boundElements,new Set,new Array(n))}))))})}},Zt=class{static unbindAffected(t,n,o){n&&si(t,n,i=>{!i||i.isDeleted||ai(t,i,(r,s,a)=>{a===n.id&&o(i,{[s]:null})})})}static rebindAffected=(t,n,o)=>{!n||n.isDeleted||si(t,n,(i,r,s)=>{if(!i||i.isDeleted){o(n,{boundElements:so(n.boundElements,new Set([s]))});return}oe(i)&&((n.boundElements?.slice()??[]).reverse().find(l=>l.type==="text")?.id===i.id?i.containerId!==n.id&&o(i,{containerId:n.id}):(i.containerId!==null&&o(i,{containerId:null}),o(n,{boundElements:so(n.boundElements,new Set([i.id]))})))})}},ni=(e,t,n)=>{let[o,i]=vr(e);return ae(O(t.x+t.width*o,t.y+t.height*i),he(t,n),t.angle)},im=(e,t)=>{let n=e.startBinding&&t.get(e.startBinding.elementId),o=e.endBinding&&t.get(e.endBinding.elementId),i=n&&e.startBinding?ni(e.startBinding.fixedPoint,n,t):O(e.x+e.points[0][0],e.y+e.points[0][1]),r=o&&e.endBinding?ni(e.endBinding.fixedPoint,o,t):O(e.x+e.points[e.points.length-1][0],e.y+e.points[e.points.length-1][1]);return[i,r]},Ja=(e,t)=>{let[n,o]=im(e,t);return[U.pointFromAbsoluteCoords(e,n,t),U.pointFromAbsoluteCoords(e,o,t)]},vr=e=>e&&(Math.abs(e[0]-.5)<1e-4||Math.abs(e[1]-.5)<1e-4)?e.map(t=>Math.abs(t-.5)<1e-4?.5001:t):e;var Cr=({points:e})=>{let t=e[0][0],n=e[0][1];return{points:e.map(o=>G(o[0]-t,o[1]-n)),offsetX:t,offsetY:n}},U=class e{elementId;selectedPointsIndices;pointerDownState;isDragging;lastUncommittedPoint;pointerOffset;startBindingElement;endBindingElement;hoverPointIndex;segmentMidPointHoveredCoords;elbowed;customLineAngle;isEditing;constructor(t,n,o=!1){this.elementId=t.id,tl(t.points[0],G(0,0))||(console.error("Linear element is not normalized",Error().stack),be(t,n,e.getNormalizeElementPointsAndCoords(t))),this.selectedPointsIndices=null,this.lastUncommittedPoint=null,this.isDragging=!1,this.pointerOffset={x:0,y:0},this.startBindingElement="keep",this.endBindingElement="keep",this.pointerDownState={prevSelectedPointsIndices:null,lastClickedPoint:-1,lastClickedIsEndPoint:!1,origin:null,segmentMidpoint:{value:null,index:null,added:!1}},this.hoverPointIndex=-1,this.segmentMidPointHoveredCoords=null,this.elbowed=B(t)&&t.elbowed,this.customLineAngle=null,this.isEditing=o}static POINT_HANDLE_SIZE=10;static getElement(t,n){let o=n.get(t);return o||null}static handleBoxSelection(t,n,o,i){if(!n.selectedLinearElement?.isEditing||!n.selectionElement)return!1;let{selectedLinearElement:r}=n,{selectedPointsIndices:s,elementId:a}=r,l=e.getElement(a,i);if(!l)return!1;let[d,c,u,p]=Y(n.selectionElement,i),f=e.getPointsGlobalCoordinates(l,i).reduce((E,h,g)=>((h[0]>=d&&h[0]<=u&&h[1]>=c&&h[1]<=p||t.shiftKey&&s?.includes(g))&&E.push(g),E),[]).filter(E=>!(B(l)&&E!==0&&E!==l.points.length-1));o({selectedLinearElement:{...r,selectedPointsIndices:f.length?f:null}})}static handlePointDragging(t,n,o,i,r){if(!r)return null;let{elementId:s}=r,a=n.scene.getNonDeletedElementsMap(),l=e.getElement(s,a),d=r.customLineAngle;if(!l||B(l)&&!r.pointerDownState.lastClickedIsEndPoint&&r.pointerDownState.lastClickedPoint!==0)return null;let c=B(l)?[r.selectedPointsIndices?.includes(0)?0:void 0,r.selectedPointsIndices?.find(m=>m>0)?l.points.length-1:void 0].filter(m=>m!==void 0):r.selectedPointsIndices,u=B(l)?r.pointerDownState.lastClickedPoint>0?l.points.length-1:0:r.pointerDownState.lastClickedPoint,p=l.points[u];if(c&&p){if(nl(t)&&c.length===1&&l.points.length>1){let h=c[0],g=l.points[h===0?1:h-1];d=r.customLineAngle??Math.atan2(l.points[h][1]-g[1],l.points[h][0]-g[0]);let[x,y]=e._getShiftLockedDelta(l,a,g,G(o,i),t[Bn.CTRL_OR_CMD]?null:n.getEffectiveGridSize(),d);e.movePoints(l,n.scene,new Map([[h,{point:G(x+g[0],y+g[1]),isDragging:h===u}]]))}else{let h=e.createPointAt(l,a,o-r.pointerOffset.x,i-r.pointerOffset.y,t[Bn.CTRL_OR_CMD]?null:n.getEffectiveGridSize()),g=h[0]-p[0],x=h[1]-p[1];e.movePoints(l,n.scene,new Map(c.map(y=>{let b=y===u?e.createPointAt(l,a,o-r.pointerOffset.x,i-r.pointerOffset.y,t[Bn.CTRL_OR_CMD]?null:n.getEffectiveGridSize()):G(l.points[y][0]+g,l.points[y][1]+x);return[y,{point:b,isDragging:y===u}]})))}W(l,a)&&hn(l,n.scene,!1);let f=[];if(er(l,!1)){let h=c[0]===0,g=c[c.length-1]===l.points.length-1,x=[];!h!=!g?x.push({x:o,y:i}):(h&&x.push(Lr(e.getPointGlobalCoordinates(l,l.points[0],a))),g&&x.push(Lr(e.getPointGlobalCoordinates(l,l.points[c[c.length-1]],a)))),x.length&&(f=ja(l,x,n.scene,n.state.zoom))}let E={...r,selectedPointsIndices:c,segmentMidPointHoveredCoords:u!==0&&u!==l.points.length-1?this.getPointGlobalCoordinates(l,p,a):null,hoverPointIndex:u===0||u===l.points.length-1?u:-1,isDragging:!0,customLineAngle:d};return{...n.state,selectedLinearElement:E,suggestedBindings:f}}return null}static handlePointerUp(t,n,o,i){let r=i.getNonDeletedElementsMap(),s=i.getNonDeletedElements(),a=dm(t,o),{elementId:l,selectedPointsIndices:d,isDragging:c,pointerDownState:u}=n,p=e.getElement(l,r);if(!p)return n;let m={};if(c&&d){for(let f of d)if(f===0||f===p.points.length-1){cm(p.points,o.zoom.value)&&(bt(p)&&i.mutateElement(p,{...rl(p,!0)},{informMutation:!1,isDragging:!1}),e.movePoints(p,i,new Map([[f,{point:f===0?p.points[p.points.length-1]:p.points[0]}]])));let E=Ar(o)?Vt((d?.length??0)>1?Lr(e.getPointAtIndexGlobalCoordinates(p,f,r)):a,s,r,o.zoom,B(p),B(p)):null;m[f===0?"startBindingElement":"endBindingElement"]=E}}return{...n,...m,segmentMidPointHoveredCoords:null,hoverPointIndex:-1,selectedPointsIndices:c||t.shiftKey?!c&&t.shiftKey&&u.prevSelectedPointsIndices?.includes(u.lastClickedPoint)?d&&d.filter(f=>f!==u.lastClickedPoint):d:d?.includes(u.lastClickedPoint)?[u.lastClickedPoint]:d,isDragging:!1,pointerOffset:{x:0,y:0},customLineAngle:null}}static getEditorMidPoints=(t,n,o)=>{let i=W(t,n);if(!B(t)&&!o.selectedLinearElement?.isEditing&&t.points.length>2&&!i)return[];let r=e.getPointsGlobalCoordinates(t,n),s=0,a=[];for(;s<r.length-1;){if(e.isSegmentTooShort(t,t.points[s],t.points[s+1],s,o.zoom)){a.push(null),s++;continue}let l=e.getSegmentMidPoint(t,s+1);a.push(l),s++}return a};static getSegmentMidpointHitCoords=(t,n,o,i)=>{let{elementId:r}=t,s=e.getElement(r,i);if(!s)return null;let a=e.getPointIndexUnderCursor(s,i,o.zoom,n.x,n.y);if(!B(s)&&a>=0||e.getPointsGlobalCoordinates(s,i).length>=3&&!o.selectedLinearElement?.isEditing&&!B(s))return null;let d=(e.POINT_HANDLE_SIZE+1)/o.zoom.value,c=t.segmentMidPointHoveredCoords;if(c&&Gn(G(c[0],c[1]),G(n.x,n.y))<=d)return c;let u=0,p=e.getEditorMidPoints(s,i,o);for(;u<p.length;){if(p[u]!==null&&Gn(p[u],G(n.x,n.y))<=d)return p[u];u++}return null};static isSegmentTooShort(t,n,o,i,r){if(B(t))return i>=0&&i<t.points.length?Gn(n,o)*r.value<e.POINT_HANDLE_SIZE/2:!1;let s=Gn(n,o);if(t.points.length>2&&t.roundness){let[a,l]=il(t);vt(a.length===0&&l.length>0,"Only linears built out of curves are supported"),vt(a.length+l.length>=i,"Invalid segment index while calculating mid point"),s=sm(l[i])}return s*r.value<e.POINT_HANDLE_SIZE*4}static getSegmentMidPoint(t,n){if(B(t)){vt(t.points.length>=n,"Invalid segment index while calculating elbow arrow mid point");let r=el(t.points[n-1],t.points[n]);return G(t.x+r[0],t.y+r[1])}let[o,i]=il(t);if(vt(o.length===0&&i.length>0||o.length>0&&i.length===0,"Only linears built out of either segments or curves are supported"),vt(o.length+i.length>=n,"Invalid segment index while calculating mid point"),o.length){let r=o[n-1];return el(r[0],r[1])}if(i.length){let r=i[n-1];return am(r,.5)}vt(!1,"Invalid segment type while calculating mid point")}static getSegmentMidPointIndex(t,n,o,i){let r=e.getElement(t.elementId,i);if(!r)return-1;let s=e.getEditorMidPoints(r,i,n),a=0;for(;a<s.length;){if(e.arePointsEqual(o,s[a]))return a+1;a++}return-1}static handlePointerDown(t,n,o,i,r,s){let a=n.state,l=s.getNonDeletedElementsMap(),d=s.getNonDeletedElements(),c={didAddPoint:!1,hitElement:null,linearElementEditor:null};if(!r)return c;let{elementId:u}=r,p=e.getElement(u,l);if(!p)return c;let m=e.getSegmentMidpointHitCoords(r,i,a,l),f=null;if(m)f=e.getSegmentMidPointIndex(r,a,m,l);else if(t.altKey&&a.selectedLinearElement?.isEditing)return r.lastUncommittedPoint==null&&(s.mutateElement(p,{points:[...p.points,e.createPointAt(p,l,i.x,i.y,t[Bn.CTRL_OR_CMD]?null:n.getEffectiveGridSize())]}),c.didAddPoint=!0),o.scheduleCapture(),c.linearElementEditor={...r,pointerDownState:{prevSelectedPointsIndices:r.selectedPointsIndices,lastClickedPoint:-1,lastClickedIsEndPoint:!1,origin:{x:i.x,y:i.y},segmentMidpoint:{value:m,index:f,added:!1}},selectedPointsIndices:[p.points.length-1],lastUncommittedPoint:null,endBindingElement:Vt(i,d,l,n.state.zoom,r.elbowed)},c.didAddPoint=!0,c;let E=e.getPointIndexUnderCursor(p,l,a.zoom,i.x,i.y);if(E>=0||m)c.hitElement=p;else{let{startBindingElement:D,endBindingElement:T}=r;Ar(a)&&er(p)&&Dr(p,D,T,s)}let[h,g,x,y]=Y(p,l),b=(h+x)/2,w=(g+y)/2,I=E>-1&&Te(G(p.x+p.points[E][0],p.y+p.points[E][1]),G(b,w),p.angle),M=E>-1||t.shiftKey?t.shiftKey||r.selectedPointsIndices?.includes(E)?um([...r.selectedPointsIndices||[],E]):[E]:null;return c.linearElementEditor={...r,pointerDownState:{prevSelectedPointsIndices:r.selectedPointsIndices,lastClickedPoint:E,lastClickedIsEndPoint:E===p.points.length-1,origin:{x:i.x,y:i.y},segmentMidpoint:{value:m,index:f,added:!1}},selectedPointsIndices:M,pointerOffset:I?{x:i.x-I[0],y:i.y-I[1]}:{x:0,y:0}},c}static arePointsEqual(t,n){return!t&&!n?!0:!t||!n?!1:tl(t,n)}static handlePointerMove(t,n,o,i){let r=i.state;if(!r.selectedLinearElement?.isEditing)return null;let{elementId:s,lastUncommittedPoint:a}=r.selectedLinearElement,l=i.scene.getNonDeletedElementsMap(),d=e.getElement(s,l);if(!d)return r.selectedLinearElement;let{points:c}=d,u=c[c.length-1];if(!t.altKey)return u===a&&e.deletePoints(d,i,[c.length-1]),r.selectedLinearElement?.lastUncommittedPoint?{...r.selectedLinearElement,lastUncommittedPoint:null}:r.selectedLinearElement;let p;if(nl(t)&&c.length>=2){let m=c[c.length-2],[f,E]=e._getShiftLockedDelta(d,l,m,G(n,o),t[Bn.CTRL_OR_CMD]?null:i.getEffectiveGridSize());p=G(f+m[0],E+m[1])}else p=e.createPointAt(d,l,n-r.selectedLinearElement.pointerOffset.x,o-r.selectedLinearElement.pointerOffset.y,t[Bn.CTRL_OR_CMD]||B(d)?null:i.getEffectiveGridSize());return u===a?e.movePoints(d,i.scene,new Map([[d.points.length-1,{point:p}]])):e.addPoints(d,i.scene,[p]),{...r.selectedLinearElement,lastUncommittedPoint:d.points[d.points.length-1]}}static getPointGlobalCoordinates(t,n,o){let[i,r,s,a]=Y(t,o),l=(i+s)/2,d=(r+a)/2,{x:c,y:u}=t;return Te(G(c+n[0],u+n[1]),G(l,d),t.angle)}static getPointsGlobalCoordinates(t,n){let[o,i,r,s]=Y(t,n),a=(o+r)/2,l=(i+s)/2;return t.points.map(d=>{let{x:c,y:u}=t;return Te(G(c+d[0],u+d[1]),G(a,l),t.angle)})}static getPointAtIndexGlobalCoordinates(t,n,o){let i=n<0?t.points.length+n:n,[r,s,a,l]=Y(t,o),d=(r+a)/2,c=(s+l)/2,u=t.points[i],{x:p,y:m}=t;return u?Te(G(p+u[0],m+u[1]),G(d,c),t.angle):Te(G(p,m),G(d,c),t.angle)}static pointFromAbsoluteCoords(t,n,o){if(B(t))return G(n[0]-t.x,n[1]-t.y);let[i,r,s,a]=Y(t,o),l=(i+s)/2,d=(r+a)/2,[c,u]=Te(G(n[0],n[1]),G(l,d),-t.angle);return G(c-t.x,u-t.y)}static getPointIndexUnderCursor(t,n,o,i,r){let s=e.getPointsGlobalCoordinates(t,n),a=s.length;for(;--a>-1;){let l=s[a];if(Gn(G(i,r),G(l[0],l[1]))*o.value<e.POINT_HANDLE_SIZE+1)return a}return-1}static createPointAt(t,n,o,i,r){let s=ol(o,i,r),[a,l,d,c]=Y(t,n),u=(a+d)/2,p=(l+c)/2,[m,f]=Te(G(s[0],s[1]),G(u,p),-t.angle);return G(m-t.x,f-t.y)}static getNormalizeElementPointsAndCoords(t){let{points:n,offsetX:o,offsetY:i}=Cr(t);return{points:n,x:t.x+o,y:t.y+i}}static duplicateSelectedPoints(t,n){vt(t.selectedLinearElement?.isEditing,"Not currently editing a linear element");let o=n.getNonDeletedElementsMap(),{selectedPointsIndices:i,elementId:r}=t.selectedLinearElement,s=e.getElement(r,o);vt(s,"The linear element does not exist in the provided Scene"),vt(i!=null,"There are no selected points to duplicate");let{points:a}=s,l=[],d=!1,c=-1,u=a.reduce((p,m,f)=>{if(++c,p.push(m),i.includes(f)){let h=a[f+1];h||(d=!0),p.push(h?G((m[0]+h[0])/2,(m[1]+h[1])/2):G(m[0],m[1])),l.push(c+1),++c}return p},[]);if(n.mutateElement(s,{points:u}),d){let p=s.points[s.points.length-1];e.movePoints(s,n,new Map([[s.points.length-1,{point:G(p[0]+30,p[1]+30)}]]))}return{...t,selectedLinearElement:{...t.selectedLinearElement,selectedPointsIndices:l}}}static deletePoints(t,n,o){let i=n.state.selectedLinearElement?.isEditing&&n.state.selectedLinearElement?.lastUncommittedPoint===t.points[t.points.length-1],r=t.points.filter((c,u)=>!o.includes(u));bt(t)&&t.polygon&&(i||o.includes(0)||o.includes(t.points.length-1))&&(r[0]=G(r[r.length-1][0],r[r.length-1][1]));let{points:a,offsetX:l,offsetY:d}=Cr({points:r});e._updatePoints(t,n.scene,a,l,d)}static addPoints(t,n,o){let i=[...t.points,...o];bt(t)&&t.polygon&&(i[0]=G(i[i.length-1][0],i[i.length-1][1]));let{points:r,offsetX:s,offsetY:a}=Cr({points:i});e._updatePoints(t,n,r,s,a)}static movePoints(t,n,o,i){let{points:r}=t;if(bt(t)&&t.polygon){let c=o.get(0),u=o.get(r.length-1);c?o.set(r.length-1,{point:G(c.point[0],c.point[1]),isDragging:c.isDragging}):u&&o.set(0,{point:G(u.point[0],u.point[1]),isDragging:u.isDragging})}let s=o.get(0)?.point??G(0,0),[a,l]=s,d=B(t)?[o.get(0)?.point??r[0],o.get(r.length-1)?.point??r[r.length-1]]:r.map((c,u)=>{let p=o.get(u)?.point??c;return G(p[0]-a,p[1]-l)});e._updatePoints(t,n,d,a,l,i,{isDragging:Array.from(o.values()).some(c=>c.isDragging)})}static shouldAddMidpoint(t,n,o,i){let r=e.getElement(t.elementId,i);if(r&&B(r)||!r)return!1;let{segmentMidpoint:s}=t.pointerDownState;if(s.added||s.value===null||s.index===null||t.pointerDownState.origin===null)return!1;let a=t.pointerDownState.origin,l=Gn(G(a.x,a.y),G(n.x,n.y));return!(!o.selectedLinearElement?.isEditing&&l<lm/o.zoom.value)}static addMidpoint(t,n,o,i,r){let s=r.getNonDeletedElementsMap(),a=e.getElement(t.elementId,s);if(!a)return;let{segmentMidpoint:l}=t.pointerDownState,d={pointerDownState:t.pointerDownState,selectedPointsIndices:t.selectedPointsIndices},c=e.createPointAt(a,s,n.x,n.y,i&&!B(a)?o.getEffectiveGridSize():null),u=[...a.points.slice(0,l.index),c,...a.points.slice(l.index)];return r.mutateElement(a,{points:u}),d.pointerDownState={...t.pointerDownState,segmentMidpoint:{...t.pointerDownState.segmentMidpoint,added:!0},lastClickedPoint:l.index},d.selectedPointsIndices=[l.index],d}static _updatePoints(t,n,o,i,r,s,a){if(B(t)){let l={};s?.startBinding!==void 0&&(l.startBinding=s.startBinding!==null&&Jn(s.startBinding)?s.startBinding:null),s?.endBinding!==void 0&&(l.endBinding=s.endBinding!==null&&Jn(s.endBinding)?s.endBinding:null),l.points=Array.from(o),n.mutateElement(t,l,{informMutation:!0,isDragging:a?.isDragging??!1})}else{let l=Gr(t,o),d=Gr(t,t.points),c=(l[0]+l[2])/2,u=(l[1]+l[3])/2,p=(d[0]+d[2])/2,m=(d[1]+d[3])/2,f=p-c,E=m-u,h=Te(G(i,r),G(f,E),t.angle);n.mutateElement(t,{...s,points:o,x:t.x+h[0],y:t.y+h[1]})}}static _getShiftLockedDelta(t,n,o,i,r,s){let a=e.getPointGlobalCoordinates(t,o,n);if(B(t))return[i[0]-a[0],i[1]-a[1]];let[l,d]=ol(i[0],i[1],r),{width:c,height:u}=sl(a[0],a[1],l,d,s);return Te(G(c,u),G(0,0),-t.angle)}static getBoundTextElementPosition=(t,n,o)=>{e.getPointsGlobalCoordinates(t,o).length<2&&be(n,o,{isDeleted:!0});let r=0,s=0;if(t.points.length%2===1){let a=Math.floor(t.points.length/2),l=e.getPointGlobalCoordinates(t,t.points[a],o);r=l[0]-n.width/2,s=l[1]-n.height/2}else{let a=t.points.length/2-1,l=e.getSegmentMidPoint(t,a+1);r=l[0]-n.width/2,s=l[1]-n.height/2}return{x:r,y:s}};static getMinMaxXYWithBoundText=(t,n,o,i)=>{let[r,s,a,l]=o,d=(r+a)/2,c=(s+l)/2,{x:u,y:p}=e.getBoundTextElementPosition(t,i,n),m=u+i.width,f=p+i.height,E=G(d,c),h=Te(G(r,s),E,t.angle),g=Te(G(a,s),E,t.angle),x=Te(G(u,p),E,-t.angle),y=Te(G(m,p),E,-t.angle),b=Te(G(u,f),E,-t.angle),w=Te(G(m,f),E,-t.angle);return h[0]<g[0]&&h[1]>=g[1]?(r=Math.min(r,b[0]),a=Math.max(a,Math.max(y[0],w[0])),s=Math.min(s,x[1]),l=Math.max(l,w[1])):h[0]>=g[0]&&h[1]>g[1]?(r=Math.min(r,w[0]),a=Math.max(a,Math.max(x[0],y[0])),s=Math.min(s,b[1]),l=Math.max(l,y[1])):h[0]>=g[0]?(r=Math.min(r,y[0]),a=Math.max(a,b[0]),s=Math.min(s,w[1]),l=Math.max(l,x[1])):h[1]<=g[1]&&(r=Math.min(r,Math.min(y[0],x[0])),a=Math.max(a,w[0]),s=Math.min(s,y[1]),l=Math.max(l,b[1])),[r,s,a,l,d,c]};static getElementAbsoluteCoords=(t,n,o=!1)=>{let i,r,s,a,l;if(t.points.length<2||!Pe.get(t)){let{minX:p,minY:m,maxX:f,maxY:E}=t.points.reduce((h,[g,x])=>(h.minY=Math.min(h.minY,x),h.minX=Math.min(h.minX,g),h.maxX=Math.max(h.maxX,g),h.maxY=Math.max(h.maxY,x),h),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});r=p+t.x,s=m+t.y,a=f+t.x,l=E+t.y}else{let p=Pe.generateElementShape(t,null),m=gt(p[0]),[f,E,h,g]=ao(m);r=f+t.x,s=E+t.y,a=h+t.x,l=g+t.y}let d=(r+a)/2,c=(s+l)/2;if(i=[r,s,a,l,d,c],!o)return i;let u=W(t,n);return u&&(i=e.getMinMaxXYWithBoundText(t,n,[r,s,a,l],u)),i};static moveFixedSegment(t,n,o,i,r){let s=r.getNonDeletedElementsMap(),a=e.getElement(t.elementId,s);if(!a||!B(a))return t;if(n&&n>0&&n<a.points.length){let l=Oe(Tt(rm(a.points[n],a.points[n-1]))),d=(a.fixedSegments??[]).reduce((m,f)=>(m[f.index]=f,m),{});d[n]={index:n,start:G(l?a.points[n-1][0]:o-a.x,l?i-a.y:a.points[n-1][1]),end:G(l?a.points[n][0]:o-a.x,l?i-a.y:a.points[n][1])};let c=Object.values(d).sort((m,f)=>m.index-f.index),u=c.map(m=>m.index).reduce((m,f)=>f<n?m+1:m,0);r.mutateElement(a,{fixedSegments:c});let p=G(a.x+(a.fixedSegments[u].start[0]+a.fixedSegments[u].end[0])/2,a.y+(a.fixedSegments[u].start[1]+a.fixedSegments[u].end[1])/2);return{...t,segmentMidPointHoveredCoords:p,pointerDownState:{...t.pointerDownState,segmentMidpoint:{added:!1,index:a.fixedSegments[u].index,value:p}}}}return t}static deleteFixedSegment(t,n,o){n.mutateElement(t,{fixedSegments:t.fixedSegments?.filter(i=>i.index!==o)})}},um=e=>{let t=[...new Set(e.filter(n=>n!==null&&n!==-1))];return t=t.sort((n,o)=>n-o),t.length?t:null};P();import{arrayToMap as mt}from"@excalidraw/common";import{isPointWithinBounds as Bm,pointFrom as Fr}from"@excalidraw/math";P();import{vectorCross as cl,vectorFromPoint as di}from"@excalidraw/math";function al(e){return[Math.min(e[0][0],e[1][0]),Math.min(e[0][1],e[1][1]),Math.max(e[0][0],e[1][0]),Math.max(e[0][1],e[1][1])]}function pm(e,t){return e[0]<=t[2]&&e[2]>=t[0]&&e[1]<=t[3]&&e[3]>=t[1]}var mm=1e-6;function ll(e,t){let n=di(e[1],e[0]),o=di(t,e[0]),i=cl(n,o);return Math.abs(i)<mm}function Br(e,t){let n=di(e[1],e[0]),o=di(t,e[0]);return cl(n,o)<0}function dl(e,t){return ll(e,t[0])||ll(e,t[1])||(Br(e,t[0])?!Br(e,t[1]):Br(e,t[1]))}function ul(e,t){return pm(al(e),al(t))&&dl(e,t)&&dl(t,e)}P();import{arrayToMap as fm}from"@excalidraw/common";import{getElementBounds as hm}from"@excalidraw/element";import{isArrowElement as Em,isExcalidrawElement as gm,isFreeDrawElement as xm,isLinearElement as wm,isTextElement as ym}from"@excalidraw/element";import{rangeIncludesValue as ci,pointFrom as Lt,pointRotateRads as bm,rangeInclusive as ui}from"@excalidraw/math";var Pm=e=>e.type==="diamond"?[Lt(e.width/2,0),Lt(e.width,e.height/2),Lt(e.width/2,e.height),Lt(0,e.height/2)]:[Lt(0,0),Lt(0+e.width,0),Lt(0+e.width,e.height),Lt(0,e.height)],Im=e=>wm(e)||xm(e)?e.points:Pm(e),pl=e=>{let t=e.reduce((n,[o,i])=>(n.minY=Math.min(n.minY,i),n.minX=Math.min(n.minX,o),n.maxX=Math.max(n.maxX,o),n.maxY=Math.max(n.maxY,i),n),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},fl=e=>{let t=Im(e),{cx:n,cy:o}=pl(t),i=Lt(n,o),r=t.map(c=>bm(c,i,e.angle)),{minX:s,minY:a,maxX:l,maxY:d}=pl(r);return[s+e.x,a+e.y,l+e.x,d+e.y]},ml=(e,t,n=!1)=>{let o=fl(e),i=t[0]<=o[0]&&t[2]>=o[2]&&t[1]<=o[1]&&t[3]>=o[3];return n?i?!0:o[0]<=t[0]&&o[2]>=t[2]&&o[1]<=t[1]&&o[3]>=t[3]:i},Sm=(e,t)=>{let n=fl(e);return(ci(n[0],ui(t[0],t[2]))||ci(t[0],ui(n[0],n[2])))&&(ci(n[1],ui(t[1],t[3]))||ci(t[1],ui(n[1],n[3])))},hl=({elements:e,bounds:t,type:n,errorMargin:o=0})=>{gm(t)&&(t=hm(t,fm(e)));let i=[t[0]-o,t[1]-o,t[2]+o,t[3]+o],r=new Set;for(let s of e){if(r.has(s.id))continue;if(n==="overlap"?Sm(s,i):n==="inside"?ml(s,i):ml(s,i,!0)){if(r.add(s.id),s.boundElements)for(let l of s.boundElements)r.add(l.id);ym(s)&&s.containerId&&r.add(s.containerId),Em(s)&&(s.startBinding&&r.add(s.startBinding.elementId),s.endBinding&&r.add(s.endBinding?.elementId))}}return e.filter(s=>r.has(s.id))};P();import{arrayToMap as Lm,isShallowEqual as Cm}from"@excalidraw/common";P();var Mm=(e,t,n)=>{let o=n.reduce((i,r)=>(r.groupIds.includes(e)&&(i[r.id]=!0),i),{});return Object.keys(o).length<2?t.selectedGroupIds[e]||t.editingGroupId===e?{selectedElementIds:t.selectedElementIds,selectedGroupIds:{...t.selectedGroupIds,[e]:!1},editingGroupId:null}:t:{editingGroupId:t.editingGroupId,selectedGroupIds:{...t.selectedGroupIds,[e]:!0},selectedElementIds:{...t.selectedElementIds,...o}}},El=function(){let e=null,t=null,n=null,o=(r,s,a,l)=>{if(n!==void 0&&s===t&&r===e&&a.editingGroupId===n?.editingGroupId)return n;let d={};for(let p of r){let m=p.groupIds;if(a.editingGroupId){let f=m.indexOf(a.editingGroupId);f>-1&&(m=m.slice(0,f))}if(m.length>0){let f=m[m.length-1];d[f]=!0}}let c={},u=s.reduce((p,m)=>{if(m.isDeleted)return p;let f=m.groupIds.find(E=>d[E]);return f&&(p[m.id]=!0,Array.isArray(c[f])?c[f].push(m.id):c[f]=[m.id]),p},{});for(let p of Object.keys(c))c[p].length<2&&d[p]&&(d[p]=!1);return t=s,e=r,n={editingGroupId:a.editingGroupId,selectedGroupIds:d,selectedElementIds:kr({...a.selectedElementIds,...u},l)},n},i=(r,s,a,l)=>{let d=l?l.scene.getSelectedElements({selectedElementIds:r.selectedElementIds,elements:s}):pt(s,r);return d.length?o(d,s,r,a):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:kr(r.selectedElementIds,a)}};return i.clearCache=()=>{t=null,e=null,n=null},i}(),Tm=(e,t)=>Or(e,t)!=null,Or=(e,t)=>t.groupIds.filter(n=>n!==e.editingGroupId).find(n=>e.selectedGroupIds[n]),Am=e=>Object.entries(e.selectedGroupIds).filter(([t,n])=>n).map(([t,n])=>t),gl=(e,t)=>{let n={...t,selectedGroupIds:{}};for(let o of e){let i=o.groupIds;if(t.editingGroupId){let r=i.indexOf(t.editingGroupId);r>-1&&(i=i.slice(0,r))}if(i.length>0){let r=i[i.length-1];n={...n,...Mm(r,n,e)}}}return n.selectedGroupIds},qy=(e,t)=>({...e,editingGroupId:t.groupIds.length?t.groupIds[0]:null,selectedGroupIds:{},selectedElementIds:{[t.id]:!0}}),Dm=(e,t)=>e.groupIds.includes(t),Ae=(e,t)=>{let n=[];for(let o of e.values())Dm(o,t)&&n.push(o);return n},vm=(e,t)=>e.groupIds.find(n=>t[n]),Ky=(e,t,n)=>{let o=[...e],i=n?o.indexOf(n):-1,r=i>-1?i:o.length;return o.splice(r,0,t),o},Qy=(e,t)=>e.filter(n=>!t[n]),Jy=(e,t)=>{let n=new Map;return e.forEach(o=>{let i=o.groupIds.length===0?o.id:o.groupIds[o.groupIds.length-1],r=n.get(i)||[],s=W(o,t);s&&r.push(s),n.set(i,[...r,o])}),Array.from(n.values())},xl=e=>{let t=new Set;for(let[,n]of e)if(!n.isDeleted)for(let o of n.groupIds??[])t.add(o);return t},wl=e=>{let t=e.flatMap(i=>i.groupIds),n=new Map,o=0;for(let i of t)n.set(i,(n.get(i)??0)+1),n.get(i)>o&&(o=n.get(i));return o===e.length},yl=e=>e.groupIds.length>0,bl=(e,t,n)=>{let o=[...e],i=t?e.indexOf(t):-1,r=i>-1?i:e.length;for(let s=0;s<r;s++)o[s]=n(o[s]);return o},pi=(e,t,n)=>{let o=Am(n),i=e.filter(u=>!ce(u)),r=new Map,s=new Map,a=u=>{let p=s.get(u.id)||[],m=W(u,t);m&&p.push(m),s.set(u.id,[...p,u])},l=(u,p)=>{let m=r.get(p)||[],f=W(u,t);f&&m.push(f),r.set(p,[...m,u])},d=(u,p)=>{let m=u.groupIds.indexOf(p,0);return u.groupIds.slice(0,m).length>0?l(u,u.groupIds[m-1]):a(u)},c=e.every(u=>Tm(n,u));return i.forEach(u=>{let p=vm(u,n.selectedGroupIds);p?o.length===1&&c?d(u,p):l(u,p):a(u)}),Array.from(r.values()).concat(Array.from(s.values()))};var Pl=e=>{let t=new Set;return e.forEach(n=>{q(n)&&t.add(n.id)}),e.filter(n=>!(n.frameId&&t.has(n.frameId)))},Rr=(e,t,n,o=!0)=>{let[i,r,s,a]=Y(t,n),l=e.filter(d=>{let[c,u,p,m]=pe(d,n),f=Ct(d,n);if(f){let[E,h,g,x]=pe(f,n);c=Math.max(E,c),u=Math.max(h,u),p=Math.min(g,p),m=Math.min(x,m)}return d.locked===!1&&d.type!=="selection"&&!ce(d)&&i<=c&&r<=u&&s>=p&&a>=m});return l=o?Pl(l):l,l=l.filter(d=>{let c=Ct(d,n);return c?qt(d,c,n):!0}),l},db=(e,t,n,o)=>{let i=new Set(t.map(r=>r.id));return e.filter(r=>{let s=Il(r,n.width,n.height,n,o);return!i.has(r.id)&&s})},cb=function(){let e=null,t=null,n=null,o=(i,r)=>(n!=null&&i===e&&r.selectedElementIds===t||(n=i.some(s=>r.selectedElementIds[s.id]),e=i,t=r.selectedElementIds),n);return o.clearCache=()=>{e=null,t=null,n=null},o}(),pt=(e,t,n)=>{let o=new Set,i=[];for(let r of e.values()){if(t.selectedElementIds[r.id]){i.push(r),o.add(r.id);continue}if(n?.includeBoundTextElement&&ce(r)&&t.selectedElementIds[r?.containerId]){i.push(r),o.add(r.id);continue}}if(n?.includeElementsInFrames){let r=[];return i.forEach(s=>{q(s)&&Kt(e,s.id).forEach(a=>!o.has(a.id)&&r.push(a)),r.push(s)}),r}return i},ub=(e,t)=>t.editingTextElement?[t.editingTextElement]:t.newElement?[t.newElement]:pt(e,t,{includeBoundTextElement:!0}),kr=(e,t)=>Cm(t.selectedElementIds,e)?t.selectedElementIds:e,Gm=(e,t)=>{let n=e.filter(j);if(n.length===1){let o=n[0],i=o.boundElements?.map(s=>s.id)??[];if(e.every(s=>s.id===o.id||i.includes(s.id)))return new U(o,Lm(t))}return null},pb=(e,t,n)=>({selectedLinearElement:Gm(e,t),...El({editingGroupId:n.editingGroupId,selectedElementIds:Pl(e).reduce((o,i)=>(ce(i)||(o[i.id]=!0),o),{})},t,n,null)});var Sl=(e,t,n)=>{let o=mt(e);for(let i of t)if(i.frameId){let r=n.get(i.id),s=n.get(i.frameId),a=r&&o.get(r);a&&be(a,o,{frameId:s??null})}};function kn(e,t,n){let o=Nr(t,n),i=Nr(e,n);return o.some(s=>i.some(a=>ul(s,a)))}var Ml=(e,t,n)=>mi(Rr(e,t,n,!1)).filter(o=>!q(o)&&!o.frameId||o.frameId===t.id),Hr=(e,t,n)=>Rr([t],e,n).some(o=>o.id===t.id),Mb=(e,t)=>{let n=mt(e);return e.filter(o=>kn(o,t,n))},Qt=(e,t,n)=>{let[o,i,r,s]=Y(t,n),[a,l,d,c]=Xe(e);return o<=a&&i<=l&&r>=d&&s>=c},qt=(e,t,n)=>Qt([e],t,n)||kn(e,t,n)||Hr(e,t,n),Tb=(e,t,n)=>{let[o,i,r,s]=Y(t,n);return Bm(Fr(o,i),Fr(e.x,e.y),Fr(r,s))},Ab=(e,t,n)=>{let o=mt(e),i=t.flatMap(r=>Ae(e,r));return i.length===0?!0:!!i.find(r=>Qt([r],n,o)||kn(r,n,o))},Db=(e,t,n)=>{let o=mt(e),i=t.flatMap(r=>Ae(e,r));return i.length===0?!0:i.find(r=>Qt([r],n,o)||kn(r,n,o))===void 0},vb=e=>{let t=new Map;for(let n of e){let o=q(n)?n.id:n.frameId;o&&!t.has(o)&&t.set(o,Kt(e,o))}return t},Kt=(e,t)=>{let n=[];for(let o of e.values())o.frameId===t&&n.push(o);return n},km=e=>e.filter(t=>q(t)),Lb=e=>{let t=mt(km(e));return e.filter(n=>t.has(n.id)||!n.frameId||!t.has(n.frameId))},Cb=(e,t,n,o)=>{let i=Kt(e,t.id),r=new Set(i),s=new Set([...Ml(e,t,o),...i.filter(p=>Hr(p,t,o))]),a=i.filter(p=>!s.has(p)),l=new Set(Array.from(s).flatMap(p=>p.groupIds));for(let p of a)if(!kn(p,t,o))p.groupIds.length===0&&r.delete(p);else if(p.groupIds.length>0)for(let m of p.groupIds)l.add(m);for(let p of a)if(p.groupIds.length>0){let m=!0;for(let f of p.groupIds)l.has(f)&&(m=!1);m&&r.delete(p)}let d=Array.from(s).filter(p=>p.groupIds.length===0);for(let p of d)r.add(p);let c=Array.from(s).filter(p=>p.groupIds.length>0),u=gl(c,n);for(let[p,m]of Object.entries(u))if(m){let f=Ae(e,p);if(Qt(f,t,o))for(let E of f)r.add(E)}return[...r].filter(p=>!(oe(p)&&p.containerId))},Gb=(e,t,n)=>Om(mi(e,Ml(e,t,n)),t,n),Om=(e,t,n)=>{let o=[],i=new Map;for(let r of e){let s=!1;if(r.groupIds.length>0){if(r.groupIds.some(a=>i.get(a)))s=!0;else{let a=new Set(r.groupIds.flatMap(l=>Ae(n,l)));s=!Qt(Array.from(a),t,n)}r.groupIds.forEach(a=>{i.set(a,s)})}s||o.push(r)}return o},Ct=(e,t)=>e.frameId&&t.get(e.frameId)||null,Bb=(e,t)=>{let n=new Set,o=mt(e);e=mi(e);for(let s of e)q(s)&&s.id!==t.id&&n.add(s.id);let i=new Set,r=[];for(let s of e)if(!(q(s)||s.frameId&&n.has(s.frameId)))if(s.groupIds.length){let a=s.groupIds.at(-1);if(!i.has(a)){i.add(a);let l=Ae(e,a);if(l.some(d=>qt(d,t,o)))for(let d of l)r.push(d)}}else qt(s,t,o)&&r.push(s);return r},Rm=(e,t,n,o)=>{let i=mt(e),r=new Map;for(let d of e.values())d.frameId===n.id&&r.set(d.id,!0);let s=new Set(t.map(d=>d.id)),a=[],l=new Set;for(let d of t)q(d)&&d.id!==n.id&&l.add(d.id);for(let d of mi(e,t)){if(q(d)||d.frameId&&l.has(d.frameId)||d.frameId&&o.selectedElementIds[d.id]&&o.selectedElementIds[d.frameId])continue;r.has(d.id)||a.push(d);let c=W(d,i);c&&!s.has(c.id)&&!r.has(c.id)&&a.push(c)}for(let d of a)be(d,i,{frameId:n.id});return e},Tl=(e,t)=>{let n=new Map,o=new Map;for(let i of e)if(i.frameId){n.set(i.id,i);let r=o.get(i.frameId)||[];r.push(i);let s=W(i,t);s&&(n.set(s.id,s),r.push(s)),o.set(i.frameId,r)}for(let[,i]of n)be(i,t,{frameId:null})},Fm=(e,t)=>{let n=Kt(e,t.id);return Tl(n,mt(e)),e},kb=(e,t,n,o)=>Rm(Fm(e,n),t,n,o.state).slice(),Ob=(e,t,n)=>{let o=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,elements:e}),i=new Set(o);if(t.editingGroupId)for(let a of o)a.groupIds.length===0?i.add(a):a.groupIds.flatMap(l=>Ae(e,l)).forEach(l=>i.add(l));let r=new Set,s=mt(e);return i.forEach(a=>{a.frameId&&!q(a)&&!Al(a,s,t)&&r.add(a)}),r.size>0&&Tl(r,s),e},mi=(e,t)=>{let n=new Set,o=t||e;for(let s of o.values()){let a=s.groupIds[s.groupIds.length-1];a&&n.add(a)}let i=new Set;for(let s of n)Ae(e,s).some(a=>q(a))&&i.add(s);let r=[];for(let s of o.values())i.has(s.groupIds[s.groupIds.length-1])||r.push(s);return r},Nm=(e,t,n)=>{let o=oe(e)&&Ce(e,t)||e;return o.frameId&&n.selectedElementIds[o.id]&&n.selectedElementIds[o.frameId]?Ct(o,t):n.selectedElementIds[o.id]&&n.selectedElementsAreBeingDragged?n.frameToHighlight:Ct(o,t)},Al=(e,t,n,o)=>{let i=o?.targetFrame??Nm(e,t,n);if(!i)return!1;let r=oe(e)&&Ce(e,t)||e,s=l=>{o?.checkedGroups&&r.groupIds.forEach(d=>{o.checkedGroups?.set(d,l)})};if(!n.selectedElementIds[r.id]||!n.selectedElementsAreBeingDragged||n.selectedElementIds[r.id]&&n.selectedElementIds[i.id])return!0;if(r.groupIds.length===0)return qt(r,i,t);for(let l of r.groupIds)if(o?.checkedGroups?.has(l))return o.checkedGroups.get(l);let a=new Set(r.groupIds.filter(l=>o?.checkedGroups?!o.checkedGroups.has(l):!0).flatMap(l=>Ae(t,l)));if(n.editingGroupId&&n.selectedElementsAreBeingDragged){let l=new Set(pt(t,n));if(n.frameToHighlight!==null)return!0;l.forEach(c=>{a.delete(c)})}for(let l of a)if(q(l))return s(!1),!1;for(let l of a)if(qt(l,i,t))return s(!0),!0;return!1},Rb=(e,t,n,o,i)=>{if(!n.frameRendering||!n.frameRendering.clip)return!1;let r=kn(e,t,o)||Hr(e,t,o);if(r){for(let s of e.groupIds)i?.set(s,!0);return!0}if(!r&&e.groupIds.length>0&&!Qt([e],t,o)){let s=!1;if(n.selectedElementsAreBeingDragged)s=Al(e,o,n,{targetFrame:t,checkedGroups:i});else{s=e.frameId===t.id;for(let a of e.groupIds)i?.set(a,s)}for(let a of e.groupIds)i?.set(a,s);return s}return!1},Hm="Frame",zm="AI Frame",_m=e=>Fo(e)?Hm:zm,Fb=e=>e.name===null?_m(e):e.name,Nb=(e,t)=>hl({elements:e,bounds:t,type:"overlap"}).filter(n=>!n.frameId||n.frameId===t.id),Hb=e=>{let t=mt(e);return e.length>1&&e.some(n=>n.frameId&&t.has(n.frameId))};var Zm="invert(100%) hue-rotate(180deg) saturate(1.25)",Gl=(e,t)=>_t(e)&&!t.imageCache.has(e.fileId),Bl=(e,t,n)=>n.theme===Cl.DARK&&_t(e)&&!Gl(e,t)&&t.imageCache.get(e.fileId)?.mimeType!==Yr.svg,wi=e=>{switch(e.type){case"freedraw":return e.strokeWidth*12;case"text":return e.fontSize/2;case"arrow":return e.endArrowhead||e.endArrowhead?40:20;default:return 20}},qm=(e,t,n,o,i=1)=>{let r=(t?.opacity??100)*e.opacity/1e4*i;return(n.has(e.id)||o&&o.some(s=>s.id===e.id)||t&&n.has(t.id))&&(r*=Xm/100),r},Km=(e,t,n)=>{let r=wi(e),[s,a,l,d]=Y(e,t),c=j(e)||Me(e)?Jt(s,l):e.width,u=j(e)||Me(e)?Jt(a,d):e.height,p=c*window.devicePixelRatio+r*2,m=u*window.devicePixelRatio+r*2,f=n.value;return(p*f>32767||m*f>32767)&&(f=Math.min(32767/p,32767/m)),p*m*f*f>16777216&&(f=Math.sqrt(16777216/(p*m))),p=Math.floor(p*f),m=Math.floor(m*f),{width:p,height:m,scale:f}},kl=(e,t,n,o,i)=>{let r=document.createElement("canvas"),s=r.getContext("2d"),a=wi(e),{width:l,height:d,scale:c}=Km(e,t,n);if(!l||!d)return null;r.width=l,r.height=d;let u=-100,p=0;if(j(e)||Me(e)){let[g,x]=Y(e,t);u=e.x>g?Jt(e.x,g)*window.devicePixelRatio*c:0,p=e.y>x?Jt(e.y,x)*window.devicePixelRatio*c:0,s.translate(u,p)}s.save(),s.translate(a*c,a*c),s.scale(window.devicePixelRatio*c,window.devicePixelRatio*c);let m=pn.canvas(r);Bl(e,o,i)&&(s.filter=Zm),gi(e,m,s,o,i),s.restore();let f=W(e,t),E=document.createElement("canvas"),h=E.getContext("2d");if(_(e)&&f){let[g,x,y,b]=Y(e,t),w=Math.max(Jt(g,y),Jt(x,b));E.width=w*window.devicePixelRatio*c+a*c*10,E.height=w*window.devicePixelRatio*c+a*c*10,h.translate(E.width/2,E.height/2),h.rotate(e.angle),h.drawImage(r,-r.width/2,-r.height/2,r.width,r.height);let[,,,,I,M]=Y(f,t);h.rotate(-e.angle);let D=(E.width-r.width)/2,T=(E.height-r.height)/2,N=E.width/2-(I-g)*window.devicePixelRatio*c-D-a*c,C=E.height/2-(M-x)*window.devicePixelRatio*c-T-a*c;h.translate(-N,-C),h.clearRect(-(f.width/2+hi)*window.devicePixelRatio*c,-(f.height/2+hi)*window.devicePixelRatio*c,(f.width+hi*2)*window.devicePixelRatio*c,(f.height+hi*2)*window.devicePixelRatio*c)}return{element:e,canvas:r,theme:i.theme,scale:c,zoomValue:n.value,canvasOffsetX:u,canvasOffsetY:p,boundTextElementVersion:W(e,t)?.version||null,containingFrameOpacity:Ct(e,t)?.opacity||100,boundTextCanvas:E,angle:e.angle,imageCrop:we(e)?e.crop:null}},t0=14,Ol=typeof document<"u"?document.createElement("img"):{src:""};Ol.src=`data:${Yr.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;var Rl=typeof document<"u"?document.createElement("img"):{src:""};Rl.src=`data:${Yr.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;var Qm=(e,t)=>{t.fillStyle="#E7E7E7",t.fillRect(0,0,e.width,e.height);let n=Math.min(e.width,e.height),o=Math.min(n,Math.min(n*.4,100));t.drawImage(e.status==="error"?Rl:Ol,e.width/2-o/2,e.height/2-o/2,o,o)},gi=(e,t,n,o,i)=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":{n.lineJoin="round",n.lineCap="round",t.draw(Pe.get(e));break}case"arrow":case"line":{n.lineJoin="round",n.lineCap="round",Pe.get(e).forEach(r=>{t.draw(r)});break}case"freedraw":{n.save(),n.fillStyle=e.strokeColor;let r=Jm(e),s=Pe.get(e);s&&t.draw(s),n.fillStyle=e.strokeColor,n.fill(r),n.restore();break}case"image":{let r=_t(e)?o.imageCache.get(e.fileId)?.image:void 0;if(r!=null&&!(r instanceof Promise)){e.roundness&&n.roundRect&&(n.beginPath(),n.roundRect(0,0,e.width,e.height,yt(Math.min(e.width,e.height),e)),n.clip());let{x:s,y:a,width:l,height:d}=e.crop?e.crop:{x:0,y:0,width:r.naturalWidth,height:r.naturalHeight};n.drawImage(r,s,a,l,d,0,0,e.width,e.height)}else Qm(e,n);break}default:if(oe(e)){let r=Wm(e.text),s=r&&!n.canvas.isConnected;s&&document.body.appendChild(n.canvas),n.canvas.setAttribute("dir",r?"rtl":"ltr"),n.save(),n.font=jm(e),n.fillStyle=e.strokeColor,n.textAlign=e.textAlign;let a=e.text.replace(/\r\n?/g,`
|
|
10
10
|
`).split(`
|
|
11
|
-
`),l=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,d=_o(e.fontSize,e.lineHeight),c=Vm(e.fontFamily,e.fontSize,d);for(let u=0;u<a.length;u++)n.fillText(a[u],l,u*d+c);n.restore(),s&&n.canvas.remove()}else throw new Error(`Unimplemented type ${e.type}`)}},xi=new WeakMap,vl=(e,t,n,o)=>{let i=n?o.zoom:{value:1},r=xi.get(e),s=r&&r.zoomValue!==i.value&&!o?.shouldCacheIgnoreZoom,a=W(e,t),l=a?.version||null,d=we(e)?e.crop:null,c=Ct(e,t)?.opacity||100;if(!r||s||r.theme!==o.theme||r.boundTextElementVersion!==l||r.imageCrop!==d||r.containingFrameOpacity!==c||_(e)&&a&&e.angle!==r.angle){let u=kl(e,t,i,n,o);return u?(xi.set(e,u),u):null}return r},_r=(e,t,n,o,i)=>{let r=e.element,s=wi(r),a=e.scale,[l,d,c,u]=Y(r,i),p=((l+c)/2+o.scrollX)*window.devicePixelRatio,m=((d+u)/2+o.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);let f=W(r,i);if(_(r)&&f){let E=(e.boundTextCanvas.width-e.canvas.width)/2,h=(e.boundTextCanvas.height-e.canvas.height)/2;t.translate(p,m),t.drawImage(e.boundTextCanvas,-(c-l)/2*window.devicePixelRatio-E/a-s,-(u-d)/2*window.devicePixelRatio-h/a-s,e.boundTextCanvas.width/a,e.boundTextCanvas.height/a)}else if(t.translate(p,m),t.rotate(r.angle),"scale"in e.element&&!Gl(r,n)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-p,-m),t.drawImage(e.canvas,(l+o.scrollX)*window.devicePixelRatio-s*e.scale/e.scale,(d+o.scrollY)*window.devicePixelRatio-s*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),A.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX==="true"&&st(r)){let E=W(r,i),h=dr(r);t.strokeStyle="#c92a2a",t.lineWidth=3,t.strokeRect((h.x+o.scrollX)*window.devicePixelRatio,(h.y+o.scrollY)*window.devicePixelRatio,et(r,E)*window.devicePixelRatio,no(r,E)*window.devicePixelRatio)}t.restore()},n0=(e,t,n,o)=>{t.save(),t.translate(e.x+n.scrollX,e.y+n.scrollY),t.fillStyle="rgba(0, 0, 200, 0.04)";let i=.5/n.zoom.value;t.fillRect(i,i,e.width,e.height),t.lineWidth=1/n.zoom.value,t.strokeStyle=o,t.strokeRect(i,i,e.width,e.height),t.restore()},o0=(e,t,n,o,i,r,s)=>{let a=s.openDialog?.name==="elementLinkSelector"&&!s.selectedElementIds[e.id]&&!s.hoveredElementIds[e.id];switch(i.globalAlpha=qm(e,Ct(e,t),r.elementsPendingErasure,r.pendingFlowchartNodes,a?Um:1),e.type){case"magicframe":case"frame":{s.frameRendering.enabled&&s.frameRendering.outline&&(i.save(),i.translate(e.x+s.scrollX,e.y+s.scrollY),i.fillStyle="rgba(0, 0, 200, 0.04)",i.lineWidth=Ei.strokeWidth/s.zoom.value,i.strokeStyle=Ei.strokeColor,aa(e)&&(i.strokeStyle=s.theme===Cl.LIGHT?"#7affd7":"#1d8264"),Ei.radius&&i.roundRect?(i.beginPath(),i.roundRect(0,0,e.width,e.height,Ei.radius/s.zoom.value),i.stroke(),i.closePath()):i.strokeRect(0,0,e.width,e.height),i.restore());break}case"freedraw":{if(Pe.generateElementShape(e,null),r.isExporting){let[l,d,c,u]=Y(e,t),p=(l+c)/2+s.scrollX,m=(d+u)/2+s.scrollY,f=(c-l)/2-(e.x-l),E=(u-d)/2-(e.y-d);i.save(),i.translate(p,m),i.rotate(e.angle),i.translate(-f,-E),gi(e,o,i,r,s),i.restore()}else{let l=vl(e,n,r,s);if(!l)return;_r(l,i,r,s,n)}break}case"rectangle":case"diamond":case"ellipse":case"line":case"arrow":case"image":case"text":case"iframe":case"embeddable":{if(Pe.generateElementShape(e,r),r.isExporting){let[l,d,c,u]=Y(e,t),p=(l+c)/2+s.scrollX,m=(d+u)/2+s.scrollY,f=(c-l)/2-(e.x-l),E=(u-d)/2-(e.y-d);if(oe(e)){let g=Ce(e,t);if(_(g)){let x=U.getBoundTextElementPosition(g,e,t);f=(c-l)/2-(x.x-l),E=(u-d)/2-(x.y-d)}}i.save(),i.translate(p,m),Bl(e,r,s)&&(i.filter="none");let h=W(e,t);if(_(e)&&h){let g=document.createElement("canvas"),x=g.getContext("2d"),y=Math.max(Jt(l,c),Jt(d,u)),b=wi(e);g.width=y*s.exportScale+b*10*s.exportScale,g.height=y*s.exportScale+b*10*s.exportScale,x.translate(g.width/2,g.height/2),x.scale(s.exportScale,s.exportScale),f=e.width/2-(e.x-l),E=e.height/2-(e.y-d),x.rotate(e.angle);let w=pn.canvas(g);x.translate(-f,-E),gi(e,w,x,r,s),x.translate(f,E),x.rotate(-e.angle);let[,,,,I,M]=Y(h,t),D=(l+c)/2-I,T=(d+u)/2-M;x.translate(-D,-T),x.clearRect(-h.width/2,-h.height/2,h.width,h.height),i.scale(1/s.exportScale,1/s.exportScale),i.drawImage(g,-g.width/2,-g.height/2,g.width,g.height)}else i.rotate(e.angle),e.type==="image"&&i.scale(e.scale[0],e.scale[1]),i.translate(-f,-E),gi(e,o,i,r,s);i.restore()}else{let l=vl(e,n,r,s);if(!l)return;let d=i.imageSmoothingEnabled;if(!s?.shouldCacheIgnoreZoom&&(!e.angle||Ym(e.angle))&&(i.imageSmoothingEnabled=!1),e.id===s.croppingElementId&&we(l.element)&&l.element.crop!==null){i.save(),i.globalAlpha=.1;let c=kl(ta(l.element,t),n,s.zoom,r,s);c&&_r(c,i,r,s,n),i.restore()}_r(l,i,r,s,n),i.imageSmoothingEnabled=d}break}default:throw new Error(`Unimplemented type ${e.type}`)}i.globalAlpha=1},Fl=new WeakMap([]);function Nl(e){let t=ef(e),n=new Path2D(t);return Fl.set(e,n),n}function Jm(e){return Fl.get(e)}function ef(e){return of(tf(e))}function i0(e,t,n){let o=pe({...e,angle:0},n),i=fi((o[0]+o[2])/2,(o[1]+o[3])/2);return $m(t.length>=2,"Freepath outline must have at least 2 points"),t.slice(2).reduce((r,s)=>(r.push(Dl(r[r.length-1][1],zr(fi(s[0]+e.x,s[1]+e.y),i,e.angle))),r),[Dl(zr(fi(t[0][0]+e.x,t[0][1]+e.y),i,e.angle),zr(fi(t[1][0]+e.x,t[1][1]+e.y),i,e.angle))])}function tf(e){let t=e.simulatePressure?e.points:e.points.length?e.points.map(([o,i],r)=>[o,i,e.pressures[r]]):[[0,0,.5]],n={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:o=>Math.sin(o*Math.PI/2),last:!!e.lastCommittedPoint};return qs(t,n)}function Ll(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}var nf=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function of(e){if(!e.length)return"";let t=e.length-1;return e.reduce((n,o,i,r)=>(i===t?n.push(o,Ll(o,r[0]),"L",r[0],"Z"):n.push(o,Ll(o,r[i+1])),n),["M",e[0],"Q"]).join(" ").replace(nf,"$1")}P();var a0=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="line"||e==="freedraw",l0=e=>e!=="image"&&e!=="frame"&&e!=="magicframe",d0=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line",c0=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="arrow"||e==="line",Hl=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image",u0=e=>e==="arrow",p0=e=>e==="arrow";var Pe=class e{static rg=new je;static cache=new WeakMap;static get=t=>e.cache.get(t);static set=(t,n)=>e.cache.set(t,n);static delete=t=>e.cache.delete(t);static destroy=()=>{e.cache=new WeakMap};static generateElementShape=(t,n)=>{let o=n?.isExporting?void 0:e.get(t);if(o!==void 0)return o;xi.delete(t);let i=uf(t,e.rg,n||{isExporting:!1,canvasBackgroundColor:af.white,embedsValidationStatus:null});return e.cache.set(t,i),i}},df=e=>[8,8+e],Ul=e=>[1.5,6+e];function cf(e){let t=e.roughness,n=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&n>=50||o>=15&&e.roundness&&Hl(e.type)||j(e)&&n>=50?t:Math.min(t/(n<10?3:2),2.5)}var Fe=(e,t=!1)=>{let n={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?df(e.strokeWidth):e.strokeStyle==="dotted"?Ul(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:cf(e),stroke:e.strokeColor,preserveVertices:t||e.roughness<rf.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return n.fillStyle=e.fillStyle,n.fill=lo(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(n.curveFitting=1),n;case"line":case"freedraw":return mn(e.points)&&(n.fillStyle=e.fillStyle,n.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),n;case"arrow":return n;default:throw new Error(`Unimplemented type ${e.type}`)}},_l=(e,t,n)=>Ro(e)&&(t||sa(e)&&n?.get(e.id)!==!0)&&lo(e.backgroundColor)&&lo(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Oo(e)?{...e,strokeColor:lo(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:lo(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Yl=(e,t,n,o,i,r,s)=>{let a=Ur(e,t,n,o);if(a===null)return[];let l=(d,c)=>{if(d===null)return[];let[,,u,p,m,f]=d;return[i.line(u,p,m,f,c)]};switch(o){case"dot":case"circle":case"circle_outline":{let[d,c,u]=a;return delete r.strokeLineDash,[i.circle(d,c,u,{...r,fill:o==="circle_outline"?s:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,r.roughness||0)})]}case"triangle":case"triangle_outline":{let[d,c,u,p,m,f]=a;return delete r.strokeLineDash,[i.polygon([[d,c],[u,p],[m,f],[d,c]],{...r,fill:o==="triangle_outline"?s:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,r.roughness||0)})]}case"diamond":case"diamond_outline":{let[d,c,u,p,m,f,E,h]=a;return delete r.strokeLineDash,[i.polygon([[d,c],[u,p],[m,f],[E,h],[d,c]],{...r,fill:o==="diamond_outline"?s:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,r.roughness||0)})]}case"crowfoot_one":return l(a,r);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[d,c,u,p,m,f]=a;if(e.strokeStyle==="dotted"){let E=Ul(e.strokeWidth-1);r.strokeLineDash=[E[0],E[1]-1]}else delete r.strokeLineDash;return r.roughness=Math.min(1,r.roughness||0),[i.line(u,p,d,c,r),i.line(m,f,d,c,r),...o==="crowfoot_one_or_many"?l(Ur(e,t,n,"crowfoot_one"),r):[]]}}},ia=e=>{let t=new je,n={seed:e.seed,disableMultiStroke:!0,disableMultiStrokeFill:!0,roughness:0,preserveVertices:!0},o=dt(e.points.reduce((i,r)=>[Math.min(e.x+r[0],i[0]),Math.min(e.y+r[1],i[1]),Math.max(e.x+r[0],i[2]),Math.max(e.y+r[1],i[3])],[1/0,1/0,-1/0,-1/0]));switch(e.type){case"line":case"arrow":{let i=e.points.length?e.points:[de(0,0)];return B(e)?t.path(Xl(i,16),n).sets[0].ops:e.roundness?t.curve(i,n).sets[0].ops.slice(0,e.points.length).map((r,s)=>{if(s===0){let a=Gt(de(e.x+r.data[0],e.y+r.data[1]),o,e.angle);return{op:"move",data:de(a[0]-e.x,a[1]-e.y)}}return{op:"bcurveTo",data:[Gt(de(e.x+r.data[0],e.y+r.data[1]),o,e.angle),Gt(de(e.x+r.data[2],e.y+r.data[3]),o,e.angle),Gt(de(e.x+r.data[4],e.y+r.data[5]),o,e.angle)].map(a=>de(a[0]-e.x,a[1]-e.y)).flat()}}):i.map((r,s)=>{let a=Gt(de(e.x+r[0],e.y+r[1]),o,e.angle);return{op:s===0?"move":"lineTo",data:de(a[0]-e.x,a[1]-e.y)}})}case"freedraw":{if(e.points.length<2)return[];let i=Wn(e.points,.75);return t.curve(i,n).sets[0].ops.slice(0,e.points.length).map((r,s)=>{if(s===0){let a=Gt(de(e.x+r.data[0],e.y+r.data[1]),o,e.angle);return{op:"move",data:de(a[0]-e.x,a[1]-e.y)}}return{op:"bcurveTo",data:[Gt(de(e.x+r.data[0],e.y+r.data[1]),o,e.angle),Gt(de(e.x+r.data[2],e.y+r.data[3]),o,e.angle),Gt(de(e.x+r.data[4],e.y+r.data[5]),o,e.angle)].map(a=>de(a[0]-e.x,a[1]-e.y)).flat()}})}}},uf=(e,t,{isExporting:n,canvasBackgroundColor:o,embedsValidationStatus:i})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let r;if(e.roundness){let s=e.width,a=e.height,l=yt(Math.min(s,a),e);r=t.path(`M ${l} 0 L ${s-l} 0 Q ${s} 0, ${s} ${l} L ${s} ${a-l} Q ${s} ${a}, ${s-l} ${a} L ${l} ${a} Q 0 ${a}, 0 ${a-l} L 0 ${l} Q 0 0, ${l} 0`,Fe(_l(e,n,i),!0))}else r=t.rectangle(0,0,e.width,e.height,Fe(_l(e,n,i),!1));return r}case"diamond":{let r,[s,a,l,d,c,u,p,m]=ko(e);if(e.roundness){let f=yt(Math.abs(s-p),e),E=yt(Math.abs(d-a),e);r=t.path(`M ${s+f} ${a+E} L ${l-f} ${d-E}
|
|
11
|
+
`),l=e.textAlign==="center"?e.width/2:e.textAlign==="right"?e.width:0,d=_o(e.fontSize,e.lineHeight),c=Vm(e.fontFamily,e.fontSize,d);for(let u=0;u<a.length;u++)n.fillText(a[u],l,u*d+c);n.restore(),s&&n.canvas.remove()}else throw new Error(`Unimplemented type ${e.type}`)}},xi=new WeakMap,vl=(e,t,n,o)=>{let i=n?o.zoom:{value:1},r=xi.get(e),s=r&&r.zoomValue!==i.value&&!o?.shouldCacheIgnoreZoom,a=W(e,t),l=a?.version||null,d=we(e)?e.crop:null,c=Ct(e,t)?.opacity||100;if(!r||s||r.theme!==o.theme||r.boundTextElementVersion!==l||r.imageCrop!==d||r.containingFrameOpacity!==c||_(e)&&a&&e.angle!==r.angle){let u=kl(e,t,i,n,o);return u?(xi.set(e,u),u):null}return r},_r=(e,t,n,o,i)=>{let r=e.element,s=wi(r),a=e.scale,[l,d,c,u]=Y(r,i),p=((l+c)/2+o.scrollX)*window.devicePixelRatio,m=((d+u)/2+o.scrollY)*window.devicePixelRatio;t.save(),t.scale(1/window.devicePixelRatio,1/window.devicePixelRatio);let f=W(r,i);if(_(r)&&f){let E=(e.boundTextCanvas.width-e.canvas.width)/2,h=(e.boundTextCanvas.height-e.canvas.height)/2;t.translate(p,m),t.drawImage(e.boundTextCanvas,-(c-l)/2*window.devicePixelRatio-E/a-s,-(u-d)/2*window.devicePixelRatio-h/a-s,e.boundTextCanvas.width/a,e.boundTextCanvas.height/a)}else if(t.translate(p,m),t.rotate(r.angle),"scale"in e.element&&!Gl(r,n)&&t.scale(e.element.scale[0],e.element.scale[1]),t.translate(-p,-m),t.drawImage(e.canvas,(l+o.scrollX)*window.devicePixelRatio-s*e.scale/e.scale,(d+o.scrollY)*window.devicePixelRatio-s*e.scale/e.scale,e.canvas.width/e.scale,e.canvas.height/e.scale),A.VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX==="true"&&st(r)){let E=W(r,i),h=dr(r);t.strokeStyle="#c92a2a",t.lineWidth=3,t.strokeRect((h.x+o.scrollX)*window.devicePixelRatio,(h.y+o.scrollY)*window.devicePixelRatio,et(r,E)*window.devicePixelRatio,no(r,E)*window.devicePixelRatio)}t.restore()},n0=(e,t,n,o)=>{t.save(),t.translate(e.x+n.scrollX,e.y+n.scrollY),t.fillStyle="rgba(0, 0, 200, 0.04)";let i=.5/n.zoom.value;t.fillRect(i,i,e.width,e.height),t.lineWidth=1/n.zoom.value,t.strokeStyle=o,t.strokeRect(i,i,e.width,e.height),t.restore()},o0=(e,t,n,o,i,r,s)=>{let a=s.openDialog?.name==="elementLinkSelector"&&!s.selectedElementIds[e.id]&&!s.hoveredElementIds[e.id];switch(i.globalAlpha=qm(e,Ct(e,t),r.elementsPendingErasure,r.pendingFlowchartNodes,a?Um:1),e.type){case"magicframe":case"frame":{s.frameRendering.enabled&&s.frameRendering.outline&&(i.save(),i.translate(e.x+s.scrollX,e.y+s.scrollY),i.fillStyle="rgba(0, 0, 200, 0.04)",i.lineWidth=Ei.strokeWidth/s.zoom.value,i.strokeStyle=Ei.strokeColor,aa(e)&&(i.strokeStyle=s.theme===Cl.LIGHT?"#7affd7":"#1d8264"),Ei.radius&&i.roundRect?(i.beginPath(),i.roundRect(0,0,e.width,e.height,Ei.radius/s.zoom.value),i.stroke(),i.closePath()):i.strokeRect(0,0,e.width,e.height),i.restore());break}case"freedraw":{if(Pe.generateElementShape(e,null),r.isExporting){let[l,d,c,u]=Y(e,t),p=(l+c)/2+s.scrollX,m=(d+u)/2+s.scrollY,f=(c-l)/2-(e.x-l),E=(u-d)/2-(e.y-d);i.save(),i.translate(p,m),i.rotate(e.angle),i.translate(-f,-E),gi(e,o,i,r,s),i.restore()}else{let l=vl(e,n,r,s);if(!l)return;_r(l,i,r,s,n)}break}case"rectangle":case"diamond":case"ellipse":case"line":case"arrow":case"image":case"text":case"iframe":case"embeddable":{if(Pe.generateElementShape(e,r),r.isExporting){let[l,d,c,u]=Y(e,t),p=(l+c)/2+s.scrollX,m=(d+u)/2+s.scrollY,f=(c-l)/2-(e.x-l),E=(u-d)/2-(e.y-d);if(oe(e)){let g=Ce(e,t);if(_(g)){let x=U.getBoundTextElementPosition(g,e,t);f=(c-l)/2-(x.x-l),E=(u-d)/2-(x.y-d)}}i.save(),i.translate(p,m),Bl(e,r,s)&&(i.filter="none");let h=W(e,t);if(_(e)&&h){let g=document.createElement("canvas"),x=g.getContext("2d"),y=Math.max(Jt(l,c),Jt(d,u)),b=wi(e);g.width=y*s.exportScale+b*10*s.exportScale,g.height=y*s.exportScale+b*10*s.exportScale,x.translate(g.width/2,g.height/2),x.scale(s.exportScale,s.exportScale),f=e.width/2-(e.x-l),E=e.height/2-(e.y-d),x.rotate(e.angle);let w=pn.canvas(g);x.translate(-f,-E),gi(e,w,x,r,s),x.translate(f,E),x.rotate(-e.angle);let[,,,,I,M]=Y(h,t),D=(l+c)/2-I,T=(d+u)/2-M;x.translate(-D,-T),x.clearRect(-h.width/2,-h.height/2,h.width,h.height),i.scale(1/s.exportScale,1/s.exportScale),i.drawImage(g,-g.width/2,-g.height/2,g.width,g.height)}else i.rotate(e.angle),e.type==="image"&&i.scale(e.scale[0],e.scale[1]),i.translate(-f,-E),gi(e,o,i,r,s);i.restore()}else{let l=vl(e,n,r,s);if(!l)return;let d=i.imageSmoothingEnabled;if(!s?.shouldCacheIgnoreZoom&&(!e.angle||Ym(e.angle))&&(i.imageSmoothingEnabled=!1),e.id===s.croppingElementId&&we(l.element)&&l.element.crop!==null){i.save(),i.globalAlpha=.1;let c=kl(ta(l.element,t),n,s.zoom,r,s);c&&_r(c,i,r,s,n),i.restore()}_r(l,i,r,s,n),i.imageSmoothingEnabled=d}break}default:throw new Error(`Unimplemented type ${e.type}`)}i.globalAlpha=1},Fl=new WeakMap([]);function Nl(e){let t=ef(e),n=new Path2D(t);return Fl.set(e,n),n}function Jm(e){return Fl.get(e)}function ef(e){return of(tf(e))}function i0(e,t,n){let o=pe({...e,angle:0},n),i=fi((o[0]+o[2])/2,(o[1]+o[3])/2);return $m(t.length>=2,"Freepath outline must have at least 2 points"),t.slice(2).reduce((r,s)=>(r.push(Dl(r[r.length-1][1],zr(fi(s[0]+e.x,s[1]+e.y),i,e.angle))),r),[Dl(zr(fi(t[0][0]+e.x,t[0][1]+e.y),i,e.angle),zr(fi(t[1][0]+e.x,t[1][1]+e.y),i,e.angle))])}function tf(e){let t=e.simulatePressure?e.points:e.points.length?e.points.map(([o,i],r)=>[o,i,e.pressures[r]]):[[0,0,.5]],n={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:o=>Math.sin(o*Math.PI/2),last:!!e.lastCommittedPoint};return qs(t,n)}function Ll(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}var nf=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function of(e){if(!e.length)return"";let t=e.length-1;return e.reduce((n,o,i,r)=>(i===t?n.push(o,Ll(o,r[0]),"L",r[0],"Z"):n.push(o,Ll(o,r[i+1])),n),["M",e[0],"Q"]).join(" ").replace(nf,"$1")}P();var a0=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="line"||e==="freedraw",l0=e=>e==="rectangle"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line"||e==="text",d0=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="freedraw"||e==="arrow"||e==="line",c0=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="ellipse"||e==="diamond"||e==="arrow"||e==="line",Hl=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image",u0=e=>e==="arrow",p0=e=>e==="arrow";var Pe=class e{static rg=new je;static cache=new WeakMap;static get=t=>e.cache.get(t);static set=(t,n)=>e.cache.set(t,n);static delete=t=>e.cache.delete(t);static destroy=()=>{e.cache=new WeakMap};static generateElementShape=(t,n)=>{let o=n?.isExporting?void 0:e.get(t);if(o!==void 0)return o;xi.delete(t);let i=uf(t,e.rg,n||{isExporting:!1,canvasBackgroundColor:af.white,embedsValidationStatus:null});return e.cache.set(t,i),i}},df=e=>[8,8+e],Ul=e=>[1.5,6+e];function cf(e){let t=e.roughness,n=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&n>=50||o>=15&&e.roundness&&Hl(e.type)||j(e)&&n>=50?t:Math.min(t/(n<10?3:2),2.5)}var Fe=(e,t=!1)=>{let n={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?df(e.strokeWidth):e.strokeStyle==="dotted"?Ul(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:cf(e),stroke:e.strokeColor,preserveVertices:t||e.roughness<rf.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return n.fillStyle=e.fillStyle,n.fill=lo(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(n.curveFitting=1),n;case"line":case"freedraw":return mn(e.points)&&(n.fillStyle=e.fillStyle,n.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),n;case"arrow":return n;default:throw new Error(`Unimplemented type ${e.type}`)}},_l=(e,t,n)=>Ro(e)&&(t||sa(e)&&n?.get(e.id)!==!0)&&lo(e.backgroundColor)&&lo(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Oo(e)?{...e,strokeColor:lo(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:lo(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Yl=(e,t,n,o,i,r,s)=>{let a=Ur(e,t,n,o);if(a===null)return[];let l=(d,c)=>{if(d===null)return[];let[,,u,p,m,f]=d;return[i.line(u,p,m,f,c)]};switch(o){case"dot":case"circle":case"circle_outline":{let[d,c,u]=a;return delete r.strokeLineDash,[i.circle(d,c,u,{...r,fill:o==="circle_outline"?s:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,r.roughness||0)})]}case"triangle":case"triangle_outline":{let[d,c,u,p,m,f]=a;return delete r.strokeLineDash,[i.polygon([[d,c],[u,p],[m,f],[d,c]],{...r,fill:o==="triangle_outline"?s:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,r.roughness||0)})]}case"diamond":case"diamond_outline":{let[d,c,u,p,m,f,E,h]=a;return delete r.strokeLineDash,[i.polygon([[d,c],[u,p],[m,f],[E,h],[d,c]],{...r,fill:o==="diamond_outline"?s:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,r.roughness||0)})]}case"crowfoot_one":return l(a,r);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[d,c,u,p,m,f]=a;if(e.strokeStyle==="dotted"){let E=Ul(e.strokeWidth-1);r.strokeLineDash=[E[0],E[1]-1]}else delete r.strokeLineDash;return r.roughness=Math.min(1,r.roughness||0),[i.line(u,p,d,c,r),i.line(m,f,d,c,r),...o==="crowfoot_one_or_many"?l(Ur(e,t,n,"crowfoot_one"),r):[]]}}},ia=e=>{let t=new je,n={seed:e.seed,disableMultiStroke:!0,disableMultiStrokeFill:!0,roughness:0,preserveVertices:!0},o=dt(e.points.reduce((i,r)=>[Math.min(e.x+r[0],i[0]),Math.min(e.y+r[1],i[1]),Math.max(e.x+r[0],i[2]),Math.max(e.y+r[1],i[3])],[1/0,1/0,-1/0,-1/0]));switch(e.type){case"line":case"arrow":{let i=e.points.length?e.points:[de(0,0)];return B(e)?t.path(Xl(i,16),n).sets[0].ops:e.roundness?t.curve(i,n).sets[0].ops.slice(0,e.points.length).map((r,s)=>{if(s===0){let a=Gt(de(e.x+r.data[0],e.y+r.data[1]),o,e.angle);return{op:"move",data:de(a[0]-e.x,a[1]-e.y)}}return{op:"bcurveTo",data:[Gt(de(e.x+r.data[0],e.y+r.data[1]),o,e.angle),Gt(de(e.x+r.data[2],e.y+r.data[3]),o,e.angle),Gt(de(e.x+r.data[4],e.y+r.data[5]),o,e.angle)].map(a=>de(a[0]-e.x,a[1]-e.y)).flat()}}):i.map((r,s)=>{let a=Gt(de(e.x+r[0],e.y+r[1]),o,e.angle);return{op:s===0?"move":"lineTo",data:de(a[0]-e.x,a[1]-e.y)}})}case"freedraw":{if(e.points.length<2)return[];let i=Wn(e.points,.75);return t.curve(i,n).sets[0].ops.slice(0,e.points.length).map((r,s)=>{if(s===0){let a=Gt(de(e.x+r.data[0],e.y+r.data[1]),o,e.angle);return{op:"move",data:de(a[0]-e.x,a[1]-e.y)}}return{op:"bcurveTo",data:[Gt(de(e.x+r.data[0],e.y+r.data[1]),o,e.angle),Gt(de(e.x+r.data[2],e.y+r.data[3]),o,e.angle),Gt(de(e.x+r.data[4],e.y+r.data[5]),o,e.angle)].map(a=>de(a[0]-e.x,a[1]-e.y)).flat()}})}}},uf=(e,t,{isExporting:n,canvasBackgroundColor:o,embedsValidationStatus:i})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let r;if(e.roundness){let s=e.width,a=e.height,l=yt(Math.min(s,a),e);r=t.path(`M ${l} 0 L ${s-l} 0 Q ${s} 0, ${s} ${l} L ${s} ${a-l} Q ${s} ${a}, ${s-l} ${a} L ${l} ${a} Q 0 ${a}, 0 ${a-l} L 0 ${l} Q 0 0, ${l} 0`,Fe(_l(e,n,i),!0))}else r=t.rectangle(0,0,e.width,e.height,Fe(_l(e,n,i),!1));return r}case"diamond":{let r,[s,a,l,d,c,u,p,m]=ko(e);if(e.roundness){let f=yt(Math.abs(s-p),e),E=yt(Math.abs(d-a),e);r=t.path(`M ${s+f} ${a+E} L ${l-f} ${d-E}
|
|
12
12
|
C ${l} ${d}, ${l} ${d}, ${l-f} ${d+E}
|
|
13
13
|
L ${c+f} ${u-E}
|
|
14
14
|
C ${c} ${u}, ${c} ${u}, ${c-f} ${u-E}
|
|
@@ -358,3 +358,6 @@ export declare enum UserIdleState {
|
|
|
358
358
|
*/
|
|
359
359
|
export declare const LINE_POLYGON_POINT_MERGE_DISTANCE = 20;
|
|
360
360
|
export declare const DOUBLE_TAP_POSITION_THRESHOLD = 35;
|
|
361
|
+
export declare const MOBILE_ACTION_BUTTON_BG: {
|
|
362
|
+
readonly background: "var(--mobile-action-button-bg)";
|
|
363
|
+
};
|
|
@@ -44,6 +44,10 @@ export declare const actionAddToLibrary: {
|
|
|
44
44
|
locked: boolean;
|
|
45
45
|
fromSelection: boolean;
|
|
46
46
|
} & import("../types").ActiveTool;
|
|
47
|
+
preferredSelectionTool: {
|
|
48
|
+
type: "selection" | "lasso";
|
|
49
|
+
initialized: boolean;
|
|
50
|
+
};
|
|
47
51
|
penMode: boolean;
|
|
48
52
|
penDetected: boolean;
|
|
49
53
|
exportBackground: boolean;
|
|
@@ -173,7 +177,7 @@ export declare const actionAddToLibrary: {
|
|
|
173
177
|
lockedMultiSelections: {
|
|
174
178
|
[groupId: string]: true;
|
|
175
179
|
};
|
|
176
|
-
stylesPanelMode: "compact" | "full";
|
|
180
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
177
181
|
};
|
|
178
182
|
} | {
|
|
179
183
|
captureUpdate: "EVENTUALLY";
|
|
@@ -212,6 +216,10 @@ export declare const actionAddToLibrary: {
|
|
|
212
216
|
locked: boolean;
|
|
213
217
|
fromSelection: boolean;
|
|
214
218
|
} & import("../types").ActiveTool;
|
|
219
|
+
preferredSelectionTool: {
|
|
220
|
+
type: "selection" | "lasso";
|
|
221
|
+
initialized: boolean;
|
|
222
|
+
};
|
|
215
223
|
penMode: boolean;
|
|
216
224
|
penDetected: boolean;
|
|
217
225
|
exportBackground: boolean;
|
|
@@ -346,7 +354,7 @@ export declare const actionAddToLibrary: {
|
|
|
346
354
|
lockedMultiSelections: {
|
|
347
355
|
[groupId: string]: true;
|
|
348
356
|
};
|
|
349
|
-
stylesPanelMode: "compact" | "full";
|
|
357
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
350
358
|
};
|
|
351
359
|
}> | {
|
|
352
360
|
captureUpdate: "EVENTUALLY";
|
|
@@ -385,6 +393,10 @@ export declare const actionAddToLibrary: {
|
|
|
385
393
|
locked: boolean;
|
|
386
394
|
fromSelection: boolean;
|
|
387
395
|
} & import("../types").ActiveTool;
|
|
396
|
+
preferredSelectionTool: {
|
|
397
|
+
type: "selection" | "lasso";
|
|
398
|
+
initialized: boolean;
|
|
399
|
+
};
|
|
388
400
|
penMode: boolean;
|
|
389
401
|
penDetected: boolean;
|
|
390
402
|
exportBackground: boolean;
|
|
@@ -519,7 +531,7 @@ export declare const actionAddToLibrary: {
|
|
|
519
531
|
lockedMultiSelections: {
|
|
520
532
|
[groupId: string]: true;
|
|
521
533
|
};
|
|
522
|
-
stylesPanelMode: "compact" | "full";
|
|
534
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
523
535
|
};
|
|
524
536
|
};
|
|
525
537
|
label: string;
|
|
@@ -64,6 +64,10 @@ export declare const actionBindText: {
|
|
|
64
64
|
locked: boolean;
|
|
65
65
|
fromSelection: boolean;
|
|
66
66
|
} & import("../types").ActiveTool;
|
|
67
|
+
preferredSelectionTool: {
|
|
68
|
+
type: "selection" | "lasso";
|
|
69
|
+
initialized: boolean;
|
|
70
|
+
};
|
|
67
71
|
penMode: boolean;
|
|
68
72
|
penDetected: boolean;
|
|
69
73
|
exportBackground: boolean;
|
|
@@ -195,7 +199,7 @@ export declare const actionBindText: {
|
|
|
195
199
|
lockedMultiSelections: {
|
|
196
200
|
[groupId: string]: true;
|
|
197
201
|
};
|
|
198
|
-
stylesPanelMode: "compact" | "full";
|
|
202
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
199
203
|
};
|
|
200
204
|
captureUpdate: "IMMEDIATELY";
|
|
201
205
|
};
|
|
@@ -249,6 +253,10 @@ export declare const actionWrapTextInContainer: {
|
|
|
249
253
|
locked: boolean;
|
|
250
254
|
fromSelection: boolean;
|
|
251
255
|
} & import("../types").ActiveTool;
|
|
256
|
+
preferredSelectionTool: {
|
|
257
|
+
type: "selection" | "lasso";
|
|
258
|
+
initialized: boolean;
|
|
259
|
+
};
|
|
252
260
|
penMode: boolean;
|
|
253
261
|
penDetected: boolean;
|
|
254
262
|
exportBackground: boolean;
|
|
@@ -380,7 +388,7 @@ export declare const actionWrapTextInContainer: {
|
|
|
380
388
|
lockedMultiSelections: {
|
|
381
389
|
[groupId: string]: true;
|
|
382
390
|
};
|
|
383
|
-
stylesPanelMode: "compact" | "full";
|
|
391
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
384
392
|
};
|
|
385
393
|
captureUpdate: "IMMEDIATELY";
|
|
386
394
|
};
|
|
@@ -137,6 +137,10 @@ export declare const actionClearCanvas: {
|
|
|
137
137
|
resizingElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
|
|
138
138
|
startBoundElement: import("@excalidraw/element/types").NonDeleted<import("@excalidraw/element/types").ExcalidrawBindableElement> | null;
|
|
139
139
|
editingFrame: string | null;
|
|
140
|
+
preferredSelectionTool: {
|
|
141
|
+
type: "selection" | "lasso";
|
|
142
|
+
initialized: boolean;
|
|
143
|
+
};
|
|
140
144
|
exportWithDarkMode: boolean;
|
|
141
145
|
exportScale: number;
|
|
142
146
|
currentItemStrokeColor: string;
|
|
@@ -191,7 +195,7 @@ export declare const actionClearCanvas: {
|
|
|
191
195
|
lockedMultiSelections: {
|
|
192
196
|
[groupId: string]: true;
|
|
193
197
|
};
|
|
194
|
-
stylesPanelMode: "compact" | "full";
|
|
198
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
195
199
|
};
|
|
196
200
|
captureUpdate: "IMMEDIATELY";
|
|
197
201
|
};
|
|
@@ -248,6 +252,10 @@ export declare const actionZoomIn: {
|
|
|
248
252
|
locked: boolean;
|
|
249
253
|
fromSelection: boolean;
|
|
250
254
|
} & import("../types").ActiveTool;
|
|
255
|
+
preferredSelectionTool: {
|
|
256
|
+
type: "selection" | "lasso";
|
|
257
|
+
initialized: boolean;
|
|
258
|
+
};
|
|
251
259
|
penMode: boolean;
|
|
252
260
|
penDetected: boolean;
|
|
253
261
|
exportBackground: boolean;
|
|
@@ -376,7 +384,7 @@ export declare const actionZoomIn: {
|
|
|
376
384
|
lockedMultiSelections: {
|
|
377
385
|
[groupId: string]: true;
|
|
378
386
|
};
|
|
379
|
-
stylesPanelMode: "compact" | "full";
|
|
387
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
380
388
|
};
|
|
381
389
|
captureUpdate: "EVENTUALLY";
|
|
382
390
|
};
|
|
@@ -435,6 +443,10 @@ export declare const actionZoomOut: {
|
|
|
435
443
|
locked: boolean;
|
|
436
444
|
fromSelection: boolean;
|
|
437
445
|
} & import("../types").ActiveTool;
|
|
446
|
+
preferredSelectionTool: {
|
|
447
|
+
type: "selection" | "lasso";
|
|
448
|
+
initialized: boolean;
|
|
449
|
+
};
|
|
438
450
|
penMode: boolean;
|
|
439
451
|
penDetected: boolean;
|
|
440
452
|
exportBackground: boolean;
|
|
@@ -563,7 +575,7 @@ export declare const actionZoomOut: {
|
|
|
563
575
|
lockedMultiSelections: {
|
|
564
576
|
[groupId: string]: true;
|
|
565
577
|
};
|
|
566
|
-
stylesPanelMode: "compact" | "full";
|
|
578
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
567
579
|
};
|
|
568
580
|
captureUpdate: "EVENTUALLY";
|
|
569
581
|
};
|
|
@@ -622,6 +634,10 @@ export declare const actionResetZoom: {
|
|
|
622
634
|
locked: boolean;
|
|
623
635
|
fromSelection: boolean;
|
|
624
636
|
} & import("../types").ActiveTool;
|
|
637
|
+
preferredSelectionTool: {
|
|
638
|
+
type: "selection" | "lasso";
|
|
639
|
+
initialized: boolean;
|
|
640
|
+
};
|
|
625
641
|
penMode: boolean;
|
|
626
642
|
penDetected: boolean;
|
|
627
643
|
exportBackground: boolean;
|
|
@@ -750,7 +766,7 @@ export declare const actionResetZoom: {
|
|
|
750
766
|
lockedMultiSelections: {
|
|
751
767
|
[groupId: string]: true;
|
|
752
768
|
};
|
|
753
|
-
stylesPanelMode: "compact" | "full";
|
|
769
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
754
770
|
};
|
|
755
771
|
captureUpdate: "EVENTUALLY";
|
|
756
772
|
};
|
|
@@ -815,6 +831,10 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fitToV
|
|
|
815
831
|
locked: boolean;
|
|
816
832
|
fromSelection: boolean;
|
|
817
833
|
} & import("../types").ActiveTool;
|
|
834
|
+
preferredSelectionTool: {
|
|
835
|
+
type: "selection" | "lasso";
|
|
836
|
+
initialized: boolean;
|
|
837
|
+
};
|
|
818
838
|
penMode: boolean;
|
|
819
839
|
penDetected: boolean;
|
|
820
840
|
exportBackground: boolean;
|
|
@@ -944,7 +964,7 @@ export declare const zoomToFitBounds: ({ bounds, appState, canvasOffsets, fitToV
|
|
|
944
964
|
lockedMultiSelections: {
|
|
945
965
|
[groupId: string]: true;
|
|
946
966
|
};
|
|
947
|
-
stylesPanelMode: "compact" | "full";
|
|
967
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
948
968
|
};
|
|
949
969
|
captureUpdate: "EVENTUALLY";
|
|
950
970
|
};
|
|
@@ -1004,6 +1024,10 @@ export declare const zoomToFit: ({ canvasOffsets, targetElements, appState, fitT
|
|
|
1004
1024
|
locked: boolean;
|
|
1005
1025
|
fromSelection: boolean;
|
|
1006
1026
|
} & import("../types").ActiveTool;
|
|
1027
|
+
preferredSelectionTool: {
|
|
1028
|
+
type: "selection" | "lasso";
|
|
1029
|
+
initialized: boolean;
|
|
1030
|
+
};
|
|
1007
1031
|
penMode: boolean;
|
|
1008
1032
|
penDetected: boolean;
|
|
1009
1033
|
exportBackground: boolean;
|
|
@@ -1133,7 +1157,7 @@ export declare const zoomToFit: ({ canvasOffsets, targetElements, appState, fitT
|
|
|
1133
1157
|
lockedMultiSelections: {
|
|
1134
1158
|
[groupId: string]: true;
|
|
1135
1159
|
};
|
|
1136
|
-
stylesPanelMode: "compact" | "full";
|
|
1160
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
1137
1161
|
};
|
|
1138
1162
|
captureUpdate: "EVENTUALLY";
|
|
1139
1163
|
};
|
|
@@ -1185,6 +1209,10 @@ export declare const actionZoomToFitSelectionInViewport: {
|
|
|
1185
1209
|
locked: boolean;
|
|
1186
1210
|
fromSelection: boolean;
|
|
1187
1211
|
} & import("../types").ActiveTool;
|
|
1212
|
+
preferredSelectionTool: {
|
|
1213
|
+
type: "selection" | "lasso";
|
|
1214
|
+
initialized: boolean;
|
|
1215
|
+
};
|
|
1188
1216
|
penMode: boolean;
|
|
1189
1217
|
penDetected: boolean;
|
|
1190
1218
|
exportBackground: boolean;
|
|
@@ -1314,7 +1342,7 @@ export declare const actionZoomToFitSelectionInViewport: {
|
|
|
1314
1342
|
lockedMultiSelections: {
|
|
1315
1343
|
[groupId: string]: true;
|
|
1316
1344
|
};
|
|
1317
|
-
stylesPanelMode: "compact" | "full";
|
|
1345
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
1318
1346
|
};
|
|
1319
1347
|
captureUpdate: "EVENTUALLY";
|
|
1320
1348
|
};
|
|
@@ -1370,6 +1398,10 @@ export declare const actionZoomToFitSelection: {
|
|
|
1370
1398
|
locked: boolean;
|
|
1371
1399
|
fromSelection: boolean;
|
|
1372
1400
|
} & import("../types").ActiveTool;
|
|
1401
|
+
preferredSelectionTool: {
|
|
1402
|
+
type: "selection" | "lasso";
|
|
1403
|
+
initialized: boolean;
|
|
1404
|
+
};
|
|
1373
1405
|
penMode: boolean;
|
|
1374
1406
|
penDetected: boolean;
|
|
1375
1407
|
exportBackground: boolean;
|
|
@@ -1499,7 +1531,7 @@ export declare const actionZoomToFitSelection: {
|
|
|
1499
1531
|
lockedMultiSelections: {
|
|
1500
1532
|
[groupId: string]: true;
|
|
1501
1533
|
};
|
|
1502
|
-
stylesPanelMode: "compact" | "full";
|
|
1534
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
1503
1535
|
};
|
|
1504
1536
|
captureUpdate: "EVENTUALLY";
|
|
1505
1537
|
};
|
|
@@ -1556,6 +1588,10 @@ export declare const actionZoomToFit: {
|
|
|
1556
1588
|
locked: boolean;
|
|
1557
1589
|
fromSelection: boolean;
|
|
1558
1590
|
} & import("../types").ActiveTool;
|
|
1591
|
+
preferredSelectionTool: {
|
|
1592
|
+
type: "selection" | "lasso";
|
|
1593
|
+
initialized: boolean;
|
|
1594
|
+
};
|
|
1559
1595
|
penMode: boolean;
|
|
1560
1596
|
penDetected: boolean;
|
|
1561
1597
|
exportBackground: boolean;
|
|
@@ -1685,7 +1721,7 @@ export declare const actionZoomToFit: {
|
|
|
1685
1721
|
lockedMultiSelections: {
|
|
1686
1722
|
[groupId: string]: true;
|
|
1687
1723
|
};
|
|
1688
|
-
stylesPanelMode: "compact" | "full";
|
|
1724
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
1689
1725
|
};
|
|
1690
1726
|
captureUpdate: "EVENTUALLY";
|
|
1691
1727
|
};
|
|
@@ -1739,6 +1775,10 @@ export declare const actionToggleTheme: {
|
|
|
1739
1775
|
locked: boolean;
|
|
1740
1776
|
fromSelection: boolean;
|
|
1741
1777
|
} & import("../types").ActiveTool;
|
|
1778
|
+
preferredSelectionTool: {
|
|
1779
|
+
type: "selection" | "lasso";
|
|
1780
|
+
initialized: boolean;
|
|
1781
|
+
};
|
|
1742
1782
|
penMode: boolean;
|
|
1743
1783
|
penDetected: boolean;
|
|
1744
1784
|
exportBackground: boolean;
|
|
@@ -1872,7 +1912,7 @@ export declare const actionToggleTheme: {
|
|
|
1872
1912
|
lockedMultiSelections: {
|
|
1873
1913
|
[groupId: string]: true;
|
|
1874
1914
|
};
|
|
1875
|
-
stylesPanelMode: "compact" | "full";
|
|
1915
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
1876
1916
|
};
|
|
1877
1917
|
captureUpdate: "EVENTUALLY";
|
|
1878
1918
|
};
|
|
@@ -1922,6 +1962,10 @@ export declare const actionToggleEraserTool: {
|
|
|
1922
1962
|
editingFrame: string | null;
|
|
1923
1963
|
elementsToHighlight: import("@excalidraw/element/types").NonDeleted<ExcalidrawElement>[] | null;
|
|
1924
1964
|
editingTextElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
|
|
1965
|
+
preferredSelectionTool: {
|
|
1966
|
+
type: "selection" | "lasso";
|
|
1967
|
+
initialized: boolean;
|
|
1968
|
+
};
|
|
1925
1969
|
penMode: boolean;
|
|
1926
1970
|
penDetected: boolean;
|
|
1927
1971
|
exportBackground: boolean;
|
|
@@ -2050,7 +2094,7 @@ export declare const actionToggleEraserTool: {
|
|
|
2050
2094
|
lockedMultiSelections: {
|
|
2051
2095
|
[groupId: string]: true;
|
|
2052
2096
|
};
|
|
2053
|
-
stylesPanelMode: "compact" | "full";
|
|
2097
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
2054
2098
|
};
|
|
2055
2099
|
captureUpdate: "IMMEDIATELY";
|
|
2056
2100
|
};
|
|
@@ -2101,6 +2145,10 @@ export declare const actionToggleLassoTool: {
|
|
|
2101
2145
|
editingFrame: string | null;
|
|
2102
2146
|
elementsToHighlight: import("@excalidraw/element/types").NonDeleted<ExcalidrawElement>[] | null;
|
|
2103
2147
|
editingTextElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
|
|
2148
|
+
preferredSelectionTool: {
|
|
2149
|
+
type: "selection" | "lasso";
|
|
2150
|
+
initialized: boolean;
|
|
2151
|
+
};
|
|
2104
2152
|
penMode: boolean;
|
|
2105
2153
|
penDetected: boolean;
|
|
2106
2154
|
exportBackground: boolean;
|
|
@@ -2229,7 +2277,7 @@ export declare const actionToggleLassoTool: {
|
|
|
2229
2277
|
lockedMultiSelections: {
|
|
2230
2278
|
[groupId: string]: true;
|
|
2231
2279
|
};
|
|
2232
|
-
stylesPanelMode: "compact" | "full";
|
|
2280
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
2233
2281
|
};
|
|
2234
2282
|
captureUpdate: "NEVER";
|
|
2235
2283
|
};
|
|
@@ -2279,6 +2327,10 @@ export declare const actionToggleHandTool: {
|
|
|
2279
2327
|
editingFrame: string | null;
|
|
2280
2328
|
elementsToHighlight: import("@excalidraw/element/types").NonDeleted<ExcalidrawElement>[] | null;
|
|
2281
2329
|
editingTextElement: import("@excalidraw/element/types").NonDeletedExcalidrawElement | null;
|
|
2330
|
+
preferredSelectionTool: {
|
|
2331
|
+
type: "selection" | "lasso";
|
|
2332
|
+
initialized: boolean;
|
|
2333
|
+
};
|
|
2282
2334
|
penMode: boolean;
|
|
2283
2335
|
penDetected: boolean;
|
|
2284
2336
|
exportBackground: boolean;
|
|
@@ -2407,7 +2459,7 @@ export declare const actionToggleHandTool: {
|
|
|
2407
2459
|
lockedMultiSelections: {
|
|
2408
2460
|
[groupId: string]: true;
|
|
2409
2461
|
};
|
|
2410
|
-
stylesPanelMode: "compact" | "full";
|
|
2462
|
+
stylesPanelMode: "compact" | "full" | "mobile";
|
|
2411
2463
|
};
|
|
2412
2464
|
captureUpdate: "IMMEDIATELY";
|
|
2413
2465
|
};
|