noteloom 0.3.2 → 0.4.0

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 (104) hide show
  1. package/README.md +344 -53
  2. package/bin/noteloom.mjs +139 -0
  3. package/dist/canvas.cjs +2 -0
  4. package/dist/canvas.cjs.map +1 -0
  5. package/dist/canvas.d.ts +2 -0
  6. package/dist/canvas.js +5 -0
  7. package/dist/canvas.js.map +1 -0
  8. package/dist/collab.cjs +2 -0
  9. package/dist/collab.cjs.map +1 -0
  10. package/dist/collab.d.ts +19 -0
  11. package/dist/collab.js +379 -0
  12. package/dist/collab.js.map +1 -0
  13. package/dist/comments.cjs +2 -0
  14. package/dist/comments.cjs.map +1 -0
  15. package/dist/comments.d.ts +17 -0
  16. package/dist/comments.js +19 -0
  17. package/dist/comments.js.map +1 -0
  18. package/dist/index.cjs +2 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.ts +392 -32
  21. package/dist/index.js +3983 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/persistence.cjs +2 -0
  24. package/dist/persistence.cjs.map +1 -0
  25. package/dist/persistence.d.ts +11 -0
  26. package/dist/persistence.js +12 -0
  27. package/dist/persistence.js.map +1 -0
  28. package/dist/shared/CommentAvatar-TKqsM8vG.js +53 -0
  29. package/dist/shared/CommentAvatar-TKqsM8vG.js.map +1 -0
  30. package/dist/shared/CommentAvatar-V457IgoQ.cjs +2 -0
  31. package/dist/shared/CommentAvatar-V457IgoQ.cjs.map +1 -0
  32. package/dist/shared/CommentThreadCard-CAJ3oPdr.cjs +2 -0
  33. package/dist/shared/CommentThreadCard-CAJ3oPdr.cjs.map +1 -0
  34. package/dist/shared/CommentThreadCard-Cxf8GwHJ.js +213 -0
  35. package/dist/shared/CommentThreadCard-Cxf8GwHJ.js.map +1 -0
  36. package/dist/shared/CommentsPanel-BwVVyMOC.js +76 -0
  37. package/dist/shared/CommentsPanel-BwVVyMOC.js.map +1 -0
  38. package/dist/shared/CommentsPanel-CES4uzye.cjs +2 -0
  39. package/dist/shared/CommentsPanel-CES4uzye.cjs.map +1 -0
  40. package/dist/shared/VersionHistory-Bg6fufP5.js +1120 -0
  41. package/dist/shared/VersionHistory-Bg6fufP5.js.map +1 -0
  42. package/dist/shared/VersionHistory-DELa2Wbq.cjs +12 -0
  43. package/dist/shared/VersionHistory-DELa2Wbq.cjs.map +1 -0
  44. package/dist/shared/VoiceListeningIndicator-BOfVmLK0.js +338 -0
  45. package/dist/shared/VoiceListeningIndicator-BOfVmLK0.js.map +1 -0
  46. package/dist/shared/VoiceListeningIndicator-DNX8JlQM.cjs +2 -0
  47. package/dist/shared/VoiceListeningIndicator-DNX8JlQM.cjs.map +1 -0
  48. package/dist/shared/fieldRegistry-BoYyW3GH.cjs +2 -0
  49. package/dist/shared/fieldRegistry-BoYyW3GH.cjs.map +1 -0
  50. package/dist/shared/fieldRegistry-PjJWXFoB.js +223 -0
  51. package/dist/shared/fieldRegistry-PjJWXFoB.js.map +1 -0
  52. package/dist/shared/icons-C1_s0jKK.js +4269 -0
  53. package/dist/shared/icons-C1_s0jKK.js.map +1 -0
  54. package/dist/shared/icons-DtCsXuU6.cjs +3531 -0
  55. package/dist/shared/icons-DtCsXuU6.cjs.map +1 -0
  56. package/dist/shared/index-B9jyyL8u.js +2145 -0
  57. package/dist/shared/index-B9jyyL8u.js.map +1 -0
  58. package/dist/shared/index-D9WEXpYM.cjs +2 -0
  59. package/dist/shared/index-D9WEXpYM.cjs.map +1 -0
  60. package/dist/shared/indexedDbPersistence-BKlGPFTP.js +112 -0
  61. package/dist/shared/indexedDbPersistence-BKlGPFTP.js.map +1 -0
  62. package/dist/shared/indexedDbPersistence-BWJ1h5Vp.cjs +2 -0
  63. package/dist/shared/indexedDbPersistence-BWJ1h5Vp.cjs.map +1 -0
  64. package/dist/shared/leafBlockFactory-A9eUhSe-.js +335 -0
  65. package/dist/shared/leafBlockFactory-A9eUhSe-.js.map +1 -0
  66. package/dist/shared/leafBlockFactory-Dp382eP8.cjs +2 -0
  67. package/dist/shared/leafBlockFactory-Dp382eP8.cjs.map +1 -0
  68. package/dist/shared/serialize-DWEfk0vU.cjs +3 -0
  69. package/dist/shared/serialize-DWEfk0vU.cjs.map +1 -0
  70. package/dist/shared/serialize-T9Odwx24.js +86 -0
  71. package/dist/shared/serialize-T9Odwx24.js.map +1 -0
  72. package/dist/shared/starter-kit-CY5wzYDf.js +4980 -0
  73. package/dist/shared/starter-kit-CY5wzYDf.js.map +1 -0
  74. package/dist/shared/starter-kit-lPN-NpJ5.cjs +27 -0
  75. package/dist/shared/starter-kit-lPN-NpJ5.cjs.map +1 -0
  76. package/dist/shared/usePopoverEdgeClamp-CDG26jBM.cjs +2 -0
  77. package/dist/shared/usePopoverEdgeClamp-CDG26jBM.cjs.map +1 -0
  78. package/dist/shared/usePopoverEdgeClamp-gmFm0CnI.js +109 -0
  79. package/dist/shared/usePopoverEdgeClamp-gmFm0CnI.js.map +1 -0
  80. package/dist/shared/useServiceWorkerUpdate-BduabXv6.js +94 -0
  81. package/dist/shared/useServiceWorkerUpdate-BduabXv6.js.map +1 -0
  82. package/dist/shared/useServiceWorkerUpdate-DQboGesi.cjs +2 -0
  83. package/dist/shared/useServiceWorkerUpdate-DQboGesi.cjs.map +1 -0
  84. package/dist/starter-kit.cjs +2 -0
  85. package/dist/starter-kit.cjs.map +1 -0
  86. package/dist/starter-kit.d.ts +9 -0
  87. package/dist/starter-kit.js +10 -0
  88. package/dist/starter-kit.js.map +1 -0
  89. package/dist/style.css +3529 -3200
  90. package/dist/versions.cjs +2 -0
  91. package/dist/versions.cjs.map +1 -0
  92. package/dist/versions.d.ts +11 -0
  93. package/dist/versions.js +13 -0
  94. package/dist/versions.js.map +1 -0
  95. package/dist/voice.cjs +2 -0
  96. package/dist/voice.cjs.map +1 -0
  97. package/dist/voice.d.ts +7 -0
  98. package/dist/voice.js +8 -0
  99. package/dist/voice.js.map +1 -0
  100. package/package.json +159 -92
  101. package/dist/noteloom.cjs +0 -3209
  102. package/dist/noteloom.cjs.map +0 -1
  103. package/dist/noteloom.es.js +0 -14622
  104. package/dist/noteloom.es.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ "use strict";const d=require("react/jsx-runtime"),l=require("react"),E=require("./icons-DtCsXuU6.cjs"),gt=require("./leafBlockFactory-Dp382eP8.cjs");function Pn(e){const r=E.useEditorStore(),t=l.useCallback(o=>r.subscribe(e,o),[r,e]),s=l.useCallback(()=>r.getBlock(e),[r,e]);return l.useSyncExternalStore(t,s)}function Or(e){const r=E.useEditorStore(),t=l.useCallback(o=>r.subscribe(e,o),[r,e]),s=l.useCallback(()=>r.getRun(e),[r,e]);return l.useSyncExternalStore(t,s)}function le(e,r,t){l.useEffect(()=>{if(!r)return;const s=Array.isArray(e)?e:[e],o=f=>{var b,m;s.some(I=>I.current&&I.current.contains(f.target))||((m=(b=f.target).closest)==null?void 0:m.call(b,".be-select-popover"))!=null||t()},i=f=>{f.key==="Escape"&&t()};return document.addEventListener("mousedown",o),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",i)}},[r,t,e])}const vn=8,An=.5,_r=.5,Br=4,wt=.15,Lr=8;function Dn(e,r){return Math.hypot(e[0]-r[0],e[1]-r[1])}function Ge(e,r,t){return Math.min(t,Math.max(r,e))}function Fe(e){return Math.round(e*100)/100}const On=.5;function Xr(e){return e.some(([,,r])=>r!==void 0&&r!==On)}function Yr(e,{size:r=vn,thinning:t=An}={}){const s=r/2,o=e.length;if(!Xr(e))return new Array(o).fill(s);const f=new Array(o);let p=0;for(let m=0;m<o;m+=1){if(m>0){const L=Dn(e[m],e[m-1]);p=p*.8+L*.2}const I=Ge(p/Lr,0,1),S=e[m][2]??On,X=.4+.6*Ge(S,0,1),C=Ge(s*X*(1-t*I),s*wt,s);f[m]=C}const b=Math.min(Br,Math.floor(o/2));for(let m=0;m<b;m+=1){const I=(m+1)/(b+1),S=wt+(1-wt)*I;f[m]*=S,f[o-1-m]*=S}return f}function Fr(e,r){const t=e.length;if(t<3||r<=0)return e;const s=new Array(t);s[0]=e[0],s[t-1]=e[t-1];for(let o=1;o<t-1;o+=1){const i=(e[o-1][0]+e[o+1][0])/2,f=(e[o-1][1]+e[o+1][1])/2,p=e[o][0]+(i-e[o][0])*r,b=e[o][1]+(f-e[o][1])*r;s[o]=[p,b,e[o][2]]}return s}function Hr(e,r){const t=e.length,s=new Array(t),o=new Array(t);for(let i=0;i<t;i+=1){const f=e[Math.max(0,i-1)],p=e[Math.min(t-1,i+1)];let b=p[0]-f[0],m=p[1]-f[1];const I=Math.hypot(b,m)||1;b/=I,m/=I;const S=-m,X=b,C=r[i];s[i]=[e[i][0]+S*C,e[i][1]+X*C],o[i]=[e[i][0]-S*C,e[i][1]-X*C]}return{left:s,right:o}}function _n(e){if(e.length===0)return"";let r=`M${Fe(e[0][0])},${Fe(e[0][1])}`;for(let t=1;t<e.length;t+=1)r+=` L${Fe(e[t][0])},${Fe(e[t][1])}`;return r}function Ur([e,r],t){const o=[];for(let i=0;i<12;i+=1){const f=i/12*Math.PI*2;o.push([e+Math.cos(f)*t,r+Math.sin(f)*t])}return`${_n(o)} Z`}function qe(e,r={}){const{size:t=vn,thinning:s=An,smoothing:o=_r}=r;if(!e||e.length===0)return"";const i=[e[0]];for(let S=1;S<e.length;S+=1)Dn(e[S],i[i.length-1])>.1&&i.push(e[S]);if(i.length===1){const S=i[0][2]??.5,X=t/2*(.4+.6*Ge(S,0,1));return Ur(i[0],X)}const f=Yr(i,{size:t,thinning:s}),p=Fr(i,o),{left:b,right:m}=Hr(p,f),I=[...b,...m.slice().reverse()];return`${_n(I)} Z`}function We(e){if(!e||e.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let r=1/0,t=1/0,s=-1/0,o=-1/0;for(const[i,f]of e)i<r&&(r=i),f<t&&(t=f),i>s&&(s=i),f>o&&(o=f);return{minX:r,minY:t,maxX:s,maxY:o}}function Nt(e,r){const t=e.getBoundingClientRect(),s=t.width||1,o=t.height||1,i=Math.min(s/r,o/r),f=(s-r*i)/2,p=(o-r*i)/2;return{rect:t,scale:i,offsetX:f,offsetY:p}}function G(e,r,t={x:0,y:0,size:1e3}){const{rect:s,scale:o,offsetX:i,offsetY:f}=Nt(r,t.size),p=t.x+(e.clientX-s.left-i)/o,b=t.y+(e.clientY-s.top-f)/o;return[p,b]}function St(e,r){return Nt(e,r).scale}function Zr(e,r,t,s){const[o,i]=G(e,r,t),{rect:f,scale:p,offsetX:b,offsetY:m}=Nt(r,s),I=o-(e.clientX-f.left-b)/p,S=i-(e.clientY-f.top-m)/p;return{x:I,y:S}}function wn(e,r){const t=e.x+e.size/2,s=e.y+e.size/2;return{x:t-r/2,y:s-r/2}}function Re(e,r,t,s){if(t<=s)return{x:e,y:r};const o=(s-t)/2;return{x:o,y:o}}function Ne(e,r,t=0){return e.minX-t<=r.maxX&&e.maxX+t>=r.minX&&e.minY-t<=r.maxY&&e.maxY+t>=r.minY}function Ae(e,r,t,s){const o=Math.min(e,t),i=Math.min(r,s),f=Math.abs(t-e),p=Math.abs(s-r);return{x:o,y:i,width:f,height:p}}function Bn(e,r,t,s,o){const i=o*Math.PI/180,f=Math.cos(i),p=Math.sin(i),b=e-t,m=r-s;return[t+b*f-m*p,s+b*p+m*f]}function Ln(e,r,t){return e>=t.x&&e<=t.x+t.width&&r>=t.y&&r<=t.y+t.height}function Kr(e,r,t){const s=t.width/2,o=t.height/2;if(s===0||o===0)return!1;const i=t.x+s,f=t.y+o,p=(e-i)/s,b=(r-f)/o;return p*p+b*b<=1}function Vr(e,r,t,s,o,i){const f=o-t,p=i-s,b=f*f+p*p;if(b===0)return Math.hypot(e-t,r-s);let m=((e-t)*f+(r-s)*p)/b;m=Math.min(1,Math.max(0,m));const I=t+m*f,S=s+m*p;return Math.hypot(e-I,r-S)}function Xn(e,r,t,s,o,i,f){return Vr(e,r,t,s,o,i)<=f}function Yn(e){const{x:r,y:t,width:s,height:o}=e;return[[r+s/2,t],[r+s,t+o/2],[r+s/2,t+o],[r,t+o/2]]}function Fn(e){const{x:r,y:t,width:s,height:o}=e;return[[r+s/2,t],[r+s,t+o],[r,t+o]]}function Hn(e,r=5){const{x:t,y:s,width:o,height:i}=e,f=t+o/2,p=s+i/2,b=o/2,m=i/2,I=.4,S=[],X=Math.PI/r;let C=-Math.PI/2;for(let L=0;L<r*2;L+=1){const P=L%2===0,nt=P?b:b*I,Q=P?m:m*I;S.push([f+Math.cos(C)*nt,p+Math.sin(C)*Q]),C+=X}return S}function Gr(e,r,t){let s=!1;for(let o=0,i=t.length-1;o<t.length;i=o,o+=1){const[f,p]=t[o],[b,m]=t[i];p>r!=m>r&&e<(b-f)*(r-p)/(m-p)+f&&(s=!s)}return s}function Un(e,r,t,s,o=24){const i=t-e,f=s-r,p=Math.hypot(i,f),[b,m]=p===0?[1,0]:[i/p,f/p],I=t-b*o,S=s-m*o,X=-m,C=b,L=o/2;return[[t,s],[I+X*L,S+C*L],[I-X*L,S-C*L]]}function Wr({compute:e,onCommit:r}){const[t,s]=l.useState(null),o=l.useCallback((i,f)=>{i.preventDefault();const p=m=>s(e(m,f)),b=m=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",b),r(e(m,f)),s(null)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",b)},[e,r]);return{dragValue:t,startDrag:o}}const Je=480,Qe=320;function qr({strokes:e=[],shapes:r=[],width:t=Je,height:s=Qe}={}){return function(i){return{block:{id:E.genId(),type:"canvas",parentId:i,contentIds:[],props:{strokes:e,shapes:r,width:t,height:s}},runs:[]}}}function De(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function J(e){return De(e).replace(/"/g,"&quot;")}function Zn(e,r){var o,i;if(!e)return"";if(e.type!=="text"){const f=(o=r==null?void 0:r.inlineRegistry)==null?void 0:o.get(e.type);return f?f.toHTML(e,r):De(e.value??"")}const t=e.marks??{};let s=De(e.value??"");if(t.code&&(s=`<code>${s}</code>`),t.bold&&(s=`<strong>${s}</strong>`),t.italic&&(s=`<em>${s}</em>`),t.underline&&(s=`<u>${s}</u>`),t.strike&&(s=`<s>${s}</s>`),t.subscript&&(s=`<sub>${s}</sub>`),t.superscript&&(s=`<sup>${s}</sup>`),t.color&&(s=`<span style="color:${J(t.color)}">${s}</span>`),t.highlight&&(s=`<span style="background-color:${J(t.highlight)}">${s}</span>`),(i=t.link)!=null&&i.href){const f=t.link.target==="_blank"?' target="_blank" rel="noopener noreferrer"':"";s=`<a href="${J(t.link.href)}"${f}>${s}</a>`}return s}function Jr(e,r){return(e??[]).map(t=>Zn(t,r)).join("")}function Qr(e,r){var t;if(!e)return"";if(e.type!=="text"){const s=(t=r==null?void 0:r.inlineRegistry)==null?void 0:t.get(e.type);return s?s.toPlainText(e,r):e.value??""}return e.value??""}function es(e){return(e??"").replace(/[\\`*_[\]]/g,r=>`\\${r}`)}function ts(e,r){var i,f;if(!e)return"";if(e.type!=="text"){const p=(i=r==null?void 0:r.inlineRegistry)==null?void 0:i.get(e.type);return p?p.toPlainText(e,r):e.value??""}const t=e.marks??{},s=e.value??"";let o=t.code?s:es(s);return t.code&&(o=`\`${o}\``),t.bold&&(o=`**${o}**`),t.italic&&(o=`*${o}*`),t.strike&&(o=`~~${o}~~`),t.underline&&(o=`<u>${o}</u>`),t.subscript&&(o=`<sub>${o}</sub>`),t.superscript&&(o=`<sup>${o}</sup>`),t.color&&(o=`<span style="color:${J(t.color)}">${o}</span>`),t.highlight&&(o=`<span style="background-color:${J(t.highlight)}">${o}</span>`),(f=t.link)!=null&&f.href&&(o=`[${o}](${t.link.href})`),o}function ns(e,r){return(e??[]).map(t=>ts(t,r)).join("")}const rs=1e6;function Te(e,r,t){return typeof e.z=="number"?e.z:r?rs+t:t}function et(e,r){const t=[...e.map((s,o)=>({kind:"stroke",item:s,z:Te(s,!1,o)})),...r.map((s,o)=>({kind:"shape",item:s,z:Te(s,!0,o)}))];return t.sort((s,o)=>s.z-o.z),t}function He(e,r){let t=-1;return e.forEach((s,o)=>{t=Math.max(t,Te(s,!1,o))}),r.forEach((s,o)=>{t=Math.max(t,Te(s,!0,o))}),t+1}function ss(e,r){let t=1/0;return e.forEach((s,o)=>{t=Math.min(t,Te(s,!1,o))}),r.forEach((s,o)=>{t=Math.min(t,Te(s,!0,o))}),t===1/0?0:t-1}const os={diamond:Yn,triangle:Fn,star:Hn};function is(e){const r=e.strokeWidth??8,t=J(e.color);if(e.type==="arrow"){const p=Math.max(16,r*3),m=Un(e.x1,e.y1,e.x2,e.y2,p).map(([I,S])=>`${I},${S}`).join(" ");return`<line x1="${e.x1}" y1="${e.y1}" x2="${e.x2}" y2="${e.y2}" stroke="${t}" stroke-width="${r}"></line><polygon points="${m}" fill="${t}"></polygon>`}const s=e.fillColor?J(e.fillColor):"none";let o;if(e.type==="rectangle")o=`<rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" fill="${s}" stroke="${t}" stroke-width="${r}"></rect>`;else if(e.type==="ellipse"){const p=e.x+e.width/2,b=e.y+e.height/2;o=`<ellipse cx="${p}" cy="${b}" rx="${e.width/2}" ry="${e.height/2}" fill="${s}" stroke="${t}" stroke-width="${r}"></ellipse>`}else if(e.type==="text"){const p=e.fontSize??28,b=De(e.text??"");o=`<foreignObject x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}"><div xmlns="http://www.w3.org/1999/xhtml" style="width:100%;height:100%;overflow:hidden;color:${t};font-size:${p}px;line-height:1.3;white-space:pre-wrap;word-break:break-word;">${b}</div></foreignObject>`}else{const p=os[e.type];if(!p)return"";const b={x:e.x,y:e.y,width:e.width,height:e.height};o=`<polygon points="${p(b).map(([I,S])=>`${I},${S}`).join(" ")}" fill="${s}" stroke="${t}" stroke-width="${r}"></polygon>`}if(!e.rotation)return o;const i=e.x+e.width/2,f=e.y+e.height/2;return`<g transform="rotate(${e.rotation} ${i} ${f})">${o}</g>`}function Kn(e){const{strokes:r=[],shapes:t=[],width:s,height:o}=e.props,i=et(r,t).map(({kind:f,item:p})=>f==="stroke"?`<path fill="${J(p.color)}" d="${qe(p.points,{size:p.size})}"></path>`:is(p)).join("");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000" width="${s}" height="${o}">${i}</svg>`}const Y=1e3,Sn="#1a1a1a",Vn=8,kn=["#1a1a1a","#e03131","#2f9e44","#1971c2","#f08c00"],as=2,cs=40,ls=24,us=6,Ue=160,kt=120,Et=.5,It=4,Ze=1.1,En=4,Ke=24,fs=1,ds=10,In={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},ps=220,hs=60,Tt=28,xs=12,ms=96,$t=10,Cn=15,zn=$t*5;function H(e){return Math.round(e/$t)*$t}function ys(e){return Math.round(e/Cn)*Cn}function bs(){const e=l.useRef(new WeakMap);return r=>{const t=e.current;let s=t.get(r);return s===void 0&&(s=qe(r.points,{size:r.size}),t.set(r,s)),s}}function gs(e,r,t){return{minX:e-t,minY:r-t,maxX:e+t,maxY:r+t}}function Rn(e){let r=0,t=0;for(const o of e.values())r+=o.x,t+=o.y;const s=e.size||1;return{x:r/s,y:t/s}}function ws(e,r,t,s){const o=e.points;if(o.length===1){const[i,f]=o[0];return Math.hypot(r-i,t-f)<=s}for(let i=0;i<o.length-1;i+=1){const[f,p]=o[i],[b,m]=o[i+1];if(Xn(r,t,f,p,b,m,s))return!0}return!1}const Ct=new Set(["rectangle","ellipse","arrow","diamond","triangle","star"]),Gn={diamond:Yn,triangle:Fn,star:Hn},Tn=[{type:"rectangle",label:"Rectangle",Icon:E.SquareIcon},{type:"ellipse",label:"Ellipse",Icon:E.CircleIcon},{type:"arrow",label:"Arrow",Icon:E.ArrowDiagonalIcon},{type:"diamond",label:"Diamond",Icon:E.DiamondIcon},{type:"triangle",label:"Triangle",Icon:E.TriangleIcon},{type:"star",label:"Star",Icon:E.StarIcon}],$n=[{mode:"object",label:"Object Eraser",Icon:E.EraserIcon},{mode:"precise",label:"Precise Eraser",Icon:E.XIcon}];function zt(e,r,t,s){return e.type==="arrow"?{type:"arrow",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,color:r,strokeWidth:t}:{type:e.type,...Ae(e.x1,e.y1,e.x2,e.y2),color:r,strokeWidth:t,fillColor:s}}const Ss=16;function Wn(e,r,t){if(e.type==="arrow")return Xn(r,t,e.x1,e.y1,e.x2,e.y2,Ss);const s={x:e.x,y:e.y,width:e.width,height:e.height};let[o,i]=[r,t];if(e.rotation){const{cx:p,cy:b}=tt(e);[o,i]=Bn(r,t,p,b,-e.rotation)}const f=Gn[e.type];return f?Gr(o,i,f(s)):e.type==="ellipse"?Kr(o,i,s):Ln(o,i,s)}function ks(e,r,t){for(let s=t.length-1;s>=0;s-=1)if(Wn(t[s],e,r))return t[s].id;return null}function je(e,r,t){return e.type==="arrow"?{...e,x1:e.x1+r,y1:e.y1+t,x2:e.x2+r,y2:e.y2+t}:{...e,x:e.x+r,y:e.y+t}}function Oe(e){return e.type==="arrow"?{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),width:Math.abs(e.x2-e.x1),height:Math.abs(e.y2-e.y1)}:{x:e.x,y:e.y,width:e.width,height:e.height}}function tt(e){const r=Oe(e);return{cx:r.x+r.width/2,cy:r.y+r.height/2}}function Pe(e,r,t){return{...e,points:e.points.map(([s,o,i])=>[s+r,o+t,i])}}function Es(e,r){const t=[];let s=[];for(let o=0;o<e.length;o+=1)r.has(o)?(s.length>0&&t.push(s),s=[]):s.push(e[o]);return s.length>0&&t.push(s),t}function qn(e){const r=We(e.points);return{x:r.minX,y:r.minY,width:r.maxX-r.minX,height:r.maxY-r.minY}}function Is(e,r){return e==="stroke"?qn(r):Oe(r)}function Mn(e,r){var f,p;const t=((f=e==null?void 0:e.props)==null?void 0:f.strokes)??[],s=((p=e==null?void 0:e.props)==null?void 0:p.shapes)??[],o=t.find(b=>b.id===r);if(o)return{kind:"stroke",item:o};const i=s.find(b=>b.id===r);return i?{kind:"shape",item:i}:null}function Cs(e,r,t,s){const o=et(t,s);for(let i=o.length-1;i>=0;i-=1){const{kind:f,item:p}=o[i];if(f==="shape"){if(Wn(p,e,r))return{kind:"shape",id:p.id}}else if(Ln(e,r,qn(p)))return{kind:"stroke",id:p.id}}return null}const Ve=24,ve=14;function Mt(e){return{nw:[e.x,e.y],ne:[e.x+e.width,e.y],sw:[e.x,e.y+e.height],se:[e.x+e.width,e.y+e.height]}}const zs={nw:"se",ne:"sw",sw:"ne",se:"nw"},Rs=32;function Jn(e){const r=Oe(e),t=r.x+r.width/2,s=r.y-Rs;if(!e.rotation)return[t,s];const{cx:o,cy:i}=tt(e);return Bn(t,s,o,i,e.rotation)}function Ts(e,r,t){if(!t)return null;if(t.type==="arrow")return Math.hypot(e-t.x1,r-t.y1)<=Ve?"start":Math.hypot(e-t.x2,r-t.y2)<=Ve?"end":null;const[s,o]=Jn(t);if(Math.hypot(e-s,r-o)<=Ve)return"rotate";if(t.rotation)return null;for(const[i,[f,p]]of Object.entries(Mt(t)))if(Math.hypot(e-f,r-p)<=Ve)return i;return null}function Rt(e,r){return r.mode==="arrow-endpoint"?r.endpoint==="start"?{...e,x1:r.x,y1:r.y}:{...e,x2:r.x,y2:r.y}:r.mode==="rotate"?{...e,rotation:r.rotation}:{...e,...Ae(r.fixedX,r.fixedY,r.x,r.y)}}function Nn({shape:e,opacity:r=1}){const t=e.strokeWidth??Vn;let s;if(e.type==="rectangle")s=d.jsx("rect",{x:e.x,y:e.y,width:e.width,height:e.height,fill:e.fillColor??"none",stroke:e.color,strokeWidth:t,opacity:r});else if(e.type==="ellipse")s=d.jsx("ellipse",{cx:e.x+e.width/2,cy:e.y+e.height/2,rx:e.width/2,ry:e.height/2,fill:e.fillColor??"none",stroke:e.color,strokeWidth:t,opacity:r});else if(e.type==="arrow"){const f=Math.max(16,t*3),p=Un(e.x1,e.y1,e.x2,e.y2,f);return d.jsxs("g",{opacity:r,children:[d.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.color,strokeWidth:t}),d.jsx("polygon",{points:p.map(([b,m])=>`${b},${m}`).join(" "),fill:e.color})]})}else if(e.type==="text")s=d.jsx("foreignObject",{x:e.x,y:e.y,width:e.width,height:e.height,opacity:r,children:d.jsx("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{width:"100%",height:"100%",overflow:"hidden",color:e.color,fontSize:e.fontSize??Tt,lineHeight:1.3,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"inherit"},children:e.text})});else{const f=Gn[e.type];if(!f)return null;const p={x:e.x,y:e.y,width:e.width,height:e.height},b=f(p).map(([m,I])=>`${m},${I}`).join(" ");s=d.jsx("polygon",{points:b,fill:e.fillColor??"none",stroke:e.color,strokeWidth:t,opacity:r})}if(!e.rotation)return s;const{cx:o,cy:i}=tt(e);return d.jsx("g",{transform:`rotate(${e.rotation} ${o} ${i})`,children:s})}function $s({id:e}){const r=E.useEditorStore(),t=Pn(e),s=E.useBlockClassName("be-canvas",t),o=bs(),[i,f]=l.useState("pen"),[p,b]=l.useState("object"),[m,I]=l.useState(Sn),[S,X]=l.useState(Vn),[C,L]=l.useState(null),[P,nt]=l.useState(!0),[Q,sr]=l.useState(Tt),[or,ir]=l.useState("rectangle"),[rt,jt]=l.useState(!1),[st,Pt]=l.useState(!1),[ot,vt]=l.useState(!1),[it,At]=l.useState(!1),[at,Dt]=l.useState(!1),[ct,Ot]=l.useState(!1),_t=l.useRef(null),Bt=l.useRef(null),Lt=l.useRef(null),Xt=l.useRef(null),Yt=l.useRef(null),Ft=l.useRef(null),Ht=l.useRef(null),Ut=l.useRef(null),Zt=l.useRef(null),Kt=l.useRef(null),Vt=l.useRef(null),Gt=l.useRef(null),ar=l.useMemo(()=>[_t,Bt],[]),cr=l.useMemo(()=>[Lt,Xt],[]),lr=l.useMemo(()=>[Yt,Ft],[]),ur=l.useMemo(()=>[Ht,Ut],[]),fr=l.useMemo(()=>[Zt,Kt],[]),dr=l.useMemo(()=>[Vt,Gt],[]),Wt=l.useCallback(()=>jt(!1),[]),lt=l.useCallback(()=>Pt(!1),[]),pr=l.useCallback(()=>vt(!1),[]),qt=l.useCallback(()=>At(!1),[]),hr=l.useCallback(()=>Dt(!1),[]),Jt=l.useCallback(()=>Ot(!1),[]);le(ar,rt,Wt),le(cr,st,lt),le(lr,ot,pr),le(ur,it,qt),le(fr,at,hr),le(dr,ct,Jt);const V=l.useRef(null),$e=l.useRef([]),ue=l.useRef(!1),fe=l.useRef(null),[Qt,en]=l.useState(null),ee=l.useRef(new Set),ie=l.useRef(new Set),de=l.useRef(new Map),pe=l.useRef(!1),he=l.useRef(null),[xr,tn]=l.useState(()=>new Set),[mr,nn]=l.useState(()=>new Set),U=l.useRef(null),[rn,ut]=l.useState(null),[R,W]=l.useState(()=>new Set),te=l.useRef(null),[D,sn]=l.useState(null),ne=l.useRef(null),[Me,on]=l.useState(null),ft=l.useRef([]),[M,xe]=l.useState(null),Z=l.useRef(null),[re,dt]=l.useState(null),[$,ae]=l.useState({x:0,y:0,zoom:1}),O=Y/$.zoom,ce=l.useRef(null),K=l.useRef(new Map),se=l.useRef(null),{dragValue:me,startDrag:an}=Wr({compute:(n,a)=>({width:Math.max(Ue,Math.round(a.startWidth+(n.clientX-a.startX))),height:Math.max(kt,Math.round(a.startHeight+(n.clientY-a.startY)))}),onCommit:n=>r.applyOperation(E.updateBlockProps(e,n))}),cn=l.useCallback(n=>{fe.current==null&&(fe.current=requestAnimationFrame(()=>{fe.current=null,en(qe($e.current,{size:n}))}))},[]),ye=l.useCallback(()=>{ue.current=!1,fe.current!=null&&(cancelAnimationFrame(fe.current),fe.current=null),$e.current=[],en(null)},[]),ln=l.useCallback(()=>{var x,h;const n=$e.current;if(n.length===0)return;const a=((x=t==null?void 0:t.props)==null?void 0:x.strokes)??[],c=((h=t==null?void 0:t.props)==null?void 0:h.shapes)??[],u={id:E.genId(),points:n,color:m,size:S,z:He(a,c)};r.applyOperation(E.updateBlockProps(e,{strokes:[...a,u]}))},[r,e,t,m,S]),un=l.useCallback(()=>{he.current==null&&(he.current=requestAnimationFrame(()=>{he.current=null,tn(new Set(ee.current)),nn(new Set(ie.current))}))},[]),_e=l.useCallback((n,a)=>{var g,w;const c=p==="precise"?us:ls,u=gs(n,a,c),x=((g=t==null?void 0:t.props)==null?void 0:g.strokes)??[];for(const y of x){if(p==="precise"){const T=We(y.points);if(!Ne(T,u,y.size/2))continue;let N=de.current.get(y.id);y.points.forEach(([B,_],j)=>{N!=null&&N.has(j)||Math.hypot(B-n,_-a)>c||(N||(N=new Set,de.current.set(y.id,N)),N.add(j))}),N!=null&&N.size&&ee.current.add(y.id);continue}if(ee.current.has(y.id))continue;const k=y.size/2,z=We(y.points);Ne(z,u,k)&&ws(y,n,a,c+k)&&ee.current.add(y.id)}const h=((w=t==null?void 0:t.props)==null?void 0:w.shapes)??[];for(const y of h){if(ie.current.has(y.id))continue;const k=Oe(y),z={minX:k.x,minY:k.y,maxX:k.x+k.width,maxY:k.y+k.height};Ne(z,u)&&ie.current.add(y.id)}un()},[t,p,un]),be=l.useCallback(()=>{pe.current=!1,he.current!=null&&(cancelAnimationFrame(he.current),he.current=null),ee.current=new Set,ie.current=new Set,de.current=new Map,tn(new Set),nn(new Set)},[]),fn=l.useCallback(()=>{var h,g;const n=p!=="precise"&&ee.current.size>0,a=p==="precise"&&de.current.size>0;if(!n&&!a&&ie.current.size===0)return;const c=((h=t==null?void 0:t.props)==null?void 0:h.strokes)??[],u=((g=t==null?void 0:t.props)==null?void 0:g.shapes)??[];let x;if(n)x=c.filter(w=>!ee.current.has(w.id));else if(a){x=[];for(const w of c){const y=de.current.get(w.id);if(!y||y.size===0){x.push(w);continue}Es(w.points,y).forEach((k,z)=>{x.push({...w,id:z===0?w.id:E.genId(),points:k})})}}else x=c;r.applyOperation(E.updateBlockProps(e,{strokes:x,shapes:u.filter(w=>!ie.current.has(w.id))}))},[r,e,t,p]),ge=l.useCallback(()=>{U.current=null,ut(null)},[]),dn=l.useCallback(()=>{var x,h;const n=U.current;if(!n)return;if(n.type==="arrow"){if(n.x1===n.x2&&n.y1===n.y2)return}else{const g=Ae(n.x1,n.y1,n.x2,n.y2);if(g.width===0||g.height===0)return}const a=((x=t==null?void 0:t.props)==null?void 0:x.strokes)??[],c=((h=t==null?void 0:t.props)==null?void 0:h.shapes)??[],u={id:E.genId(),...zt(n,m,S,C),z:He(a,c)};r.applyOperation(E.updateBlockProps(e,{shapes:[...c,u]}))},[r,e,t,m,S,C]),we=l.useCallback(()=>{te.current=null,sn(null)},[]),pn=l.useCallback(()=>{var g,w;const n=te.current;if(!n||n.dx===0&&n.dy===0)return;const a=new Set(n.ids),c=((g=t==null?void 0:t.props)==null?void 0:g.strokes)??[],u=((w=t==null?void 0:t.props)==null?void 0:w.shapes)??[],x=c.map(y=>a.has(y.id)?Pe(y,n.dx,n.dy):y),h=u.map(y=>a.has(y.id)?je(y,n.dx,n.dy):y);r.applyOperation(E.updateBlockProps(e,{strokes:x,shapes:h}))},[r,e,t]),Se=l.useCallback(()=>{ne.current=null,on(null)},[]),hn=l.useCallback(()=>{var g,w;const n=ne.current;if(!n)return;const a=Ae(n.startX,n.startY,n.x,n.y);if(a.width<En&&a.height<En){W(new Set);return}const c={minX:a.x,minY:a.y,maxX:a.x+a.width,maxY:a.y+a.height},u=((g=t==null?void 0:t.props)==null?void 0:g.strokes)??[],x=((w=t==null?void 0:t.props)==null?void 0:w.shapes)??[],h=[];for(const y of u)Ne(We(y.points),c)&&h.push(y.id);for(const y of x){const k=Oe(y),z={minX:k.x,minY:k.y,maxX:k.x+k.width,maxY:k.y+k.height};Ne(z,c)&&h.push(y.id)}W(new Set(h))},[t]),pt=l.useCallback(()=>{R.size!==0&&(ft.current=[...R].map(n=>Mn(t,n)).filter(Boolean))},[t,R]),ht=l.useCallback(()=>{var w,y;const n=ft.current;if(n.length===0)return;const a=((w=t==null?void 0:t.props)==null?void 0:w.strokes)??[],c=((y=t==null?void 0:t.props)==null?void 0:y.shapes)??[];let u=He(a,c);const x=[],h=[],g=[];for(const{kind:k,item:z}of n){const T=E.genId();g.push(T);const N=u;u+=1,k==="stroke"?x.push({...Pe(z,Ke,Ke),id:T,z:N}):h.push({...je(z,Ke,Ke),id:T,z:N})}r.applyOperation(E.updateBlockProps(e,{strokes:[...a,...x],shapes:[...c,...h]})),W(new Set(g)),f("select")},[r,e,t]),ke=l.useCallback(n=>{var k,z;if(R.size===0)return;const a=((k=t==null?void 0:t.props)==null?void 0:k.strokes)??[],c=((z=t==null?void 0:t.props)==null?void 0:z.shapes)??[],u=a.filter(T=>R.has(T.id)),x=c.filter(T=>R.has(T.id)),h=et(u,x);if(h.length===0)return;const g=n?He(a,c):ss(a,c)-h.length,w=new Map(h.map(({item:T},N)=>[T.id,g+N])),y=T=>w.has(T.id)?{...T,z:w.get(T.id)}:T;r.applyOperation(E.updateBlockProps(e,{strokes:a.map(y),shapes:c.map(y)}))},[r,e,t,R]),yr=l.useCallback(()=>ke(!0),[ke]),br=l.useCallback(()=>ke(!1),[ke]),xt=l.useCallback((n,a)=>{xe({id:null,x:n,y:a,width:ps,height:hs,text:"",color:m,fontSize:Q})},[m,Q]),Be=l.useCallback(n=>{xe({id:n.id,x:n.x,y:n.y,width:n.width,height:n.height,text:n.text,color:n.color,fontSize:n.fontSize??Tt})},[]),gr=l.useCallback(()=>{xe(null)},[]),wr=l.useCallback(()=>{var g,w,y;const n=M;if(!n)return;xe(null);const a=((g=t==null?void 0:t.props)==null?void 0:g.shapes)??[],c=n.text;if(!c.trim()){n.id&&(r.applyOperation(E.updateBlockProps(e,{shapes:a.filter(k=>k.id!==n.id)})),W(new Set)),(w=V.current)==null||w.focus();return}const u=n.id??E.genId(),x={id:u,type:"text",x:n.x,y:n.y,width:n.width,height:n.height,text:c,color:n.color,fontSize:n.fontSize},h=n.id?a.map(k=>k.id===n.id?x:k):[...a,x];r.applyOperation(E.updateBlockProps(e,{shapes:h})),W(new Set([u])),f("select"),(y=V.current)==null||y.focus()},[r,e,t,M]),Ee=l.useCallback(()=>{Z.current=null,dt(null)},[]),xn=l.useCallback(()=>{var h;const n=Z.current;if(!n)return;const a=((h=t==null?void 0:t.props)==null?void 0:h.shapes)??[],c=a.find(g=>g.id===n.shapeId);if(!c)return;const u=Rt(c,n);if(u.type!=="arrow"&&(u.width===0||u.height===0))return;const x=a.map(g=>g.id===n.shapeId?u:g);r.applyOperation(E.updateBlockProps(e,{shapes:x}))},[r,e,t]),mn=l.useCallback(n=>{var c;const a=V.current;if((c=a==null?void 0:a.hasPointerCapture)!=null&&c.call(a,n)&&a.releasePointerCapture(n),U.current){ge();return}if(te.current){we();return}if(ne.current){Se();return}if(Z.current){Ee();return}if(ue.current){ye();return}pe.current&&be()},[ge,we,Se,Ee,ye,be]),Sr=l.useCallback(n=>{var u,x,h,g,w;if(n.key==="Backspace"||n.key==="Delete"){if(R.size===0)return;n.preventDefault();const y=((u=t==null?void 0:t.props)==null?void 0:u.strokes)??[],k=((x=t==null?void 0:t.props)==null?void 0:x.shapes)??[];r.applyOperation(E.updateBlockProps(e,{strokes:y.filter(z=>!R.has(z.id)),shapes:k.filter(z=>!R.has(z.id))})),W(new Set);return}if(In[n.key]&&!n.ctrlKey&&!n.metaKey){if(R.size===0)return;n.preventDefault();const y=n.shiftKey?ds:fs,[k,z]=In[n.key],T=k*y,N=z*y,B=((h=t==null?void 0:t.props)==null?void 0:h.strokes)??[],_=((g=t==null?void 0:t.props)==null?void 0:g.shapes)??[];r.applyOperation(E.updateBlockProps(e,{strokes:B.map(j=>R.has(j.id)?Pe(j,T,N):j),shapes:_.map(j=>R.has(j.id)?je(j,T,N):j)}));return}if(n.key==="Enter"&&!n.ctrlKey&&!n.metaKey){if(R.size!==1)return;const[y]=R,k=(((w=t==null?void 0:t.props)==null?void 0:w.shapes)??[]).find(z=>z.id===y&&z.type==="text");if(!k)return;n.preventDefault(),Be(k);return}if(!(n.ctrlKey||n.metaKey))return;const c=n.key.toLowerCase();if(c==="c"){if(R.size===0)return;n.preventDefault(),pt()}else if(c==="v"){if(ft.current.length===0)return;n.preventDefault(),ht()}else if(c==="d"){if(R.size===0)return;n.preventDefault(),pt(),ht()}else if(n.shiftKey&&(c==="]"||c==="[")){if(R.size===0)return;n.preventDefault(),ke(c==="]")}},[r,e,t,R,pt,ht,ke,Be]),oe={x:$.x,y:$.y,size:O},mt=l.useCallback(n=>{const a=V.current;if(!a)return;if(n.preventDefault(),n.ctrlKey||n.metaKey){ae(u=>{const x=n.deltaY<0?Ze:1/Ze,h=Math.min(It,Math.max(Et,u.zoom*x)),g=Y/h,{x:w,y}=Zr(n,a,{x:u.x,y:u.y,size:Y/u.zoom},g);return{...Re(w,y,g,Y),zoom:h}});return}const c=St(a,O);ae(u=>({...u,...Re(u.x+n.deltaX/c,u.y+n.deltaY/c,O,Y)}))},[O]);l.useEffect(()=>{const n=V.current;if(n)return n.addEventListener("wheel",mt,{passive:!1}),()=>n.removeEventListener("wheel",mt)},[mt]);const kr=l.useCallback(()=>{ae(n=>{const a=Math.min(It,n.zoom*Ze),c=Y/a,{x:u,y:x}=wn({x:n.x,y:n.y,size:Y/n.zoom},c);return{...Re(u,x,c,Y),zoom:a}})},[]),Er=l.useCallback(()=>{ae(n=>{const a=Math.max(Et,n.zoom/Ze),c=Y/a,{x:u,y:x}=wn({x:n.x,y:n.y,size:Y/n.zoom},c);return{...Re(u,x,c,Y),zoom:a}})},[]),Ir=l.useCallback(()=>{ae({x:0,y:0,zoom:1})},[]),Cr=l.useCallback(()=>{if(!t)return;const n=Kn(t),a=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,c=new Image;c.onload=()=>{const u=document.createElement("canvas");u.width=t.props.width,u.height=t.props.height;const x=u.getContext("2d");if(!x)return;x.drawImage(c,0,0,u.width,u.height);const h=document.createElement("a");h.href=u.toDataURL("image/png"),h.download="canvas.png",document.body.appendChild(h),h.click(),document.body.removeChild(h)},c.src=a},[t]),zr=l.useCallback(n=>{var w;if(i!=="select")return;const a=V.current;if(!a)return;const[c,u]=G(n,a,{x:$.x,y:$.y,size:O}),x=((w=t==null?void 0:t.props)==null?void 0:w.shapes)??[],h=ks(c,u,x),g=x.find(y=>y.id===h);(g==null?void 0:g.type)==="text"&&(W(new Set([g.id])),Be(g))},[i,$.x,$.y,O,t,Be]),Rr=l.useCallback(n=>{var x,h,g,w,y,k,z,T,N;const a=V.current;if(!a)return;if(n.pointerType==="touch"&&(K.current.set(n.pointerId,{x:n.clientX,y:n.clientY}),K.current.size>=2)){if(n.preventDefault(),(x=a.setPointerCapture)==null||x.call(a,n.pointerId),!se.current){for(const _ of K.current.keys())_!==n.pointerId&&mn(_);const B=Rn(K.current);se.current={startCenterX:B.x,startCenterY:B.y,startViewX:$.x,startViewY:$.y}}return}if(M){if((g=(h=n.target)==null?void 0:h.closest)!=null&&g.call(h,".be-canvas-text-editor"))return;if((y=(w=document.activeElement)==null?void 0:w.blur)==null||y.call(w),i==="text"){let[B,_]=G(n,a,oe);P&&([B,_]=[H(B),H(_)]),xt(B,_),f("text");return}}if(n.button===1){n.preventDefault(),(k=a.setPointerCapture)==null||k.call(a,n.pointerId),ce.current={startClientX:n.clientX,startClientY:n.clientY,startViewX:$.x,startViewY:$.y};return}if(!n.isPrimary||n.button!==void 0&&n.button!==0)return;n.preventDefault(),(z=a.setPointerCapture)==null||z.call(a,n.pointerId);const[c,u]=G(n,a,oe);if(i==="eraser")ee.current=new Set,ie.current=new Set,de.current=new Map,pe.current=!0,_e(c,u);else if(Ct.has(i)){const B=P?H(c):c,_=P?H(u):u;U.current={type:i,x1:B,y1:_,x2:B,y2:_},ut(zt(U.current,m,S,C))}else if(i==="select"){const B=((T=t==null?void 0:t.props)==null?void 0:T.strokes)??[],_=((N=t==null?void 0:t.props)==null?void 0:N.shapes)??[],j=R.size===1?_.find(q=>R.has(q.id))??null:null,Ye=Ts(c,u,j);if(Ye){if(Ye==="rotate"){const{cx:q,cy:Ce}=tt(j),ze=Math.atan2(u-Ce,c-q)*180/Math.PI;Z.current={mode:"rotate",shapeId:j.id,cx:q,cy:Ce,startAngle:ze,startRotation:j.rotation??0,rotation:j.rotation??0}}else if(j.type==="arrow")Z.current={mode:"arrow-endpoint",shapeId:j.id,endpoint:Ye,x:c,y:u};else{const[q,Ce]=Mt(j)[zs[Ye]];Z.current={mode:"rect-corner",shapeId:j.id,fixedX:q,fixedY:Ce,x:c,y:u}}dt(Rt(j,Z.current));return}const Ie=Cs(c,u,B,_);if(Ie){if(n.shiftKey){W(Ce=>{const ze=new Set(Ce);return ze.has(Ie.id)?ze.delete(Ie.id):ze.add(Ie.id),ze});return}const q=R.has(Ie.id)?R:new Set([Ie.id]);W(q),te.current={ids:[...q],startX:c,startY:u,dx:0,dy:0},a.focus()}else ne.current={startX:c,startY:u,x:c,y:u}}else i==="text"?xt(P?H(c):c,P?H(u):u):i==="pen"&&($e.current=[[c,u,n.pressure||.5]],ue.current=!0)},[i,_e,$.x,$.y,O,m,S,C,P,t,R,xt,M,mn]),Tr=l.useCallback(n=>{var c;const a=V.current;if(a){if(n.pointerType==="touch"&&K.current.has(n.pointerId)&&(K.current.set(n.pointerId,{x:n.clientX,y:n.clientY}),se.current)){n.preventDefault();const u=St(a,O),x=Rn(K.current),{startCenterX:h,startCenterY:g,startViewX:w,startViewY:y}=se.current,k=(x.x-h)/u,z=(x.y-g)/u;ae(T=>({...T,...Re(w-k,y-z,O,Y)}));return}if(ce.current){const u=St(a,O),{startClientX:x,startClientY:h,startViewX:g,startViewY:w}=ce.current,y=(n.clientX-x)/u,k=(n.clientY-h)/u;ae(z=>({...z,...Re(g-y,w-k,O,Y)}));return}if(U.current){let[u,x]=G(n,a,oe);P&&([u,x]=[H(u),H(x)]),U.current={...U.current,x2:u,y2:x},ut(zt(U.current,m,S,C));return}if(te.current){const[u,x]=G(n,a,oe),h=te.current;h.dx=P?H(u-h.startX):u-h.startX,h.dy=P?H(x-h.startY):x-h.startY,sn({ids:h.ids,dx:h.dx,dy:h.dy});return}if(ne.current){const[u,x]=G(n,a,oe),h=ne.current;h.x=u,h.y=x,on(Ae(h.startX,h.startY,h.x,h.y));return}if(Z.current){let[u,x]=G(n,a,oe);const h=Z.current;if(h.mode==="rotate"){const y=Math.atan2(x-h.cy,u-h.cx)*180/Math.PI,k=h.startRotation+(y-h.startAngle);h.rotation=P?ys(k):k}else P&&([u,x]=[H(u),H(x)]),h.x=u,h.y=x;const w=(((c=t==null?void 0:t.props)==null?void 0:c.shapes)??[]).find(y=>y.id===h.shapeId);w&&dt(Rt(w,h));return}if(ue.current){const[u,x]=G(n,a,oe);$e.current.push([u,x,n.pressure||.5]),cn(S)}else if(pe.current){const[u,x]=G(n,a,oe);_e(u,x)}}},[cn,_e,$.x,$.y,O,S,m,C,P,t]),v=l.useCallback(n=>{var c;const a=V.current;(c=a==null?void 0:a.hasPointerCapture)!=null&&c.call(a,n.pointerId)&&a.releasePointerCapture(n.pointerId)},[]),$r=l.useCallback(n=>{if(n.pointerType==="touch"&&(K.current.delete(n.pointerId),se.current)){v(n),K.current.size<2&&(se.current=null);return}if(ce.current){v(n),ce.current=null;return}if(U.current){v(n),dn(),ge();return}if(te.current){v(n),pn(),we();return}if(ne.current){v(n),hn(),Se();return}if(Z.current){v(n),xn(),Ee();return}ue.current?(v(n),ln(),ye()):pe.current&&(v(n),fn(),be())},[v,dn,ge,pn,we,hn,Se,xn,Ee,ln,ye,fn,be]),Mr=l.useCallback(n=>{if(n.pointerType==="touch"&&(K.current.delete(n.pointerId),se.current)){v(n),K.current.size<2&&(se.current=null);return}if(ce.current){v(n),ce.current=null;return}if(U.current){v(n),ge();return}if(te.current){v(n),we();return}if(ne.current){v(n),Se();return}if(Z.current){v(n),Ee();return}ue.current?(v(n),ye()):pe.current&&(v(n),be())},[v,ge,we,Se,Ee,ye,be]),Nr=l.useCallback(n=>{var a,c;an(n,{startX:n.clientX,startY:n.clientY,startWidth:((a=t==null?void 0:t.props)==null?void 0:a.width)??Je,startHeight:((c=t==null?void 0:t.props)==null?void 0:c.height)??Qe})},[an,t]),jr=l.useCallback(n=>{var h,g;const a=((h=t==null?void 0:t.props)==null?void 0:h.width)??Je,c=((g=t==null?void 0:t.props)==null?void 0:g.height)??Qe,u=n.shiftKey?4:24;let x;if(n.key==="ArrowLeft")x={width:Math.max(Ue,a-u)};else if(n.key==="ArrowRight")x={width:a+u};else if(n.key==="ArrowUp")x={height:Math.max(kt,c-u)};else if(n.key==="ArrowDown")x={height:c+u};else if(n.key==="Home")x={width:Ue,height:kt};else return;n.preventDefault(),r.applyOperation(E.updateBlockProps(e,x))},[r,e,t]);if(!t)return null;const{strokes:yn=[],shapes:bn=[],width:Pr,height:vr}=t.props,gn=(me==null?void 0:me.width)??Pr,Ar=(me==null?void 0:me.height)??vr,Le=6,Xe=[...R].map(n=>{var x;const a=Mn(t,n);if(!a)return null;let{kind:c,item:u}=a;return(x=D==null?void 0:D.ids)!=null&&x.includes(n)?u=c==="stroke"?Pe(u,D.dx,D.dy):je(u,D.dx,D.dy):c==="shape"&&(re==null?void 0:re.id)===n&&(u=re),{id:n,kind:c,item:u,box:Is(c,u),rotation:c==="shape"?u.rotation:0}}).filter(Boolean),yt=Xe.length===1&&Xe[0].kind==="shape"?Xe[0]:null,F=(yt==null?void 0:yt.item)??null,Dr=F&&F.type==="arrow"?[["start",F.x1,F.y1],["end",F.x2,F.y2]]:F&&!F.rotation?Object.entries(Mt(F)).map(([n,[a,c]])=>[n,a,c]):[],bt=F&&F.type!=="arrow"?Jn(F):null;return d.jsxs("div",{className:s,"data-block-id":e,"data-tool":i,contentEditable:!1,tabIndex:-1,children:[d.jsxs("div",{className:"be-canvas-toolbar",contentEditable:!1,children:[d.jsx("button",{type:"button",className:`be-canvas-toolbar-btn${i==="pen"?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":i==="pen","aria-label":"Pen",title:"Pen",onClick:()=>f("pen"),children:d.jsx(E.PencilIcon,{size:14})}),d.jsxs("div",{className:"be-canvas-picker-wrap",children:[d.jsx("button",{ref:Vt,type:"button",className:`be-canvas-toolbar-btn${i==="eraser"?" be-canvas-toolbar-btn-active":""}`,"aria-haspopup":"true","aria-expanded":ct,"aria-pressed":i==="eraser","aria-label":"Eraser",title:"Eraser",onClick:()=>Ot(n=>!n),children:(()=>{var a;const n=((a=$n.find(c=>c.mode===p))==null?void 0:a.Icon)??E.EraserIcon;return d.jsx(n,{size:14})})()}),ct&&d.jsx("div",{ref:Gt,className:"be-canvas-picker be-canvas-shape-picker",role:"menu","aria-label":"Eraser",children:$n.map(({mode:n,label:a,Icon:c})=>d.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-btn${i==="eraser"&&p===n?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":i==="eraser"&&p===n,"aria-label":a,title:a,onClick:()=>{f("eraser"),b(n),Jt()},children:d.jsx(c,{size:14})},n))})]}),d.jsx("button",{type:"button",className:`be-canvas-toolbar-btn${i==="select"?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":i==="select","aria-label":"Select",title:"Select",onClick:()=>f("select"),children:d.jsx(E.CursorIcon,{size:14})}),d.jsx("button",{type:"button",className:`be-canvas-toolbar-btn${i==="text"?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":i==="text","aria-label":"Text",title:"Text",onClick:()=>f("text"),children:d.jsx(E.TextIcon,{size:14})}),d.jsxs("div",{className:"be-canvas-picker-wrap",children:[d.jsx("button",{ref:Zt,type:"button",className:"be-canvas-toolbar-btn","aria-haspopup":"true","aria-expanded":at,"aria-label":`Font size: ${M?M.fontSize:Q}`,title:"Font size",onClick:()=>Dt(n=>!n),children:d.jsx("span",{className:"be-canvas-font-size-trigger",children:"A"})}),at&&d.jsxs("div",{ref:Kt,className:"be-canvas-picker be-canvas-size-picker",role:"dialog","aria-label":"Font size",children:[d.jsx("span",{className:"be-canvas-size-preview","aria-hidden":"true",children:d.jsx("span",{className:"be-canvas-font-size-preview-letter",style:{fontSize:M?M.fontSize:Q},children:"A"})}),d.jsx("input",{type:"range",className:"be-canvas-size-slider",min:xs,max:ms,value:M?M.fontSize:Q,onChange:n=>{const a=Number(n.target.value);sr(a),M&&xe(c=>c&&{...c,fontSize:a})},"aria-label":"Font size"}),d.jsxs("span",{className:"be-canvas-size-value",children:[M?M.fontSize:Q,"px"]})]})]}),d.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Bring to front",title:"Bring to front",onClick:yr,disabled:R.size===0,children:d.jsx(E.ArrowUpIcon,{size:14})}),d.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Send to back",title:"Send to back",onClick:br,disabled:R.size===0,children:d.jsx(E.ArrowDownIcon,{size:14})}),d.jsx("span",{className:"be-canvas-toolbar-divider"}),d.jsxs("div",{className:"be-canvas-picker-wrap",children:[d.jsx("button",{ref:Ht,type:"button",className:`be-canvas-toolbar-btn${Ct.has(i)?" be-canvas-toolbar-btn-active":""}`,"aria-haspopup":"true","aria-expanded":it,"aria-label":"Shape",title:"Shape",onClick:()=>At(n=>!n),children:(()=>{var a;const n=((a=Tn.find(c=>c.type===(Ct.has(i)?i:or)))==null?void 0:a.Icon)??E.SquareIcon;return d.jsx(n,{size:14})})()}),it&&d.jsx("div",{ref:Ut,className:"be-canvas-picker be-canvas-shape-picker",role:"menu","aria-label":"Shape",children:Tn.map(({type:n,label:a,Icon:c})=>d.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-btn${i===n?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":i===n,"aria-label":a,title:a,onClick:()=>{f(n),ir(n),qt()},children:d.jsx(c,{size:14})},n))})]}),d.jsx("span",{className:"be-canvas-toolbar-divider"}),d.jsxs("div",{className:"be-canvas-picker-wrap",children:[d.jsx("button",{ref:_t,type:"button",className:"be-canvas-toolbar-btn","aria-haspopup":"true","aria-expanded":rt,"aria-label":`Color: ${m}`,title:"Color",onClick:()=>jt(n=>!n),children:d.jsx("span",{className:"be-canvas-color-trigger-dot",style:{backgroundColor:m}})}),rt&&d.jsxs("div",{ref:Bt,className:"be-canvas-picker be-canvas-color-picker",role:"menu","aria-label":"Pen color",children:[kn.map(n=>d.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-swatch${m===n?" be-canvas-toolbar-swatch-active":""}`,style:{backgroundColor:n},"aria-pressed":m===n,"aria-label":`Color ${n}`,title:`Color ${n}`,onClick:()=>{I(n),Wt()}},n)),d.jsx("label",{className:"be-canvas-custom-swatch",title:"Custom color","aria-label":"Custom color",children:d.jsx("input",{type:"color",value:m,onChange:n=>I(n.target.value)})})]})]}),d.jsx("span",{className:"be-canvas-toolbar-divider"}),d.jsxs("div",{className:"be-canvas-picker-wrap",children:[d.jsx("button",{ref:Lt,type:"button",className:"be-canvas-toolbar-btn","aria-haspopup":"true","aria-expanded":st,"aria-label":`Fill: ${C??"none"}`,title:"Fill",onClick:()=>Pt(n=>!n),children:d.jsx("span",{className:`be-canvas-fill-trigger-dot${C?"":" be-canvas-fill-trigger-dot-none"}`,style:C?{backgroundColor:C}:void 0})}),st&&d.jsxs("div",{ref:Xt,className:"be-canvas-picker be-canvas-color-picker",role:"menu","aria-label":"Shape fill",children:[d.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-swatch be-canvas-fill-swatch-none${C===null?" be-canvas-toolbar-swatch-active":""}`,"aria-pressed":C===null,"aria-label":"No fill",title:"No fill",onClick:()=>{L(null),lt()}}),kn.map(n=>d.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-swatch${C===n?" be-canvas-toolbar-swatch-active":""}`,style:{backgroundColor:n},"aria-pressed":C===n,"aria-label":`Fill ${n}`,title:`Fill ${n}`,onClick:()=>{L(n),lt()}},n)),d.jsx("label",{className:"be-canvas-custom-swatch",title:"Custom fill","aria-label":"Custom fill",children:d.jsx("input",{type:"color",value:C??Sn,onChange:n=>L(n.target.value)})})]})]}),d.jsx("span",{className:"be-canvas-toolbar-divider"}),d.jsxs("div",{className:"be-canvas-picker-wrap",children:[d.jsx("button",{ref:Yt,type:"button",className:"be-canvas-toolbar-btn","aria-haspopup":"true","aria-expanded":ot,"aria-label":`Stroke size: ${S}`,title:"Stroke size",onClick:()=>vt(n=>!n),children:d.jsx("span",{className:"be-canvas-size-trigger-dot",style:{width:Math.min(S,16),height:Math.min(S,16)}})}),ot&&d.jsxs("div",{ref:Ft,className:"be-canvas-picker be-canvas-size-picker",role:"dialog","aria-label":"Stroke size",children:[d.jsx("span",{className:"be-canvas-size-preview","aria-hidden":"true",children:d.jsx("span",{className:"be-canvas-size-preview-dot",style:{width:S,height:S}})}),d.jsx("input",{type:"range",className:"be-canvas-size-slider",min:as,max:cs,value:S,onChange:n=>X(Number(n.target.value)),"aria-label":"Stroke size"}),d.jsxs("span",{className:"be-canvas-size-value",children:[S,"px"]})]})]}),d.jsx("span",{className:"be-canvas-toolbar-divider"}),d.jsx("button",{type:"button",className:`be-canvas-toolbar-btn${P?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":P,"aria-label":"Snap to grid",title:P?"Snap to grid: ON — drawing, moving, resizing and rotating align to the dotted grid. Click to turn off.":"Snap to grid: OFF — click to turn on (aligns drawing, moving, resizing and rotating to a grid)",onClick:()=>nt(n=>!n),children:d.jsx(E.MagnetIcon,{size:14})}),d.jsx("span",{className:"be-canvas-toolbar-divider"}),d.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Zoom out",title:"Zoom out",onClick:Er,disabled:$.zoom<=Et,children:"−"}),d.jsxs("button",{type:"button",className:"be-canvas-zoom-label","aria-label":`Zoom: ${Math.round($.zoom*100)}%. Click to reset to 100%.`,title:"Reset zoom to 100%",onClick:Ir,children:[Math.round($.zoom*100),"%"]}),d.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Zoom in",title:"Zoom in",onClick:kr,disabled:$.zoom>=It,children:"+"}),d.jsx("span",{className:"be-canvas-toolbar-divider"}),d.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Export PNG",title:"Export as PNG",onClick:Cr,disabled:yn.length===0&&bn.length===0,children:d.jsx(E.DownloadIcon,{size:14})})]}),d.jsxs("svg",{ref:V,className:"be-canvas-surface",viewBox:`${$.x} ${$.y} ${O} ${O}`,width:gn,height:Ar,tabIndex:-1,onPointerDown:Rr,onPointerMove:Tr,onPointerUp:$r,onPointerCancel:Mr,onDoubleClick:zr,onKeyDown:Sr,children:[P&&d.jsxs(d.Fragment,{children:[d.jsx("defs",{children:d.jsx("pattern",{id:`be-canvas-grid-${e}`,width:zn,height:zn,patternUnits:"userSpaceOnUse",children:d.jsx("circle",{cx:1,cy:1,r:1.5,className:"be-canvas-grid-dot"})})}),d.jsx("rect",{className:"be-canvas-grid-background",x:$.x,y:$.y,width:O,height:O,fill:`url(#be-canvas-grid-${e})`})]}),et(yn,bn).map(({kind:n,item:a})=>{var x,h;if(n==="stroke"){const g=a,y=((x=D==null?void 0:D.ids)==null?void 0:x.includes(g.id))?qe(Pe(g,D.dx,D.dy).points,{size:g.size}):o(g);return d.jsx("path",{d:y,fill:g.color,fillRule:"nonzero",opacity:xr.has(g.id)?.25:1},g.id)}const c=a;let u=c;return(h=D==null?void 0:D.ids)!=null&&h.includes(c.id)?u=je(c,D.dx,D.dy):(re==null?void 0:re.id)===c.id&&(u=re),d.jsx(Nn,{shape:u,opacity:mr.has(c.id)?.25:1},c.id)}),Qt&&d.jsx("path",{d:Qt,fill:m,fillRule:"nonzero"}),rn&&d.jsx(Nn,{shape:rn,opacity:.6}),Xe.map(({id:n,box:a,rotation:c})=>d.jsx("g",{transform:c?`rotate(${c} ${a.x+a.width/2} ${a.y+a.height/2})`:void 0,children:d.jsx("rect",{className:"be-canvas-selection-box",x:a.x-Le,y:a.y-Le,width:a.width+Le*2,height:a.height+Le*2,fill:"none"})},n)),Dr.map(([n,a,c])=>d.jsx("rect",{className:"be-canvas-selection-handle",x:a-ve/2,y:c-ve/2,width:ve,height:ve},n)),bt&&d.jsx("circle",{className:"be-canvas-rotate-handle",cx:bt[0],cy:bt[1],r:ve/2}),Me&&d.jsx("rect",{className:"be-canvas-marquee",x:Me.x,y:Me.y,width:Me.width,height:Me.height}),M&&d.jsx("foreignObject",{x:M.x,y:M.y,width:M.width,height:M.height,children:d.jsx("textarea",{xmlns:"http://www.w3.org/1999/xhtml",ref:n=>n==null?void 0:n.focus(),className:"be-canvas-text-editor",value:M.text,style:{color:M.color,fontSize:M.fontSize},onChange:n=>xe(a=>a&&{...a,text:n.target.value}),onBlur:()=>wr(),onKeyDown:n=>{n.key==="Escape"&&(n.preventDefault(),gr()),n.stopPropagation()}})})]}),d.jsx("div",{className:"be-canvas-resize-handle",onMouseDown:Nr,onKeyDown:jr,role:"slider",tabIndex:0,"aria-label":"Resize canvas (Left/Right for width, Up/Down for height)","aria-valuemin":Ue,"aria-valuenow":gn,contentEditable:!1})]})}const Qn="block",er="inline",tr="extension",jn={blocks:!1,runs:!0,void:!0};function A(e,r){throw new TypeError(`${e}: ${r}`)}function nr(e){(!e||typeof e!="object")&&A("defineBlock","config must be an object");const{name:r,component:t,contentModel:s,isLeaf:o,...i}=e;(typeof r!="string"||!r.trim())&&A("defineBlock","`name` must be a non-empty string"),typeof t!="function"&&A("defineBlock",`block "${r}": \`component\` must be a React component`),s!==void 0&&!(s in jn)&&A("defineBlock",`block "${r}": \`contentModel\` must be 'blocks', 'runs', or 'void' (got ${JSON.stringify(s)})`);const f=o!==void 0?!!o:s===void 0?!1:jn[s];return{...i,...s!==void 0?{contentModel:s}:{},name:r,kind:Qn,component:t,isLeaf:f}}function Ms(e){(!e||typeof e!="object")&&A("defineInline","config must be an object");const{name:r,component:t,atomic:s,isAtomic:o,...i}=e;return(typeof r!="string"||!r.trim())&&A("defineInline","`name` must be a non-empty string"),typeof t!="function"&&A("defineInline",`inline "${r}": \`component\` must be a React component`),(s!==void 0?!!s:o!==void 0?!!o:!0)!==!0&&A("defineInline",`inline "${r}": only atomic inline types are supported today`),{...i,name:r,kind:er,component:t,isAtomic:!0}}function Ns(e){(!e||typeof e!="object")&&A("defineExtension","config must be an object");const{name:r,blocks:t=[],inlineTypes:s=[],keymap:o,onBeforeInput:i,onPaste:f,setup:p,...b}=e;(typeof r!="string"||!r.trim())&&A("defineExtension","`name` must be a non-empty string"),Array.isArray(t)||A("defineExtension",`extension "${r}": \`blocks\` must be an array`),Array.isArray(s)||A("defineExtension",`extension "${r}": \`inlineTypes\` must be an array`),o!==void 0&&(typeof o!="object"||o===null)&&A("defineExtension",`extension "${r}": \`keymap\` must be an object`);for(const[m,I]of[["onBeforeInput",i],["onPaste",f],["setup",p]])I!==void 0&&typeof I!="function"&&A("defineExtension",`extension "${r}": \`${m}\` must be a function`);return{...b,name:r,kind:tr,blocks:t,inlineTypes:s,...o!==void 0?{keymap:o}:{},...i!==void 0?{onBeforeInput:i}:{},...f!==void 0?{onPaste:f}:{},...p!==void 0?{setup:p}:{}}}function js(e){return!!e&&e.kind===Qn}function Ps(e){return!!e&&e.kind===er}function vs(e){return!!e&&e.kind===tr}function rr(e,{registry:r,inlineRegistry:t}){Array.isArray(e)||A("registerExtensions","`extensions` must be an array");for(const s of e.flat(1/0))vs(s)?rr([...s.blocks,...s.inlineTypes],{registry:r,inlineRegistry:t}):js(s)?(r||A("registerExtensions",`no block registry given for "${s.name}"`),r.register(s.name,s)):Ps(s)?(t||A("registerExtensions",`no inline registry given for "${s.name}"`),t.register(s.name,s)):A("registerExtensions","each item must be a defineBlock() / defineInline() result or a defineExtension() bundle (missing `kind`)")}function As(e){const{strokes:r=[],shapes:t=[]}=e.props;return!r.length&&!t.length?"<p></p>":Kn(e)}function Ds(){return""}function Os(){return null}function _s(e,{blockId:r,runId:t,sliceStart:s,sliceEnd:o}){const i=e.getRun(t),f=(i==null?void 0:i.value)??"";e.applyOperation(E.updateRun(t,{value:f.slice(0,s)+f.slice(o)}));const p=gt.insertSiblingAfter(e,r,qr());return gt.insertSiblingAfterAndFocus(e,p,gt.createTextLeafBlock("paragraph")),p}const Bs=nr({name:"canvas",contentModel:"void",component:$s,defaultProps:{strokes:[],shapes:[],width:Je,height:Qe},toHTML:As,toPlainText:Ds,fromHTML:Os,slashCommand:{label:"Canvas",icon:E.ScribbleIcon,keywords:["canvas","draw","drawing","sketch","freehand"],run:_s}});exports.canvasBlockType=Bs;exports.defineBlock=nr;exports.defineExtension=Ns;exports.defineInline=Ms;exports.escapeAttr=J;exports.escapeHTML=De;exports.registerExtensions=rr;exports.runToHTML=Zn;exports.runToPlainText=Qr;exports.runsToHTML=Jr;exports.runsToMarkdown=ns;exports.useBlock=Pn;exports.useOutsideClickAndEscape=le;exports.useRun=Or;
2
+ //# sourceMappingURL=index-D9WEXpYM.cjs.map