@excalidraw/math 0.18.0-abeeaeb → 0.18.0-afa3a65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/dev/index.js +36 -42
  2. package/dist/dev/index.js.map +2 -2
  3. package/dist/prod/index.js +1 -1
  4. package/dist/types/common/src/colors.d.ts +8 -0
  5. package/dist/types/common/src/constants.d.ts +44 -0
  6. package/dist/types/common/src/keys.d.ts +2 -0
  7. package/dist/types/common/src/random.d.ts +7 -0
  8. package/dist/types/element/src/Scene.d.ts +1 -1
  9. package/dist/types/element/src/comparisons.d.ts +5 -3
  10. package/dist/types/element/src/delta.d.ts +23 -1
  11. package/dist/types/element/src/flowchart.d.ts +5 -1
  12. package/dist/types/element/src/frame.d.ts +2 -2
  13. package/dist/types/element/src/index.d.ts +1 -0
  14. package/dist/types/element/src/linearElementEditor.d.ts +10 -0
  15. package/dist/types/element/src/mutateElement.d.ts +1 -1
  16. package/dist/types/element/src/newElement.d.ts +24 -2
  17. package/dist/types/element/src/sizeHelpers.d.ts +6 -0
  18. package/dist/types/element/src/stickyNote.d.ts +183 -0
  19. package/dist/types/element/src/textElement.d.ts +2 -1
  20. package/dist/types/element/src/transform.d.ts +25 -6
  21. package/dist/types/element/src/typeChecks.d.ts +3 -2
  22. package/dist/types/element/src/types.d.ts +35 -6
  23. package/dist/types/element/src/utils.d.ts +7 -3
  24. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +12 -0
  25. package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
  26. package/dist/types/excalidraw/actions/actionBoundText.d.ts +8 -0
  27. package/dist/types/excalidraw/actions/actionCanvas.d.ts +28 -0
  28. package/dist/types/excalidraw/actions/actionClipboard.d.ts +8 -0
  29. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +4 -0
  30. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +13 -1
  31. package/dist/types/excalidraw/actions/actionDeselect.d.ts +4 -0
  32. package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -2
  33. package/dist/types/excalidraw/actions/actionElementLink.d.ts +4 -0
  34. package/dist/types/excalidraw/actions/actionElementLock.d.ts +8 -0
  35. package/dist/types/excalidraw/actions/actionExport.d.ts +8 -0
  36. package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
  37. package/dist/types/excalidraw/actions/actionFrame.d.ts +63 -1
  38. package/dist/types/excalidraw/actions/actionGroup.d.ts +8 -0
  39. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +55 -1
  40. package/dist/types/excalidraw/actions/actionLink.d.ts +4 -0
  41. package/dist/types/excalidraw/actions/actionMenu.d.ts +4 -0
  42. package/dist/types/excalidraw/actions/actionProperties.d.ts +18 -6
  43. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +4 -0
  44. package/dist/types/excalidraw/actions/actionStyles.d.ts +5 -1
  45. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +4 -0
  46. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +4 -0
  47. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +4 -0
  48. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +4 -0
  49. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +4 -0
  50. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +4 -0
  51. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +4 -0
  52. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +4 -0
  53. package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
  54. package/dist/types/excalidraw/appState.d.ts +4 -0
  55. package/dist/types/excalidraw/components/App.arrowText.d.ts +40 -8
  56. package/dist/types/excalidraw/components/App.cursor.d.ts +8 -0
  57. package/dist/types/excalidraw/components/App.d.ts +92 -6
  58. package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
  59. package/dist/types/excalidraw/components/IconButton.d.ts +2 -0
  60. package/dist/types/excalidraw/components/Tools.d.ts +7 -2
  61. package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +2 -0
  62. package/dist/types/excalidraw/components/icons.d.ts +1 -0
  63. package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +2 -2
  64. package/dist/types/excalidraw/data/blob.d.ts +8 -0
  65. package/dist/types/excalidraw/data/json.d.ts +4 -0
  66. package/dist/types/excalidraw/fonts/Fonts.d.ts +3 -2
  67. package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
  68. package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
  69. package/dist/types/excalidraw/renderer/interactiveScene.d.ts +1 -1
  70. package/dist/types/excalidraw/scene/Renderer.d.ts +50 -1
  71. package/dist/types/excalidraw/scene/index.d.ts +1 -1
  72. package/dist/types/excalidraw/scene/types.d.ts +1 -0
  73. package/dist/types/excalidraw/types.d.ts +30 -2
  74. package/dist/types/excalidraw/viewport.d.ts +4 -0
  75. package/dist/types/math/src/curve.d.ts +19 -12
  76. package/dist/types/math/src/segment.d.ts +6 -0
  77. package/dist/types/utils/src/export.d.ts +1 -0
  78. package/dist/types/utils/src/shape.d.ts +2 -2
  79. package/package.json +2 -2
@@ -1 +1 @@
1
- var G=1e-4,It=(t,n,o)=>Math.min(Math.max(t,n),o),St=(t,n,o="round")=>{let e=Math.pow(10,n);return Math[o]((t+Number.EPSILON)*e)/e},Vt=(t,n,o="round")=>{let e=1/n;return Math[o](t*e)/e},Ct=(t,n)=>(t+n)/2,H=t=>typeof t=="number"&&Number.isFinite(t),vt=(t,n,o=1e-4)=>Math.abs(t-n)<o;var C=t=>t<0?t%(2*Math.PI)+2*Math.PI:t%(2*Math.PI),Ft=([t,n])=>[Math.hypot(t,n),C(Math.atan2(n,t))];function et(t){return t*Math.PI/180}function wt(t){return t*180/Math.PI}function Dt(t){return Math.abs(Math.sin(2*t))<1e-4}function Et(t,n,o){return t=C(t),n=C(n),o=C(o),n<o?t>=n&&t<=o:t>=n||t<=o}function qt(t,n){t=C(t),n=C(n);let o=t-n;return o<-Math.PI?o=o+2*Math.PI:o>Math.PI&&(o=o-2*Math.PI),Math.abs(o)}function f(t,n,o=0,e=0){return[t-o,n-e]}function y(t,n=[0,0],o,e=[0,1]){let r=f(t[0]-n[0],t[1]-n[1]);return o&&rt(r)<o*o?e:r}function k(t,n){return t[0]*n[1]-n[0]*t[1]}function O(t,n){return t[0]*n[0]+t[1]*n[1]}function jt(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="number"&&!isNaN(t[0])&&typeof t[1]=="number"&&!isNaN(t[1])}function X(t,n){return[t[0]+n[0],t[1]+n[1]]}function Y(t,n){return[t[0]-n[0],t[1]-n[1]]}function M(t,n){return f(t[0]*n,t[1]*n)}function rt(t){return t[0]*t[0]+t[1]*t[1]}function xt(t){return Math.sqrt(rt(t))}var E=t=>{let n=xt(t);return n===0?f(0,0):f(t[0]/n,t[1]/n)},v=t=>f(t[1],-t[0]);function x(t,n){return typeof t=="object"?[t.x,t.y]:[t,n]}function Wt(t){return t.length===2?x(t[0],t[1]):void 0}function Ht(t){return t}function V(t,n=x(0,0)){return x(n[0]+t[0],n[1]+t[1])}function I(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="number"&&!isNaN(t[0])&&typeof t[1]=="number"&&!isNaN(t[1])}function B(t,n,o=1e-4){let e=Math.abs;return e(t[0]-n[0])<o&&e(t[1]-n[1])<o}function W(t,n,o){if(!o)return t;let[e,r]=t,[a,i]=n;return x((e-a)*Math.cos(o)-(r-i)*Math.sin(o)+a,(e-a)*Math.sin(o)+(r-i)*Math.cos(o)+i)}function Qt(t,n,o){return W(t,n,et(o))}function bt(t,n=[0,0]){return x(t[0]+n[0],t[1]+n[1])}function Q(t,n){return x((t[0]+n[0])/2,(t[1]+n[1])/2)}function _(t,n){return Math.hypot(n[0]-t[0],n[1]-t[1])}function Jt(t,n){let o=n[0]-t[0],e=n[1]-t[1];return o*o+e*e}var Zt=(t,n,o)=>bt(n,M(y(t,n),o)),Kt=(t,n,o)=>n[0]<=Math.max(t[0],o[0])&&n[0]>=Math.min(t[0],o[0])&&n[1]<=Math.max(t[1],o[1])&&n[1]>=Math.min(t[1],o[1]),Ut=t=>Array.isArray(t)&&t.length===2&&H(t[0])&&H(t[1]);var J=[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Z=[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872];function it(t,n,o,e){return[t,n,o,e]}function pt(t,n,o,e,r=.001,a=10){let i=1/0,l=0;for(;i>=r;){if(l>=a)return null;let c=1-o,s=c*c,P=s*c,u=o*o,m=u*o,b=P*t[0][0]+3*s*o*t[1][0]+3*c*u*t[2][0]+m*t[3][0],p=P*t[0][1]+3*s*o*t[1][1]+3*c*u*t[2][1]+m*t[3][1],d=n[0][0]+e*(n[1][0]-n[0][0]),g=n[0][1]+e*(n[1][1]-n[0][1]),L=b-d,R=p-g;if(i=Math.abs(L)+Math.abs(R),i<r)break;let z=-3*s*t[0][0]+3*s*t[1][0]-6*c*o*t[1][0]-3*u*t[2][0]+6*c*o*t[2][0]+3*u*t[3][0],T=-3*s*t[0][1]+3*s*t[1][1]-6*c*o*t[1][1]-3*u*t[2][1]+6*c*o*t[2][1]+3*u*t[3][1],A=-(n[1][0]-n[0][0]),F=-(n[1][1]-n[0][1]),w=z*F-A*T;if(Math.abs(w)<1e-12)return null;let D=1/w,j=D*(F*-L-A*-R),mt=D*(-T*-L+z*-R);o+=j,e+=mt,l+=1}return[o,e]}var S=(t,n)=>x((1-n)**3*t[0][0]+3*(1-n)**2*n*t[1][0]+3*(1-n)*n**2*t[2][0]+n**3*t[3][0],(1-n)**3*t[0][1]+3*(1-n)**2*n*t[1][1]+3*(1-n)*n**2*t[2][1]+n**3*t[3][1]),K=[[.5,0],[.2,0],[.8,0]],U=([t,n],o,e,r=.01,a=4)=>{let i=pt(e,o,t,n,r,a);if(!i)return null;let[l,c]=i;return l<0||l>1||c<0||c>1?null:S(e,l)};function ln(t,n,o){let e=U(K[0],n,t,o?.tolerance,o?.iterLimit);return e?[e]:(e=U(K[1],n,t,o?.tolerance,o?.iterLimit),e?[e]:(e=U(K[2],n,t,o?.tolerance,o?.iterLimit),e?[e]:[]))}function dt(t,n,o=.001){let e=(s,P,u,m=o)=>{let b=s,p=P,d;for(;p-b>m;)d=(p+b)/2,u(d-m)<u(d+m)?p=d:b=d;return d},a=0;for(let s=1/0,P=0;P<30;P++){let u=_(n,S(t,P/30));u<s&&(s=u,a=P)}let i=Math.max((a-1)/30,0),l=Math.min((a+1)/30,1),c=e(i,l,s=>_(n,S(t,s)));return c==null?null:S(t,c)}function cn(t,n){let o=dt(t,n);return o?_(n,o):1/0}function sn(t){return Array.isArray(t)&&t.length===4&&I(t[0])&&I(t[1])&&I(t[2])&&I(t[3])}function $([t,n,o,e],r){return f(-3*(1-r)*(1-r)*t[0]+3*(1-r)*(1-r)*n[0]-6*r*(1-r)*n[0]-3*r*r*o[0]+6*r*(1-r)*o[0]+3*r*r*e[0],-3*(1-r)*(1-r)*t[1]+3*(1-r)*(1-r)*n[1]-6*r*(1-r)*n[1]-3*r*r*o[1]+6*r*(1-r)*o[1]+3*r*r*e[1])}function Pn(t,n=.5){if(t.length<2)return;let o=[];for(let e=0;e<t.length-1;e++){let r=t[e-1<0?0:e-1],a=t[e],i=t[e+1>=t.length?t.length-1:e+1],l=a[0]+(i[0]-r[0])*n/2,c=a[1]+(i[1]-r[1])*n/2;o.push([x(l,c),x(i[0],i[1])])}return o}function un(t,n=.5){if(t.length<2)return;let o=[];for(let e=0;e<t.length-1;e++){let r=t[e-1<0?0:e-1],a=t[e],i=t[e+1>=t.length?t.length-1:e+1],l=t[e+2>=t.length?t.length-1:e+2],c=[(i[0]-r[0])*n,(i[1]-r[1])*n],s=[(l[0]-a[0])*n,(l[1]-a[1])*n],P=a[0]+c[0]/3,u=a[1]+c[1]/3,m=i[0]-s[0]/3,b=i[1]-s[1]/3;o.push(it(x(a[0],a[1]),x(P,u),x(m,b),x(i[0],i[1])))}return o}function mn([t,n,o,e],r,a=50){let i=[];for(let l=0;l<=a;l++){let c=l/a,s=it(t,n,o,e),P=S(s,c),u=E($(s,c)),m=v(u);i.push(V(M(m,r),P))}return i}function xn(t,n,o,e,r=50){let a=[];for(let i=0;i<=r;i++){let l=i/r,c=1-l,s=x(c*c*t[0]+2*c*l*n[0]+l*l*o[0],c*c*t[1]+2*c*l*n[1]+l*l*o[1]),P=2*(1-l)*(n[0]-t[0])+2*l*(o[0]-n[0]),u=2*(1-l)*(n[1]-t[1])+2*l*(o[1]-n[1]),m=E(f(P,u)),b=v(m);a.push(V(M(b,e),s))}return a}function at(t){let o=0;for(let e=0;e<24;e++){let r=.5*J[e]+.5,a=$(t,r),i=Math.sqrt(a[0]*a[0]+a[1]*a[1]);o+=Z[e]*i}return .5*o}function ft(t,n){if(n<=0)return 0;if(n>=1)return at(t);let o=n/2,e=n/2,r=0;for(let a=0;a<24;a++){let i=o*J[a]+e,l=$(t,i),c=Math.sqrt(l[0]*l[0]+l[1]*l[1]);r+=Z[a]*c}return o*r}function bn(t,n){if(n<=0)return S(t,0);if(n>=1)return S(t,1);let o=at(t),e=o*n,r=0,a=1,i=n,l=0,c=o*1e-4,s=20;for(let P=0;P<s&&(l=ft(t,i),!(Math.abs(l-e)<c));P++)l<e?r=i:a=i,i=(r+a)/2;return S(t,i)}function Ln(t,n,o){return{center:t,halfWidth:n,halfHeight:o}}var yn=(t,n)=>{let{center:o,halfWidth:e,halfHeight:r}=n,a=(t[0]-o[0])/e,i=(t[1]-o[1])/r;return a*a+i*i<=1},Gn=(t,n,o=1e-4)=>ht(t,n)<=o,ht=(t,n)=>{let{halfWidth:o,halfHeight:e,center:r}=n,a=o,i=e,l=X(y(t),M(y(r),-1)),c=Math.abs(l[0]),s=Math.abs(l[1]),P=.707,u=.707;for(let p=0;p<3;p++){let d=a*P,g=i*u,L=(a*a-i*i)*P**3/a,R=(i*i-a*a)*u**3/i,z=d-L,T=g-R,A=c-L,F=s-R,w=Math.hypot(T,z),D=Math.hypot(F,A);P=Math.min(1,Math.max(0,(A*w/D+L)/a)),u=Math.min(1,Math.max(0,(F*w/D+R)/i));let j=Math.hypot(u,P);P/=j,u/=j}let[m,b]=[a*P*Math.sign(l[0]),i*u*Math.sign(l[1])];return _(V(l),x(m,b))};function Mn(t,n){let o=t.halfWidth,e=t.halfHeight,r=y(n[1],n[0]),a=f(n[0][0]-t.center[0],n[0][1]-t.center[1]),i=f(r[0]/(o*o),r[1]/(e*e)),l=f(a[0]/(o*o),a[1]/(e*e)),c=O(r,i),s=O(r,l),P=O(a,l)-1,u=s*s-c*P,m=[];if(u>0){let b=(-s-Math.sqrt(u))/c,p=(-s+Math.sqrt(u))/c;0<=b&&b<=1&&m.push(x(n[0][0]+(n[1][0]-n[0][0])*b,n[0][1]+(n[1][1]-n[0][1])*b)),0<=p&&p<=1&&m.push(x(n[0][0]+(n[1][0]-n[0][0])*p,n[0][1]+(n[1][1]-n[0][1])*p))}else if(u===0){let b=-s/c;0<=b&&b<=1&&m.push(x(n[0][0]+(n[1][0]-n[0][0])*b,n[0][1]+(n[1][1]-n[0][1])*b))}return m}function Rn({center:t,halfWidth:n,halfHeight:o},[e,r]){let[a,i]=t,l=e[0]-a,c=e[1]-i,s=r[0]-a,P=r[1]-i,u=Math.pow(s-l,2)/Math.pow(n,2)+Math.pow(P-c,2)/Math.pow(o,2),m=2*(l*(s-l)/Math.pow(n,2)+c*(P-c)/Math.pow(o,2)),b=Math.pow(l,2)/Math.pow(n,2)+Math.pow(c,2)/Math.pow(o,2)-1,p=(-m+Math.sqrt(Math.pow(m,2)-4*u*b))/(2*u),d=(-m-Math.sqrt(Math.pow(m,2)-4*u*b))/(2*u),g=[x(l+p*(s-l)+a,c+p*(P-c)+i),x(l+d*(s-l)+a,c+d*(P-c)+i)].filter(L=>!isNaN(L[0])&&!isNaN(L[1]));return g.length===2&&B(g[0],g[1])?[g[0]]:g}function tt(t,n){return[t,n]}function lt(t,n){let o=t[1][1]-t[0][1],e=t[0][0]-t[1][0],r=n[1][1]-n[0][1],a=n[0][0]-n[1][0],i=o*a-r*e;if(i!==0){let l=o*t[0][0]+e*t[0][1],c=r*n[0][0]+a*n[0][1];return x((l*a-c*e)/i,(o*c-r*l)/i)}return null}function gt(t){let n=0,o=0;for(let[e,r]of t)n+=e,o+=r;return x(n/t.length,o/t.length)}function An(t){t.length<2&&console.error("Degenerate point set: at least two points are required");let n=gt(t),o=0,e=0,r=0;for(let[P,u]of t){let m=P-n[0],b=u-n[1];o+=m*m,e+=b*b,r+=m*b}o/=t.length,e/=t.length,r/=t.length;let a=o+e,i=Math.hypot(o-e,2*r),l=(a+i)/2,c=(a-i)/2,s;return Math.abs(r)>Number.EPSILON?s=E(f(l-e,r)):s=o>=e?f(1,0):f(0,1),{centroid:n,major:s,minor:v(s),majorVariance:l,minorVariance:c}}function Lt(t,n,o=1){let{centroid:e,major:r,minor:a}=n;return t.map(([i,l])=>{let c=i-e[0],s=l-e[1];return[(c*r[0]+s*r[1])*o,(c*a[0]+s*a[1])*o]})}function Fn(t,n){let o=Lt(t,n).map(([r])=>r);if(yt(o)<=0)return n;let e=M(n.major,-1);return{...n,major:e,minor:v(e)}}function wn(t){return t.majorVariance>0?t.minorVariance/t.majorVariance:1}function ct(t,n){let o=t.length,e=0;for(let l of t)e+=l;e/=o;let r=0,a=0;for(let l of t){let c=l-e;r+=c*c,a+=c**n}r/=o,a/=o;let i=Math.sqrt(r);return i>Number.EPSILON?a/i**n:0}function yt(t){return ct(t,3)}function Dn(t){return ct(t,4)}function jn(...t){return st(t)}function kn(t){return st(t)}var On=(t,n)=>{let o=t[0],e=t[1],r=!1;for(let a=0,i=n.length-1;a<n.length;i=a++){let l=n[a][0],c=n[a][1],s=n[i][0],P=n[i][1];(c>e&&P<=e||c<=e&&P>e)&&o<(s-l)*(e-c)/(P-c)+l&&(r=!r)}return r},Xn=(t,n)=>{let[o,e]=t,r=0;for(let a=0;a<n.length;a++){let i=(a+1)%n.length,[l,c]=n[a],[s,P]=n[i];c<=e?P>e&&(s-l)*(e-c)-(o-l)*(P-c)>0&&r++:P<=e&&(s-l)*(e-c)-(o-l)*(P-c)<0&&r--}return r!==0};function st(t){return Pt(t)?t:[...t,t[0]]}function Pt(t,n=1e-4){return B(t[0],t[t.length-1],n)}function Gt(t,n=1e-4){let o=Pt(t,n)?t.slice(0,-1):t,e=0;for(let r=0,a=o.length-1;r<o.length;a=r++)e+=o[a][0]*o[r][1]-o[r][0]*o[a][1];return e/2}function Yn(t,n=1e-4){return Math.abs(Gt(t,n))}function Bn(t){if(t.length<3)return[...t];let n=[...t].sort((a,i)=>a[0]===i[0]?a[1]-i[1]:a[0]-i[0]),o=(a,i,l)=>(i[0]-a[0])*(l[1]-a[1])-(i[1]-a[1])*(l[0]-a[0]),e=a=>{let i=[];for(let l of a){for(;i.length>=2&&o(i[i.length-2],i[i.length-1],l)<=0;)i.pop();i.push(l)}return i.pop(),i},r=[...e(n),...e([...n].reverse())];return r.length>=3?r:[...t]}function Wn(t,n){if(t.length<3)return[...t];let o=i=>{let l=t[(i-1+t.length)%t.length],c=t[i],s=t[(i+1)%t.length],P=Math.atan2(c[1]-l[1],c[0]-l[0]),u=Math.atan2(s[1]-c[1],s[0]-c[0]);return Math.abs(Mt(u-P))},e=0;for(let i=1;i<t.length;i++)o(i)>o(e)&&(e=i);let r=[],a=0;for(let i=0;i<t.length;i++){let l=(e+i)%t.length;a+=o(l),a>=n&&(r.push(t[l]),a=0)}return r.length>=3?r:[...t]}function Mt(t){let n=t;for(;n>Math.PI;)n-=2*Math.PI;for(;n<-Math.PI;)n+=2*Math.PI;return n}import{toBrandedType as nt}from"@excalidraw/common";function Zn(t,n){return nt([t,n])}function Kn(t){return nt(t)}var Un=([t,n],[o,e])=>t<=o?n>=o:t>=o?e>=t:!1,$n=([t,n],[o,e])=>{let r=Math.max(t,o),a=Math.min(n,e);return r<=a?nt([r,a]):null},to=(t,[n,o])=>t>=n&&t<=o;function N(t,n){return[t,n]}var lo=t=>Array.isArray(t)&&t.length===2&&I(t[0])&&I(t[1]),co=(t,n,o)=>N(W(t[0],o||Q(t[0],t[1]),n),W(t[1],o||Q(t[0],t[1]),n)),so=(t,n)=>{let o=y(t[0]),e=y(t[1]),r=y(n[0]),a=y(n[1]),i=Y(e,o),l=Y(a,r),c=k(i,l);if(c===0)return null;let s=Y(y(n[0]),y(t[0])),P=k(s,i)/c,u=k(s,l)/c;if(P===0)return null;let m=X(o,M(i,u));return u>=0&&u<1&&P>=0&&P<1?V(m):null},ut=(t,n,o=1e-4)=>{let e=q(t,n);return e===0?!0:e<o},q=(t,n)=>{let[o,e]=t,[[r,a],[i,l]]=n,c=o-r,s=e-a,P=i-r,u=l-a,m=c*P+s*u,b=P*P+u*u,p=-1;b!==0&&(p=m/b);let d,g;p<0?(d=r,g=a):p>1?(d=i,g=l):(d=r+p*P,g=a+p*u);let L=o-d,R=e-g;return Math.sqrt(L*L+R*R)};function ot(t,n,o){let e=lt(tt(t[0],t[1]),tt(n[0],n[1]));return!e||!ut(e,n,o)||!ut(e,t,o)?null:e}function Po(t,n){return ot(t,n)?0:Math.min(q(t[0],n),q(t[1],n),q(n[0],t),q(n[1],t))}function Rt(t,n){return[t,n]}function po(t,n,o,e){return Rt(x(t,n),x(o,e))}function fo(t,n){return[N(t[0],x(t[1][0],t[0][1])),N(x(t[1][0],t[0][1]),t[1]),N(t[1],x(t[0][0],t[1][1])),N(x(t[0][0],t[1][1]),t[0])].map(o=>ot(n,o)).filter(o=>!!o)}function ho(t,n){let[[o,e],[r,a]]=t,[[i,l],[c,s]]=n;return o<c&&r>i&&e<s&&a>l}function yo([t,n,o],e){let r=(P,u,m)=>(P[0]-m[0])*(u[1]-m[1])-(u[0]-m[0])*(P[1]-m[1]),a=r(e,t,n),i=r(e,n,o),l=r(e,o,t),c=a<0||i<0||l<0,s=a>0||i>0||l>0;return!(c&&s)}export{G as PRECISION,Ct as average,S as bezierEquation,Ft as cartesian2Polar,gt as centroid,It as clamp,Bn as convexHull,it as curve,un as curveCatmullRomCubicApproxPoints,Pn as curveCatmullRomQuadraticApproxPoints,dt as curveClosestPoint,ln as curveIntersectLineSegment,at as curveLength,ft as curveLengthAtParameter,mn as curveOffsetPoints,bn as curvePointAtLength,cn as curvePointDistance,$ as curveTangent,et as degreesToRadians,q as distanceToLineSegment,Ln as ellipse,ht as ellipseDistanceFromPoint,yn as ellipseIncludesPoint,Rn as ellipseLineIntersectionPoints,Mn as ellipseSegmentInterceptPoints,Gn as ellipseTouchesPoint,wn as elongation,vt as isCloseTo,sn as isCurve,H as isFiniteNumber,lo as isLineSegment,I as isPoint,Kt as isPointWithinBounds,Dt as isRightAngleRads,Ut as isValidPoint,jt as isVector,Dn as kurtosis,tt as line,N as lineSegment,ot as lineSegmentIntersectionPoints,co as lineSegmentRotate,Po as lineSegmentsDistance,lt as linesIntersectAt,C as normalizeRadians,xn as offsetPointsForQuadraticBezier,Fn as orientPrincipalAxes,Q as pointCenter,_ as pointDistance,Jt as pointDistanceSq,x as pointFrom,Wt as pointFromArray,Ht as pointFromPair,V as pointFromVector,ut as pointOnLineSegment,Qt as pointRotateDegs,W as pointRotateRads,Zt as pointScaleFromOrigin,bt as pointTranslate,B as pointsEqual,jn as polygon,Yn as polygonArea,kn as polygonFromPoints,On as polygonIncludesPoint,Xn as polygonIncludesPointNonZero,Pt as polygonIsClosed,Gt as polygonSignedArea,An as principalAxes,Lt as principalCoords,Et as radiansBetweenAngles,qt as radiansDifference,wt as radiansToDegrees,to as rangeIncludesValue,Zn as rangeInclusive,Kn as rangeInclusiveFromPair,$n as rangeIntersection,Un as rangesOverlap,Rt as rectangle,po as rectangleFromNumberSequence,fo as rectangleIntersectLineSegment,ho as rectangleIntersectRectangle,St as round,Vt as roundToStep,so as segmentsIntersectAt,Wn as simplifyConvexPolygon,yt as skewness,ct as standardizedMoment,yo as triangleIncludesPoint,f as vector,X as vectorAdd,k as vectorCross,O as vectorDot,y as vectorFromPoint,xt as vectorMagnitude,rt as vectorMagnitudeSq,v as vectorNormal,E as vectorNormalize,M as vectorScale,Y as vectorSubtract};
1
+ var g=1e-4,vt=(t,n,o)=>Math.min(Math.max(t,n),o),Vt=(t,n,o="round")=>{let e=Math.pow(10,n);return Math[o]((t+Number.EPSILON)*e)/e},_t=(t,n,o="round")=>{let e=1/n;return Math[o](t*e)/e},Nt=(t,n)=>(t+n)/2,H=t=>typeof t=="number"&&Number.isFinite(t),At=(t,n,o=1e-4)=>Math.abs(t-n)<o;var V=t=>t<0?t%(2*Math.PI)+2*Math.PI:t%(2*Math.PI),Et=([t,n])=>[Math.hypot(t,n),V(Math.atan2(n,t))];function et(t){return t*Math.PI/180}function qt(t){return t*180/Math.PI}function zt(t){return Math.abs(Math.sin(2*t))<1e-4}function Tt(t,n,o){return t=V(t),n=V(n),o=V(o),n<o?t>=n&&t<=o:t>=n||t<=o}function jt(t,n){t=V(t),n=V(n);let o=t-n;return o<-Math.PI?o=o+2*Math.PI:o>Math.PI&&(o=o-2*Math.PI),Math.abs(o)}function d(t,n,o=0,e=0){return[t-o,n-e]}function L(t,n=[0,0],o,e=[0,1]){let r=d(t[0]-n[0],t[1]-n[1]);return o&&rt(r)<o*o?e:r}function k(t,n){return t[0]*n[1]-n[0]*t[1]}function O(t,n){return t[0]*n[0]+t[1]*n[1]}function Xt(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="number"&&!isNaN(t[0])&&typeof t[1]=="number"&&!isNaN(t[1])}function X(t,n){return[t[0]+n[0],t[1]+n[1]]}function Y(t,n){return[t[0]-n[0],t[1]-n[1]]}function y(t,n){return d(t[0]*n,t[1]*n)}function rt(t){return t[0]*t[0]+t[1]*t[1]}function xt(t){return Math.sqrt(rt(t))}var E=t=>{let n=xt(t);return n===0?d(0,0):d(t[0]/n,t[1]/n)},_=t=>d(t[1],-t[0]);function x(t,n){return typeof t=="object"?[t.x,t.y]:[t,n]}function Jt(t){return t.length===2?x(t[0],t[1]):void 0}function Zt(t){return t}function v(t,n=x(0,0)){return x(n[0]+t[0],n[1]+t[1])}function R(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="number"&&!isNaN(t[0])&&typeof t[1]=="number"&&!isNaN(t[1])}function B(t,n,o=1e-4){let e=Math.abs;return e(t[0]-n[0])<o&&e(t[1]-n[1])<o}function W(t,n,o){if(!o)return t;let[e,r]=t,[i,a]=n;return x((e-i)*Math.cos(o)-(r-a)*Math.sin(o)+i,(e-i)*Math.sin(o)+(r-a)*Math.cos(o)+a)}function Kt(t,n,o){return W(t,n,et(o))}function bt(t,n=[0,0]){return x(t[0]+n[0],t[1]+n[1])}function Q(t,n){return x((t[0]+n[0])/2,(t[1]+n[1])/2)}function S(t,n){return Math.hypot(n[0]-t[0],n[1]-t[1])}function Ut(t,n){let o=n[0]-t[0],e=n[1]-t[1];return o*o+e*e}var $t=(t,n,o)=>bt(n,y(L(t,n),o)),tn=(t,n,o)=>n[0]<=Math.max(t[0],o[0])&&n[0]>=Math.min(t[0],o[0])&&n[1]<=Math.max(t[1],o[1])&&n[1]>=Math.min(t[1],o[1]),nn=t=>Array.isArray(t)&&t.length===2&&H(t[0])&&H(t[1]);var J=[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Z=[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872];function it(t,n,o,e){return[t,n,o,e]}function pt(t,n,o,e,r=.001,i=10){let a=1/0,l=0;for(;a>=r;){if(l>=i)return null;let c=1-o,s=c*c,P=s*c,u=o*o,m=u*o,b=P*t[0][0]+3*s*o*t[1][0]+3*c*u*t[2][0]+m*t[3][0],p=P*t[0][1]+3*s*o*t[1][1]+3*c*u*t[2][1]+m*t[3][1],h=n[0][0]+e*(n[1][0]-n[0][0]),M=n[0][1]+e*(n[1][1]-n[0][1]),G=b-h,C=p-M;if(a=Math.abs(G)+Math.abs(C),a<r)break;let z=-3*s*t[0][0]+3*s*t[1][0]-6*c*o*t[1][0]-3*u*t[2][0]+6*c*o*t[2][0]+3*u*t[3][0],T=-3*s*t[0][1]+3*s*t[1][1]-6*c*o*t[1][1]-3*u*t[2][1]+6*c*o*t[2][1]+3*u*t[3][1],A=-(n[1][0]-n[0][0]),F=-(n[1][1]-n[0][1]),D=z*F-A*T;if(Math.abs(D)<1e-12)return null;let w=1/D,j=w*(F*-G-A*-C),mt=w*(-T*-G+z*-C);o+=j,e+=mt,l+=1}return[o,e]}var I=(t,n)=>x((1-n)**3*t[0][0]+3*(1-n)**2*n*t[1][0]+3*(1-n)*n**2*t[2][0]+n**3*t[3][0],(1-n)**3*t[0][1]+3*(1-n)**2*n*t[1][1]+3*(1-n)*n**2*t[2][1]+n**3*t[3][1]),K=[[.5,0],[.2,0],[.8,0]],U=([t,n],o,e,r=.01,i=4)=>{let a=pt(e,o,t,n,r,i);if(!a)return null;let[l,c]=a;return l<0||l>1||c<0||c>1?null:I(e,l)};function Pn(t,n,o){let e=U(K[0],n,t,o?.tolerance,o?.iterLimit);return e?[e]:(e=U(K[1],n,t,o?.tolerance,o?.iterLimit),e?[e]:(e=U(K[2],n,t,o?.tolerance,o?.iterLimit),e?[e]:[]))}function dt(t,n,o=.001){let e=(s,P,u,m=o)=>{let b=s,p=P,h;for(;p-b>m;)h=(p+b)/2,u(h-m)<u(h+m)?p=h:b=h;return h},i=0;for(let s=1/0,P=0;P<=30;P++){let u=S(n,I(t,P/30));u<s&&(s=u,i=P)}let a=Math.max((i-1)/30,0),l=Math.min((i+1)/30,1);return e(a,l,s=>S(n,I(t,s)))??i/30}function ft(t,n,o=.001){return I(t,dt(t,n,o))}function un(t,n,o=.001){return S(n,ft(t,n,o))}function mn(t){return Array.isArray(t)&&t.length===4&&R(t[0])&&R(t[1])&&R(t[2])&&R(t[3])}function $([t,n,o,e],r){return d(-3*(1-r)*(1-r)*t[0]+3*(1-r)*(1-r)*n[0]-6*r*(1-r)*n[0]-3*r*r*o[0]+6*r*(1-r)*o[0]+3*r*r*e[0],-3*(1-r)*(1-r)*t[1]+3*(1-r)*(1-r)*n[1]-6*r*(1-r)*n[1]-3*r*r*o[1]+6*r*(1-r)*o[1]+3*r*r*e[1])}function xn(t,n=.5){if(t.length<2)return;let o=[];for(let e=0;e<t.length-1;e++){let r=t[e-1<0?0:e-1],i=t[e],a=t[e+1>=t.length?t.length-1:e+1],l=i[0]+(a[0]-r[0])*n/2,c=i[1]+(a[1]-r[1])*n/2;o.push([x(l,c),x(a[0],a[1])])}return o}function bn(t,n=.5){if(t.length<2)return;let o=[];for(let e=0;e<t.length-1;e++){let r=t[e-1<0?0:e-1],i=t[e],a=t[e+1>=t.length?t.length-1:e+1],l=t[e+2>=t.length?t.length-1:e+2],c=[(a[0]-r[0])*n,(a[1]-r[1])*n],s=[(l[0]-i[0])*n,(l[1]-i[1])*n],P=i[0]+c[0]/3,u=i[1]+c[1]/3,m=a[0]-s[0]/3,b=a[1]-s[1]/3;o.push(it(x(i[0],i[1]),x(P,u),x(m,b),x(a[0],a[1])))}return o}function pn([t,n,o,e],r,i=50){let a=[];for(let l=0;l<=i;l++){let c=l/i,s=it(t,n,o,e),P=I(s,c),u=E($(s,c)),m=_(u);a.push(v(y(m,r),P))}return a}function dn(t,n,o,e,r=50){let i=[];for(let a=0;a<=r;a++){let l=a/r,c=1-l,s=x(c*c*t[0]+2*c*l*n[0]+l*l*o[0],c*c*t[1]+2*c*l*n[1]+l*l*o[1]),P=2*(1-l)*(n[0]-t[0])+2*l*(o[0]-n[0]),u=2*(1-l)*(n[1]-t[1])+2*l*(o[1]-n[1]),m=E(d(P,u)),b=_(m);i.push(v(y(b,e),s))}return i}function at(t){let o=0;for(let e=0;e<24;e++){let r=.5*J[e]+.5,i=$(t,r),a=Math.sqrt(i[0]*i[0]+i[1]*i[1]);o+=Z[e]*a}return .5*o}function ht(t,n){if(n<=0)return 0;if(n>=1)return at(t);let o=n/2,e=n/2,r=0;for(let i=0;i<24;i++){let a=o*J[i]+e,l=$(t,a),c=Math.sqrt(l[0]*l[0]+l[1]*l[1]);r+=Z[i]*c}return o*r}function fn(t,n,o=at(t)){if(n<=0)return I(t,0);if(n>=1)return I(t,1);let e=o*n,r=0,i=1,a=n,l=0,c=o*1e-4,s=20;for(let P=0;P<s&&(l=ht(t,a),!(Math.abs(l-e)<c));P++)l<e?r=a:i=a,a=(r+i)/2;return I(t,a)}function Mn(t,n,o){return{center:t,halfWidth:n,halfHeight:o}}var Rn=(t,n)=>{let{center:o,halfWidth:e,halfHeight:r}=n,i=(t[0]-o[0])/e,a=(t[1]-o[1])/r;return i*i+a*a<=1},Sn=(t,n,o=1e-4)=>Lt(t,n)<=o,Lt=(t,n)=>{let{halfWidth:o,halfHeight:e,center:r}=n,i=o,a=e,l=X(L(t),y(L(r),-1)),c=Math.abs(l[0]),s=Math.abs(l[1]),P=.707,u=.707;for(let p=0;p<3;p++){let h=i*P,M=a*u,G=(i*i-a*a)*P**3/i,C=(a*a-i*i)*u**3/a,z=h-G,T=M-C,A=c-G,F=s-C,D=Math.hypot(T,z),w=Math.hypot(F,A);P=Math.min(1,Math.max(0,(A*D/w+G)/i)),u=Math.min(1,Math.max(0,(F*D/w+C)/a));let j=Math.hypot(u,P);P/=j,u/=j}let[m,b]=[i*P*Math.sign(l[0]),a*u*Math.sign(l[1])];return S(v(l),x(m,b))};function In(t,n){let o=t.halfWidth,e=t.halfHeight,r=L(n[1],n[0]),i=d(n[0][0]-t.center[0],n[0][1]-t.center[1]),a=d(r[0]/(o*o),r[1]/(e*e)),l=d(i[0]/(o*o),i[1]/(e*e)),c=O(r,a),s=O(r,l),P=O(i,l)-1,u=s*s-c*P,m=[];if(u>0){let b=(-s-Math.sqrt(u))/c,p=(-s+Math.sqrt(u))/c;0<=b&&b<=1&&m.push(x(n[0][0]+(n[1][0]-n[0][0])*b,n[0][1]+(n[1][1]-n[0][1])*b)),0<=p&&p<=1&&m.push(x(n[0][0]+(n[1][0]-n[0][0])*p,n[0][1]+(n[1][1]-n[0][1])*p))}else if(u===0){let b=-s/c;0<=b&&b<=1&&m.push(x(n[0][0]+(n[1][0]-n[0][0])*b,n[0][1]+(n[1][1]-n[0][1])*b))}return m}function Cn({center:t,halfWidth:n,halfHeight:o},[e,r]){let[i,a]=t,l=e[0]-i,c=e[1]-a,s=r[0]-i,P=r[1]-a,u=Math.pow(s-l,2)/Math.pow(n,2)+Math.pow(P-c,2)/Math.pow(o,2),m=2*(l*(s-l)/Math.pow(n,2)+c*(P-c)/Math.pow(o,2)),b=Math.pow(l,2)/Math.pow(n,2)+Math.pow(c,2)/Math.pow(o,2)-1,p=(-m+Math.sqrt(Math.pow(m,2)-4*u*b))/(2*u),h=(-m-Math.sqrt(Math.pow(m,2)-4*u*b))/(2*u),M=[x(l+p*(s-l)+i,c+p*(P-c)+a),x(l+h*(s-l)+i,c+h*(P-c)+a)].filter(G=>!isNaN(G[0])&&!isNaN(G[1]));return M.length===2&&B(M[0],M[1])?[M[0]]:M}function tt(t,n){return[t,n]}function lt(t,n){let o=t[1][1]-t[0][1],e=t[0][0]-t[1][0],r=n[1][1]-n[0][1],i=n[0][0]-n[1][0],a=o*i-r*e;if(a!==0){let l=o*t[0][0]+e*t[0][1],c=r*n[0][0]+i*n[0][1];return x((l*i-c*e)/a,(o*c-r*l)/a)}return null}function gt(t){let n=0,o=0;for(let[e,r]of t)n+=e,o+=r;return x(n/t.length,o/t.length)}function wn(t){t.length<2&&console.error("Degenerate point set: at least two points are required");let n=gt(t),o=0,e=0,r=0;for(let[P,u]of t){let m=P-n[0],b=u-n[1];o+=m*m,e+=b*b,r+=m*b}o/=t.length,e/=t.length,r/=t.length;let i=o+e,a=Math.hypot(o-e,2*r),l=(i+a)/2,c=(i-a)/2,s;return Math.abs(r)>Number.EPSILON?s=E(d(l-e,r)):s=o>=e?d(1,0):d(0,1),{centroid:n,major:s,minor:_(s),majorVariance:l,minorVariance:c}}function yt(t,n,o=1){let{centroid:e,major:r,minor:i}=n;return t.map(([a,l])=>{let c=a-e[0],s=l-e[1];return[(c*r[0]+s*r[1])*o,(c*i[0]+s*i[1])*o]})}function En(t,n){let o=yt(t,n).map(([r])=>r);if(Gt(o)<=0)return n;let e=y(n.major,-1);return{...n,major:e,minor:_(e)}}function qn(t){return t.majorVariance>0?t.minorVariance/t.majorVariance:1}function ct(t,n){let o=t.length,e=0;for(let l of t)e+=l;e/=o;let r=0,i=0;for(let l of t){let c=l-e;r+=c*c,i+=c**n}r/=o,i/=o;let a=Math.sqrt(r);return a>Number.EPSILON?i/a**n:0}function Gt(t){return ct(t,3)}function zn(t){return ct(t,4)}function Xn(...t){return st(t)}function Yn(t){return st(t)}var Bn=(t,n)=>{let o=t[0],e=t[1],r=!1;for(let i=0,a=n.length-1;i<n.length;a=i++){let l=n[i][0],c=n[i][1],s=n[a][0],P=n[a][1];(c>e&&P<=e||c<=e&&P>e)&&o<(s-l)*(e-c)/(P-c)+l&&(r=!r)}return r},Wn=(t,n)=>{let[o,e]=t,r=0;for(let i=0;i<n.length;i++){let a=(i+1)%n.length,[l,c]=n[i],[s,P]=n[a];c<=e?P>e&&(s-l)*(e-c)-(o-l)*(P-c)>0&&r++:P<=e&&(s-l)*(e-c)-(o-l)*(P-c)<0&&r--}return r!==0};function st(t){return Pt(t)?t:[...t,t[0]]}function Pt(t,n=1e-4){return B(t[0],t[t.length-1],n)}function Mt(t,n=1e-4){let o=Pt(t,n)?t.slice(0,-1):t,e=0;for(let r=0,i=o.length-1;r<o.length;i=r++)e+=o[i][0]*o[r][1]-o[r][0]*o[i][1];return e/2}function Hn(t,n=1e-4){return Math.abs(Mt(t,n))}function Qn(t){if(t.length<3)return[...t];let n=[...t].sort((i,a)=>i[0]===a[0]?i[1]-a[1]:i[0]-a[0]),o=(i,a,l)=>(a[0]-i[0])*(l[1]-i[1])-(a[1]-i[1])*(l[0]-i[0]),e=i=>{let a=[];for(let l of i){for(;a.length>=2&&o(a[a.length-2],a[a.length-1],l)<=0;)a.pop();a.push(l)}return a.pop(),a},r=[...e(n),...e([...n].reverse())];return r.length>=3?r:[...t]}function Jn(t,n){if(t.length<3)return[...t];let o=a=>{let l=t[(a-1+t.length)%t.length],c=t[a],s=t[(a+1)%t.length],P=Math.atan2(c[1]-l[1],c[0]-l[0]),u=Math.atan2(s[1]-c[1],s[0]-c[0]);return Math.abs(Rt(u-P))},e=0;for(let a=1;a<t.length;a++)o(a)>o(e)&&(e=a);let r=[],i=0;for(let a=0;a<t.length;a++){let l=(e+a)%t.length;i+=o(l),i>=n&&(r.push(t[l]),i=0)}return r.length>=3?r:[...t]}function Rt(t){let n=t;for(;n>Math.PI;)n-=2*Math.PI;for(;n<-Math.PI;)n+=2*Math.PI;return n}import{toBrandedType as nt}from"@excalidraw/common";function $n(t,n){return nt([t,n])}function to(t){return nt(t)}var no=([t,n],[o,e])=>t<=o?n>=o:t>=o?e>=t:!1,oo=([t,n],[o,e])=>{let r=Math.max(t,o),i=Math.min(n,e);return r<=i?nt([r,i]):null},eo=(t,[n,o])=>t>=n&&t<=o;function N(t,n){return[t,n]}var Po=t=>Array.isArray(t)&&t.length===2&&R(t[0])&&R(t[1]),uo=(t,n,o)=>N(W(t[0],o||Q(t[0],t[1]),n),W(t[1],o||Q(t[0],t[1]),n)),mo=(t,n)=>{let o=L(t[0]),e=L(t[1]),r=L(n[0]),i=L(n[1]),a=Y(e,o),l=Y(i,r),c=k(a,l);if(c===0)return null;let s=Y(L(n[0]),L(t[0])),P=k(s,a)/c,u=k(s,l)/c;if(P===0)return null;let m=X(o,y(a,u));return u>=0&&u<1&&P>=0&&P<1?v(m):null},ut=(t,n,o=1e-4)=>{let e=q(t,n);return e===0?!0:e<o},q=(t,n)=>S(t,St(n,It(t,n)));function St(t,n){let[[o,e],[r,i]]=t;return x(o+n*(r-o),e+n*(i-e))}function ot(t,n,o){let e=lt(tt(t[0],t[1]),tt(n[0],n[1]));return!e||!ut(e,n,o)||!ut(e,t,o)?null:e}function xo(t,n){return ot(t,n)?0:Math.min(q(t[0],n),q(t[1],n),q(n[0],t),q(n[1],t))}function It(t,n){let[o,e]=t,[[r,i],[a,l]]=n,c=o-r,s=e-i,P=a-r,u=l-i,m=c*P+s*u,b=P*P+u*u,p=0;return b!==0&&(p=m/b),Math.max(0,Math.min(1,p))}function Ct(t,n){return[t,n]}function Lo(t,n,o,e){return Ct(x(t,n),x(o,e))}function go(t,n){return[N(t[0],x(t[1][0],t[0][1])),N(x(t[1][0],t[0][1]),t[1]),N(t[1],x(t[0][0],t[1][1])),N(x(t[0][0],t[1][1]),t[0])].map(o=>ot(n,o)).filter(o=>!!o)}function yo(t,n){let[[o,e],[r,i]]=t,[[a,l],[c,s]]=n;return o<c&&r>a&&e<s&&i>l}function Ro([t,n,o],e){let r=(P,u,m)=>(P[0]-m[0])*(u[1]-m[1])-(u[0]-m[0])*(P[1]-m[1]),i=r(e,t,n),a=r(e,n,o),l=r(e,o,t),c=i<0||a<0||l<0,s=i>0||a>0||l>0;return!(c&&s)}export{g as PRECISION,Nt as average,I as bezierEquation,Et as cartesian2Polar,gt as centroid,vt as clamp,Qn as convexHull,it as curve,bn as curveCatmullRomCubicApproxPoints,xn as curveCatmullRomQuadraticApproxPoints,dt as curveClosestParameter,ft as curveClosestPoint,Pn as curveIntersectLineSegment,at as curveLength,ht as curveLengthAtParameter,pn as curveOffsetPoints,fn as curvePointAtLength,un as curvePointDistance,$ as curveTangent,et as degreesToRadians,q as distanceToLineSegment,Mn as ellipse,Lt as ellipseDistanceFromPoint,Rn as ellipseIncludesPoint,Cn as ellipseLineIntersectionPoints,In as ellipseSegmentInterceptPoints,Sn as ellipseTouchesPoint,qn as elongation,At as isCloseTo,mn as isCurve,H as isFiniteNumber,Po as isLineSegment,R as isPoint,tn as isPointWithinBounds,zt as isRightAngleRads,nn as isValidPoint,Xt as isVector,zn as kurtosis,tt as line,N as lineSegment,It as lineSegmentClosestParameter,ot as lineSegmentIntersectionPoints,St as lineSegmentPointAt,uo as lineSegmentRotate,xo as lineSegmentsDistance,lt as linesIntersectAt,V as normalizeRadians,dn as offsetPointsForQuadraticBezier,En as orientPrincipalAxes,Q as pointCenter,S as pointDistance,Ut as pointDistanceSq,x as pointFrom,Jt as pointFromArray,Zt as pointFromPair,v as pointFromVector,ut as pointOnLineSegment,Kt as pointRotateDegs,W as pointRotateRads,$t as pointScaleFromOrigin,bt as pointTranslate,B as pointsEqual,Xn as polygon,Hn as polygonArea,Yn as polygonFromPoints,Bn as polygonIncludesPoint,Wn as polygonIncludesPointNonZero,Pt as polygonIsClosed,Mt as polygonSignedArea,wn as principalAxes,yt as principalCoords,Tt as radiansBetweenAngles,jt as radiansDifference,qt as radiansToDegrees,eo as rangeIncludesValue,$n as rangeInclusive,to as rangeInclusiveFromPair,oo as rangeIntersection,no as rangesOverlap,Ct as rectangle,Lo as rectangleFromNumberSequence,go as rectangleIntersectLineSegment,yo as rectangleIntersectRectangle,Vt as round,_t as roundToStep,mo as segmentsIntersectAt,Jn as simplifyConvexPolygon,Gt as skewness,ct as standardizedMoment,Ro as triangleIncludesPoint,d as vector,X as vectorAdd,k as vectorCross,O as vectorDot,L as vectorFromPoint,xt as vectorMagnitude,rt as vectorMagnitudeSq,_ as vectorNormal,E as vectorNormalize,y as vectorScale,Y as vectorSubtract};
@@ -36,6 +36,9 @@ export declare const COLOR_TOP_PICKS_SLOTS = 5;
36
36
  export declare const DEFAULT_ELEMENT_STROKE_PICKS: ColorTuple;
37
37
  export declare const DEFAULT_ELEMENT_BACKGROUND_PICKS: ColorTuple;
38
38
  export declare const BUCKET_FILL_BACKGROUND_PICKS: ColorTuple;
39
+ export declare const DEFAULT_STICKY_NOTE_BG = "#ffdf6b";
40
+ export declare const STICKY_NOTE_STROKE_PICKS: ColorTuple;
41
+ export declare const STICKY_NOTE_BACKGROUND_PICKS: ColorTuple;
39
42
  export declare const DEFAULT_CANVAS_BACKGROUND_PICKS: ColorTuple;
40
43
  export declare const DEFAULT_ELEMENT_STROKE_COLOR_PALETTE: {
41
44
  readonly cyan: readonly ["#e3fafc", "#99e9f2", "#3bc9db", "#15aabf", "#0c8599"];
@@ -73,6 +76,11 @@ export declare const DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE: {
73
76
  };
74
77
  export declare const getAllColorsSpecificShade: (index: 0 | 1 | 2 | 3 | 4) => ("#fff5f5" | "#ffc9c9" | "#ff8787" | "#fa5252" | "#e03131" | "#fff0f6" | "#fcc2d7" | "#f783ac" | "#e64980" | "#c2255c" | "#f8f0fc" | "#eebefa" | "#da77f2" | "#be4bdb" | "#9c36b5" | "#f3f0ff" | "#d0bfff" | "#9775fa" | "#7950f2" | "#6741d9" | "#e7f5ff" | "#a5d8ff" | "#4dabf7" | "#228be6" | "#1971c2" | "#e3fafc" | "#99e9f2" | "#3bc9db" | "#15aabf" | "#0c8599" | "#e6fcf5" | "#96f2d7" | "#38d9a9" | "#12b886" | "#099268" | "#ebfbee" | "#b2f2bb" | "#69db7c" | "#40c057" | "#2f9e44" | "#fff9db" | "#ffec99" | "#ffd43b" | "#fab005" | "#f08c00" | "#fff4e6" | "#ffd8a8" | "#ffa94d" | "#fd7e14" | "#e8590c")[];
75
78
  export declare const rgbToHex: (r: number, g: number, b: number, a?: number) => string;
79
+ /**
80
+ * @returns the color with its alpha replaced by `alpha` (as #RRGGBBAA), or the
81
+ * input unchanged if it's not a valid color
82
+ */
83
+ export declare const setColorAlpha: (color: string, alpha: number) => string;
76
84
  /**
77
85
  * @returns #RRGGBB or #RRGGBBAA based on color containing non-opaque alpha,
78
86
  * null if not valid color
@@ -1,5 +1,6 @@
1
1
  import type { ExcalidrawElement, FontFamilyValues } from "@excalidraw/element/types";
2
2
  import type { AppProps, AppState } from "@excalidraw/excalidraw/types";
3
+ export { DEFAULT_STICKY_NOTE_BG } from "./colors";
3
4
  export declare const supportsResizeObserver: boolean;
4
5
  export declare const APP_NAME = "Excalidraw";
5
6
  export declare const TEXT_AUTOWRAP_THRESHOLD = 36;
@@ -52,6 +53,7 @@ export declare enum EVENT {
52
53
  POINTER_MOVE = "pointermove",
53
54
  POINTER_DOWN = "pointerdown",
54
55
  POINTER_UP = "pointerup",
56
+ POINTER_CANCEL = "pointercancel",
55
57
  STATE_CHANGE = "statechange",
56
58
  WHEEL = "wheel",
57
59
  TOUCH_START = "touchstart",
@@ -150,6 +152,47 @@ export declare const FRAME_STYLE: {
150
152
  };
151
153
  export declare const MIN_FONT_SIZE = 1;
152
154
  export declare const DEFAULT_FONT_SIZE = 20;
155
+ export declare const STICKY_NOTE_MIN_FONT_SIZE = 16;
156
+ export declare const STICKY_NOTE_MAX_FONT_SIZE = 512;
157
+ export declare const STICKY_NOTE_FALLBACK_FONT_SIZE = 28;
158
+ export declare const STICKY_NOTE_FONT_STEP = 2;
159
+ export declare const STICKY_NOTE_PADDING = 16;
160
+ /**
161
+ * The creation-date footer: a 20px text row under the label body plus a 12px
162
+ * gap above it, inside the note's bottom padding. Reserved for every note —
163
+ * also when `created` is unknown — so geometry never depends on data
164
+ * availability. The label is chosen by width bucket, never measured, so
165
+ * painting stays measurement-free (the server has no text measurer):
166
+ * `minBodyWidthForYear` is the worst case ("30 May 2026") in the system sans
167
+ * stack at 12px, with margin for wider fallbacks such as DejaVu Sans.
168
+ */
169
+ /**
170
+ * The creation-date footer of a sticky note. The label body ends `height`
171
+ * above the note's bottom padding, and the date's baseline sits
172
+ * `baselineFromBottom` above the note's bottom edge — so the 12px glyphs
173
+ * (~9px above the baseline, ~3px below) end up roughly 11px from the edge
174
+ * with a ~13px gap to the label body above them.
175
+ */
176
+ export declare const STICKY_NOTE_FOOTER: {
177
+ readonly height: 20;
178
+ readonly fontSize: 12;
179
+ readonly fontFamily: "Helvetica, Arial, sans-serif";
180
+ readonly baselineFromBottom: 14;
181
+ readonly opacity: 1;
182
+ readonly minBodyWidthForYear: 80;
183
+ };
184
+ /**
185
+ * outer height → label body height: top + bottom padding + footer. The body
186
+ * is what the label is fitted into; a middle-aligned label is still centered
187
+ * in the whole padded note when it fits (see `computeBoundTextPosition`).
188
+ */
189
+ export declare const STICKY_NOTE_BODY_INSET_Y: number;
190
+ export declare const DEFAULT_STICKY_NOTE_SIZE = 250;
191
+ export declare const STICKY_NOTE_MIN_SIZE = 75;
192
+ export declare const STICKY_NOTE_SHADOW_OFFSET = 3;
193
+ export declare const STICKY_NOTE_SHADOW_OPACITY = 0.16;
194
+ export declare const STICKY_NOTE_EDGE_SHADOW_WIDTH = 0.5;
195
+ export declare const STICKY_NOTE_EDGE_SHADOW_OPACITY = 0.08;
153
196
  export declare const DEFAULT_FONT_FAMILY: FontFamilyValues;
154
197
  export declare const DEFAULT_TEXT_ALIGN = "left";
155
198
  export declare const DEFAULT_VERTICAL_ALIGN = "top";
@@ -313,6 +356,7 @@ export declare const TOOL_TYPE: {
313
356
  readonly hand: "hand";
314
357
  readonly frame: "frame";
315
358
  readonly magicframe: "magicframe";
359
+ readonly stickynote: "stickynote";
316
360
  readonly embeddable: "embeddable";
317
361
  readonly laser: "laser";
318
362
  readonly autoshape: "autoshape";
@@ -55,6 +55,7 @@ export declare const KEYS: {
55
55
  readonly H: "h";
56
56
  readonly I: "i";
57
57
  readonly L: "l";
58
+ readonly N: "n";
58
59
  readonly O: "o";
59
60
  readonly P: "p";
60
61
  readonly Q: "q";
@@ -111,6 +112,7 @@ export declare const KeyCodeMap: Map<ValueOf<{
111
112
  readonly H: "h";
112
113
  readonly I: "i";
113
114
  readonly L: "l";
115
+ readonly N: "n";
114
116
  readonly O: "o";
115
117
  readonly P: "p";
116
118
  readonly Q: "q";
@@ -1,3 +1,10 @@
1
1
  export declare const randomInteger: () => number;
2
2
  export declare const reseed: (seed: number) => void;
3
3
  export declare const randomId: () => string;
4
+ /**
5
+ * Deterministic PRNG (mulberry32) for a given seed: same seed, same
6
+ * sequence — used where a render must be stable across frames and clients
7
+ * (e.g. the sticky note's corner jitter) and roughjs's `Random` is
8
+ * unsuitable (it degenerates for seed 0). Returns numbers in [0, 1).
9
+ */
10
+ export declare const seededRandom: (seed: number) => () => number;
@@ -72,7 +72,7 @@ export declare class Scene {
72
72
  getElementIndex(elementId: string): number;
73
73
  getContainerElement: (element: (ExcalidrawElement & {
74
74
  containerId: ExcalidrawElement["id"] | null;
75
- }) | null) => import("@excalidraw/element/types").ExcalidrawLinearElement | import("@excalidraw/element/types").ExcalidrawSelectionElement | import("@excalidraw/element/types").ExcalidrawRectangleElement | import("@excalidraw/element/types").ExcalidrawDiamondElement | import("@excalidraw/element/types").ExcalidrawEllipseElement | import("@excalidraw/element/types").ExcalidrawEmbeddableElement | import("@excalidraw/element/types").ExcalidrawIframeElement | import("@excalidraw/element/types").ExcalidrawImageElement | import("@excalidraw/element/types").ExcalidrawFrameElement | import("@excalidraw/element/types").ExcalidrawMagicFrameElement | import("@excalidraw/element/types").ExcalidrawTextElement | import("@excalidraw/element/types").ExcalidrawFreeDrawElement | null;
75
+ }) | null) => import("@excalidraw/element/types").ExcalidrawLinearElement | import("@excalidraw/element/types").ExcalidrawSelectionElement | import("@excalidraw/element/types").ExcalidrawRectangleElement | import("@excalidraw/element/types").ExcalidrawStickyNoteElement | import("@excalidraw/element/types").ExcalidrawDiamondElement | import("@excalidraw/element/types").ExcalidrawEllipseElement | import("@excalidraw/element/types").ExcalidrawEmbeddableElement | import("@excalidraw/element/types").ExcalidrawIframeElement | import("@excalidraw/element/types").ExcalidrawImageElement | import("@excalidraw/element/types").ExcalidrawFrameElement | import("@excalidraw/element/types").ExcalidrawMagicFrameElement | import("@excalidraw/element/types").ExcalidrawTextElement | import("@excalidraw/element/types").ExcalidrawFreeDrawElement | null;
76
76
  getElementsFromId: (id: string) => ExcalidrawElement[];
77
77
  mutateElement<TElement extends Mutable<ExcalidrawElement>>(element: TElement, updates: ElementUpdate<TElement>, options?: {
78
78
  informMutation: boolean;
@@ -1,9 +1,11 @@
1
1
  import type { ElementOrToolType } from "@excalidraw/excalidraw/types";
2
- export declare const hasBackground: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape" | "bucketfill";
3
- export declare const hasStrokeColor: (type: ElementOrToolType) => type is "line" | "arrow" | "text" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "freedraw" | "autoshape";
2
+ export declare const hasBackground: (type: ElementOrToolType) => type is "line" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape" | "bucketfill";
3
+ export declare const hasFillStyle: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape" | "bucketfill";
4
+ export declare const hasStrokeColor: (type: ElementOrToolType) => type is "line" | "arrow" | "text" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "embeddable" | "freedraw" | "autoshape";
4
5
  export declare const hasStrokeWidth: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "freedraw" | "autoshape";
5
6
  export declare const hasStrokeStyle: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "diamond" | "ellipse" | "embeddable" | "iframe" | "autoshape";
7
+ export declare const hasRoughness: (type: ElementOrToolType) => type is "line" | "arrow" | "rectangle" | "stickynote" | "diamond" | "ellipse" | "embeddable" | "iframe" | "autoshape";
6
8
  export declare const hasFreedrawMode: (type: ElementOrToolType) => type is "freedraw";
7
- export declare const canChangeRoundness: (type: ElementOrToolType) => type is "line" | "rectangle" | "diamond" | "embeddable" | "iframe" | "image";
9
+ export declare const canChangeRoundness: (type: ElementOrToolType) => type is "line" | "rectangle" | "stickynote" | "diamond" | "embeddable" | "iframe" | "image";
8
10
  export declare const toolIsArrow: (type: ElementOrToolType) => type is "arrow";
9
11
  export declare const canHaveArrowheads: (type: ElementOrToolType) => type is "arrow";
@@ -192,7 +192,29 @@ export declare class ElementsDelta implements DeltaContainer<SceneElementsMap> {
192
192
  private static createGetter;
193
193
  private static applyDelta;
194
194
  /**
195
- * Check for visible changes regardless of whether they were removed, added or updated.
195
+ * Whether an element looks different after the delta and the layout that
196
+ * followed it — was applied. The input to history's "skip entries with no
197
+ * visible change" loop.
198
+ *
199
+ * Both sides are first reduced to what actually paints:
200
+ * - a missing or deleted element paints nothing;
201
+ * - an empty text element paints nothing either — unless it carries arrow
202
+ * bindings (an arrow may end at it) or sits on an arrow (an empty label
203
+ * still cuts the arrow's gap);
204
+ * so an empty label's deletion or restoration compares as nothing against
205
+ * nothing. Two painting elements are then compared property by property:
206
+ * - `version`, `versionNonce`, `updated`, `created` are metadata, and
207
+ * `index` is covered by the separate z-order check (`reorderElements`);
208
+ * - `boundElements` is compared as `type:id` references with references to
209
+ * empty labels dropped, so adding or removing an empty label's reference
210
+ * is not visible on its own, and binding repair that rebuilt equal
211
+ * objects is not either;
212
+ * - everything else counts. Nested arrays (`points`, binding fixed points)
213
+ * compare by reference, which can only over-report a change — the safe
214
+ * direction, where undo stops one entry early.
215
+ *
216
+ * `previousElements` holds only `idsToCheck` (see `applyTo`); the label
217
+ * lookups it serves are for elements whose labels are in that set.
196
218
  */
197
219
  private static checkForVisibleDifference;
198
220
  /**
@@ -1,7 +1,11 @@
1
1
  import type { AppState, PendingExcalidrawElements } from "@excalidraw/excalidraw/types";
2
- import { type NonDeleted, type ElementsMap, type ExcalidrawElement, type ExcalidrawFlowchartNodeElement } from "./types";
2
+ import { type NonDeleted, type ElementsMap, type ExcalidrawElement, type ExcalidrawFlowchartNodeElement, type NonDeletedExcalidrawElement } from "./types";
3
3
  import type { Scene } from "./Scene";
4
4
  export type LinkDirection = "up" | "right" | "down" | "left";
5
+ export declare const addNewNodes: (startNode: NonDeleted<ExcalidrawFlowchartNodeElement>, appState: AppState, direction: LinkDirection, scene: Scene, numberOfNodes: number, stickyCrossStart?: number | null) => {
6
+ nodes: NonDeletedExcalidrawElement[];
7
+ crossStart: number;
8
+ };
5
9
  export declare class FlowChartNavigator {
6
10
  isExploring: boolean;
7
11
  private sameLevelNodes;
@@ -31,8 +31,8 @@ export declare const getFrameLikeElements: (allElements: ExcalidrawElementsInclu
31
31
  */
32
32
  export declare const getRootElements: <T extends ExcalidrawElement>(allElements: readonly T[]) => T[];
33
33
  export declare const getElementsInResizingFrame: (allElements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, appState: AppState, elementsMap: ElementsMap) => ExcalidrawElement[];
34
- export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
35
- export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
34
+ export declare const getElementsInNewFrame: (elements: ExcalidrawElementsIncludingDeleted, frame: ExcalidrawFrameLikeElement, elementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawStickyNoteElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
35
+ export declare const omitPartialGroups: (elements: ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, allElementsMap: ElementsMap) => (import("./types").ExcalidrawLinearElement | import("./types").ExcalidrawSelectionElement | import("./types").ExcalidrawRectangleElement | import("./types").ExcalidrawStickyNoteElement | import("./types").ExcalidrawDiamondElement | import("./types").ExcalidrawEllipseElement | import("./types").ExcalidrawEmbeddableElement | import("./types").ExcalidrawIframeElement | import("./types").ExcalidrawImageElement | import("./types").ExcalidrawFrameElement | import("./types").ExcalidrawMagicFrameElement | import("./types").ExcalidrawTextElement | import("./types").ExcalidrawFreeDrawElement)[];
36
36
  export declare const getContainingFrame: (element: ExcalidrawElement, elementsMap: ElementsMap) => ExcalidrawFrameLikeElement | null;
37
37
  /** */
38
38
  export declare const filterElementsEligibleAsFrameChildren: (elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement) => ExcalidrawElement[];
@@ -49,6 +49,7 @@ export * from "./showSelectedShapeActions";
49
49
  export * from "./sizeHelpers";
50
50
  export * from "./sortElements";
51
51
  export * from "./store";
52
+ export * from "./stickyNote";
52
53
  export * from "./textElement";
53
54
  export * from "./textMeasurements";
54
55
  export * from "./textWrapping";
@@ -65,6 +65,8 @@ export declare class LinearElementEditor {
65
65
  }, linearElementEditor: LinearElementEditor, scene: Scene): {
66
66
  didAddPoint: boolean;
67
67
  hitElement: NonDeleted<ExcalidrawElement> | null;
68
+ /** the pointer went down on the arrow's label, grabbing it for a drag */
69
+ hitBoundText: boolean;
68
70
  linearElementEditor: LinearElementEditor | null;
69
71
  };
70
72
  static arePointsEqual<Point extends LocalPoint | GlobalPoint>(point1: Point | null, point2: Point | null): boolean;
@@ -76,6 +78,11 @@ export declare class LinearElementEditor {
76
78
  static getPointAtIndexGlobalCoordinates(element: ExcalidrawLinearElement, indexMaybeFromEnd: number, // -1 for last element
77
79
  elementsMap: ElementsMap): GlobalPoint;
78
80
  static pointFromAbsoluteCoords(element: ExcalidrawLinearElement, absoluteCoords: GlobalPoint, elementsMap: ElementsMap): LocalPoint;
81
+ /**
82
+ * Whether the point at `index` is an interactive handle. Elbow arrows only
83
+ * expose their endpoints; their intermediate route points are not draggable.
84
+ */
85
+ static isPointHandle(element: ExcalidrawLinearElement, index: number): boolean;
79
86
  static getPointIndexUnderCursor(element: ExcalidrawLinearElement, elementsMap: ElementsMap, zoom: AppState["zoom"], x: number, y: number): number;
80
87
  static createPointAt(element: ExcalidrawLinearElement, elementsMap: ElementsMap, scenePointerX: number, scenePointerY: number, gridSize: NullableGridSize): LocalPoint;
81
88
  /**
@@ -114,10 +121,13 @@ export declare class LinearElementEditor {
114
121
  * segment.
115
122
  */
116
123
  static getBoundTextElementCenter: (element: ExcalidrawLinearElement, elementsMap: ElementsMap) => GlobalPoint;
124
+ static handleBoundTextDragging(linearElementEditor: LinearElementEditor, scene: Scene, pointerX: number, pointerY: number): LinearElementEditor | null;
125
+ static getPointAtPathParameter(container: ExcalidrawLinearElement, pathParameter: number, elementsMap: ElementsMap): GlobalPoint | null;
117
126
  static getBoundTextElementPosition: (element: ExcalidrawLinearElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
118
127
  x: number;
119
128
  y: number;
120
129
  };
130
+ private static computeBoundTextElementPosition;
121
131
  static getMinMaxXYWithBoundText: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, elementBounds: Bounds, boundTextElement: ExcalidrawTextElementWithContainer) => [number, number, number, number, number, number];
122
132
  static getElementAbsoluteCoords: (element: ExcalidrawLinearElement, elementsMap: ElementsMap, includeBoundText?: boolean) => [number, number, number, number, number, number];
123
133
  static moveFixedSegment(linearElement: LinearElementEditor, index: number, x: number, y: number, scene: Scene): Pick<LinearElementEditor, "segmentMidPointHoveredCoords" | "initialState">;
@@ -1,6 +1,6 @@
1
1
  import type { Mutable } from "@excalidraw/common/utility-types";
2
2
  import type { ElementsMap, ExcalidrawElement } from "./types";
3
- export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "updated">;
3
+ export type ElementUpdate<TElement extends ExcalidrawElement> = Omit<Partial<TElement>, "id" | "updated" | "created">;
4
4
  /**
5
5
  * This function tracks updates of text elements for the purposes for collaboration.
6
6
  * The version is used to compare updates when more than one user is working in
@@ -1,9 +1,29 @@
1
1
  import type { MarkOptional } from "@excalidraw/common/utility-types";
2
- import type { ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, ExcalidrawLineElement } from "./types";
3
- export type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "index" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity" | "customData">;
2
+ import type { ExcalidrawImageElement, ExcalidrawTextElement, ExcalidrawLinearElement, ExcalidrawGenericElement, NonDeleted, TextAlign, VerticalAlign, Arrowhead, ExcalidrawFreeDrawElement, FontFamilyValues, ExcalidrawTextContainer, ExcalidrawFrameElement, ExcalidrawEmbeddableElement, ExcalidrawMagicFrameElement, ExcalidrawIframeElement, ElementsMap, ExcalidrawArrowElement, ExcalidrawElbowArrowElement, ExcalidrawLineElement, ExcalidrawStickyNoteElement } from "./types";
3
+ export type ElementConstructorOpts = MarkOptional<Omit<ExcalidrawGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "frameId" | "index" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "strokeStyle" | "fillStyle" | "strokeColor" | "backgroundColor" | "roughness" | "strokeWidth" | "roundness" | "locked" | "opacity" | "customData" | "created">;
4
4
  export declare const newElement: (opts: {
5
5
  type: ExcalidrawGenericElement["type"];
6
6
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawGenericElement>;
7
+ /**
8
+ * Style invariants of a sticky note: never-transparent colors, solid fill.
9
+ * Applied by the constructor and by every normalization pass. Returns the
10
+ * same object when nothing needs fixing.
11
+ */
12
+ export declare const normalizeStickyNoteStyle: <T extends ExcalidrawStickyNoteElement>(element: T) => T;
13
+ /**
14
+ * Geometry invariants of a *finalized* sticky note: minimum size and
15
+ * `baseHeight ≤ height`. Deliberately not part of the constructor — a
16
+ * pointer-down draft starts at 0×0 like every other tool and is previewed at
17
+ * its true dragged size; pointer-up, restore, the skeleton path and the
18
+ * action post-passes enforce this.
19
+ */
20
+ export declare const normalizeStickyNoteGeometry: <T extends ExcalidrawStickyNoteElement>(element: T) => T;
21
+ /** all sticky note invariants (style + finalized geometry) */
22
+ export declare const normalizeStickyNote: <T extends ExcalidrawStickyNoteElement>(element: T) => T;
23
+ export declare const newStickyNoteElement: (opts: {
24
+ type: "stickynote";
25
+ baseHeight?: number;
26
+ } & ElementConstructorOpts) => NonDeleted<ExcalidrawStickyNoteElement>;
7
27
  export declare const newEmbeddableElement: (opts: {
8
28
  type: "embeddable";
9
29
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawEmbeddableElement>;
@@ -39,6 +59,8 @@ export declare const newTextElement: (opts: {
39
59
  containerId?: ExcalidrawTextContainer["id"] | null;
40
60
  lineHeight?: ExcalidrawTextElement["lineHeight"];
41
61
  autoResize?: ExcalidrawTextElement["autoResize"];
62
+ labelPosition?: ExcalidrawTextElement["labelPosition"];
63
+ baseFontSize?: ExcalidrawTextElement["baseFontSize"];
42
64
  } & ElementConstructorOpts) => NonDeleted<ExcalidrawTextElement>;
43
65
  export declare const refreshTextDimensions: (textElement: ExcalidrawTextElement, container: ExcalidrawTextContainer | null, elementsMap: ElementsMap, text?: string) => {
44
66
  x: number;
@@ -1,5 +1,11 @@
1
1
  import type { AppState, Offsets, Zoom } from "@excalidraw/excalidraw/types";
2
2
  import type { ElementsMap, ExcalidrawElement } from "./types";
3
+ export type VerticalResizeAnchor = "top" | "bottom" | "center";
4
+ /** Keeps the chosen edge or center fixed when an element's height changes. */
5
+ export declare const getPositionAfterHeightChange: (element: Pick<ExcalidrawElement, "x" | "y" | "height" | "angle">, nextHeight: number, anchor?: VerticalResizeAnchor) => {
6
+ x: number;
7
+ y: number;
8
+ };
3
9
  export declare const INVISIBLY_SMALL_ELEMENT_SIZE = 0.1;
4
10
  export declare const isInvisiblySmallElement: (element: ExcalidrawElement) => boolean;
5
11
  export declare const isElementInViewport: (element: ExcalidrawElement, width: number, height: number, viewTransformations: {
@@ -0,0 +1,183 @@
1
+ import type { Scene } from "./Scene";
2
+ import type { VerticalResizeAnchor } from "./sizeHelpers";
3
+ import type { TransformHandleDirection } from "./transformHandles";
4
+ import type { ElementsMap, ExcalidrawElement, ExcalidrawStickyNoteElement, ExcalidrawTextElement, NonDeletedExcalidrawElement } from "./types";
5
+ export type StickyNoteRenderPoint = {
6
+ x: number;
7
+ y: number;
8
+ };
9
+ export type StickyNotePathCommand = {
10
+ type: "move";
11
+ point: StickyNoteRenderPoint;
12
+ } | {
13
+ type: "line";
14
+ point: StickyNoteRenderPoint;
15
+ } | {
16
+ type: "quadratic";
17
+ control: StickyNoteRenderPoint;
18
+ point: StickyNoteRenderPoint;
19
+ };
20
+ export declare const normalizeStickyNoteStrokeColor: (strokeColor: string | null | undefined) => string;
21
+ export declare const normalizeStickyNoteBackgroundColor: (backgroundColor: string | null | undefined) => string;
22
+ /**
23
+ * The update that applies a picked color to an element under the sticky
24
+ * note policy: a note is always filled and its label — the visible text,
25
+ * which the note's own `strokeColor` seeds — never goes transparent. Every
26
+ * color surface (actions, both eyedroppers, paste styles, bind) routes
27
+ * through this instead of re-deriving the rule.
28
+ */
29
+ /**
30
+ * The element a color pick on `element` lands on. A note's label has no fill
31
+ * of its own, so a background pick on the label — the styles panel while
32
+ * editing it — goes to the note; everything else colors itself.
33
+ */
34
+ export declare const getColorTargetElement: (element: ExcalidrawElement, property: "strokeColor" | "backgroundColor", elementsMap: ElementsMap) => ExcalidrawElement;
35
+ export declare const getColorUpdate: (element: ExcalidrawElement, property: "strokeColor" | "backgroundColor", color: string, elementsMap: ElementsMap) => {
36
+ strokeColor: string;
37
+ } | {
38
+ backgroundColor: string;
39
+ };
40
+ /**
41
+ * A note's ink is one color: the container's `strokeColor` — the seed for a
42
+ * new label and what the creation-date footer paints with — and its label's.
43
+ * Run after a property write to copy the side that changed onto the other;
44
+ * when both changed, or neither (data that drifted), the label wins: it is
45
+ * the text the user styled. A transparent label always takes the note's
46
+ * color. Returns the same array when nothing needs to change.
47
+ */
48
+ export declare const syncStickyNoteInk: <T extends ExcalidrawElement>(elements: readonly T[], prevElementsMap: ElementsMap) => readonly T[];
49
+ export declare const getStickyNoteCornerRadius: (element: ExcalidrawStickyNoteElement) => number;
50
+ export declare const getStickyNoteRenderPoints: (element: ExcalidrawStickyNoteElement, { offsetX, offsetY, seedOffset, }?: {
51
+ offsetX?: number;
52
+ offsetY?: number;
53
+ seedOffset?: number;
54
+ }) => StickyNoteRenderPoint[];
55
+ export declare const getStickyNotePathCommands: (element: ExcalidrawStickyNoteElement, { shadow }?: {
56
+ shadow?: boolean;
57
+ }) => StickyNotePathCommand[];
58
+ export declare const normalizeStickyNoteFontSize: (fontSize: number) => number;
59
+ /** whether the text element is the label of a sticky note */
60
+ export declare const isStickyNoteBoundText: (textElement: ExcalidrawTextElement, elementsMap: ElementsMap) => boolean;
61
+ /**
62
+ * The font size the user picked: the ceiling the auto-fit shrinks from for a
63
+ * sticky note label, plain `fontSize` for any other text.
64
+ *
65
+ * Container-aware on purpose — generic binding repair (duplication, history)
66
+ * rewrites `containerId` without touching the ceiling, so a numeric
67
+ * `baseFontSize` alone does not prove the text is still sticky-bound.
68
+ */
69
+ export declare const getBaseFontSize: (textElement: ExcalidrawTextElement, elementsMap: ElementsMap) => number;
70
+ /** the update that applies a user-picked font size (see `getBaseFontSize`) */
71
+ export declare const getBaseFontSizeUpdate: (textElement: ExcalidrawTextElement, fontSize: number, elementsMap: ElementsMap) => {
72
+ fontSize: number;
73
+ } | {
74
+ baseFontSize: number;
75
+ };
76
+ /**
77
+ * The creation-date label: absolute, so painting needs no clock and exports
78
+ * don't go stale, and short ("7 Sep") while the year is the current one.
79
+ * `null` when the note has no usable timestamp (files restored without one).
80
+ * Fixed English in the viewer's local time zone — the element package has no
81
+ * locale, and the footer is chosen by width bucket rather than measured.
82
+ */
83
+ export declare const getStickyNoteDateLabel: (created: ExcalidrawStickyNoteElement["created"], { short, now }?: {
84
+ short?: boolean;
85
+ now?: number;
86
+ }) => string | null;
87
+ /**
88
+ * What the footer paints and where, in note-local coordinates — shared by the
89
+ * canvas and SVG renderers, which take the font and opacity from
90
+ * `STICKY_NOTE_FOOTER`. `null` for the 0×0 creation draft and anything under
91
+ * the data floor, where the band would overlap the top padding.
92
+ */
93
+ export declare const getStickyNoteFooter: (element: Pick<ExcalidrawStickyNoteElement, "created" | "width" | "height">, now?: number) => {
94
+ text: string;
95
+ x: number;
96
+ y: number;
97
+ } | null;
98
+ /**
99
+ * The smallest note the UI lets a user create or resize to: one line at the
100
+ * label's font ceiling plus padding (and, vertically, the footer), never below
101
+ * `STICKY_NOTE_MIN_SIZE`. Without the font term a fresh note would grow on
102
+ * the very first keystroke. Data-level passes (restore, action post-passes)
103
+ * only enforce the constant floor — the layout grows a note as needed.
104
+ */
105
+ export declare const getStickyNoteMinSize: ({ fontSize, fontFamily, }: Pick<ExcalidrawTextElement, "fontSize" | "fontFamily">) => {
106
+ width: number;
107
+ height: number;
108
+ };
109
+ export type StickyNoteLayoutAnchor = VerticalResizeAnchor;
110
+ export type StickyNoteLayoutOpts = {
111
+ /** unwrapped text to lay out; defaults to the label's `originalText` */
112
+ originalText?: string;
113
+ /**
114
+ * absolute base-height intent — the gesture-start value to preserve, or the
115
+ * height a resize asked for. Omitted = keep the note's live `baseHeight`
116
+ * (typing, style changes, restore).
117
+ */
118
+ baseHeight?: number;
119
+ /**
120
+ * absolute font-ceiling intent (a proportional resize passes
121
+ * `gesture-start ceiling × scale`). Omitted = keep the label's live ceiling.
122
+ * Never a multiplier on the live value — that compounds across pointer-moves.
123
+ */
124
+ baseFontSize?: number;
125
+ /** the edge that stays put when the content correction changes the height */
126
+ anchor?: StickyNoteLayoutAnchor;
127
+ };
128
+ export type StickyNoteLayout = {
129
+ container: Pick<ExcalidrawStickyNoteElement, "x" | "y" | "width" | "height" | "baseHeight">;
130
+ text: Pick<ExcalidrawTextElement, "text" | "fontSize" | "baseFontSize" | "width" | "height" | "x" | "y" | "angle"> | null;
131
+ };
132
+ /**
133
+ * The single source of truth for a sticky note's geometry: wraps the label at
134
+ * the note's width, fits the font under the ceiling, grows the note past
135
+ * `baseHeight` only when the text still overflows at the minimum size, and
136
+ * positions the label inside. Pure — returns the updates for both elements.
137
+ */
138
+ export declare const getStickyNoteLayout: (container: ExcalidrawStickyNoteElement, textElement: ExcalidrawTextElement | null, opts?: StickyNoteLayoutOpts) => StickyNoteLayout;
139
+ /**
140
+ * Resize intents for a sticky note — the §3.3 matrix of the plan. Every value
141
+ * is absolute and derived from the gesture-start snapshot on each pointer-move,
142
+ * so releasing Shift (or Alt) mid-gesture restores the original base height
143
+ * and ceiling instead of keeping values a previous move scaled.
144
+ *
145
+ * - width-only gestures (free E/W, Stats W) preserve the base height
146
+ * - height-changing gestures use the requested height as the new base
147
+ * - proportional gestures (Shift on any handle, aspect-locked multi-select,
148
+ * Stats group) additionally scale the font ceiling with the note
149
+ * - flips preserve everything
150
+ * - the content correction anchors at the edge the gesture holds still
151
+ */
152
+ export declare const getStickyNoteResizeIntent: (
153
+ /** the note with the requested geometry already applied */
154
+ container: ExcalidrawStickyNoteElement, originalElementsMap: ElementsMap, handleDirection: TransformHandleDirection, { proportional, fromCenter, flip, }: {
155
+ proportional: boolean;
156
+ fromCenter: boolean;
157
+ flip?: boolean;
158
+ }) => Pick<StickyNoteLayoutOpts, "baseHeight" | "baseFontSize" | "anchor">;
159
+ /**
160
+ * Applies `getStickyNoteLayout` to a live scene, then runs the bound-arrow
161
+ * pass unless the caller already owns one (`bindings: false`) or needs to
162
+ * forward its context (`bindings: { simultaneouslyUpdated }` — arrows resized
163
+ * in the same gesture must not be moved by the pass, `updateBoundElements`
164
+ * skips them only when told).
165
+ */
166
+ export declare const updateStickyNoteLayout: (container: ExcalidrawStickyNoteElement, scene: Scene, { text, bindings, ...layoutOpts }?: StickyNoteLayoutOpts & {
167
+ /** the label to lay out when it is an uncommitted clone (font actions clone before install) */
168
+ text?: ExcalidrawTextElement | null;
169
+ bindings?: {
170
+ simultaneouslyUpdated?: readonly NonDeletedExcalidrawElement[];
171
+ } | false;
172
+ }) => StickyNoteLayout;
173
+ /**
174
+ * Applies `getStickyNoteLayout` inside an immutable elements array (property
175
+ * actions, paste styles, restore): the notes among `affectedIds` — or the
176
+ * notes whose labels are — get both halves merged into their clones. Elements
177
+ * that need no change keep their identity and version; when `prevElementsMap`
178
+ * is given, notes whose layout inputs did not change skip the fit entirely.
179
+ * Bound arrows are the caller's job once the result is installed.
180
+ */
181
+ export declare const relayoutStickyNotes: <T extends ExcalidrawElement>(elements: readonly T[], affectedIds: ReadonlySet<ExcalidrawElement["id"]>, opts?: {
182
+ prevElementsMap?: ElementsMap;
183
+ }) => readonly T[];
@@ -4,7 +4,7 @@ import type { Scene } from "./Scene";
4
4
  import type { MaybeTransformHandleType } from "./transformHandles";
5
5
  import type { ElementsMap, ExcalidrawElement, ExcalidrawElementType, ExcalidrawTextContainer, ExcalidrawTextElement, ExcalidrawTextElementWithContainer, NonDeleted } from "./types";
6
6
  export declare const redrawTextBoundingBox: (textElement: ExcalidrawTextElement, container: ExcalidrawElement | null, scene: Scene) => void;
7
- export declare const handleBindTextResize: (container: ExcalidrawElement, scene: Scene, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean, shouldResizeFromCenter?: boolean) => void;
7
+ export declare const handleBindTextResize: (container: ExcalidrawElement, scene: Scene, transformHandleType: MaybeTransformHandleType, shouldMaintainAspectRatio?: boolean, shouldResizeFromCenter?: boolean, flipByY?: boolean) => void;
8
8
  export declare const computeBoundTextPosition: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, elementsMap: ElementsMap) => {
9
9
  x: number;
10
10
  y: number;
@@ -40,4 +40,5 @@ export declare const getBoundTextMaxWidth: (container: ExcalidrawElement, boundT
40
40
  export declare const getBoundTextMaxHeight: (container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer) => number;
41
41
  /** retrieves text from text elements and concatenates to a single string */
42
42
  export declare const getTextFromElements: (elements: readonly ExcalidrawElement[], separator?: string) => string;
43
+ export declare const DEFAULT_BOUND_TEXT_LABEL_POSITION = 0.5;
43
44
  export {};