@filekit-studio/sketch 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/export.d.mts +1 -1
- package/dist/export.d.ts +1 -1
- package/dist/export.js +26 -26
- package/dist/export.mjs +26 -26
- package/dist/{index-DNRZSQHn.d.mts → index-BBEbI15I.d.mts} +1 -0
- package/dist/{index-DNRZSQHn.d.ts → index-BBEbI15I.d.ts} +1 -0
- package/dist/index.d.mts +111 -39
- package/dist/index.d.ts +111 -39
- package/dist/index.js +92 -92
- package/dist/index.mjs +92 -92
- package/dist/styles.css +12 -18
- package/package.json +1 -1
package/dist/export.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {rgb,PDFDocument}from'pdf-lib';async function yt(t,e,n){if(typeof window>"u")return;let h=typeof n=="string"?n:n?.mimeType;if(typeof t=="string"&&t.startsWith("data:")){let c=document.createElement("a");c.href=t,c.download=e,c.style.display="none",document.body.appendChild(c),c.click(),document.body.removeChild(c);return}let d=t instanceof Blob?t:new Blob([t],{type:h}),u=URL.createObjectURL(d),l=document.createElement("a");l.href=u,l.download=e,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>{URL.revokeObjectURL(u);},1e3);}var wt=[{key:"q",name:"Transparent",stroke:{light:"transparent",dark:"transparent"},fill:{light:"transparent",dark:"transparent"}},{key:"w",name:"White",stroke:{light:"#ffffff",dark:"#ffffff"},fill:{light:"#ffffff",dark:"#ffffff"}},{key:"e",name:"Grey",stroke:{light:"#343a40",dark:"#ced4da"},fill:{light:"#e9ecef",dark:"#2e3238"}},{key:"r",name:"Black / Off-white",stroke:{light:"#1e1e24",dark:"#f8f9fa"},fill:{light:"#1e1e24",dark:"#1e1e24"}},{key:"t",name:"Warm Taupe",stroke:{light:"#865e3c",dark:"#d8c2b0"},fill:{light:"#f4ece4",dark:"#362b28"}},{key:"a",name:"Teal Cyan",stroke:{light:"#0c8599",dark:"#22b8cf"},fill:{light:"#c5f6fa",dark:"#0c383e"}},{key:"s",name:"Sky Blue",stroke:{light:"#1971c2",dark:"#4dabf7"},fill:{light:"#a5d8ff",dark:"#182a4d"}},{key:"d",name:"Royal Purple",stroke:{light:"#6741d9",dark:"#b197fc"},fill:{light:"#d0bfff",dark:"#2b1e4a"}},{key:"f",name:"Violet Magenta",stroke:{light:"#ae3ec9",dark:"#e599f7"},fill:{light:"#eebefa",dark:"#381e3d"}},{key:"g",name:"Crimson Berry",stroke:{light:"#c2255c",dark:"#f783ac"},fill:{light:"#fcc2d7",dark:"#3e1828"}},{key:"z",name:"Green",stroke:{light:"#2f9e44",dark:"#51cf66"},fill:{light:"#b2f2bb",dark:"#143823"}},{key:"x",name:"Mint Emerald",stroke:{light:"#087f5b",dark:"#38d9a9"},fill:{light:"#96f2d7",dark:"#123d33"}},{key:"c",name:"Amber Yellow",stroke:{light:"#f59f00",dark:"#ffd43b"},fill:{light:"#ffec99",dark:"#3d2e14"}},{key:"v",name:"Vivid Orange",stroke:{light:"#f76707",dark:"#ffa94d"},fill:{light:"#ffd8a8",dark:"#3d2014"}},{key:"b",name:"Coral Red",stroke:{light:"#e03131",dark:"#ff8787"},fill:{light:"#ffc9c9",dark:"#2e1418"}}];wt.map(t=>({name:t.name,hex:t.stroke.light,shortcut:t.key}));wt.map(t=>({name:t.name,hex:t.fill.light}));var bt={"#fef08a":{bg:"#fef08a",backSheetBg:"#fefce8",backSheetBorder:"#fde047",mainBorder:"rgba(234, 179, 8, 0.45)",tapeBg:"rgba(254, 249, 195, 0.95)",tapeBorder:"rgba(202, 138, 4, 0.35)",text:"#713f12",sheen:"rgba(255, 255, 255, 0.8)"},"#fde68a":{bg:"#fde68a",backSheetBg:"#fef9d9",backSheetBorder:"#fcd34d",mainBorder:"rgba(245, 158, 11, 0.4)",tapeBg:"rgba(255, 250, 224, 0.95)",tapeBorder:"rgba(217, 119, 6, 0.35)",text:"#78350f",sheen:"rgba(255, 255, 255, 0.8)"},"#bbf7d0":{bg:"#bbf7d0",backSheetBg:"#f0fdf4",backSheetBorder:"#86efac",mainBorder:"rgba(74, 222, 128, 0.45)",tapeBg:"rgba(240, 253, 244, 0.95)",tapeBorder:"rgba(22, 163, 74, 0.35)",text:"#14532d",sheen:"rgba(255, 255, 255, 0.8)"},"#bae6fd":{bg:"#bae6fd",backSheetBg:"#f0f9ff",backSheetBorder:"#7dd3fc",mainBorder:"rgba(56, 189, 248, 0.45)",tapeBg:"rgba(240, 249, 255, 0.95)",tapeBorder:"rgba(2, 132, 199, 0.35)",text:"#0c4a6e",sheen:"rgba(255, 255, 255, 0.8)"},"#fed7aa":{bg:"#fed7aa",backSheetBg:"#fff7ed",backSheetBorder:"#fdba74",mainBorder:"rgba(251, 146, 60, 0.45)",tapeBg:"rgba(255, 247, 237, 0.95)",tapeBorder:"rgba(234, 88, 12, 0.35)",text:"#7c2d12",sheen:"rgba(255, 255, 255, 0.8)"},"#e9d5ff":{bg:"#e9d5ff",backSheetBg:"#faf5ff",backSheetBorder:"#d8b4fe",mainBorder:"rgba(192, 132, 252, 0.45)",tapeBg:"rgba(250, 245, 255, 0.95)",tapeBorder:"rgba(147, 51, 234, 0.35)",text:"#581c87",sheen:"rgba(255, 255, 255, 0.8)"},"#fecdd3":{bg:"#fecdd3",backSheetBg:"#fff1f2",backSheetBorder:"#fda4af",mainBorder:"rgba(251, 113, 133, 0.45)",tapeBg:"rgba(255, 241, 242, 0.95)",tapeBorder:"rgba(225, 29, 72, 0.35)",text:"#881337",sheen:"rgba(255, 255, 255, 0.8)"}},pt={"#fef08a":{bg:"#2b230d",backSheetBg:"#1c1608",backSheetBorder:"#4a3c18",mainBorder:"rgba(250, 204, 21, 0.5)",tapeBg:"rgba(254, 240, 138, 0.18)",tapeBorder:"rgba(250, 204, 21, 0.45)",text:"#fef08a",sheen:"rgba(254, 240, 138, 0.15)"},"#fde68a":{bg:"#2b230d",backSheetBg:"#1c1608",backSheetBorder:"#4a3c18",mainBorder:"rgba(250, 204, 21, 0.5)",tapeBg:"rgba(254, 240, 138, 0.18)",tapeBorder:"rgba(250, 204, 21, 0.45)",text:"#fde68a",sheen:"rgba(254, 240, 138, 0.15)"},"#bbf7d0":{bg:"#10281b",backSheetBg:"#091b11",backSheetBorder:"#1e4730",mainBorder:"rgba(74, 222, 128, 0.5)",tapeBg:"rgba(187, 247, 208, 0.18)",tapeBorder:"rgba(74, 222, 128, 0.45)",text:"#bbf7d0",sheen:"rgba(187, 247, 208, 0.15)"},"#bae6fd":{bg:"#102436",backSheetBg:"#091724",backSheetBorder:"#1d4160",mainBorder:"rgba(56, 189, 248, 0.5)",tapeBg:"rgba(186, 230, 253, 0.18)",tapeBorder:"rgba(56, 189, 248, 0.45)",text:"#bae6fd",sheen:"rgba(186, 230, 253, 0.15)"},"#fed7aa":{bg:"#321d10",backSheetBg:"#201107",backSheetBorder:"#56321c",mainBorder:"rgba(251, 146, 60, 0.5)",tapeBg:"rgba(254, 215, 170, 0.18)",tapeBorder:"rgba(251, 146, 60, 0.45)",text:"#fed7aa",sheen:"rgba(254, 215, 170, 0.15)"},"#e9d5ff":{bg:"#271638",backSheetBg:"#190d24",backSheetBorder:"#462865",mainBorder:"rgba(192, 132, 252, 0.5)",tapeBg:"rgba(233, 213, 255, 0.18)",tapeBorder:"rgba(192, 132, 252, 0.45)",text:"#e9d5ff",sheen:"rgba(233, 213, 255, 0.15)"},"#fecdd3":{bg:"#321319",backSheetBg:"#210b10",backSheetBorder:"#56222b",mainBorder:"rgba(251, 113, 133, 0.5)",tapeBg:"rgba(254, 205, 211, 0.18)",tapeBorder:"rgba(251, 113, 133, 0.45)",text:"#fecdd3",sheen:"rgba(254, 205, 211, 0.15)"}};function mt(t){let e=t.replace("#","").trim();if(e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),e.length===6){let n=parseInt(e,16);if(!isNaN(n))return {r:n>>16&255,g:n>>8&255,b:n&255}}return {r:254,g:240,b:138}}function $t(t,e,n){t/=255,e/=255,n/=255;let h=Math.max(t,e,n),d=Math.min(t,e,n),u=0,l=0,c=(h+d)/2;if(h!==d){let a=h-d;switch(l=c>.5?a/(2-h-d):a/(h+d),h){case t:u=(e-n)/a+(e<n?6:0);break;case e:u=(n-t)/a+2;break;case n:u=(t-e)/a+4;break}u/=6;}return {h:Math.round(u*360),s:Math.round(l*100),l:Math.round(c*100)}}function Q(t,e=false){let n=(t||"#fde68a").toLowerCase();if(e){if(pt[n])return pt[n];let{r:s,g:r,b:i}=mt(n),{h:f,s:o}=$t(s,r,i),y=Math.max(35,o);return {bg:`hsl(${f}, ${Math.round(y*.45)}%, 16%)`,backSheetBg:`hsl(${f}, ${Math.round(y*.5)}%, 10%)`,backSheetBorder:`hsl(${f}, ${Math.round(y*.6)}%, 28%)`,mainBorder:`hsla(${f}, ${Math.round(y*.9)}%, 65%, 0.5)`,tapeBg:`hsla(${f}, ${Math.round(y*.8)}%, 80%, 0.18)`,tapeBorder:`hsla(${f}, ${Math.round(y*.9)}%, 70%, 0.45)`,text:`hsl(${f}, ${Math.round(y*.95)}%, 88%)`,sheen:`hsla(${f}, ${Math.round(y*.8)}%, 85%, 0.15)`}}if(bt[n])return bt[n];let{r:h,g:d,b:u}=mt(n),{h:l,s:c}=$t(h,d,u),a=Math.max(30,c);return {bg:t||"#fde68a",backSheetBg:`hsl(${l}, ${Math.round(a*.75)}%, 94%)`,backSheetBorder:`hsl(${l}, ${Math.round(a*.85)}%, 72%)`,mainBorder:`hsl(${l}, ${Math.round(a*.95)}%, 42%)`,tapeBg:`hsla(${l}, ${Math.round(a*.6)}%, 96%, 0.95)`,tapeBorder:`hsla(${l}, ${Math.round(a*.9)}%, 42%, 0.38)`,text:`hsl(${l}, ${Math.round(a*.95)}%, 16%)`,sheen:"rgba(255, 255, 255, 0.8)"}}var j=[{value:"fuzzy",label:"Handwritten",cssFont:"'Fuzzy Bubbles', cursive, sans-serif"},{value:"comic",label:"Playful",cssFont:"'Comic Neue', cursive, sans-serif"},{value:"patrick",label:"Calm",cssFont:"'Patrick Hand SC', sans-serif"},{value:"sans",label:"Formal",cssFont:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},{value:"mono",label:"Code",cssFont:"'JetBrains Mono', 'Geist Mono', 'Courier New', Consolas, monospace"}];function tt(t){return t==="fuzzy"||t==="edusa"||t==="playpen"||t==="caveat"?j[0]:t==="comic"||t==="handlee"?j[1]:t==="serif"||t==="patrick"?j[2]:t==="sans"?j[3]:t==="mono"?j[4]:j.find(e=>e.value===t)||j[0]}function U(t,e){if(!t||t==="transparent")return t||"transparent";let n=t.trim().toLowerCase();if(e){if(["#000000","#020617","#0f172a","#111827","#18181b","#1e1e24","#1e293b","#27272a","#334155","#343a40","#3f3f46","#475569","#52525b","#1f2937","#242731"].includes(n))return "#f8f9fa";if(["#e2e8f0","#e5e7eb","#cbd5e1","#ced4da"].includes(n))return "#374151";if(["#64748b","#71717a","#78716c","#868e96"].includes(n))return "#ced4da";if(["#94a3b8"].includes(n))return "#64748b";if(["#713f12","#865e3c","#a89984","#78350f","#451a03"].includes(n))return "#ffd43b";if(["#042f2e","#134e4a","#115e59","#0f766e","#0d9488","#0891b2","#0c8599","#14b8a6","#2dd4bf","#164e63","#155e75","#0e7490"].includes(n))return "#22b8cf";if(["#172554","#1e3a8a","#1e40af","#1d4ed8","#2563eb","#1971c2","#0b6eff","#3b82f6","#182a4d","#0c4a6e","#075985","#0369a1","#0284c7"].includes(n))return "#4dabf7";if(["#3b0764","#581c87","#6b21a8","#7e22ce","#9333ea","#a855f7","#2e1065","#4c1d95","#5b21b6","#6741d9","#6965db","#7c3aed","#2b1e4a","#1e1b4b","#312e81","#3730a3","#4338ca","#4f46e5"].includes(n))return "#b197fc";if(["#ae3ec9","#9c36b5","#be185d","#381e3d","#86198f","#701a75"].includes(n))return "#e599f7";if(["#4c0519","#881337","#9f1239","#c2255c","#db2777","#e11d48","#f43f5e","#f472b6","#3e1828","#831843","#9d174d"].includes(n))return "#f783ac";if(["#052e16","#14532d","#166534","#15803d","#16a34a","#2f9e44","#22c55e","#143823"].includes(n))return "#51cf66";if(["#064e3b","#065f46","#047857","#087f5b","#059669","#10b981","#123d33","#022c22"].includes(n))return "#38d9a9";if(["#713f12","#854d0e","#a16207","#ca8a04","#eab308","#f59f00","#d97706","#b45309","#3d2e14","#78350f","#451a03"].includes(n))return "#ffd43b";if(["#451a03","#7c2d12","#9a3412","#c2410c","#ea580c","#f76707","#f97316","#3d2014"].includes(n))return "#ffa94d";if(["#450a0a","#7f1d1d","#991b1b","#b91c1c","#dc2626","#e03131","#ef4444","#2e1418"].includes(n))return "#ff8787";if(["#ffffff","#fff"].includes(n))return "#ffffff"}else {if(["#f8f9fa","#f8fafc","#f3f4f6","#ffffff","#fff"].includes(n))return "#111827";if(["#374151","#475569","#64748b","#ced4da"].includes(n))return "#e2e8f0";if(["#d8c2b0"].includes(n))return "#865e3c";if(["#22b8cf","#5eead4","#2dd4bf"].includes(n))return "#0c8599";if(["#4dabf7","#60a5fa","#74c0fc"].includes(n))return "#1971c2";if(["#b197fc","#a5b4fc","#c4b5fd"].includes(n))return "#6741d9";if(["#e599f7","#c084fc"].includes(n))return "#ae3ec9";if(["#f783ac","#fb7185","#f472b6"].includes(n))return "#c2255c";if(["#51cf66","#4ade80"].includes(n))return "#2f9e44";if(["#38d9a9","#34d399"].includes(n))return "#087f5b";if(["#ffd43b","#fde047","#facc15"].includes(n))return "#f59f00";if(["#ffa94d","#fb923c"].includes(n))return "#f76707";if(["#ff8787","#f87171"].includes(n))return "#e03131"}return t}function et(t,e,n){if(!t||t==="transparent")return "transparent";let h=t.trim().toLowerCase();if(["#ffffff","#fff"].includes(h))return "#ffffff";if(["#000000","#1e1e24","#111827","#121212","#18181b"].includes(h))return h==="#000000"?"#000000":"#1e1e24";if(["#f8f9fa","#f8fafc","#f1f5f9","#f3f4f6"].includes(h))return "#f8f9fa";if(n){if(["#e5e7eb","#e2e8f0"].includes(h)||["#1f2937","#242731","#16171b","#1e2029","#0f172a","#1e293b","#374151"].includes(h))return "#242731";if(["#e9ecef","#dee2e6","#ced4da","#2e3238","#212529","#343a40"].includes(h))return "#2e3238";if(["#f4ece4","#f5f0eb","#a89984","#e2d9cc","#362b28"].includes(h))return "#362b28";if(["#c5f6fa","#ccfbf1","#99f6e4","#5eead4","#2dd4bf","#14b8a6","#0d9488","#cffafe","#0c383e"].includes(h))return "#0c383e";if(["#a5d8ff","#d0ebff","#e0f2fe","#bae6fd","#dbeafe","#bfdbfe","#93c5fd","#60a5fa","#182a4d"].includes(h))return "#182a4d";if(["#d0bfff","#e5dbff","#ede9fe","#e0e7ff","#c7d2fe","#a5b4fc","#818cf8","#1e1b4b","#2b1e4a"].includes(h))return "#1e1b4b";if(["#eebefa","#f5d0fe","#e9d5ff","#d8b4fe","#c084fc","#381e3d"].includes(h))return "#381e3d";if(["#fcc2d7","#f8d7da","#3e1828"].includes(h))return "#3e1828";if(["#ffc9c9","#ffe3e3","#ffe4e6","#fecdd3","#fce7f3","#fbcfe8","#fda4af","#fb7185","#2e1418"].includes(h))return "#2e1418";if(["#b2f2bb","#d3f9d8","#dcfce7","#bbf7d0","#d1fae5","#a7f3d0","#143823"].includes(h))return "#143823";if(["#96f2d7","#c3fae8","#123d33"].includes(h))return "#123d33";if(["#ffec99","#fff3bf","#fef9c3","#fef08a","#fde047","#3d2e14"].includes(h))return "#3d2e14";if(["#ffd8a8","#ffe8cc","#ffedd5","#fed7aa","#3d2014"].includes(h))return "#3d2014";if(["#fee2e2","#fca5a5","#f87171","#2e1418"].includes(h))return "#2e1418"}else {if(["#1f2937","#242731","#16171b","#1e2029","#0f172a","#1e293b","#374151"].includes(h))return "#ffffff";if(["#ced4da","#e9ecef","#dee2e6","#e2e8f0","#cbd5e1","#2e3238","#212529","#343a40"].includes(h))return "#e9ecef";if(["#362b28"].includes(h))return "#f4ece4";if(["#0c383e","#042f2e"].includes(h))return "#c5f6fa";if(["#182a4d","#172554"].includes(h))return "#a5d8ff";if(["#2b1e4a","#1e1b4b","#3b0764"].includes(h))return "#d0bfff";if(["#381e3d"].includes(h))return "#eebefa";if(["#3e1828"].includes(h))return "#fcc2d7";if(["#2e1418","#4c0519","#450a0a"].includes(h))return "#ffc9c9";if(["#143823","#052e16"].includes(h))return "#b2f2bb";if(["#123d33"].includes(h))return "#96f2d7";if(["#3d2e14","#422006"].includes(h))return "#ffec99";if(["#3d2014","#431407"].includes(h))return "#ffd8a8"}return t}function xt(t){return t?t.startsWith("top")?{dx:0,dy:-1}:t.startsWith("bottom")?{dx:0,dy:1}:t.startsWith("left")?{dx:-1,dy:0}:t.startsWith("right")?{dx:1,dy:0}:{dx:0,dy:0}:{dx:0,dy:0}}function at(t){let e={x:t.x,y:t.y},n={x:t.x+t.width,y:t.y+t.height},h=t.arrowType||"straight";if(h==="straight"){let r=Math.atan2(n.y-e.y,n.x-e.x);return {type:"straight",points:[e,n],departureAngle:r,arrivalAngle:r}}if(h==="curved"){let r=t.controlPoint;if(!r){let o=(e.x+n.x)/2,y=(e.y+n.y)/2,x=n.x-e.x,g=n.y-e.y,b=Math.hypot(x,g),m=Math.min(45,Math.max(15,b*.2)),k=b>0?-g/b*m:0,v=b>0?x/b*m:0;r={x:o+k,y:y+v};}let i=Math.atan2(r.y-e.y,r.x-e.x),f=Math.atan2(n.y-r.y,n.x-r.x);return {type:"curved",points:[e,n],controlPoint:r,departureAngle:i,arrivalAngle:f}}let d=n.x-e.x,u=n.y-e.y,l=t.controlPoint1,c=t.controlPoint2;if(!l||!c){let r=t.startBinding?.anchor,i=t.endBinding?.anchor,f=xt(r),o=xt(i);if(r&&i&&(f.dx!==0||f.dy!==0||o.dx!==0||o.dy!==0)){let y=Math.max(35,Math.hypot(d,u)*.35);l=l||{x:e.x+f.dx*y,y:e.y+f.dy*y},c=c||{x:n.x+o.dx*y,y:n.y+o.dy*y};}else l=l||{x:e.x+d*.4,y:e.y},c=c||{x:e.x+d*.6,y:n.y};}let a=Math.atan2(l.y-e.y,l.x-e.x),s=Math.atan2(n.y-c.y,n.x-c.x);return {type:"elbow",points:[e,n],controlPoint1:l,controlPoint2:c,departureAngle:a,arrivalAngle:s}}function kt(t,e,n=12){if(e.length<2)return;if(e.length===2){t.moveTo(e[0].x,e[0].y),t.lineTo(e[1].x,e[1].y);return}t.moveTo(e[0].x,e[0].y);for(let d=1;d<e.length-1;d++){let u=e[d-1],l=e[d],c=e[d+1],a=Math.hypot(l.x-u.x,l.y-u.y),s=Math.hypot(c.x-l.x,c.y-l.y),r=Math.min(n,a/2,s/2);t.arcTo(l.x,l.y,c.x,c.y,r);}let h=e[e.length-1];t.lineTo(h.x,h.y);}var ct=new Map;function W(t,e,n,h=1){if(e==="solid"||!e)return n;if(e==="transparent"||n==="transparent")return "transparent";let d=`${e}-${n}-${Math.round(h*10)/10}`;if(ct.has(d)){let r=ct.get(d);if(r)return r}if(typeof document>"u")return n;let l=e==="dots"?Math.max(8,Math.round(10*h)):Math.max(10,Math.round(14*h)),c=document.createElement("canvas");c.width=l,c.height=l;let a=c.getContext("2d");if(!a)return n;if(a.strokeStyle=n,a.fillStyle=n,a.lineWidth=Math.max(1.2,1.8*h),a.lineCap="round",e==="hachure")a.beginPath(),a.moveTo(0,l),a.lineTo(l,0),a.moveTo(-l/2,l/2),a.lineTo(l/2,-l/2),a.moveTo(l/2,l*1.5),a.lineTo(l*1.5,l/2),a.stroke();else if(e==="hachure-right")a.beginPath(),a.moveTo(0,0),a.lineTo(l,l),a.moveTo(l/2,-l/2),a.lineTo(l*1.5,l/2),a.moveTo(-l/2,l/2),a.lineTo(l/2,l*1.5),a.stroke();else if(e==="cross-hatch")a.beginPath(),a.moveTo(0,l),a.lineTo(l,0),a.moveTo(-l/2,l/2),a.lineTo(l/2,-l/2),a.moveTo(l/2,l*1.5),a.lineTo(l*1.5,l/2),a.moveTo(0,0),a.lineTo(l,l),a.moveTo(l/2,-l/2),a.lineTo(l*1.5,l/2),a.moveTo(-l/2,l/2),a.lineTo(l/2,l*1.5),a.stroke();else if(e==="dots"){let r=Math.max(.8,1.3*h);a.beginPath(),a.arc(l/2,l/2,r,0,Math.PI*2),a.fill();}let s=t.createPattern(c,"repeat");return s?(ct.set(d,s),s):n}function F(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return Math.abs(e)||12345}var X=class{state;constructor(e){this.state=e%2147483647,this.state<=0&&(this.state+=2147483646);}next(){return this.state=this.state*16807%2147483647,(this.state-1)/2147483646}offset(e){return (this.next()*2-1)*e}};function N(t,e,n,h,d,u,l={}){let c=l.roughness??1.5,a=l.bowing??1.8,s=l.overshoot??2.8,r=h-e,i=d-n,f=Math.hypot(r,i);if(f<1)return;let o=-i/f,y=r/f,x=u.offset(a*Math.min(6,c*1.4)),g=(e+h)/2+o*x,b=(n+d)/2+y*x,m=u.offset(s*c*.9),k=e-r/f*m,v=n-i/f*m,S=h+r/f*m,C=d+i/f*m;t.beginPath(),t.moveTo(k+u.offset(.8*c),v+u.offset(.8*c)),t.quadraticCurveTo(g,b,S+u.offset(.8*c),C+u.offset(.8*c)),t.stroke();let B=u.offset(a*Math.min(6,c*1.1)),Y=(e+h)/2+o*B,w=(n+d)/2+y*B,P=u.offset(s*c*.7),M=e-r/f*P,p=n-i/f*P,$=h+r/f*P,T=d+i/f*P;t.beginPath(),t.moveTo(M+u.offset(1*c),p+u.offset(1*c)),t.quadraticCurveTo(Y,w,$+u.offset(1*c),T+u.offset(1*c)),t.stroke();}function G(t,e,n,h=1.2){if(e.length<3)return;t.beginPath();let d=e[0];t.moveTo(d.x+n.offset(.8*h),d.y+n.offset(.8*h));for(let u=0;u<e.length;u++){let l=e[u],c=e[(u+1)%e.length],a=(l.x+c.x)/2+n.offset(1.2*h),s=(l.y+c.y)/2+n.offset(1.2*h),r=c.x+n.offset(.8*h),i=c.y+n.offset(.8*h);t.quadraticCurveTo(a,s,r,i);}t.closePath();}function K(t,e,n,h={}){for(let d=0;d<e.length;d++){let u=e[d],l=e[(d+1)%e.length];N(t,u.x,u.y,l.x,l.y,n,h);}}function Mt(t,e,n,h,d,u,l=false,c=true,a={}){let s=new X(F(u)),r=a.roughness??1.2,i=[{x:e,y:n},{x:e+h,y:n},{x:e+h,y:n+d},{x:e,y:n+d}];l&&(G(t,i,s,r),t.fill()),c&&K(t,i,s,a);}function Pt(t,e,n,h,d,u,l,c=false,a=true,s={}){let r=new X(F(l)),i=s.roughness??1.2,f=Math.min(u,Math.abs(h)/2,Math.abs(d)/2),o={x:e+f,y:n},y={x:e+h-f,y:n},x={x:e+h,y:n+f},g={x:e+h,y:n+d-f},b={x:e+h-f,y:n+d},m={x:e+f,y:n+d},k={x:e,y:n+d-f},v={x:e,y:n+f};if(c&&(t.beginPath(),t.moveTo(o.x,o.y),t.lineTo(y.x,y.y),t.arcTo(e+h,n,e+h,n+f,f),t.lineTo(g.x,g.y),t.arcTo(e+h,n+d,e+h-f,n+d,f),t.lineTo(m.x,m.y),t.arcTo(e,n+d,e,n+d-f,f),t.lineTo(v.x,v.y),t.arcTo(e,n,e+f,n,f),t.closePath(),t.fill()),a){N(t,o.x,o.y,y.x,y.y,r,s),N(t,x.x,x.y,g.x,g.y,r,s),N(t,b.x,b.y,m.x,m.y,r,s),N(t,k.x,k.y,v.x,v.y,r,s);let S=[{cx:e+h-f,cy:n+f,sa:-Math.PI/2,ea:0},{cx:e+h-f,cy:n+d-f,sa:0,ea:Math.PI/2},{cx:e+f,cy:n+d-f,sa:Math.PI/2,ea:Math.PI},{cx:e+f,cy:n+f,sa:Math.PI,ea:Math.PI*3/2}];for(let C of S)for(let B=0;B<2;B++){t.beginPath();let Y=r.offset(.8*i);t.arc(C.cx,C.cy,Math.max(1,f+Y),C.sa,C.ea),t.stroke();}}}function it(t,e,n,h,d,u,l=false,c=true,a={}){let s=new X(F(u)),r=a.roughness??1.2;if(l){t.beginPath();let i=8;for(let f=0;f<i;f++){let o=f/i*Math.PI*2,y=1+s.offset(.04*r),x=e+Math.cos(o)*h*y,g=n+Math.sin(o)*d*y;f===0?t.moveTo(x,g):t.lineTo(x,g);}t.closePath(),t.fill();}if(c){t.beginPath();let i=12;for(let y=0;y<=i+1;y++){let x=y/i*Math.PI*2,g=s.offset(1.2*r),b=s.offset(1.2*r),m=e+Math.cos(x)*(h+g),k=n+Math.sin(x)*(d+b);y===0?t.moveTo(m,k):t.lineTo(m,k);}t.stroke(),t.beginPath();let f=10,o=s.offset(.3);for(let y=0;y<=f+1;y++){let x=o+y/f*Math.PI*2,g=s.offset(1*r),b=s.offset(1*r),m=e+Math.cos(x)*(h+g),k=n+Math.sin(x)*(d+b);y===0?t.moveTo(m,k):t.lineTo(m,k);}t.stroke();}}var Tt=new Map;function ut(t,e,n){let h=[],d=e.split(`
|
|
2
|
-
`);for(let u of d){if(!u){h.push("");continue}let l=u.split(" "),c="";for(let a=0;a<l.length;a++){let s=l[a];if(t.measureText(s).width>n){c&&(h.push(c),c="");let f="";for(let o of s)t.measureText(f+o).width>n&&f?(h.push(f),f=o):f+=o;c=f;continue}let r=c?`${c} ${s}`:s;t.measureText(r).width>n&&c?(h.push(c),c=s):c=r;}c&&h.push(c);}return h}function lt(t){let e=Math.max(1,t.rows||3),n=Math.max(1,t.cols||3),h=Math.max(60,Math.abs(t.width)),d=Math.max(40,Math.abs(t.height)),u=t.colWidths&&t.colWidths.length===n?[...t.colWidths]:Array.from({length:n},()=>h/n),l=t.rowHeights&&t.rowHeights.length===e?[...t.rowHeights]:Array.from({length:e},()=>d/e);u=u.map(y=>Math.max(30,isNaN(y)||y<=0?h/n:y)),l=l.map(y=>Math.max(22,isNaN(y)||y<=0?d/e:y));let c=[0];for(let y=0;y<n;y++)c.push(c[y]+u[y]);let a=[0];for(let y=0;y<e;y++)a.push(a[y]+l[y]);let s=c[n],r=a[e],i=Math.min(t.x,t.x+t.width),f=Math.min(t.y,t.y+t.height);return {rows:e,cols:n,colWidths:u,rowHeights:l,colOffsets:c,rowOffsets:a,totalWidth:s,totalHeight:r,getCellBounds:(y,x)=>{let g=Math.max(0,Math.min(e-1,y)),
|
|
3
|
-
`):ut(t,e.text,x),C=b*1.35;if(e.type!=="text")for(;(S.length*C>g||S.some(p=>t.measureText(p).width>x))&&b>m;)b-=.75*n,t.font=`normal ${v} ${b}px ${o.cssFont}`,S=ut(t,e.text,x),C=b*1.35;let B=S.length*C,Y=(C-b)/2,w=e.type==="text"?(l+Math.max(0,(a-B/n)/2))*n+Y:y.centerY*n-B/2+Y,P=e.textAlign||(e.type==="text"?"left":"center");t.textAlign=P,t.textBaseline="top";let M=P==="center"?e.type==="text"?(u+c/2)*n:y.centerX*n:P==="right"?e.type==="text"?(u+c-4)*n:(y.boxX+y.boxW)*n-4*n:e.type==="text"?(u+4)*n:y.boxX*n+4*n;if(e.type==="sticky"){let p=Q(e.stickyColor||e.fillColor,d);t.fillStyle=e.strokeColor&&e.strokeColor!=="transparent"?U(e.strokeColor,d):p.text;}else t.fillStyle=U(e.strokeColor||"#1e1e24",d);if(e.type!=="text"){if(t.save(),t.beginPath(),e.type==="rectangle"||e.type==="sticky"){let p=e.type==="sticky",$=(e.edgeStyle||"round")==="round"||p,T=p?Math.min(22*n,s*.16,r*.16):$?Math.min(16*n,s*.2,r*.2):0;T>0&&typeof t.roundRect=="function"?t.roundRect(u+2,l+2,c-4,a-4,T):t.rect(u+2,l+2,c-4,a-4);}else if(e.type==="ellipse")t.ellipse(i,f,Math.max(1,s/2-2),Math.max(1,r/2-2),0,0,Math.PI*2);else if(e.type==="diamond")t.moveTo(i,l+2),t.lineTo(u+c-2,f),t.lineTo(i,l+a-2),t.lineTo(u+2,f),t.closePath();else if(e.type==="triangle")t.moveTo(i,l+2),t.lineTo(u+c-2,l+a-2),t.lineTo(u+2,l+a-2),t.closePath();else if(e.type==="capsule"){let p=Math.min(s,r)/2-2;s>=r?(t.arc(u+p+2,l+p+2,p,Math.PI/2,Math.PI*3/2),t.lineTo(u+c-p-2,l+2),t.arc(u+c-p-2,l+p+2,p,Math.PI*3/2,Math.PI/2),t.lineTo(u+p+2,l+a-2)):(t.arc(u+p+2,l+p+2,p,Math.PI,0),t.lineTo(u+c-2,l+a-p-2),t.arc(u+p+2,l+a-p-2,p,0,Math.PI),t.lineTo(u+2,l+p+2)),t.closePath();}else if(e.type==="trapezoid"){let p=Math.min(s*.2,40*n);t.moveTo(u+p+2,l+2),t.lineTo(u+c-p-2,l+2),t.lineTo(u+c-2,l+a-2),t.lineTo(u+2,l+a-2),t.closePath();}else if(e.type==="hexagon"){let p=Math.min(s*.22,45*n);t.moveTo(u+p+2,l+2),t.lineTo(u+c-p-2,l+2),t.lineTo(u+c-2,f),t.lineTo(u+c-p-2,l+a-2),t.lineTo(u+p+2,l+a-2),t.lineTo(u+2,f),t.closePath();}else if(e.type==="parallelogram"){let p=Math.min(36*n,s*.22);t.moveTo(u+p+2,l+2),t.lineTo(u+c-2,l+2),t.lineTo(u+c-p-2,l+a-2),t.lineTo(u+2,l+a-2),t.closePath();}else if(e.type==="cylinder"){let p=Math.abs(c/2)-2,$=Math.min(24*n,r*.2);t.ellipse(i,l+$,p,$,0,Math.PI,0),t.lineTo(u+c-2,l+a-$),t.ellipse(i,l+a-$,p,$,0,0,Math.PI),t.lineTo(u+2,l+$),t.closePath();}else t.rect(u+2,l+2,c-4,a-4);t.clip();}S.forEach((p,$)=>{t.fillText(p,M,w+$*C);}),e.type!=="text"&&t.restore();}function St(t,e,n,h,d,u,l,c=1,a=false){if(!d||d==="none")return;let s=d===true?"arrow":d;t.save(),t.translate(e,n),t.rotate(h),t.strokeStyle=u,t.fillStyle=u,t.lineWidth=Math.max(1,l*c),t.lineCap="round",t.lineJoin="round";let r=Math.max(1.5,l*c);switch(s){case "arrow":{let i=Math.max(12*c,r*4.5),f=i*.55;t.beginPath(),t.moveTo(-i,-f),t.lineTo(0,0),t.lineTo(-i,f),t.stroke();break}case "triangle":{let i=Math.max(14*c,r*4.8),f=i*.55;t.beginPath(),t.moveTo(0,0),t.lineTo(-i,-f),t.lineTo(-i,f),t.closePath(),t.fill(),t.stroke();break}case "barbed":{let i=Math.max(16*c,r*5.2),f=i*.55,o=i*.35;t.beginPath(),t.moveTo(0,0),t.lineTo(-i,-f),t.lineTo(-i+o,0),t.lineTo(-i,f),t.closePath(),t.fill(),t.stroke();break}case "dot":{let i=Math.max(4.5*c,r*1.8);t.beginPath(),t.arc(-i,0,i,0,Math.PI*2),t.fill();break}case "circle":{let i=Math.max(4.5*c,r*1.8);t.beginPath(),t.arc(-i,0,i,0,Math.PI*2),t.fillStyle=a?"#181818":"#ffffff",t.fill(),t.stroke();break}case "diamond":{let i=Math.max(13*c,r*4.2),f=i*.5;t.beginPath(),t.moveTo(0,0),t.lineTo(-i/2,-f),t.lineTo(-i,0),t.lineTo(-i/2,f),t.closePath(),t.fill(),t.stroke();break}case "diamond_outline":{let i=Math.max(13*c,r*4.2),f=i*.5;t.beginPath(),t.moveTo(0,0),t.lineTo(-i/2,-f),t.lineTo(-i,0),t.lineTo(-i/2,f),t.closePath(),t.fillStyle=a?"#181818":"#ffffff",t.fill(),t.stroke();break}case "bar":case "crowfoot_one":{let i=Math.max(12*c,r*4.5);t.beginPath(),t.moveTo(0,-i/2),t.lineTo(0,i/2),t.stroke();break}case "crowfoot_many":{let i=Math.max(12*c,r*4),f=i*.7;t.beginPath(),t.moveTo(-i,-f),t.lineTo(0,0),t.lineTo(-i,f),t.moveTo(-i,0),t.lineTo(0,0),t.stroke();break}case "crowfoot_one_many":{let i=Math.max(14*c,r*4.5),f=i*.65;t.beginPath(),t.moveTo(-i,-f),t.lineTo(0,0),t.lineTo(-i,f),t.moveTo(-i,0),t.lineTo(0,0),t.moveTo(-i*.45,-f),t.lineTo(-i*.45,f),t.stroke();break}case "crowfoot_strictly_one":{let i=Math.max(12*c,r*4.5),f=Math.max(5*c,r*2);t.beginPath(),t.moveTo(0,-i/2),t.lineTo(0,i/2),t.moveTo(-f,-i/2),t.lineTo(-f,i/2),t.stroke();break}case "crowfoot_zero_one":{let i=Math.max(12*c,r*4.5),f=Math.max(4*c,r*1.5);t.beginPath(),t.arc(-f*2-2*c,0,f,0,Math.PI*2),t.fillStyle=a?"#181818":"#ffffff",t.fill(),t.stroke(),t.beginPath(),t.moveTo(0,-i/2),t.lineTo(0,i/2),t.stroke();break}case "crowfoot_zero_many":{let i=Math.max(12*c,r*4),f=i*.65,o=Math.max(4*c,r*1.5);t.beginPath(),t.moveTo(-i,-f),t.lineTo(0,0),t.lineTo(-i,f),t.moveTo(-i,0),t.lineTo(0,0),t.stroke(),t.beginPath(),t.arc(-i-o-2*c,0,o,0,Math.PI*2),t.fillStyle=a?"#181818":"#ffffff",t.fill(),t.stroke();break}}t.restore();}function ot(t,e,n=1,h=false,d=false,u=false){t.save(),t.globalAlpha=e.opacity??1;let l=e.x+e.width/2,c=e.y+e.height/2;e.rotation&&(t.translate(l,c),t.rotate(e.rotation),t.translate(-l,-c)),u&&e.type!=="frame"?(t.shadowColor=d?"rgba(0, 0, 0, 0.45)":"rgba(15, 23, 42, 0.08)",t.shadowBlur=Math.round((d?12:10)*n),t.shadowOffsetX=0,t.shadowOffsetY=Math.round((d?4:3)*n)):t.shadowColor="transparent";let a=U(e.strokeColor,d),s=et(e.fillColor,e.fillStyle,d);t.strokeStyle=a,t.lineWidth=Math.max(1,e.strokeWidth*n),t.lineCap="round",t.lineJoin="round",e.strokeStyle==="dashed"?t.setLineDash([Math.max(6,e.strokeWidth*2.5*n),Math.max(4,e.strokeWidth*1.8*n)]):e.strokeStyle==="dotted"?t.setLineDash([Math.max(1.5,e.strokeWidth*.8*n),Math.max(4,e.strokeWidth*1.8*n)]):t.setLineDash([]);let{x:r,y:i,width:f,height:o}=e,y=e.roughStyle==="rough"||e.roughness!==void 0&&e.roughness>0,x={roughness:e.roughness||1.2};switch(e.type){case "rectangle":{let b=(e.edgeStyle||"round")==="round"?Math.min(16,Math.min(Math.abs(f),Math.abs(o))*.25):0;s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n)),y?b>0?Pt(t,r,i,f,o,b,e.id,!!(s&&s!=="transparent"),e.strokeWidth>0&&a!=="transparent",x):Mt(t,r,i,f,o,e.id,!!(s&&s!=="transparent"),e.strokeWidth>0&&a!=="transparent",x):(s&&s!=="transparent"&&(b>0?(st(t,r,i,f,o,b),t.fill()):t.fillRect(r,i,f,o)),e.strokeWidth>0&&a!=="transparent"&&(b>0?(st(t,r,i,f,o,b),t.stroke()):t.strokeRect(r,i,f,o))),_(t,e,n,h,d);break}case "ellipse":{let g=Math.abs(f/2),b=Math.abs(o/2);s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n)),y?it(t,l,c,g,b,e.id,!!(s&&s!=="transparent"),e.strokeWidth>0&&a!=="transparent",x):(t.beginPath(),t.ellipse(l,c,g,b,0,0,Math.PI*2),s&&s!=="transparent"&&t.fill(),e.strokeWidth>0&&a!=="transparent"&&t.stroke()),_(t,e,n,h,d);break}case "diamond":{if(y){let g=new X(F(e.id)),b=[{x:l,y:i},{x:r+f,y:c},{x:l,y:i+o},{x:r,y:c}];s&&s!=="transparent"&&(G(t,b,g,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&K(t,b,g,x);}else t.beginPath(),t.moveTo(l,i),t.lineTo(r+f,c),t.lineTo(l,i+o),t.lineTo(r,c),t.closePath(),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&t.stroke();_(t,e,n,h,d);break}case "table":{let g=lt(e),m=(e.edgeStyle||"round")==="round"?Math.min(10,Math.min(g.totalWidth,g.totalHeight)*.05):0;st(t,r,i,g.totalWidth,g.totalHeight,m);let k=s&&s!=="transparent"?s:d?"rgba(24, 24, 28, 0.95)":"rgba(255, 255, 255, 0.95)";t.fillStyle=k,t.fill();let v=e.cells||{},S=e.hasHeaderRow??true,C=e.hasHeaderCol??false;for(let p=0;p<g.rows;p++)for(let $=0;$<g.cols;$++){let T=`${p}_${$}`,I=v[T],E=g.getCellBounds(p,$),R=null;I?.fill?R=I.fill:e.tableStyle==="swot"?p===0&&$===0?R=d?"rgba(16, 185, 129, 0.18)":"rgba(16, 185, 129, 0.12)":p===0&&$===1?R=d?"rgba(245, 158, 11, 0.18)":"rgba(245, 158, 11, 0.12)":p===1&&$===0?R=d?"rgba(59, 130, 246, 0.18)":"rgba(59, 130, 246, 0.12)":p===1&&$===1&&(R=d?"rgba(239, 68, 68, 0.18)":"rgba(239, 68, 68, 0.12)"):e.tableStyle==="kanban"&&p===0?$===0?R=d?"rgba(107, 114, 128, 0.22)":"rgba(107, 114, 128, 0.12)":$===1?R=d?"rgba(99, 102, 241, 0.22)":"rgba(99, 102, 241, 0.12)":$===2&&(R=d?"rgba(16, 185, 129, 0.22)":"rgba(16, 185, 129, 0.12)"):S&&p===0?R=d?"rgba(99, 102, 241, 0.22)":"rgba(99, 102, 241, 0.10)":C&&$===0?R=d?"rgba(99, 102, 241, 0.14)":"rgba(99, 102, 241, 0.06)":e.tableStyle==="zebra"&&p%2===1&&(R=d?"rgba(255, 255, 255, 0.03)":"rgba(0, 0, 0, 0.025)"),R&&(t.fillStyle=R,t.fillRect(E.x,E.y,E.width,E.height));}let B=Math.max(1,e.strokeWidth||1.5),Y=a;t.strokeStyle=Y,t.lineWidth=B;for(let p=1;p<g.cols;p++){let $=r+g.colOffsets[p];t.beginPath(),t.moveTo($,i),t.lineTo($,i+g.totalHeight),t.stroke();}for(let p=1;p<g.rows;p++){let $=i+g.rowOffsets[p];t.beginPath(),t.moveTo(r,$),t.lineTo(r+g.totalWidth,$),t.stroke();}e.strokeWidth>0&&a!=="transparent"&&(st(t,r,i,g.totalWidth,g.totalHeight,m),t.stroke());let w=Math.max(10,e.fontSize||13),P=tt(e.fontFamily),M=P.cssFont;for(let p=0;p<g.rows;p++)for(let $=0;$<g.cols;$++){if(h&&e.editingCell&&e.editingCell.row===p&&e.editingCell.col===$)continue;let I=`${p}_${$}`,E=v[I],R=E?.text??"";if(!R)continue;let z=g.getCellBounds(p,$),A=S&&p===0||C&&$===0||E?.bold,H=E?.align||(A?"center":"left");t.save(),t.beginPath(),t.rect(z.x+2,z.y+2,z.width-4,z.height-4),t.clip();let O=P.value==="fuzzy"||P.value==="edusa",q=P.value==="patrick"||P.value==="comic"||P.value==="handlee"?"400":O?A?"700":"400":A?"600":"400";t.font=`${q} ${w}px ${M}`,t.fillStyle=E?.color||(A&&S&&p===0?d?"#ffffff":"#1e1b4b":a),t.textBaseline="middle";let nt=ut(t,R,z.width-16),dt=w*1.35,Yt=nt.length*dt,At=z.y+(z.height-Yt)/2+dt/2;nt.forEach((Wt,Ht)=>{let Xt=At+Ht*dt,rt=z.x+8;H==="center"?(t.textAlign="center",rt=z.x+z.width/2):H==="right"?(t.textAlign="right",rt=z.x+z.width-8):(t.textAlign="left",rt=z.x+8),t.fillText(Wt,rt,Xt);}),t.restore();}break}case "cylinder":{let g=Math.abs(f/2),b=Math.min(24*n,Math.abs(o)*.2),m=i+b,k=i+o-b;if(y){let v=new X(F(e.id)),S=[{x:r,y:m},{x:r+f,y:m},{x:r+f,y:k},{x:r,y:k}];s&&s!=="transparent"&&(G(t,S,v,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&(N(t,r,m,r,k,v,x),N(t,r+f,m,r+f,k,v,x),it(t,l,k,g,b,e.id+"_b",false,true,x)),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n)),it(t,l,m,g,b,e.id+"_t",!!(s&&s!=="transparent"),e.strokeWidth>0&&a!=="transparent",x);}else t.beginPath(),t.ellipse(l,m,g,b,0,Math.PI,0),t.lineTo(r+f,k),t.ellipse(l,k,g,b,0,0,Math.PI),t.lineTo(r,m),t.closePath(),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&(t.beginPath(),t.moveTo(r,m),t.lineTo(r,k),t.ellipse(l,k,g,b,0,Math.PI,0,true),t.lineTo(r+f,m),t.stroke()),t.beginPath(),t.ellipse(l,m,g,b,0,0,Math.PI*2),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&t.stroke();_(t,e,n,h,d);break}case "parallelogram":{let g=Math.min(36*n,Math.abs(f)*.22),b=[{x:r+g,y:i},{x:r+f,y:i},{x:r+f-g,y:i+o},{x:r,y:i+o}];if(y){let m=new X(F(e.id));s&&s!=="transparent"&&(G(t,b,m,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&K(t,b,m,x);}else t.beginPath(),t.moveTo(b[0].x,b[0].y),t.lineTo(b[1].x,b[1].y),t.lineTo(b[2].x,b[2].y),t.lineTo(b[3].x,b[3].y),t.closePath(),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&t.stroke();_(t,e,n,h,d);break}case "cloud":{let g=Math.abs(f),b=Math.abs(o);t.beginPath(),t.moveTo(r+g*.2,i+b*.7),t.bezierCurveTo(r+g*.1,i+b*.85,r+g*.35,i+b*.95,r+g*.5,i+b*.85),t.bezierCurveTo(r+g*.65,i+b*.95,r+g*.9,i+b*.85,r+g*.85,i+b*.65),t.bezierCurveTo(r+g*1.02,i+b*.5,r+g*.98,i+b*.25,r+g*.8,i+b*.25),t.bezierCurveTo(r+g*.78,i+b*.05,r+g*.52,i+b*.05,r+g*.45,i+b*.2),t.bezierCurveTo(r+g*.35,i+b*.08,r+g*.12,i+b*.15,r+g*.15,i+b*.4),t.bezierCurveTo(r-g*.02,i+b*.45,r-g*.01,i+b*.68,r+g*.2,i+b*.7),t.closePath(),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&(t.stroke(),y&&t.stroke()),_(t,e,n,h,d);break}case "star":{let b=Math.min(Math.abs(f),Math.abs(o))/2,m=b*.45,k=Math.PI/2*3,v=Math.PI/5,S=[];for(let C=0;C<5;C++)S.push({x:l+Math.cos(k)*b,y:c+Math.sin(k)*b}),k+=v,S.push({x:l+Math.cos(k)*m,y:c+Math.sin(k)*m}),k+=v;if(y){let C=new X(F(e.id));s&&s!=="transparent"&&(G(t,S,C,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&K(t,S,C,x);}else {t.beginPath(),t.moveTo(S[0].x,S[0].y);for(let C=1;C<S.length;C++)t.lineTo(S[C].x,S[C].y);t.closePath(),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),u&&(t.shadowColor="transparent"),e.strokeWidth>0&&a!=="transparent"&&t.stroke();}_(t,e,n,h,d);break}case "triangle":{let g=(e.edgeStyle||"round")==="round",b={x:r+f/2,y:i},m={x:r+f,y:i+o},k={x:r,y:i+o},v=[b,m,k];if(y){let S=new X(F(e.id));s&&s!=="transparent"&&(G(t,v,S,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&K(t,v,S,x);}else {if(t.beginPath(),g){let S=Math.min(12,Math.min(Math.abs(f),Math.abs(o))*.15);t.moveTo((b.x+m.x)/2,(b.y+m.y)/2),t.arcTo(m.x,m.y,k.x,k.y,S),t.arcTo(k.x,k.y,b.x,b.y,S),t.arcTo(b.x,b.y,m.x,m.y,S),t.closePath();}else t.moveTo(b.x,b.y),t.lineTo(m.x,m.y),t.lineTo(k.x,k.y),t.closePath();s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),u&&(t.shadowColor="transparent"),e.strokeWidth>0&&a!=="transparent"&&t.stroke();}_(t,e,n,h,d);break}case "trapezoid":{let g=(e.edgeStyle||"round")==="round",b=Math.min(Math.abs(f)*.2,40*n),m={x:r+b,y:i},k={x:r+f-b,y:i},v={x:r+f,y:i+o},S={x:r,y:i+o},C=[m,k,v,S];if(y){let B=new X(F(e.id));s&&s!=="transparent"&&(G(t,C,B,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&K(t,C,B,x);}else {if(t.beginPath(),g){let B=Math.min(10,Math.min(Math.abs(f),Math.abs(o))*.15);t.moveTo((m.x+k.x)/2,m.y),t.arcTo(k.x,k.y,v.x,v.y,B),t.arcTo(v.x,v.y,S.x,S.y,B),t.arcTo(S.x,S.y,m.x,m.y,B),t.arcTo(m.x,m.y,k.x,k.y,B),t.closePath();}else t.moveTo(m.x,m.y),t.lineTo(k.x,k.y),t.lineTo(v.x,v.y),t.lineTo(S.x,S.y),t.closePath();s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),u&&(t.shadowColor="transparent"),e.strokeWidth>0&&a!=="transparent"&&t.stroke();}_(t,e,n,h,d);break}case "hexagon":{let g=(e.edgeStyle||"round")==="round",b=Math.min(Math.abs(f)*.22,45*n),m={x:r+b,y:i},k={x:r+f-b,y:i},v={x:r+f,y:i+o/2},S={x:r+f-b,y:i+o},C={x:r+b,y:i+o},B={x:r,y:i+o/2},Y=[m,k,v,S,C,B];if(y){let w=new X(F(e.id));s&&s!=="transparent"&&(G(t,Y,w,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&K(t,Y,w,x);}else {if(t.beginPath(),g){let w=Math.min(10,Math.min(Math.abs(f),Math.abs(o))*.12);t.moveTo((m.x+k.x)/2,m.y),t.arcTo(k.x,k.y,v.x,v.y,w),t.arcTo(v.x,v.y,S.x,S.y,w),t.arcTo(S.x,S.y,C.x,C.y,w),t.arcTo(C.x,C.y,B.x,B.y,w),t.arcTo(B.x,B.y,m.x,m.y,w),t.arcTo(m.x,m.y,k.x,k.y,w),t.closePath();}else t.moveTo(m.x,m.y),t.lineTo(k.x,k.y),t.lineTo(v.x,v.y),t.lineTo(S.x,S.y),t.lineTo(C.x,C.y),t.lineTo(B.x,B.y),t.closePath();s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),u&&(t.shadowColor="transparent"),e.strokeWidth>0&&a!=="transparent"&&t.stroke();}_(t,e,n,h,d);break}case "capsule":{let g=Math.abs(f),b=Math.abs(o),m=Math.min(g,b)/2;t.beginPath(),g>=b?(t.arc(r+m,i+m,m,Math.PI/2,Math.PI*3/2),t.lineTo(r+f-m,i),t.arc(r+f-m,i+m,m,Math.PI*3/2,Math.PI/2),t.lineTo(r+m,i+o)):(t.arc(r+m,i+m,m,Math.PI,0),t.lineTo(r+f-m,i+o-m),t.arc(r+m,i+o-m,m,0,Math.PI),t.lineTo(r,i+m)),t.closePath(),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),u&&(t.shadowColor="transparent"),e.strokeWidth>0&&a!=="transparent"&&(t.stroke(),y&&t.stroke()),_(t,e,n,h,d);break}case "arrow":case "line":{let g=at(e),b={x:r+f,y:i+o};if(y&&g.type==="straight"){let k=new X(F(e.id));N(t,r,i,b.x,b.y,k,x);}else t.beginPath(),g.type==="straight"?(t.moveTo(r,i),t.lineTo(b.x,b.y)):g.type==="curved"&&g.controlPoint?(t.moveTo(r,i),t.quadraticCurveTo(g.controlPoint.x,g.controlPoint.y,b.x,b.y)):g.type==="elbow"&&g.controlPoint1&&g.controlPoint2?(t.moveTo(r,i),t.bezierCurveTo(g.controlPoint1.x,g.controlPoint1.y,g.controlPoint2.x,g.controlPoint2.y,b.x,b.y)):kt(t,g.points,Math.max(8,12*n)),t.stroke(),y&&t.stroke();e.startArrowhead&&e.startArrowhead!=="none"&&St(t,r,i,g.departureAngle+Math.PI,e.startArrowhead,a,e.strokeWidth,n,d);let m=e.endArrowhead!==void 0?e.endArrowhead:e.type==="arrow"?"arrow":"none";m&&m!=="none"&&St(t,b.x,b.y,g.arrivalAngle,m,a,e.strokeWidth,n,d);break}case "pen":{let g=e.points;if(!g||g.length<2)break;t.beginPath(),t.moveTo(g[0].x,g[0].y);for(let m=1;m<g.length-1;m++){let k=(g[m].x+g[m+1].x)/2,v=(g[m].y+g[m+1].y)/2;t.quadraticCurveTo(g[m].x,g[m].y,k,v);}let b=g[g.length-1];t.lineTo(b.x,b.y),t.stroke();break}case "text":{_(t,e,n,h,d);break}case "sticky":{let g=Q(e.stickyColor||e.fillColor,d),b=Math.abs(f),m=Math.abs(o),k=Math.min(22*n,Math.min(b,m)*.16),v=Math.min(13*n,b*.08),S=Math.min(13*n,m*.08);t.fillStyle=g.backSheetBg,t.strokeStyle=g.backSheetBorder,t.lineWidth=1.5*n,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(r+v,i+S,f,o,k):t.rect(r+v,i+S,f,o),t.fill(),t.stroke(),t.save(),t.shadowColor="rgba(0, 0, 0, 0.08)",t.shadowBlur=8*n,t.shadowOffsetX=1*n,t.shadowOffsetY=3*n,t.fillStyle=g.bg,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(r,i,f,o,k):t.rect(r,i,f,o),t.fill(),t.restore(),t.strokeStyle=g.mainBorder,t.lineWidth=1.5*n,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(r,i,f,o,k):t.rect(r,i,f,o),t.stroke(),t.save(),t.strokeStyle=g.sheen,t.lineWidth=1.5*n,t.beginPath();let C=2*n,B=Math.max(2,k-C);typeof t.roundRect=="function"&&t.roundRect(r+C,i+C,f-C*2,o-C*2,B),t.stroke(),t.restore();let Y=Math.min(64*n,Math.max(30*n,b*.28)),w=Math.min(18*n,Math.max(10*n,m*.09)),P=r+(f-Y)/2,M=i-w*.42,p=4*n;t.save(),t.shadowColor="rgba(0, 0, 0, 0.06)",t.shadowBlur=4*n,t.shadowOffsetY=1*n,t.fillStyle=g.tapeBg,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(P,M,Y,w,p):t.rect(P,M,Y,w),t.fill(),t.restore(),t.strokeStyle=g.tapeBorder,t.lineWidth=1*n,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(P,M,Y,w,p):t.rect(P,M,Y,w),t.stroke(),_(t,e,n,h,d);break}case "image":{if(e.dataUrl){let g=Tt.get(e.dataUrl);if(g||(g=new Image,g.crossOrigin="anonymous",g.onload=()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("sketch-redraw-canvas"));},g.src=e.dataUrl,Tt.set(e.dataUrl,g)),g.complete&&g.naturalWidth>0)if(e.edgeStyle==="round"){let b=Math.min(10*n,Math.abs(f)/4,Math.abs(o)/4);t.save(),t.beginPath(),typeof t.roundRect=="function"?t.roundRect(r,i,f,o,b):t.rect(r,i,f,o),t.clip(),t.drawImage(g,r,i,f,o),t.restore();}else t.drawImage(g,r,i,f,o);}break}case "frame":{let g=f<0?r+f:r,b=o<0?i+o:i,m=Math.abs(f),k=Math.abs(o);if(e.fillColor&&e.fillColor!=="transparent"?(t.fillStyle=et(e.fillColor,e.fillStyle||"solid",d),t.fillRect(g,b,m,k)):(t.fillStyle=d?"rgba(255, 255, 255, 0.02)":"rgba(255, 255, 255, 0.85)",t.fillRect(g,b,m,k)),e.strokeColor!=="transparent"){t.save();let v=e.strokeColor&&e.strokeColor!=="transparent"?U(e.strokeColor,d):d?"#818cf8":"#6366f1";t.strokeStyle=v,t.lineWidth=Math.max(1,(e.strokeWidth||1.5)*n),e.strokeStyle==="dashed"?t.setLineDash([6*n,6*n]):e.strokeStyle==="dotted"?t.setLineDash([2*n,4*n]):t.setLineDash([]),t.strokeRect(g,b,m,k),t.restore();}if(!h){let v=e.frameLabel||"Frame",S=Math.max(11,12*n);t.save(),t.font=`600 ${S}px Inter, -apple-system, sans-serif`;let C=t.measureText(v),B=8*n,Y=S+8*n,w=C.width+B*2,P=g+m-w,M=b-Y-3*n;t.fillStyle=d?"#27272a":"#e4e4e7",typeof t.roundRect=="function"?(t.beginPath(),t.roundRect(P,M,w,Y,4*n),t.fill()):t.fillRect(P,M,w,Y),t.fillStyle=d?"#f4f4f5":"#18181b",t.textAlign="left",t.textBaseline="middle",t.fillText(v,P+B,M+Y/2),t.restore();}break}}t.restore();}function D(t){let e=Math.min(t.x,t.x+t.width),n=Math.min(t.y,t.y+t.height),h=Math.abs(t.width),d=Math.abs(t.height);return {x:e,y:n,width:h,height:d}}function L(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Z(t){if(!t||t==="transparent")return false;if(t.startsWith("#")){let e=t.replace("#","");if(e.length===3){let n=parseInt(e[0]+e[0],16),h=parseInt(e[1]+e[1],16),d=parseInt(e[2]+e[2],16);return n*.299+h*.587+d*.114<128}if(e.length===6){let n=parseInt(e.substring(0,2),16),h=parseInt(e.substring(2,4),16),d=parseInt(e.substring(4,6),16);return n*.299+h*.587+d*.114<128}}return false}function vt(t,e,n,h,d,u,l){if(!h||h==="none")return "";let c=h===true?"arrow":h,a=Math.max(1.5,u),s=`transform="translate(${t}, ${e}) rotate(${n*180/Math.PI})"`;switch(c){case "arrow":{let r=Math.max(12,a*4.5),i=r*.55;return `<path d="M ${-r} ${-i} L 0 0 L ${-r} ${i}" fill="none" stroke="${d}" stroke-width="${a}" stroke-linecap="round" stroke-linejoin="round" opacity="${l}" ${s} />
|
|
1
|
+
import {rgb,PDFDocument}from'pdf-lib';async function yt(t,e,n){if(typeof window>"u")return;let h=typeof n=="string"?n:n?.mimeType;if(typeof t=="string"&&t.startsWith("data:")){let c=document.createElement("a");c.href=t,c.download=e,c.style.display="none",document.body.appendChild(c),c.click(),document.body.removeChild(c);return}let d=t instanceof Blob?t:new Blob([t],{type:h}),u=URL.createObjectURL(d),l=document.createElement("a");l.href=u,l.download=e,l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>{URL.revokeObjectURL(u);},1e3);}var wt=[{key:"q",name:"Transparent",stroke:{light:"transparent",dark:"transparent"},fill:{light:"transparent",dark:"transparent"}},{key:"w",name:"White",stroke:{light:"#ffffff",dark:"#ffffff"},fill:{light:"#ffffff",dark:"#ffffff"}},{key:"e",name:"Grey",stroke:{light:"#343a40",dark:"#ced4da"},fill:{light:"#e9ecef",dark:"#2e3238"}},{key:"r",name:"Black / Off-white",stroke:{light:"#1e1e24",dark:"#f8f9fa"},fill:{light:"#1e1e24",dark:"#1e1e24"}},{key:"t",name:"Warm Taupe",stroke:{light:"#865e3c",dark:"#d8c2b0"},fill:{light:"#f4ece4",dark:"#362b28"}},{key:"a",name:"Teal Cyan",stroke:{light:"#0c8599",dark:"#22b8cf"},fill:{light:"#c5f6fa",dark:"#0c383e"}},{key:"s",name:"Sky Blue",stroke:{light:"#1971c2",dark:"#4dabf7"},fill:{light:"#a5d8ff",dark:"#182a4d"}},{key:"d",name:"Royal Purple",stroke:{light:"#6741d9",dark:"#b197fc"},fill:{light:"#d0bfff",dark:"#2b1e4a"}},{key:"f",name:"Violet Magenta",stroke:{light:"#ae3ec9",dark:"#e599f7"},fill:{light:"#eebefa",dark:"#381e3d"}},{key:"g",name:"Crimson Berry",stroke:{light:"#c2255c",dark:"#f783ac"},fill:{light:"#fcc2d7",dark:"#3e1828"}},{key:"z",name:"Green",stroke:{light:"#2f9e44",dark:"#51cf66"},fill:{light:"#b2f2bb",dark:"#143823"}},{key:"x",name:"Mint Emerald",stroke:{light:"#087f5b",dark:"#38d9a9"},fill:{light:"#96f2d7",dark:"#123d33"}},{key:"c",name:"Amber Yellow",stroke:{light:"#f59f00",dark:"#ffd43b"},fill:{light:"#ffec99",dark:"#3d2e14"}},{key:"v",name:"Vivid Orange",stroke:{light:"#f76707",dark:"#ffa94d"},fill:{light:"#ffd8a8",dark:"#3d2014"}},{key:"b",name:"Coral Red",stroke:{light:"#e03131",dark:"#ff8787"},fill:{light:"#ffc9c9",dark:"#2e1418"}}];wt.map(t=>({name:t.name,hex:t.stroke.light,shortcut:t.key}));wt.map(t=>({name:t.name,hex:t.fill.light}));var pt={"#fef08a":{bg:"#fef08a",backSheetBg:"#fefce8",backSheetBorder:"#fde047",mainBorder:"rgba(234, 179, 8, 0.45)",tapeBg:"rgba(254, 249, 195, 0.95)",tapeBorder:"rgba(202, 138, 4, 0.35)",text:"#713f12",sheen:"rgba(255, 255, 255, 0.8)"},"#fde68a":{bg:"#fde68a",backSheetBg:"#fef9d9",backSheetBorder:"#fcd34d",mainBorder:"rgba(245, 158, 11, 0.4)",tapeBg:"rgba(255, 250, 224, 0.95)",tapeBorder:"rgba(217, 119, 6, 0.35)",text:"#78350f",sheen:"rgba(255, 255, 255, 0.8)"},"#bbf7d0":{bg:"#bbf7d0",backSheetBg:"#f0fdf4",backSheetBorder:"#86efac",mainBorder:"rgba(74, 222, 128, 0.45)",tapeBg:"rgba(240, 253, 244, 0.95)",tapeBorder:"rgba(22, 163, 74, 0.35)",text:"#14532d",sheen:"rgba(255, 255, 255, 0.8)"},"#bae6fd":{bg:"#bae6fd",backSheetBg:"#f0f9ff",backSheetBorder:"#7dd3fc",mainBorder:"rgba(56, 189, 248, 0.45)",tapeBg:"rgba(240, 249, 255, 0.95)",tapeBorder:"rgba(2, 132, 199, 0.35)",text:"#0c4a6e",sheen:"rgba(255, 255, 255, 0.8)"},"#fed7aa":{bg:"#fed7aa",backSheetBg:"#fff7ed",backSheetBorder:"#fdba74",mainBorder:"rgba(251, 146, 60, 0.45)",tapeBg:"rgba(255, 247, 237, 0.95)",tapeBorder:"rgba(234, 88, 12, 0.35)",text:"#7c2d12",sheen:"rgba(255, 255, 255, 0.8)"},"#e9d5ff":{bg:"#e9d5ff",backSheetBg:"#faf5ff",backSheetBorder:"#d8b4fe",mainBorder:"rgba(192, 132, 252, 0.45)",tapeBg:"rgba(250, 245, 255, 0.95)",tapeBorder:"rgba(147, 51, 234, 0.35)",text:"#581c87",sheen:"rgba(255, 255, 255, 0.8)"},"#fecdd3":{bg:"#fecdd3",backSheetBg:"#fff1f2",backSheetBorder:"#fda4af",mainBorder:"rgba(251, 113, 133, 0.45)",tapeBg:"rgba(255, 241, 242, 0.95)",tapeBorder:"rgba(225, 29, 72, 0.35)",text:"#881337",sheen:"rgba(255, 255, 255, 0.8)"}},bt={"#fef08a":{bg:"#2b230d",backSheetBg:"#1c1608",backSheetBorder:"#4a3c18",mainBorder:"rgba(250, 204, 21, 0.5)",tapeBg:"rgba(254, 240, 138, 0.18)",tapeBorder:"rgba(250, 204, 21, 0.45)",text:"#fef08a",sheen:"rgba(254, 240, 138, 0.15)"},"#fde68a":{bg:"#2b230d",backSheetBg:"#1c1608",backSheetBorder:"#4a3c18",mainBorder:"rgba(250, 204, 21, 0.5)",tapeBg:"rgba(254, 240, 138, 0.18)",tapeBorder:"rgba(250, 204, 21, 0.45)",text:"#fde68a",sheen:"rgba(254, 240, 138, 0.15)"},"#bbf7d0":{bg:"#10281b",backSheetBg:"#091b11",backSheetBorder:"#1e4730",mainBorder:"rgba(74, 222, 128, 0.5)",tapeBg:"rgba(187, 247, 208, 0.18)",tapeBorder:"rgba(74, 222, 128, 0.45)",text:"#bbf7d0",sheen:"rgba(187, 247, 208, 0.15)"},"#bae6fd":{bg:"#102436",backSheetBg:"#091724",backSheetBorder:"#1d4160",mainBorder:"rgba(56, 189, 248, 0.5)",tapeBg:"rgba(186, 230, 253, 0.18)",tapeBorder:"rgba(56, 189, 248, 0.45)",text:"#bae6fd",sheen:"rgba(186, 230, 253, 0.15)"},"#fed7aa":{bg:"#321d10",backSheetBg:"#201107",backSheetBorder:"#56321c",mainBorder:"rgba(251, 146, 60, 0.5)",tapeBg:"rgba(254, 215, 170, 0.18)",tapeBorder:"rgba(251, 146, 60, 0.45)",text:"#fed7aa",sheen:"rgba(254, 215, 170, 0.15)"},"#e9d5ff":{bg:"#271638",backSheetBg:"#190d24",backSheetBorder:"#462865",mainBorder:"rgba(192, 132, 252, 0.5)",tapeBg:"rgba(233, 213, 255, 0.18)",tapeBorder:"rgba(192, 132, 252, 0.45)",text:"#e9d5ff",sheen:"rgba(233, 213, 255, 0.15)"},"#fecdd3":{bg:"#321319",backSheetBg:"#210b10",backSheetBorder:"#56222b",mainBorder:"rgba(251, 113, 133, 0.5)",tapeBg:"rgba(254, 205, 211, 0.18)",tapeBorder:"rgba(251, 113, 133, 0.45)",text:"#fecdd3",sheen:"rgba(254, 205, 211, 0.15)"}};function mt(t){let e=t.replace("#","").trim();if(e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),e.length===6){let n=parseInt(e,16);if(!isNaN(n))return {r:n>>16&255,g:n>>8&255,b:n&255}}return {r:254,g:240,b:138}}function $t(t,e,n){t/=255,e/=255,n/=255;let h=Math.max(t,e,n),d=Math.min(t,e,n),u=0,l=0,c=(h+d)/2;if(h!==d){let a=h-d;switch(l=c>.5?a/(2-h-d):a/(h+d),h){case t:u=(e-n)/a+(e<n?6:0);break;case e:u=(n-t)/a+2;break;case n:u=(t-e)/a+4;break}u/=6;}return {h:Math.round(u*360),s:Math.round(l*100),l:Math.round(c*100)}}function Q(t,e=false){let n=(t||"#fde68a").toLowerCase();if(e){if(bt[n])return bt[n];let{r:s,g:r,b:i}=mt(n),{h:f,s:o}=$t(s,r,i),y=Math.max(35,o);return {bg:`hsl(${f}, ${Math.round(y*.45)}%, 16%)`,backSheetBg:`hsl(${f}, ${Math.round(y*.5)}%, 10%)`,backSheetBorder:`hsl(${f}, ${Math.round(y*.6)}%, 28%)`,mainBorder:`hsla(${f}, ${Math.round(y*.9)}%, 65%, 0.5)`,tapeBg:`hsla(${f}, ${Math.round(y*.8)}%, 80%, 0.18)`,tapeBorder:`hsla(${f}, ${Math.round(y*.9)}%, 70%, 0.45)`,text:`hsl(${f}, ${Math.round(y*.95)}%, 88%)`,sheen:`hsla(${f}, ${Math.round(y*.8)}%, 85%, 0.15)`}}if(pt[n])return pt[n];let{r:h,g:d,b:u}=mt(n),{h:l,s:c}=$t(h,d,u),a=Math.max(30,c);return {bg:t||"#fde68a",backSheetBg:`hsl(${l}, ${Math.round(a*.75)}%, 94%)`,backSheetBorder:`hsl(${l}, ${Math.round(a*.85)}%, 72%)`,mainBorder:`hsl(${l}, ${Math.round(a*.95)}%, 42%)`,tapeBg:`hsla(${l}, ${Math.round(a*.6)}%, 96%, 0.95)`,tapeBorder:`hsla(${l}, ${Math.round(a*.9)}%, 42%, 0.38)`,text:`hsl(${l}, ${Math.round(a*.95)}%, 16%)`,sheen:"rgba(255, 255, 255, 0.8)"}}var j=[{value:"fuzzy",label:"Handwritten",cssFont:"'Fuzzy Bubbles', cursive, sans-serif"},{value:"comic",label:"Playful",cssFont:"'Comic Neue', cursive, sans-serif"},{value:"patrick",label:"Calm",cssFont:"'Patrick Hand SC', sans-serif"},{value:"sans",label:"Formal",cssFont:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif"},{value:"mono",label:"Code",cssFont:"'JetBrains Mono', 'Geist Mono', 'Courier New', Consolas, monospace"}];function tt(t){return t==="fuzzy"||t==="edusa"||t==="playpen"||t==="caveat"?j[0]:t==="comic"||t==="handlee"?j[1]:t==="serif"||t==="patrick"?j[2]:t==="sans"?j[3]:t==="mono"?j[4]:j.find(e=>e.value===t)||j[0]}function U(t,e){if(!t||t==="transparent")return t||"transparent";let n=t.trim().toLowerCase();if(e){if(["#000000","#020617","#0f172a","#111827","#18181b","#1e1e24","#1e293b","#27272a","#334155","#343a40","#3f3f46","#475569","#52525b","#1f2937","#242731"].includes(n)||["#e2e8f0","#e5e7eb","#cbd5e1","#ced4da"].includes(n))return "#f8f9fa";if(["#64748b","#71717a","#78716c","#868e96"].includes(n))return "#ced4da";if(["#94a3b8"].includes(n))return "#e2e8f0";if(["#713f12","#865e3c","#a89984","#78350f","#451a03"].includes(n))return "#ffd43b";if(["#042f2e","#134e4a","#115e59","#0f766e","#0d9488","#0891b2","#0c8599","#14b8a6","#2dd4bf","#164e63","#155e75","#0e7490"].includes(n))return "#22b8cf";if(["#172554","#1e3a8a","#1e40af","#1d4ed8","#2563eb","#1971c2","#0b6eff","#3b82f6","#182a4d","#0c4a6e","#075985","#0369a1","#0284c7"].includes(n))return "#4dabf7";if(["#3b0764","#581c87","#6b21a8","#7e22ce","#9333ea","#a855f7","#2e1065","#4c1d95","#5b21b6","#6741d9","#6965db","#7c3aed","#2b1e4a","#1e1b4b","#312e81","#3730a3","#4338ca","#4f46e5"].includes(n))return "#b197fc";if(["#ae3ec9","#9c36b5","#be185d","#381e3d","#86198f","#701a75"].includes(n))return "#e599f7";if(["#4c0519","#881337","#9f1239","#c2255c","#db2777","#e11d48","#f43f5e","#f472b6","#3e1828","#831843","#9d174d"].includes(n))return "#f783ac";if(["#052e16","#14532d","#166534","#15803d","#16a34a","#2f9e44","#22c55e","#143823"].includes(n))return "#51cf66";if(["#064e3b","#065f46","#047857","#087f5b","#059669","#10b981","#123d33","#022c22"].includes(n))return "#38d9a9";if(["#713f12","#854d0e","#a16207","#ca8a04","#eab308","#f59f00","#d97706","#b45309","#3d2e14","#78350f","#451a03"].includes(n))return "#ffd43b";if(["#451a03","#7c2d12","#9a3412","#c2410c","#ea580c","#f76707","#f97316","#3d2014"].includes(n))return "#ffa94d";if(["#450a0a","#7f1d1d","#991b1b","#b91c1c","#dc2626","#e03131","#ef4444","#2e1418"].includes(n))return "#ff8787";if(["#ffffff","#fff"].includes(n))return "#ffffff"}else {if(["#f8f9fa","#f8fafc","#f3f4f6","#ffffff","#fff"].includes(n))return "#111827";if(["#e2e8f0","#e5e7eb","#cbd5e1","#ced4da"].includes(n))return "#475569";if(["#94a3b8"].includes(n))return "#64748b";if(["#d8c2b0"].includes(n))return "#865e3c";if(["#22b8cf","#5eead4","#2dd4bf"].includes(n))return "#0c8599";if(["#4dabf7","#60a5fa","#74c0fc"].includes(n))return "#1971c2";if(["#b197fc","#a5b4fc","#c4b5fd"].includes(n))return "#6741d9";if(["#e599f7","#c084fc"].includes(n))return "#ae3ec9";if(["#f783ac","#fb7185","#f472b6"].includes(n))return "#c2255c";if(["#51cf66","#4ade80"].includes(n))return "#2f9e44";if(["#38d9a9","#34d399"].includes(n))return "#087f5b";if(["#ffd43b","#fde047","#facc15"].includes(n))return "#f59f00";if(["#ffa94d","#fb923c"].includes(n))return "#f76707";if(["#ff8787","#f87171"].includes(n))return "#e03131"}return t}function et(t,e,n){if(!t||t==="transparent")return "transparent";let h=t.trim().toLowerCase();if(["#ffffff","#fff"].includes(h))return "#ffffff";if(["#000000","#1e1e24","#111827","#121212","#18181b"].includes(h))return h==="#000000"?"#000000":"#1e1e24";if(["#f8f9fa","#f8fafc","#f1f5f9","#f3f4f6"].includes(h))return "#f8f9fa";if(n){if(["#e5e7eb","#e2e8f0"].includes(h)||["#1f2937","#242731","#16171b","#1e2029","#0f172a","#1e293b","#374151"].includes(h))return "#242731";if(["#e9ecef","#dee2e6","#ced4da","#2e3238","#212529","#343a40"].includes(h))return "#2e3238";if(["#f4ece4","#f5f0eb","#a89984","#e2d9cc","#362b28"].includes(h))return "#362b28";if(["#c5f6fa","#ccfbf1","#99f6e4","#5eead4","#2dd4bf","#14b8a6","#0d9488","#cffafe","#0c383e"].includes(h))return "#0c383e";if(["#a5d8ff","#d0ebff","#e0f2fe","#bae6fd","#dbeafe","#bfdbfe","#93c5fd","#60a5fa","#182a4d"].includes(h))return "#182a4d";if(["#d0bfff","#e5dbff","#ede9fe","#e0e7ff","#c7d2fe","#a5b4fc","#818cf8","#1e1b4b","#2b1e4a"].includes(h))return "#1e1b4b";if(["#eebefa","#f5d0fe","#e9d5ff","#d8b4fe","#c084fc","#381e3d"].includes(h))return "#381e3d";if(["#fcc2d7","#f8d7da","#3e1828"].includes(h))return "#3e1828";if(["#ffc9c9","#ffe3e3","#ffe4e6","#fecdd3","#fce7f3","#fbcfe8","#fda4af","#fb7185","#2e1418"].includes(h))return "#2e1418";if(["#b2f2bb","#d3f9d8","#dcfce7","#bbf7d0","#d1fae5","#a7f3d0","#143823"].includes(h))return "#143823";if(["#96f2d7","#c3fae8","#123d33"].includes(h))return "#123d33";if(["#ffec99","#fff3bf","#fef9c3","#fef08a","#fde047","#3d2e14"].includes(h))return "#3d2e14";if(["#ffd8a8","#ffe8cc","#ffedd5","#fed7aa","#3d2014"].includes(h))return "#3d2014";if(["#fee2e2","#fca5a5","#f87171","#2e1418"].includes(h))return "#2e1418"}else {if(["#1f2937","#242731","#16171b","#1e2029","#0f172a","#1e293b","#374151"].includes(h))return "#ffffff";if(["#ced4da","#e9ecef","#dee2e6","#e2e8f0","#cbd5e1","#2e3238","#212529","#343a40"].includes(h))return "#e9ecef";if(["#362b28"].includes(h))return "#f4ece4";if(["#0c383e","#042f2e"].includes(h))return "#c5f6fa";if(["#182a4d","#172554"].includes(h))return "#a5d8ff";if(["#2b1e4a","#1e1b4b","#3b0764"].includes(h))return "#d0bfff";if(["#381e3d"].includes(h))return "#eebefa";if(["#3e1828"].includes(h))return "#fcc2d7";if(["#2e1418","#4c0519","#450a0a"].includes(h))return "#ffc9c9";if(["#143823","#052e16"].includes(h))return "#b2f2bb";if(["#123d33"].includes(h))return "#96f2d7";if(["#3d2e14","#422006"].includes(h))return "#ffec99";if(["#3d2014","#431407"].includes(h))return "#ffd8a8"}return t}function xt(t){return t?t.startsWith("top")?{dx:0,dy:-1}:t.startsWith("bottom")?{dx:0,dy:1}:t.startsWith("left")?{dx:-1,dy:0}:t.startsWith("right")?{dx:1,dy:0}:{dx:0,dy:0}:{dx:0,dy:0}}function at(t){let e={x:t.x,y:t.y},n={x:t.x+t.width,y:t.y+t.height},h=t.arrowType||"straight";if(h==="straight"){let r=Math.atan2(n.y-e.y,n.x-e.x);return {type:"straight",points:[e,n],departureAngle:r,arrivalAngle:r}}if(h==="curved"){let r=t.controlPoint;if(!r){let o=(e.x+n.x)/2,y=(e.y+n.y)/2,x=n.x-e.x,g=n.y-e.y,p=Math.hypot(x,g),m=Math.min(45,Math.max(15,p*.2)),k=p>0?-g/p*m:0,v=p>0?x/p*m:0;r={x:o+k,y:y+v};}let i=Math.atan2(r.y-e.y,r.x-e.x),f=Math.atan2(n.y-r.y,n.x-r.x);return {type:"curved",points:[e,n],controlPoint:r,departureAngle:i,arrivalAngle:f}}let d=n.x-e.x,u=n.y-e.y,l=t.controlPoint1,c=t.controlPoint2;if(!l||!c){let r=t.startBinding?.anchor,i=t.endBinding?.anchor,f=xt(r),o=xt(i);if(r&&i&&(f.dx!==0||f.dy!==0||o.dx!==0||o.dy!==0)){let y=Math.max(35,Math.hypot(d,u)*.35);l=l||{x:e.x+f.dx*y,y:e.y+f.dy*y},c=c||{x:n.x+o.dx*y,y:n.y+o.dy*y};}else l=l||{x:e.x+d*.4,y:e.y},c=c||{x:e.x+d*.6,y:n.y};}let a=Math.atan2(l.y-e.y,l.x-e.x),s=Math.atan2(n.y-c.y,n.x-c.x);return {type:"elbow",points:[e,n],controlPoint1:l,controlPoint2:c,departureAngle:a,arrivalAngle:s}}function kt(t,e,n=12){if(e.length<2)return;if(e.length===2){t.moveTo(e[0].x,e[0].y),t.lineTo(e[1].x,e[1].y);return}t.moveTo(e[0].x,e[0].y);for(let d=1;d<e.length-1;d++){let u=e[d-1],l=e[d],c=e[d+1],a=Math.hypot(l.x-u.x,l.y-u.y),s=Math.hypot(c.x-l.x,c.y-l.y),r=Math.min(n,a/2,s/2);t.arcTo(l.x,l.y,c.x,c.y,r);}let h=e[e.length-1];t.lineTo(h.x,h.y);}var ct=new Map;function W(t,e,n,h=1){if(e==="solid"||!e)return n;if(e==="transparent"||n==="transparent")return "transparent";let d=`${e}-${n}-${Math.round(h*10)/10}`;if(ct.has(d)){let r=ct.get(d);if(r)return r}if(typeof document>"u")return n;let l=e==="dots"?Math.max(8,Math.round(10*h)):Math.max(10,Math.round(14*h)),c=document.createElement("canvas");c.width=l,c.height=l;let a=c.getContext("2d");if(!a)return n;if(a.strokeStyle=n,a.fillStyle=n,a.lineWidth=Math.max(1.2,1.8*h),a.lineCap="round",e==="hachure")a.beginPath(),a.moveTo(0,l),a.lineTo(l,0),a.moveTo(-l/2,l/2),a.lineTo(l/2,-l/2),a.moveTo(l/2,l*1.5),a.lineTo(l*1.5,l/2),a.stroke();else if(e==="hachure-right")a.beginPath(),a.moveTo(0,0),a.lineTo(l,l),a.moveTo(l/2,-l/2),a.lineTo(l*1.5,l/2),a.moveTo(-l/2,l/2),a.lineTo(l/2,l*1.5),a.stroke();else if(e==="cross-hatch")a.beginPath(),a.moveTo(0,l),a.lineTo(l,0),a.moveTo(-l/2,l/2),a.lineTo(l/2,-l/2),a.moveTo(l/2,l*1.5),a.lineTo(l*1.5,l/2),a.moveTo(0,0),a.lineTo(l,l),a.moveTo(l/2,-l/2),a.lineTo(l*1.5,l/2),a.moveTo(-l/2,l/2),a.lineTo(l/2,l*1.5),a.stroke();else if(e==="dots"){let r=Math.max(.8,1.3*h);a.beginPath(),a.arc(l/2,l/2,r,0,Math.PI*2),a.fill();}let s=t.createPattern(c,"repeat");return s?(ct.set(d,s),s):n}function F(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return Math.abs(e)||12345}var X=class{state;constructor(e){this.state=e%2147483647,this.state<=0&&(this.state+=2147483646);}next(){return this.state=this.state*16807%2147483647,(this.state-1)/2147483646}offset(e){return (this.next()*2-1)*e}};function N(t,e,n,h,d,u,l={}){let c=l.roughness??1.5,a=l.bowing??1.8,s=l.overshoot??2.8,r=h-e,i=d-n,f=Math.hypot(r,i);if(f<1)return;let o=-i/f,y=r/f,x=u.offset(a*Math.min(6,c*1.4)),g=(e+h)/2+o*x,p=(n+d)/2+y*x,m=u.offset(s*c*.9),k=e-r/f*m,v=n-i/f*m,S=h+r/f*m,C=d+i/f*m;t.beginPath(),t.moveTo(k+u.offset(.8*c),v+u.offset(.8*c)),t.quadraticCurveTo(g,p,S+u.offset(.8*c),C+u.offset(.8*c)),t.stroke();let B=u.offset(a*Math.min(6,c*1.1)),Y=(e+h)/2+o*B,w=(n+d)/2+y*B,P=u.offset(s*c*.7),M=e-r/f*P,b=n-i/f*P,$=h+r/f*P,T=d+i/f*P;t.beginPath(),t.moveTo(M+u.offset(1*c),b+u.offset(1*c)),t.quadraticCurveTo(Y,w,$+u.offset(1*c),T+u.offset(1*c)),t.stroke();}function G(t,e,n,h=1.2){if(e.length<3)return;t.beginPath();let d=e[0];t.moveTo(d.x+n.offset(.8*h),d.y+n.offset(.8*h));for(let u=0;u<e.length;u++){let l=e[u],c=e[(u+1)%e.length],a=(l.x+c.x)/2+n.offset(1.2*h),s=(l.y+c.y)/2+n.offset(1.2*h),r=c.x+n.offset(.8*h),i=c.y+n.offset(.8*h);t.quadraticCurveTo(a,s,r,i);}t.closePath();}function K(t,e,n,h={}){for(let d=0;d<e.length;d++){let u=e[d],l=e[(d+1)%e.length];N(t,u.x,u.y,l.x,l.y,n,h);}}function Mt(t,e,n,h,d,u,l=false,c=true,a={}){let s=new X(F(u)),r=a.roughness??1.2,i=[{x:e,y:n},{x:e+h,y:n},{x:e+h,y:n+d},{x:e,y:n+d}];l&&(G(t,i,s,r),t.fill()),c&&K(t,i,s,a);}function Pt(t,e,n,h,d,u,l,c=false,a=true,s={}){let r=new X(F(l)),i=s.roughness??1.2,f=Math.min(u,Math.abs(h)/2,Math.abs(d)/2),o={x:e+f,y:n},y={x:e+h-f,y:n},x={x:e+h,y:n+f},g={x:e+h,y:n+d-f},p={x:e+h-f,y:n+d},m={x:e+f,y:n+d},k={x:e,y:n+d-f},v={x:e,y:n+f};if(c&&(t.beginPath(),t.moveTo(o.x,o.y),t.lineTo(y.x,y.y),t.arcTo(e+h,n,e+h,n+f,f),t.lineTo(g.x,g.y),t.arcTo(e+h,n+d,e+h-f,n+d,f),t.lineTo(m.x,m.y),t.arcTo(e,n+d,e,n+d-f,f),t.lineTo(v.x,v.y),t.arcTo(e,n,e+f,n,f),t.closePath(),t.fill()),a){N(t,o.x,o.y,y.x,y.y,r,s),N(t,x.x,x.y,g.x,g.y,r,s),N(t,p.x,p.y,m.x,m.y,r,s),N(t,k.x,k.y,v.x,v.y,r,s);let S=[{cx:e+h-f,cy:n+f,sa:-Math.PI/2,ea:0},{cx:e+h-f,cy:n+d-f,sa:0,ea:Math.PI/2},{cx:e+f,cy:n+d-f,sa:Math.PI/2,ea:Math.PI},{cx:e+f,cy:n+f,sa:Math.PI,ea:Math.PI*3/2}];for(let C of S)for(let B=0;B<2;B++){t.beginPath();let Y=r.offset(.8*i);t.arc(C.cx,C.cy,Math.max(1,f+Y),C.sa,C.ea),t.stroke();}}}function it(t,e,n,h,d,u,l=false,c=true,a={}){let s=new X(F(u)),r=a.roughness??1.2;if(l){t.beginPath();let i=8;for(let f=0;f<i;f++){let o=f/i*Math.PI*2,y=1+s.offset(.04*r),x=e+Math.cos(o)*h*y,g=n+Math.sin(o)*d*y;f===0?t.moveTo(x,g):t.lineTo(x,g);}t.closePath(),t.fill();}if(c){t.beginPath();let i=12;for(let y=0;y<=i+1;y++){let x=y/i*Math.PI*2,g=s.offset(1.2*r),p=s.offset(1.2*r),m=e+Math.cos(x)*(h+g),k=n+Math.sin(x)*(d+p);y===0?t.moveTo(m,k):t.lineTo(m,k);}t.stroke(),t.beginPath();let f=10,o=s.offset(.3);for(let y=0;y<=f+1;y++){let x=o+y/f*Math.PI*2,g=s.offset(1*r),p=s.offset(1*r),m=e+Math.cos(x)*(h+g),k=n+Math.sin(x)*(d+p);y===0?t.moveTo(m,k):t.lineTo(m,k);}t.stroke();}}var Tt=new Map;function ut(t,e,n){let h=[],d=e.split(`
|
|
2
|
+
`);for(let u of d){if(!u){h.push("");continue}let l=u.split(" "),c="";for(let a=0;a<l.length;a++){let s=l[a];if(t.measureText(s).width>n){c&&(h.push(c),c="");let f="";for(let o of s)t.measureText(f+o).width>n&&f?(h.push(f),f=o):f+=o;c=f;continue}let r=c?`${c} ${s}`:s;t.measureText(r).width>n&&c?(h.push(c),c=s):c=r;}c&&h.push(c);}return h}function lt(t){let e=Math.max(1,t.rows||3),n=Math.max(1,t.cols||3),h=Math.max(60,Math.abs(t.width)),d=Math.max(40,Math.abs(t.height)),u=t.colWidths&&t.colWidths.length===n?[...t.colWidths]:Array.from({length:n},()=>h/n),l=t.rowHeights&&t.rowHeights.length===e?[...t.rowHeights]:Array.from({length:e},()=>d/e);u=u.map(y=>Math.max(30,isNaN(y)||y<=0?h/n:y)),l=l.map(y=>Math.max(22,isNaN(y)||y<=0?d/e:y));let c=[0];for(let y=0;y<n;y++)c.push(c[y]+u[y]);let a=[0];for(let y=0;y<e;y++)a.push(a[y]+l[y]);let s=c[n],r=a[e],i=Math.min(t.x,t.x+t.width),f=Math.min(t.y,t.y+t.height);return {rows:e,cols:n,colWidths:u,rowHeights:l,colOffsets:c,rowOffsets:a,totalWidth:s,totalHeight:r,getCellBounds:(y,x)=>{let g=Math.max(0,Math.min(e-1,y)),p=Math.max(0,Math.min(n-1,x));return {x:i+c[p],y:f+a[g],width:u[p],height:l[g]}}}}function Lt(t){let{x:e,y:n,width:h,height:d}=t,u=Math.abs(h),l=Math.abs(d),c=e+h/2,a=n+d/2;switch(t.type){case "table":{let s=lt(t),r=t.editingCell?t.editingCell.row:0,i=t.editingCell?t.editingCell.col:0,f=s.getCellBounds(r,i),o=6,y=4,x=Math.max(16,f.width-o*2),g=Math.max(16,f.height-y*2);return {boxX:f.x+o,boxY:f.y+y,boxW:x,boxH:g,centerX:f.x+f.width/2,centerY:f.y+f.height/2}}case "rectangle":{let s=(t.edgeStyle||"round")==="round",r=s?Math.max(12,u*.08):8,i=s?Math.max(10,l*.08):6,f=Math.max(16,u-r*2),o=Math.max(16,l-i*2);return {boxX:e+r,boxY:n+i,boxW:f,boxH:o,centerX:c,centerY:a}}case "sticky":{let f=Math.max(16,u-28),o=Math.max(16,l-34);return {boxX:e+14,boxY:n+20,boxW:f,boxH:o,centerX:c,centerY:n+20+o/2}}case "ellipse":{let s=Math.max(16,u*.68),r=Math.max(16,l*.68);return {boxX:c-s/2,boxY:a-r/2,boxW:s,boxH:r,centerX:c,centerY:a}}case "diamond":{let s=Math.max(16,u*.52),r=Math.max(16,l*.5);return {boxX:c-s/2,boxY:a-r/2,boxW:s,boxH:r,centerX:c,centerY:a}}case "triangle":{let s=Math.max(16,u*.5),r=Math.max(16,l*.42),i=n+l*.62;return {boxX:c-s/2,boxY:i-r/2,boxW:s,boxH:r,centerX:c,centerY:i}}case "capsule":{let s=Math.min(u,l),r=u>=l,i=Math.max(16,r?u-s*.72:u-16),f=Math.max(16,r?l-16:l-s*.72);return {boxX:c-i/2,boxY:a-f/2,boxW:i,boxH:f,centerX:c,centerY:a}}case "trapezoid":{let s=Math.min(u*.2,40),r=Math.max(16,u-s*2.2),i=Math.max(16,l-18);return {boxX:c-r/2,boxY:a-i/2+2,boxW:r,boxH:i,centerX:c,centerY:a+2}}case "hexagon":{let s=Math.min(u*.22,45),r=Math.max(16,u-s*2.1),i=Math.max(16,l-16);return {boxX:c-r/2,boxY:a-i/2,boxW:r,boxH:i,centerX:c,centerY:a}}case "parallelogram":{let s=Math.min(36,u*.22),r=Math.max(16,u-s*2.2),i=Math.max(16,l-16);return {boxX:c-r/2,boxY:a-i/2,boxW:r,boxH:i,centerX:c,centerY:a}}case "cylinder":{let s=Math.min(22,l*.18),r=Math.max(16,u-28),i=Math.max(16,l-s*3.2),f=a+s*.5;return {boxX:c-r/2,boxY:f-i/2,boxW:r,boxH:i,centerX:c,centerY:f}}case "cloud":{let s=Math.max(16,u*.58),r=Math.max(16,l*.44);return {boxX:c-s/2,boxY:a-r/2,boxW:s,boxH:r,centerX:c,centerY:a}}case "star":{let s=Math.max(16,u*.4),r=Math.max(16,l*.4);return {boxX:c-s/2,boxY:a-r/2,boxW:s,boxH:r,centerX:c,centerY:a}}default:return {boxX:e+4,boxY:n+2,boxW:Math.max(16,u-8),boxH:Math.max(16,l-4),centerX:c,centerY:a}}}function st(t,e,n,h,d,u=0){if(t.beginPath(),u>0)if(typeof t.roundRect=="function")t.roundRect(e,n,h,d,u);else {let l=Math.min(u,Math.abs(h)/2,Math.abs(d)/2);t.moveTo(e+l,n),t.arcTo(e+h,n,e+h,n+d,l),t.arcTo(e+h,n+d,e,n+d,l),t.arcTo(e,n+d,e,n,l),t.arcTo(e,n,e+h,n,l),t.closePath();}else t.rect(e,n,h,d);}function _(t,e,n=1,h=false,d=false){if(!e.text||h)return;let{x:u,y:l,width:c,height:a}=e,s=Math.abs(c),r=Math.abs(a),i=u+c/2,f=l+a/2,o=tt(e.fontFamily),y=Lt(e),x=e.type==="text"?1/0:y.boxW*n,g=e.type==="text"?1/0:y.boxH*n,p=(e.fontSize||(e.type==="sticky"?20:22))*n,m=8*n,k=o.value==="fuzzy"||o.value==="edusa",v=o.value==="patrick"||o.value==="comic"||o.value==="handlee"?"400":k?e.type==="sticky"||e.type!=="text"?"700":"400":e.type==="sticky"||e.type!=="text"?"600":"500";t.font=`normal ${v} ${p}px ${o.cssFont}`;let S=e.type==="text"?e.text.split(`
|
|
3
|
+
`):ut(t,e.text,x),C=p*1.35;if(e.type!=="text")for(;(S.length*C>g||S.some(b=>t.measureText(b).width>x))&&p>m;)p-=.75*n,t.font=`normal ${v} ${p}px ${o.cssFont}`,S=ut(t,e.text,x),C=p*1.35;let B=S.length*C,Y=(C-p)/2,w=e.type==="text"?(l+Math.max(0,(a-B/n)/2))*n+Y:y.centerY*n-B/2+Y,P=e.textAlign||(e.type==="text"?"left":"center");t.textAlign=P,t.textBaseline="top";let M=P==="center"?e.type==="text"?(u+c/2)*n:y.centerX*n:P==="right"?e.type==="text"?(u+c-4)*n:(y.boxX+y.boxW)*n-4*n:e.type==="text"?(u+4)*n:y.boxX*n+4*n;if(e.type==="sticky"){let b=Q(e.stickyColor||e.fillColor,d);t.fillStyle=e.strokeColor&&e.strokeColor!=="transparent"?U(e.strokeColor,d):b.text;}else t.fillStyle=U(e.textColor||(d?"#f8fafc":"#0f172a"),d);if(e.type!=="text"){if(t.save(),t.beginPath(),e.type==="rectangle"||e.type==="sticky"){let b=e.type==="sticky",$=(e.edgeStyle||"round")==="round"||b,T=b?Math.min(22*n,s*.16,r*.16):$?Math.min(16*n,s*.2,r*.2):0;T>0&&typeof t.roundRect=="function"?t.roundRect(u+2,l+2,c-4,a-4,T):t.rect(u+2,l+2,c-4,a-4);}else if(e.type==="ellipse")t.ellipse(i,f,Math.max(1,s/2-2),Math.max(1,r/2-2),0,0,Math.PI*2);else if(e.type==="diamond")t.moveTo(i,l+2),t.lineTo(u+c-2,f),t.lineTo(i,l+a-2),t.lineTo(u+2,f),t.closePath();else if(e.type==="triangle")t.moveTo(i,l+2),t.lineTo(u+c-2,l+a-2),t.lineTo(u+2,l+a-2),t.closePath();else if(e.type==="capsule"){let b=Math.min(s,r)/2-2;s>=r?(t.arc(u+b+2,l+b+2,b,Math.PI/2,Math.PI*3/2),t.lineTo(u+c-b-2,l+2),t.arc(u+c-b-2,l+b+2,b,Math.PI*3/2,Math.PI/2),t.lineTo(u+b+2,l+a-2)):(t.arc(u+b+2,l+b+2,b,Math.PI,0),t.lineTo(u+c-2,l+a-b-2),t.arc(u+b+2,l+a-b-2,b,0,Math.PI),t.lineTo(u+2,l+b+2)),t.closePath();}else if(e.type==="trapezoid"){let b=Math.min(s*.2,40*n);t.moveTo(u+b+2,l+2),t.lineTo(u+c-b-2,l+2),t.lineTo(u+c-2,l+a-2),t.lineTo(u+2,l+a-2),t.closePath();}else if(e.type==="hexagon"){let b=Math.min(s*.22,45*n);t.moveTo(u+b+2,l+2),t.lineTo(u+c-b-2,l+2),t.lineTo(u+c-2,f),t.lineTo(u+c-b-2,l+a-2),t.lineTo(u+b+2,l+a-2),t.lineTo(u+2,f),t.closePath();}else if(e.type==="parallelogram"){let b=Math.min(36*n,s*.22);t.moveTo(u+b+2,l+2),t.lineTo(u+c-2,l+2),t.lineTo(u+c-b-2,l+a-2),t.lineTo(u+2,l+a-2),t.closePath();}else if(e.type==="cylinder"){let b=Math.abs(c/2)-2,$=Math.min(24*n,r*.2);t.ellipse(i,l+$,b,$,0,Math.PI,0),t.lineTo(u+c-2,l+a-$),t.ellipse(i,l+a-$,b,$,0,0,Math.PI),t.lineTo(u+2,l+$),t.closePath();}else e.type==="cloud"?t.ellipse(i,f,Math.max(1,s*.38),Math.max(1,r*.35),0,0,Math.PI*2):t.rect(u+2,l+2,c-4,a-4);t.clip();}S.forEach((b,$)=>{t.fillText(b,M,w+$*C);}),e.type!=="text"&&t.restore();}function St(t,e,n,h,d,u,l,c=1,a=false){if(!d||d==="none")return;let s=d===true?"arrow":d;t.save(),t.translate(e,n),t.rotate(h),t.strokeStyle=u,t.fillStyle=u,t.lineWidth=Math.max(1,l*c),t.lineCap="round",t.lineJoin="round";let r=Math.max(1.5,l*c);switch(s){case "arrow":{let i=Math.max(12*c,r*4.5),f=i*.55;t.beginPath(),t.moveTo(-i,-f),t.lineTo(0,0),t.lineTo(-i,f),t.stroke();break}case "triangle":{let i=Math.max(14*c,r*4.8),f=i*.55;t.beginPath(),t.moveTo(0,0),t.lineTo(-i,-f),t.lineTo(-i,f),t.closePath(),t.fill(),t.stroke();break}case "barbed":{let i=Math.max(16*c,r*5.2),f=i*.55,o=i*.35;t.beginPath(),t.moveTo(0,0),t.lineTo(-i,-f),t.lineTo(-i+o,0),t.lineTo(-i,f),t.closePath(),t.fill(),t.stroke();break}case "dot":{let i=Math.max(4.5*c,r*1.8);t.beginPath(),t.arc(-i,0,i,0,Math.PI*2),t.fill();break}case "circle":{let i=Math.max(4.5*c,r*1.8);t.beginPath(),t.arc(-i,0,i,0,Math.PI*2),t.fillStyle=a?"#181818":"#ffffff",t.fill(),t.stroke();break}case "diamond":{let i=Math.max(13*c,r*4.2),f=i*.5;t.beginPath(),t.moveTo(0,0),t.lineTo(-i/2,-f),t.lineTo(-i,0),t.lineTo(-i/2,f),t.closePath(),t.fill(),t.stroke();break}case "diamond_outline":{let i=Math.max(13*c,r*4.2),f=i*.5;t.beginPath(),t.moveTo(0,0),t.lineTo(-i/2,-f),t.lineTo(-i,0),t.lineTo(-i/2,f),t.closePath(),t.fillStyle=a?"#181818":"#ffffff",t.fill(),t.stroke();break}case "bar":case "crowfoot_one":{let i=Math.max(12*c,r*4.5);t.beginPath(),t.moveTo(0,-i/2),t.lineTo(0,i/2),t.stroke();break}case "crowfoot_many":{let i=Math.max(12*c,r*4),f=i*.7;t.beginPath(),t.moveTo(-i,-f),t.lineTo(0,0),t.lineTo(-i,f),t.moveTo(-i,0),t.lineTo(0,0),t.stroke();break}case "crowfoot_one_many":{let i=Math.max(14*c,r*4.5),f=i*.65;t.beginPath(),t.moveTo(-i,-f),t.lineTo(0,0),t.lineTo(-i,f),t.moveTo(-i,0),t.lineTo(0,0),t.moveTo(-i*.45,-f),t.lineTo(-i*.45,f),t.stroke();break}case "crowfoot_strictly_one":{let i=Math.max(12*c,r*4.5),f=Math.max(5*c,r*2);t.beginPath(),t.moveTo(0,-i/2),t.lineTo(0,i/2),t.moveTo(-f,-i/2),t.lineTo(-f,i/2),t.stroke();break}case "crowfoot_zero_one":{let i=Math.max(12*c,r*4.5),f=Math.max(4*c,r*1.5);t.beginPath(),t.arc(-f*2-2*c,0,f,0,Math.PI*2),t.fillStyle=a?"#181818":"#ffffff",t.fill(),t.stroke(),t.beginPath(),t.moveTo(0,-i/2),t.lineTo(0,i/2),t.stroke();break}case "crowfoot_zero_many":{let i=Math.max(12*c,r*4),f=i*.65,o=Math.max(4*c,r*1.5);t.beginPath(),t.moveTo(-i,-f),t.lineTo(0,0),t.lineTo(-i,f),t.moveTo(-i,0),t.lineTo(0,0),t.stroke(),t.beginPath(),t.arc(-i-o-2*c,0,o,0,Math.PI*2),t.fillStyle=a?"#181818":"#ffffff",t.fill(),t.stroke();break}}t.restore();}function ot(t,e,n=1,h=false,d=false,u=false){t.save(),t.globalAlpha=e.opacity??1;let l=e.x+e.width/2,c=e.y+e.height/2;e.rotation&&(t.translate(l,c),t.rotate(e.rotation),t.translate(-l,-c)),u&&e.type!=="frame"?(t.shadowColor=d?"rgba(0, 0, 0, 0.45)":"rgba(15, 23, 42, 0.08)",t.shadowBlur=Math.round((d?12:10)*n),t.shadowOffsetX=0,t.shadowOffsetY=Math.round((d?4:3)*n)):t.shadowColor="transparent";let a=U(e.strokeColor,d),s=et(e.fillColor,e.fillStyle,d);t.strokeStyle=a,t.lineWidth=Math.max(1,e.strokeWidth*n),t.lineCap="round",t.lineJoin="round",e.strokeStyle==="dashed"?t.setLineDash([Math.max(6,e.strokeWidth*2.5*n),Math.max(4,e.strokeWidth*1.8*n)]):e.strokeStyle==="dotted"?t.setLineDash([Math.max(1.5,e.strokeWidth*.8*n),Math.max(4,e.strokeWidth*1.8*n)]):t.setLineDash([]);let{x:r,y:i,width:f,height:o}=e,y=e.roughStyle==="rough"||e.roughness!==void 0&&e.roughness>0,x={roughness:e.roughness||1.2};switch(e.type){case "rectangle":{let p=(e.edgeStyle||"round")==="round"?Math.min(16,Math.min(Math.abs(f),Math.abs(o))*.25):0;s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n)),y?p>0?Pt(t,r,i,f,o,p,e.id,!!(s&&s!=="transparent"),e.strokeWidth>0&&a!=="transparent",x):Mt(t,r,i,f,o,e.id,!!(s&&s!=="transparent"),e.strokeWidth>0&&a!=="transparent",x):(s&&s!=="transparent"&&(p>0?(st(t,r,i,f,o,p),t.fill()):t.fillRect(r,i,f,o)),e.strokeWidth>0&&a!=="transparent"&&(p>0?(st(t,r,i,f,o,p),t.stroke()):t.strokeRect(r,i,f,o))),_(t,e,n,h,d);break}case "ellipse":{let g=Math.abs(f/2),p=Math.abs(o/2);s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n)),y?it(t,l,c,g,p,e.id,!!(s&&s!=="transparent"),e.strokeWidth>0&&a!=="transparent",x):(t.beginPath(),t.ellipse(l,c,g,p,0,0,Math.PI*2),s&&s!=="transparent"&&t.fill(),e.strokeWidth>0&&a!=="transparent"&&t.stroke()),_(t,e,n,h,d);break}case "diamond":{if(y){let g=new X(F(e.id)),p=[{x:l,y:i},{x:r+f,y:c},{x:l,y:i+o},{x:r,y:c}];s&&s!=="transparent"&&(G(t,p,g,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&K(t,p,g,x);}else t.beginPath(),t.moveTo(l,i),t.lineTo(r+f,c),t.lineTo(l,i+o),t.lineTo(r,c),t.closePath(),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&t.stroke();_(t,e,n,h,d);break}case "table":{let g=lt(e),m=(e.edgeStyle||"round")==="round"?Math.min(10,Math.min(g.totalWidth,g.totalHeight)*.05):0;st(t,r,i,g.totalWidth,g.totalHeight,m);let k=s&&s!=="transparent"?s:d?"rgba(24, 24, 28, 0.95)":"rgba(255, 255, 255, 0.95)";t.fillStyle=k,t.fill();let v=e.cells||{},S=e.hasHeaderRow??true,C=e.hasHeaderCol??false;for(let b=0;b<g.rows;b++)for(let $=0;$<g.cols;$++){let T=`${b}_${$}`,I=v[T],E=g.getCellBounds(b,$),R=null;I?.fill?R=I.fill:e.tableStyle==="swot"?b===0&&$===0?R=d?"rgba(16, 185, 129, 0.18)":"rgba(16, 185, 129, 0.12)":b===0&&$===1?R=d?"rgba(245, 158, 11, 0.18)":"rgba(245, 158, 11, 0.12)":b===1&&$===0?R=d?"rgba(59, 130, 246, 0.18)":"rgba(59, 130, 246, 0.12)":b===1&&$===1&&(R=d?"rgba(239, 68, 68, 0.18)":"rgba(239, 68, 68, 0.12)"):e.tableStyle==="kanban"&&b===0?$===0?R=d?"rgba(107, 114, 128, 0.22)":"rgba(107, 114, 128, 0.12)":$===1?R=d?"rgba(99, 102, 241, 0.22)":"rgba(99, 102, 241, 0.12)":$===2&&(R=d?"rgba(16, 185, 129, 0.22)":"rgba(16, 185, 129, 0.12)"):S&&b===0?R=d?"rgba(99, 102, 241, 0.22)":"rgba(99, 102, 241, 0.10)":C&&$===0?R=d?"rgba(99, 102, 241, 0.14)":"rgba(99, 102, 241, 0.06)":e.tableStyle==="zebra"&&b%2===1&&(R=d?"rgba(255, 255, 255, 0.03)":"rgba(0, 0, 0, 0.025)"),R&&(t.fillStyle=R,t.fillRect(E.x,E.y,E.width,E.height));}let B=Math.max(1,e.strokeWidth||1.5),Y=a;t.strokeStyle=Y,t.lineWidth=B;for(let b=1;b<g.cols;b++){let $=r+g.colOffsets[b];t.beginPath(),t.moveTo($,i),t.lineTo($,i+g.totalHeight),t.stroke();}for(let b=1;b<g.rows;b++){let $=i+g.rowOffsets[b];t.beginPath(),t.moveTo(r,$),t.lineTo(r+g.totalWidth,$),t.stroke();}e.strokeWidth>0&&a!=="transparent"&&(st(t,r,i,g.totalWidth,g.totalHeight,m),t.stroke());let w=Math.max(10,e.fontSize||13),P=tt(e.fontFamily),M=P.cssFont;for(let b=0;b<g.rows;b++)for(let $=0;$<g.cols;$++){if(h&&e.editingCell&&e.editingCell.row===b&&e.editingCell.col===$)continue;let I=`${b}_${$}`,E=v[I],R=E?.text??"";if(!R)continue;let z=g.getCellBounds(b,$),A=S&&b===0||C&&$===0||E?.bold,H=E?.align||(A?"center":"left");t.save(),t.beginPath(),t.rect(z.x+2,z.y+2,z.width-4,z.height-4),t.clip();let O=P.value==="fuzzy"||P.value==="edusa",q=P.value==="patrick"||P.value==="comic"||P.value==="handlee"?"400":O?A?"700":"400":A?"600":"400";t.font=`${q} ${w}px ${M}`,t.fillStyle=E?.color||(A&&S&&b===0?d?"#ffffff":"#1e1b4b":a),t.textBaseline="middle";let nt=ut(t,R,z.width-16),dt=w*1.35,Yt=nt.length*dt,At=z.y+(z.height-Yt)/2+dt/2;nt.forEach((Wt,Ht)=>{let Xt=At+Ht*dt,rt=z.x+8;H==="center"?(t.textAlign="center",rt=z.x+z.width/2):H==="right"?(t.textAlign="right",rt=z.x+z.width-8):(t.textAlign="left",rt=z.x+8),t.fillText(Wt,rt,Xt);}),t.restore();}break}case "cylinder":{let g=Math.abs(f/2),p=Math.min(24*n,Math.abs(o)*.2),m=i+p,k=i+o-p;if(y){let v=new X(F(e.id)),S=[{x:r,y:m},{x:r+f,y:m},{x:r+f,y:k},{x:r,y:k}];s&&s!=="transparent"&&(G(t,S,v,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&(N(t,r,m,r,k,v,x),N(t,r+f,m,r+f,k,v,x),it(t,l,k,g,p,e.id+"_b",false,true,x)),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n)),it(t,l,m,g,p,e.id+"_t",!!(s&&s!=="transparent"),e.strokeWidth>0&&a!=="transparent",x);}else t.beginPath(),t.ellipse(l,m,g,p,0,Math.PI,0),t.lineTo(r+f,k),t.ellipse(l,k,g,p,0,0,Math.PI),t.lineTo(r,m),t.closePath(),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&(t.beginPath(),t.moveTo(r,m),t.lineTo(r,k),t.ellipse(l,k,g,p,0,Math.PI,0,true),t.lineTo(r+f,m),t.stroke()),t.beginPath(),t.ellipse(l,m,g,p,0,0,Math.PI*2),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&t.stroke();_(t,e,n,h,d);break}case "parallelogram":{let g=Math.min(36*n,Math.abs(f)*.22),p=[{x:r+g,y:i},{x:r+f,y:i},{x:r+f-g,y:i+o},{x:r,y:i+o}];if(y){let m=new X(F(e.id));s&&s!=="transparent"&&(G(t,p,m,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&K(t,p,m,x);}else t.beginPath(),t.moveTo(p[0].x,p[0].y),t.lineTo(p[1].x,p[1].y),t.lineTo(p[2].x,p[2].y),t.lineTo(p[3].x,p[3].y),t.closePath(),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&t.stroke();_(t,e,n,h,d);break}case "cloud":{let g=Math.abs(f),p=Math.abs(o);t.beginPath(),t.moveTo(r+g*.2,i+p*.7),t.bezierCurveTo(r+g*.1,i+p*.85,r+g*.35,i+p*.95,r+g*.5,i+p*.85),t.bezierCurveTo(r+g*.65,i+p*.95,r+g*.9,i+p*.85,r+g*.85,i+p*.65),t.bezierCurveTo(r+g*1.02,i+p*.5,r+g*.98,i+p*.25,r+g*.8,i+p*.25),t.bezierCurveTo(r+g*.78,i+p*.05,r+g*.52,i+p*.05,r+g*.45,i+p*.2),t.bezierCurveTo(r+g*.35,i+p*.08,r+g*.12,i+p*.15,r+g*.15,i+p*.4),t.bezierCurveTo(r-g*.02,i+p*.45,r-g*.01,i+p*.68,r+g*.2,i+p*.7),t.closePath(),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&(t.stroke(),y&&t.stroke()),_(t,e,n,h,d);break}case "star":{let p=Math.min(Math.abs(f),Math.abs(o))/2,m=p*.45,k=Math.PI/2*3,v=Math.PI/5,S=[];for(let C=0;C<5;C++)S.push({x:l+Math.cos(k)*p,y:c+Math.sin(k)*p}),k+=v,S.push({x:l+Math.cos(k)*m,y:c+Math.sin(k)*m}),k+=v;if(y){let C=new X(F(e.id));s&&s!=="transparent"&&(G(t,S,C,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&K(t,S,C,x);}else {t.beginPath(),t.moveTo(S[0].x,S[0].y);for(let C=1;C<S.length;C++)t.lineTo(S[C].x,S[C].y);t.closePath(),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),u&&(t.shadowColor="transparent"),e.strokeWidth>0&&a!=="transparent"&&t.stroke();}_(t,e,n,h,d);break}case "triangle":{let g=(e.edgeStyle||"round")==="round",p={x:r+f/2,y:i},m={x:r+f,y:i+o},k={x:r,y:i+o},v=[p,m,k];if(y){let S=new X(F(e.id));s&&s!=="transparent"&&(G(t,v,S,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&K(t,v,S,x);}else {if(t.beginPath(),g){let S=Math.min(12,Math.min(Math.abs(f),Math.abs(o))*.15);t.moveTo((p.x+m.x)/2,(p.y+m.y)/2),t.arcTo(m.x,m.y,k.x,k.y,S),t.arcTo(k.x,k.y,p.x,p.y,S),t.arcTo(p.x,p.y,m.x,m.y,S),t.closePath();}else t.moveTo(p.x,p.y),t.lineTo(m.x,m.y),t.lineTo(k.x,k.y),t.closePath();s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),u&&(t.shadowColor="transparent"),e.strokeWidth>0&&a!=="transparent"&&t.stroke();}_(t,e,n,h,d);break}case "trapezoid":{let g=(e.edgeStyle||"round")==="round",p=Math.min(Math.abs(f)*.2,40*n),m={x:r+p,y:i},k={x:r+f-p,y:i},v={x:r+f,y:i+o},S={x:r,y:i+o},C=[m,k,v,S];if(y){let B=new X(F(e.id));s&&s!=="transparent"&&(G(t,C,B,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&K(t,C,B,x);}else {if(t.beginPath(),g){let B=Math.min(10,Math.min(Math.abs(f),Math.abs(o))*.15);t.moveTo((m.x+k.x)/2,m.y),t.arcTo(k.x,k.y,v.x,v.y,B),t.arcTo(v.x,v.y,S.x,S.y,B),t.arcTo(S.x,S.y,m.x,m.y,B),t.arcTo(m.x,m.y,k.x,k.y,B),t.closePath();}else t.moveTo(m.x,m.y),t.lineTo(k.x,k.y),t.lineTo(v.x,v.y),t.lineTo(S.x,S.y),t.closePath();s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),u&&(t.shadowColor="transparent"),e.strokeWidth>0&&a!=="transparent"&&t.stroke();}_(t,e,n,h,d);break}case "hexagon":{let g=(e.edgeStyle||"round")==="round",p=Math.min(Math.abs(f)*.22,45*n),m={x:r+p,y:i},k={x:r+f-p,y:i},v={x:r+f,y:i+o/2},S={x:r+f-p,y:i+o},C={x:r+p,y:i+o},B={x:r,y:i+o/2},Y=[m,k,v,S,C,B];if(y){let w=new X(F(e.id));s&&s!=="transparent"&&(G(t,Y,w,x.roughness),t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),e.strokeWidth>0&&a!=="transparent"&&K(t,Y,w,x);}else {if(t.beginPath(),g){let w=Math.min(10,Math.min(Math.abs(f),Math.abs(o))*.12);t.moveTo((m.x+k.x)/2,m.y),t.arcTo(k.x,k.y,v.x,v.y,w),t.arcTo(v.x,v.y,S.x,S.y,w),t.arcTo(S.x,S.y,C.x,C.y,w),t.arcTo(C.x,C.y,B.x,B.y,w),t.arcTo(B.x,B.y,m.x,m.y,w),t.arcTo(m.x,m.y,k.x,k.y,w),t.closePath();}else t.moveTo(m.x,m.y),t.lineTo(k.x,k.y),t.lineTo(v.x,v.y),t.lineTo(S.x,S.y),t.lineTo(C.x,C.y),t.lineTo(B.x,B.y),t.closePath();s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),u&&(t.shadowColor="transparent"),e.strokeWidth>0&&a!=="transparent"&&t.stroke();}_(t,e,n,h,d);break}case "capsule":{let g=Math.abs(f),p=Math.abs(o),m=Math.min(g,p)/2;t.beginPath(),g>=p?(t.arc(r+m,i+m,m,Math.PI/2,Math.PI*3/2),t.lineTo(r+f-m,i),t.arc(r+f-m,i+m,m,Math.PI*3/2,Math.PI/2),t.lineTo(r+m,i+o)):(t.arc(r+m,i+m,m,Math.PI,0),t.lineTo(r+f-m,i+o-m),t.arc(r+m,i+o-m,m,0,Math.PI),t.lineTo(r,i+m)),t.closePath(),s&&s!=="transparent"&&(t.fillStyle=W(t,e.fillStyle||"solid",s,n),t.fill()),u&&(t.shadowColor="transparent"),e.strokeWidth>0&&a!=="transparent"&&(t.stroke(),y&&t.stroke()),_(t,e,n,h,d);break}case "arrow":case "line":{let g=at(e),p={x:r+f,y:i+o};if(y&&g.type==="straight"){let k=new X(F(e.id));N(t,r,i,p.x,p.y,k,x);}else t.beginPath(),g.type==="straight"?(t.moveTo(r,i),t.lineTo(p.x,p.y)):g.type==="curved"&&g.controlPoint?(t.moveTo(r,i),t.quadraticCurveTo(g.controlPoint.x,g.controlPoint.y,p.x,p.y)):g.type==="elbow"&&g.controlPoint1&&g.controlPoint2?(t.moveTo(r,i),t.bezierCurveTo(g.controlPoint1.x,g.controlPoint1.y,g.controlPoint2.x,g.controlPoint2.y,p.x,p.y)):kt(t,g.points,Math.max(8,12*n)),t.stroke(),y&&t.stroke();e.startArrowhead&&e.startArrowhead!=="none"&&St(t,r,i,g.departureAngle+Math.PI,e.startArrowhead,a,e.strokeWidth,n,d);let m=e.endArrowhead!==void 0?e.endArrowhead:e.type==="arrow"?"arrow":"none";m&&m!=="none"&&St(t,p.x,p.y,g.arrivalAngle,m,a,e.strokeWidth,n,d);break}case "pen":{let g=e.points;if(!g||g.length<2)break;t.beginPath(),t.moveTo(g[0].x,g[0].y);for(let m=1;m<g.length-1;m++){let k=(g[m].x+g[m+1].x)/2,v=(g[m].y+g[m+1].y)/2;t.quadraticCurveTo(g[m].x,g[m].y,k,v);}let p=g[g.length-1];t.lineTo(p.x,p.y),t.stroke();break}case "text":{_(t,e,n,h,d);break}case "sticky":{let g=Q(e.stickyColor||e.fillColor,d),p=Math.abs(f),m=Math.abs(o),k=Math.min(22*n,Math.min(p,m)*.16),v=Math.min(13*n,p*.08),S=Math.min(13*n,m*.08);t.fillStyle=g.backSheetBg,t.strokeStyle=g.backSheetBorder,t.lineWidth=1.5*n,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(r+v,i+S,f,o,k):t.rect(r+v,i+S,f,o),t.fill(),t.stroke(),t.save(),t.shadowColor="rgba(0, 0, 0, 0.08)",t.shadowBlur=8*n,t.shadowOffsetX=1*n,t.shadowOffsetY=3*n,t.fillStyle=g.bg,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(r,i,f,o,k):t.rect(r,i,f,o),t.fill(),t.restore(),t.strokeStyle=g.mainBorder,t.lineWidth=1.5*n,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(r,i,f,o,k):t.rect(r,i,f,o),t.stroke(),t.save(),t.strokeStyle=g.sheen,t.lineWidth=1.5*n,t.beginPath();let C=2*n,B=Math.max(2,k-C);typeof t.roundRect=="function"&&t.roundRect(r+C,i+C,f-C*2,o-C*2,B),t.stroke(),t.restore();let Y=Math.min(64*n,Math.max(30*n,p*.28)),w=Math.min(18*n,Math.max(10*n,m*.09)),P=r+(f-Y)/2,M=i-w*.42,b=4*n;t.save(),t.shadowColor="rgba(0, 0, 0, 0.06)",t.shadowBlur=4*n,t.shadowOffsetY=1*n,t.fillStyle=g.tapeBg,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(P,M,Y,w,b):t.rect(P,M,Y,w),t.fill(),t.restore(),t.strokeStyle=g.tapeBorder,t.lineWidth=1*n,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(P,M,Y,w,b):t.rect(P,M,Y,w),t.stroke(),_(t,e,n,h,d);break}case "image":{if(e.dataUrl){let g=Tt.get(e.dataUrl);if(g||(g=new Image,g.crossOrigin="anonymous",g.onload=()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("sketch-redraw-canvas"));},g.src=e.dataUrl,Tt.set(e.dataUrl,g)),g.complete&&g.naturalWidth>0)if(e.edgeStyle==="round"){let p=Math.min(10*n,Math.abs(f)/4,Math.abs(o)/4);t.save(),t.beginPath(),typeof t.roundRect=="function"?t.roundRect(r,i,f,o,p):t.rect(r,i,f,o),t.clip(),t.drawImage(g,r,i,f,o),t.restore();}else t.drawImage(g,r,i,f,o);}break}case "frame":{let g=f<0?r+f:r,p=o<0?i+o:i,m=Math.abs(f),k=Math.abs(o);if(e.fillColor&&e.fillColor!=="transparent"&&(t.fillStyle=et(e.fillColor,e.fillStyle||"solid",d),t.fillRect(g,p,m,k)),e.strokeColor!=="transparent"){t.save();let v=e.strokeColor&&e.strokeColor!=="transparent"?U(e.strokeColor,d):d?"#818cf8":"#6366f1";t.strokeStyle=v,t.lineWidth=Math.max(1,(e.strokeWidth||1.5)*n),e.strokeStyle==="dashed"?t.setLineDash([6*n,6*n]):e.strokeStyle==="dotted"?t.setLineDash([2*n,4*n]):t.setLineDash([]),t.strokeRect(g,p,m,k),t.restore();}if(!h){let v=e.frameLabel||"Frame",S=Math.max(11,12*n);t.save(),t.font=`600 ${S}px Inter, -apple-system, sans-serif`;let C=t.measureText(v),B=8*n,Y=S+8*n,w=C.width+B*2,P=g+m-w,M=p-Y-3*n;t.fillStyle=d?"#27272a":"#e4e4e7",typeof t.roundRect=="function"?(t.beginPath(),t.roundRect(P,M,w,Y,4*n),t.fill()):t.fillRect(P,M,w,Y),t.fillStyle=d?"#f4f4f5":"#18181b",t.textAlign="left",t.textBaseline="middle",t.fillText(v,P+B,M+Y/2),t.restore();}break}}t.restore();}function D(t){let e=Math.min(t.x,t.x+t.width),n=Math.min(t.y,t.y+t.height),h=Math.abs(t.width),d=Math.abs(t.height);return {x:e,y:n,width:h,height:d}}function L(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Z(t){if(!t||t==="transparent")return false;if(t.startsWith("#")){let e=t.replace("#","");if(e.length===3){let n=parseInt(e[0]+e[0],16),h=parseInt(e[1]+e[1],16),d=parseInt(e[2]+e[2],16);return n*.299+h*.587+d*.114<128}if(e.length===6){let n=parseInt(e.substring(0,2),16),h=parseInt(e.substring(2,4),16),d=parseInt(e.substring(4,6),16);return n*.299+h*.587+d*.114<128}}return false}function vt(t,e,n,h,d,u,l){if(!h||h==="none")return "";let c=h===true?"arrow":h,a=Math.max(1.5,u),s=`transform="translate(${t}, ${e}) rotate(${n*180/Math.PI})"`;switch(c){case "arrow":{let r=Math.max(12,a*4.5),i=r*.55;return `<path d="M ${-r} ${-i} L 0 0 L ${-r} ${i}" fill="none" stroke="${d}" stroke-width="${a}" stroke-linecap="round" stroke-linejoin="round" opacity="${l}" ${s} />
|
|
4
4
|
`}case "triangle":{let r=Math.max(14,a*4.8),i=r*.55;return `<polygon points="0,0 ${-r},${-i} ${-r},${i}" fill="${d}" stroke="${d}" stroke-width="${a}" stroke-linejoin="round" opacity="${l}" ${s} />
|
|
5
5
|
`}case "barbed":{let r=Math.max(16,a*5.2),i=r*.55,f=r*.35;return `<polygon points="0,0 ${-r},${-i} ${-r+f},0 ${-r},${i}" fill="${d}" stroke="${d}" stroke-width="${a}" stroke-linejoin="round" opacity="${l}" ${s} />
|
|
6
6
|
`}case "dot":{let r=Math.max(4.5,a*1.8);return `<circle cx="${-r}" cy="0" r="${r}" fill="${d}" opacity="${l}" ${s} />
|
|
@@ -13,54 +13,54 @@ import {rgb,PDFDocument}from'pdf-lib';async function yt(t,e,n){if(typeof window>
|
|
|
13
13
|
`}case "crowfoot_strictly_one":{let r=Math.max(12,a*4.5),i=Math.max(5,a*2);return `<path d="M 0 ${-r/2} L 0 ${r/2} M ${-i} ${-r/2} L ${-i} ${r/2}" fill="none" stroke="${d}" stroke-width="${a}" stroke-linecap="round" opacity="${l}" ${s} />
|
|
14
14
|
`}case "crowfoot_zero_one":{let r=Math.max(12,a*4.5),i=Math.max(4,a*1.5);return `<circle cx="${-i*2-2}" cy="0" r="${i}" fill="white" stroke="${d}" stroke-width="${a}" opacity="${l}" ${s} /><line x1="0" y1="${-r/2}" x2="0" y2="${r/2}" stroke="${d}" stroke-width="${a}" stroke-linecap="round" opacity="${l}" ${s} />
|
|
15
15
|
`}case "crowfoot_zero_many":{let r=Math.max(12,a*4),i=r*.65,f=Math.max(4,a*1.5);return `<path d="M ${-r} ${-i} L 0 0 L ${-r} ${i} M ${-r} 0 L 0 0" fill="none" stroke="${d}" stroke-width="${a}" stroke-linecap="round" opacity="${l}" ${s} /><circle cx="${-r-f-2}" cy="0" r="${f}" fill="white" stroke="${d}" stroke-width="${a}" opacity="${l}" ${s} />
|
|
16
|
-
`}default:return ""}}function V(t,e=40){if(t.length===0)return {minX:0,minY:0,maxX:800,maxY:600,width:800,height:600};let n=1/0,h=1/0,d=-1/0,u=-1/0;for(let l of t){let c=D(l);if(n=Math.min(n,c.x),h=Math.min(h,c.y),d=Math.max(d,c.x+c.width),u=Math.max(u,c.y+c.height),l.points&&l.points.length>0)for(let a of l.points)n=Math.min(n,a.x),h=Math.min(h,a.y),d=Math.max(d,a.x),u=Math.max(u,a.y);}return n-=e,h-=e,d+=e,u+=e,{minX:n,minY:h,maxX:d,maxY:u,width:Math.max(100,d-n),height:Math.max(100,u-h)}}async function Bt(t,e={}){let{scale:n=2,backgroundColor:h="#ffffff",gridStyle:d="none",padding:u=40}=e,l=V(t,u),c=document.createElement("canvas");c.width=l.width*n,c.height=l.height*n;let a=c.getContext("2d");if(!a)throw new Error("Could not create canvas 2d context");let s=e.isDark??(Z(h)||h==="transparent"&&typeof document<"u"&&document.documentElement.classList.contains("dark"));if(h&&h!=="transparent"&&(a.fillStyle=h,a.fillRect(0,0,c.width,c.height)),d&&d!=="none"){if(d==="dots"){let f=24*n,o=Math.max(.8*n,1.05*n);a.fillStyle=s?"rgba(255, 255, 255, 0.14)":"rgba(0, 0, 0, 0.12)";for(let y=0;y<c.width;y+=f)for(let x=0;x<c.height;x+=f)a.beginPath(),a.arc(y,x,o,0,Math.PI*2),a.fill();}else if(d==="grid"){let f=20*n;a.strokeStyle=s?"rgba(255, 255, 255, 0.08)":"rgba(0, 0, 0, 0.08)",a.lineWidth=1*n,a.setLineDash([1.5*n,3.5*n]),a.beginPath();for(let o=0;o<c.width;o+=f)a.moveTo(o,0),a.lineTo(o,c.height);for(let o=0;o<c.height;o+=f)a.moveTo(0,o),a.lineTo(c.width,o);a.stroke(),a.setLineDash([]);}else if(d==="cross"){let f=32*n;a.strokeStyle=s?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.10)",a.lineWidth=1*n,a.beginPath();for(let o=0;o<c.width;o+=f)for(let y=0;y<c.height;y+=f)a.moveTo(o-3*n,y),a.lineTo(o+3*n,y),a.moveTo(o,y-3*n),a.lineTo(o,y+3*n);a.stroke();}}a.save(),a.scale(n,n),a.translate(-l.minX,-l.minY);let r=t.filter(f=>f.type==="image"&&f.dataUrl);r.length>0&&await Promise.all(r.map(f=>new Promise(o=>{let y=new Image;y.crossOrigin="anonymous",y.onload=()=>o(),y.onerror=()=>o(),y.src=f.dataUrl;})));let i=[...t].sort((f,o)=>(f.zIndex??0)-(o.zIndex??0));for(let f of i)ot(a,f,1,false,s);return a.restore(),c.toDataURL("image/png")}function Ot(t,e={}){let{backgroundColor:n="#ffffff",gridStyle:h="none",padding:d=40}=e,u=V(t,d),l=e.isDark??(Z(n)||n==="transparent"&&typeof document<"u"&&document.documentElement.classList.contains("dark")),c=[...t].sort((o,y)=>(o.zIndex??0)-(y.zIndex??0)),a="";for(let o of c){let y=o.opacity??1,x=U(o.strokeColor??"#000",l),g=o.strokeWidth??2,
|
|
17
|
-
`,o.text){let
|
|
18
|
-
`),E=T*1.35,R=$-I.length*E/2+T*.8;I.forEach((z,A)=>{a+=`<text x="${
|
|
19
|
-
`;});}break}case "ellipse":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.abs(o.width/2),
|
|
16
|
+
`}default:return ""}}function V(t,e=40){if(t.length===0)return {minX:0,minY:0,maxX:800,maxY:600,width:800,height:600};let n=1/0,h=1/0,d=-1/0,u=-1/0;for(let l of t){let c=D(l);if(n=Math.min(n,c.x),h=Math.min(h,c.y),d=Math.max(d,c.x+c.width),u=Math.max(u,c.y+c.height),l.points&&l.points.length>0)for(let a of l.points)n=Math.min(n,a.x),h=Math.min(h,a.y),d=Math.max(d,a.x),u=Math.max(u,a.y);}return n-=e,h-=e,d+=e,u+=e,{minX:n,minY:h,maxX:d,maxY:u,width:Math.max(100,d-n),height:Math.max(100,u-h)}}async function Bt(t,e={}){let{scale:n=2,backgroundColor:h="#ffffff",gridStyle:d="none",padding:u=40}=e,l=V(t,u),c=document.createElement("canvas");c.width=l.width*n,c.height=l.height*n;let a=c.getContext("2d");if(!a)throw new Error("Could not create canvas 2d context");let s=e.isDark??(Z(h)||h==="transparent"&&typeof document<"u"&&document.documentElement.classList.contains("dark"));if(h&&h!=="transparent"&&(a.fillStyle=h,a.fillRect(0,0,c.width,c.height)),d&&d!=="none"){if(d==="dots"){let f=24*n,o=Math.max(.8*n,1.05*n);a.fillStyle=s?"rgba(255, 255, 255, 0.14)":"rgba(0, 0, 0, 0.12)";for(let y=0;y<c.width;y+=f)for(let x=0;x<c.height;x+=f)a.beginPath(),a.arc(y,x,o,0,Math.PI*2),a.fill();}else if(d==="grid"){let f=20*n;a.strokeStyle=s?"rgba(255, 255, 255, 0.08)":"rgba(0, 0, 0, 0.08)",a.lineWidth=1*n,a.setLineDash([1.5*n,3.5*n]),a.beginPath();for(let o=0;o<c.width;o+=f)a.moveTo(o,0),a.lineTo(o,c.height);for(let o=0;o<c.height;o+=f)a.moveTo(0,o),a.lineTo(c.width,o);a.stroke(),a.setLineDash([]);}else if(d==="cross"){let f=32*n;a.strokeStyle=s?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.10)",a.lineWidth=1*n,a.beginPath();for(let o=0;o<c.width;o+=f)for(let y=0;y<c.height;y+=f)a.moveTo(o-3*n,y),a.lineTo(o+3*n,y),a.moveTo(o,y-3*n),a.lineTo(o,y+3*n);a.stroke();}}a.save(),a.scale(n,n),a.translate(-l.minX,-l.minY);let r=t.filter(f=>f.type==="image"&&f.dataUrl);r.length>0&&await Promise.all(r.map(f=>new Promise(o=>{let y=new Image;y.crossOrigin="anonymous",y.onload=()=>o(),y.onerror=()=>o(),y.src=f.dataUrl;})));let i=[...t].sort((f,o)=>(f.zIndex??0)-(o.zIndex??0));for(let f of i)ot(a,f,1,false,s);return a.restore(),c.toDataURL("image/png")}function Ot(t,e={}){let{backgroundColor:n="#ffffff",gridStyle:h="none",padding:d=40}=e,u=V(t,d),l=e.isDark??(Z(n)||n==="transparent"&&typeof document<"u"&&document.documentElement.classList.contains("dark")),c=[...t].sort((o,y)=>(o.zIndex??0)-(y.zIndex??0)),a="";for(let o of c){let y=o.opacity??1,x=U(o.strokeColor??"#000",l),g=o.strokeWidth??2,p=et(o.fillColor,o.fillStyle,l),m=!p||p==="transparent"?"none":p,k=o.strokeStyle==="dashed"?"8,6":o.strokeStyle==="dotted"?"3,4":"none",v=tt(o.fontFamily),S=v.cssFont.replace(/"/g,"""),C=v.value==="fuzzy"||v.value==="edusa",B=v.value==="patrick"||v.value==="comic"||v.value==="handlee"?"400":C?o.type==="sticky"||o.type!=="text"?"700":"400":"600",Y=w=>w;switch(o.type){case "rectangle":{let P=(o.edgeStyle||"round")==="round"?Math.min(16,Math.min(Math.abs(o.width),Math.abs(o.height))*.25):0,M=P>0?` rx="${P}"`:"";if(a+=`<rect x="${o.x}" y="${o.y}" width="${o.width}" height="${o.height}"${M} fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
17
|
+
`,o.text){let b=o.x+o.width/2,$=o.y+o.height/2,T=o.fontSize||20,I=o.text.split(`
|
|
18
|
+
`),E=T*1.35,R=$-I.length*E/2+T*.8;I.forEach((z,A)=>{a+=`<text x="${b}" y="${R+A*E}" font-family="${S}" font-size="${T}" fill="${x}" text-anchor="middle" font-weight="${B}">${L(Y(z))}</text>
|
|
19
|
+
`;});}break}case "ellipse":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.abs(o.width/2),b=Math.abs(o.height/2);if(a+=`<ellipse cx="${w}" cy="${P}" rx="${M}" ry="${b}" fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
20
20
|
`,o.text){let $=o.fontSize||20,T=o.text.split(`
|
|
21
21
|
`),I=$*1.35,E=P-T.length*I/2+$*.8;T.forEach((R,z)=>{a+=`<text x="${w}" y="${E+z*I}" font-family="${S}" font-size="${$}" fill="${x}" text-anchor="middle" font-weight="${B}">${L(Y(R))}</text>
|
|
22
22
|
`;});}break}case "diamond":{let w=o.x+o.width/2,P=o.y+o.height/2,M=`${w},${o.y} ${o.x+o.width},${P} ${w},${o.y+o.height} ${o.x},${P}`;if(a+=`<polygon points="${M}" fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
23
|
-
`,o.text){let
|
|
24
|
-
`),T=
|
|
25
|
-
`;});}break}case "cylinder":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.abs(o.width/2),
|
|
26
|
-
`,a+=`<ellipse cx="${w}" cy="${$}" rx="${M}" ry="${
|
|
23
|
+
`,o.text){let b=o.fontSize||20,$=o.text.split(`
|
|
24
|
+
`),T=b*1.35,I=P-$.length*T/2+b*.8;$.forEach((E,R)=>{a+=`<text x="${w}" y="${I+R*T}" font-family="${S}" font-size="${b}" fill="${x}" text-anchor="middle" font-weight="${B}">${L(Y(E))}</text>
|
|
25
|
+
`;});}break}case "cylinder":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.abs(o.width/2),b=Math.min(24,Math.abs(o.height)*.2),$=o.y+b,T=o.y+o.height-b,I=`M ${o.x} ${$} A ${M} ${b} 0 0 1 ${o.x+o.width} ${$} L ${o.x+o.width} ${T} A ${M} ${b} 0 0 1 ${o.x} ${T} Z`;if(a+=`<path d="${I}" fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
26
|
+
`,a+=`<ellipse cx="${w}" cy="${$}" rx="${M}" ry="${b}" fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
27
27
|
`,o.text){let E=o.fontSize||20,R=o.text.split(`
|
|
28
28
|
`),z=E*1.35,A=P-R.length*z/2+E*.8;R.forEach((H,O)=>{a+=`<text x="${w}" y="${A+O*z}" font-family="${S}" font-size="${E}" fill="${x}" text-anchor="middle" font-weight="${B}">${L(Y(H))}</text>
|
|
29
29
|
`;});}break}case "table":{let w=lt(o),M=(o.edgeStyle||"round")==="round"?6:0;a+=`<rect x="${o.x}" y="${o.y}" width="${w.totalWidth}" height="${w.totalHeight}" rx="${M}" fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
30
30
|
`;for(let T=1;T<w.cols;T++){let I=o.x+w.colOffsets[T];a+=`<line x1="${I}" y1="${o.y}" x2="${I}" y2="${o.y+w.totalHeight}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" />
|
|
31
31
|
`;}for(let T=1;T<w.rows;T++){let I=o.y+w.rowOffsets[T];a+=`<line x1="${o.x}" y1="${I}" x2="${o.x+w.totalWidth}" y2="${I}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" />
|
|
32
|
-
`;}let
|
|
33
|
-
`;}break}case "parallelogram":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.min(36,o.width*.22),
|
|
32
|
+
`;}let b=o.cells||{},$=o.fontSize||13;for(let T=0;T<w.rows;T++)for(let I=0;I<w.cols;I++){let E=`${T}_${I}`,R=b[E];if(!R?.text)continue;let z=w.getCellBounds(T,I),A=o.hasHeaderRow&&T===0||R.bold,H=z.y+z.height/2+$*.35,O=z.x+8;a+=`<text x="${O}" y="${H}" font-family="${S}" font-size="${$}" fill="${x}" font-weight="${C?A?"700":"400":A?"600":"400"}">${L(R.text)}</text>
|
|
33
|
+
`;}break}case "parallelogram":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.min(36,o.width*.22),b=`${o.x+M},${o.y} ${o.x+o.width},${o.y} ${o.x+o.width-M},${o.y+o.height} ${o.x},${o.y+o.height}`;if(a+=`<polygon points="${b}" fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
34
34
|
`,o.text){let $=o.fontSize||20,T=o.text.split(`
|
|
35
35
|
`),I=$*1.35,E=P-T.length*I/2+$*.8;T.forEach((R,z)=>{a+=`<text x="${w}" y="${E+z*I}" font-family="${S}" font-size="${$}" fill="${x}" text-anchor="middle" font-weight="${B}">${L(R)}</text>
|
|
36
|
-
`;});}break}case "cloud":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.abs(o.width),
|
|
36
|
+
`;});}break}case "cloud":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.abs(o.width),b=Math.abs(o.height),$=o.x,T=o.y,I=`M ${$+M*.2} ${T+b*.7} C ${$+M*.1} ${T+b*.85}, ${$+M*.35} ${T+b*.95}, ${$+M*.5} ${T+b*.85} C ${$+M*.65} ${T+b*.95}, ${$+M*.9} ${T+b*.85}, ${$+M*.85} ${T+b*.65} C ${$+M*1.02} ${T+b*.5}, ${$+M*.98} ${T+b*.25}, ${$+M*.8} ${T+b*.25} C ${$+M*.78} ${T+b*.05}, ${$+M*.52} ${T+b*.05}, ${$+M*.45} ${T+b*.2} C ${$+M*.35} ${T+b*.08}, ${$+M*.12} ${T+b*.15}, ${$+M*.15} ${T+b*.4} C ${$-M*.02} ${T+b*.45}, ${$-M*.01} ${T+b*.68}, ${$+M*.2} ${T+b*.7} Z`;if(a+=`<path d="${I}" fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
37
37
|
`,o.text){let E=o.fontSize||20,R=o.text.split(`
|
|
38
38
|
`),z=E*1.35,A=P-R.length*z/2+E*.8;R.forEach((H,O)=>{a+=`<text x="${w}" y="${A+O*z}" font-family="${S}" font-size="${E}" fill="${x}" text-anchor="middle" font-weight="${B}">${L(H)}</text>
|
|
39
|
-
`;});}break}case "star":{let w=o.x+o.width/2,P=o.y+o.height/2,M=5,
|
|
39
|
+
`;});}break}case "star":{let w=o.x+o.width/2,P=o.y+o.height/2,M=5,b=Math.min(Math.abs(o.width),Math.abs(o.height))/2,$=b*.45,T=Math.PI/2*3,I=Math.PI/M,E=[];for(let R=0;R<M;R++){let z=w+Math.cos(T)*b,A=P+Math.sin(T)*b;E.push(`${z},${A}`),T+=I;let H=w+Math.cos(T)*$,O=P+Math.sin(T)*$;E.push(`${H},${O}`),T+=I;}if(a+=`<polygon points="${E.join(" ")}" fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
40
40
|
`,o.text){let R=o.fontSize||20,z=o.text.split(`
|
|
41
41
|
`),A=R*1.35,H=P-z.length*A/2+R*.8;z.forEach((O,q)=>{a+=`<text x="${w}" y="${H+q*A}" font-family="${S}" font-size="${R}" fill="${x}" text-anchor="middle" font-weight="${B}">${L(O)}</text>
|
|
42
42
|
`;});}break}case "triangle":{let w=o.x+o.width/2,P=o.y+o.height/2,M=`${w},${o.y} ${o.x+o.width},${o.y+o.height} ${o.x},${o.y+o.height}`;if(a+=`<polygon points="${M}" fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
43
|
-
`,o.text){let
|
|
44
|
-
`),T=
|
|
45
|
-
`;});}break}case "trapezoid":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.min(Math.abs(o.width)*.2,40),
|
|
43
|
+
`,o.text){let b=o.fontSize||20,$=o.text.split(`
|
|
44
|
+
`),T=b*1.35,I=P-$.length*T/2+b*.8+o.height*.1;$.forEach((E,R)=>{a+=`<text x="${w}" y="${I+R*T}" font-family="${S}" font-size="${b}" fill="${x}" text-anchor="middle" font-weight="${B}">${L(E)}</text>
|
|
45
|
+
`;});}break}case "trapezoid":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.min(Math.abs(o.width)*.2,40),b=`${o.x+M},${o.y} ${o.x+o.width-M},${o.y} ${o.x+o.width},${o.y+o.height} ${o.x},${o.y+o.height}`;if(a+=`<polygon points="${b}" fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
46
46
|
`,o.text){let $=o.fontSize||20,T=o.text.split(`
|
|
47
47
|
`),I=$*1.35,E=P-T.length*I/2+$*.8;T.forEach((R,z)=>{a+=`<text x="${w}" y="${E+z*I}" font-family="${S}" font-size="${$}" fill="${x}" text-anchor="middle" font-weight="${B}">${L(R)}</text>
|
|
48
|
-
`;});}break}case "hexagon":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.min(Math.abs(o.width)*.22,45),
|
|
48
|
+
`;});}break}case "hexagon":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.min(Math.abs(o.width)*.22,45),b=`${o.x+M},${o.y} ${o.x+o.width-M},${o.y} ${o.x+o.width},${P} ${o.x+o.width-M},${o.y+o.height} ${o.x+M},${o.y+o.height} ${o.x},${P}`;if(a+=`<polygon points="${b}" fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
49
49
|
`,o.text){let $=o.fontSize||20,T=o.text.split(`
|
|
50
50
|
`),I=$*1.35,E=P-T.length*I/2+$*.8;T.forEach((R,z)=>{a+=`<text x="${w}" y="${E+z*I}" font-family="${S}" font-size="${$}" fill="${x}" text-anchor="middle" font-weight="${B}">${L(R)}</text>
|
|
51
|
-
`;});}break}case "capsule":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.abs(o.width),
|
|
51
|
+
`;});}break}case "capsule":{let w=o.x+o.width/2,P=o.y+o.height/2,M=Math.abs(o.width),b=Math.abs(o.height),$=Math.min(M,b)/2;if(a+=`<rect x="${o.x}" y="${o.y}" width="${o.width}" height="${o.height}" rx="${$}" fill="${m}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" />
|
|
52
52
|
`,o.text){let T=o.fontSize||20,I=o.text.split(`
|
|
53
53
|
`),E=T*1.35,R=P-I.length*E/2+T*.8;I.forEach((z,A)=>{a+=`<text x="${w}" y="${R+A*E}" font-family="${S}" font-size="${T}" fill="${x}" text-anchor="middle" font-weight="${B}">${L(z)}</text>
|
|
54
54
|
`;});}break}case "line":case "arrow":{let w=at(o),P=o.x+o.width,M=o.y+o.height;if(w.type==="straight")a+=`<line x1="${o.x}" y1="${o.y}" x2="${P}" y2="${M}" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" stroke-linecap="round" />
|
|
55
55
|
`;else if(w.type==="curved"&&w.controlPoint){let $=`M ${o.x} ${o.y} Q ${w.controlPoint.x} ${w.controlPoint.y} ${P} ${M}`;a+=`<path d="${$}" fill="none" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" stroke-linecap="round" />
|
|
56
56
|
`;}else if(w.type==="elbow"&&w.controlPoint1&&w.controlPoint2){let $=`M ${o.x} ${o.y} C ${w.controlPoint1.x} ${w.controlPoint1.y}, ${w.controlPoint2.x} ${w.controlPoint2.y}, ${P} ${M}`;a+=`<path d="${$}" fill="none" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" stroke-linecap="round" />
|
|
57
57
|
`;}else {let $=w.points.map((T,I)=>`${I===0?"M":"L"} ${T.x} ${T.y}`).join(" ");a+=`<path d="${$}" fill="none" stroke="${x}" stroke-width="${g}" stroke-dasharray="${k}" opacity="${y}" stroke-linecap="round" stroke-linejoin="round" />
|
|
58
|
-
`;}o.startArrowhead&&o.startArrowhead!=="none"&&(a+=vt(o.x,o.y,w.departureAngle+Math.PI,o.startArrowhead,x,g,y));let
|
|
58
|
+
`;}o.startArrowhead&&o.startArrowhead!=="none"&&(a+=vt(o.x,o.y,w.departureAngle+Math.PI,o.startArrowhead,x,g,y));let b=o.endArrowhead!==void 0?o.endArrowhead:o.type==="arrow"?"arrow":"none";b&&b!=="none"&&(a+=vt(P,M,w.arrivalAngle,b,x,g,y));break}case "pen":{if(o.points&&o.points.length>1){let w=o.points.map((P,M)=>`${M===0?"M":"L"} ${P.x} ${P.y}`).join(" ");a+=`<path d="${w}" fill="none" stroke="${x}" stroke-width="${g}" stroke-linecap="round" stroke-linejoin="round" opacity="${y}" />
|
|
59
59
|
`;}break}case "text":{if(o.text){let w=o.text.split(`
|
|
60
|
-
`),P=o.fontSize||22,M=P*1.35,
|
|
61
|
-
`;});}break}case "sticky":{let w=Q(o.stickyColor||o.fillColor),P=Math.abs(o.width),M=Math.abs(o.height),
|
|
62
|
-
`,a+=`<rect x="${o.x}" y="${o.y}" width="${o.width}" height="${o.height}" rx="${
|
|
63
|
-
`,a+=`<rect x="${o.x+2}" y="${o.y+2}" width="${o.width-4}" height="${o.height-4}" rx="${Math.max(2,
|
|
60
|
+
`),P=o.fontSize||22,M=P*1.35,b=(M-P)/2,$=o.textAlign||"left",T=$==="center"?"middle":$==="right"?"end":"start",I=$==="center"?o.x+o.width/2:$==="right"?o.x+o.width-4:o.x+4;w.forEach((E,R)=>{a+=`<text x="${I}" y="${o.y+b+P+R*M}" text-anchor="${T}" font-size="${P}" font-weight="${B}" fill="${x}" font-family="${S}" opacity="${y}">${L(Y(E))}</text>
|
|
61
|
+
`;});}break}case "sticky":{let w=Q(o.stickyColor||o.fillColor),P=Math.abs(o.width),M=Math.abs(o.height),b=Math.min(22,Math.min(P,M)*.16),$=Math.min(13,P*.08),T=Math.min(13,M*.08);a+=`<rect x="${o.x+$}" y="${o.y+T}" width="${o.width}" height="${o.height}" rx="${b}" fill="${w.backSheetBg}" stroke="${w.backSheetBorder}" stroke-width="1.5" opacity="${y}" />
|
|
62
|
+
`,a+=`<rect x="${o.x}" y="${o.y}" width="${o.width}" height="${o.height}" rx="${b}" fill="${w.bg}" stroke="${w.mainBorder}" stroke-width="1.5" opacity="${y}" />
|
|
63
|
+
`,a+=`<rect x="${o.x+2}" y="${o.y+2}" width="${o.width-4}" height="${o.height-4}" rx="${Math.max(2,b-2)}" fill="none" stroke="${w.sheen}" stroke-width="1.5" opacity="${y}" />
|
|
64
64
|
`;let I=Math.min(64,Math.max(30,P*.28)),E=Math.min(18,Math.max(10,M*.09)),R=o.x+(o.width-I)/2,z=o.y-E*.42;if(a+=`<rect x="${R}" y="${z}" width="${I}" height="${E}" rx="4" fill="${w.tapeBg}" stroke="${w.tapeBorder}" stroke-width="1" opacity="${y}" />
|
|
65
65
|
`,o.text){let A=o.text.split(`
|
|
66
66
|
`),H=o.fontSize||20,O=o.strokeColor&&o.strokeColor!=="transparent"?U(o.strokeColor,l):w.text;A.forEach((q,nt)=>{a+=`<text x="${o.x+o.width/2}" y="${o.y+32+nt*(H*1.3)}" font-size="${H}" font-weight="${B}" text-anchor="middle" fill="${O}" font-family="${S}" opacity="${y}">${L(Y(q))}</text>
|
|
@@ -88,4 +88,4 @@ import {rgb,PDFDocument}from'pdf-lib';async function yt(t,e,n){if(typeof window>
|
|
|
88
88
|
${n!=="transparent"?`<rect x="${u.minX}" y="${u.minY}" width="${u.width}" height="${u.height}" fill="${n}" />`:""}
|
|
89
89
|
${i}
|
|
90
90
|
${a}
|
|
91
|
-
</svg>`}function _t(t){let e=t.split(";base64,"),n=e[0].split(":")[1],h=window.atob(e[1]),d=h.length,u=new Uint8Array(d);for(let l=0;l<d;++l)u[l]=h.charCodeAt(l);return new Blob([u],{type:n})}async function Ft(t,e={}){try{let n=await Bt(t,e),h=_t(n);return await navigator.clipboard.write([new ClipboardItem({"image/png":h})]),!0}catch(n){return console.warn("Clipboard copy failed:",n),false}}function ft(t,e){let n=D(t);return e.filter(h=>{if(h.id===t.id)return false;let d=D(h),u=d.x+d.width/2,l=d.y+d.height/2;return u>=n.x&&u<=n.x+n.width&&l>=n.y&&l<=n.y+n.height})}async function Dt(t,e,n={}){let{scale:h=2,backgroundColor:d=t.fillColor&&t.fillColor!=="transparent"?t.fillColor:"#ffffff",padding:u=0}=n,l=D(t),c=document.createElement("canvas");c.width=Math.max(10,(l.width+u*2)*h),c.height=Math.max(10,(l.height+u*2)*h);let a=c.getContext("2d");if(!a)throw new Error("Could not create canvas context");let s=n.isDark??(Z(d)||d==="transparent"&&typeof document<"u"&&document.documentElement.classList.contains("dark"));d&&d!=="transparent"&&(a.fillStyle=d,a.fillRect(0,0,c.width,c.height)),a.save(),a.scale(h,h),a.translate(-l.x+u,-l.y+u),a.beginPath(),a.rect(l.x,l.y,l.width,l.height),a.clip();let r=ft(t,e),i=r.filter(o=>o.type==="image"&&o.dataUrl);i.length>0&&await Promise.all(i.map(o=>new Promise(y=>{let x=new Image;x.crossOrigin="anonymous",x.onload=()=>y(),x.onerror=()=>y(),x.src=o.dataUrl;})));let f=[...r].sort((o,y)=>(o.zIndex??0)-(y.zIndex??0));for(let o of f)ot(a,o,1,false,s);return a.restore(),c.toDataURL("image/png")}var Ct=595.28,Rt=841.89,ht=24,Nt=.75;function Gt(t,e=ht){let n=t==="landscape",h=n?Rt:Ct,d=n?Ct:Rt;return {pageWidth:h,pageHeight:d,margin:e,printableWidth:Math.max(100,h-e*2),printableHeight:Math.max(100,d-e*2)}}var gt=class{parent=new Map;find(e){if(!this.parent.has(e))return this.parent.set(e,e),e;let n=this.parent.get(e);if(n===e)return e;let h=this.find(n);return this.parent.set(e,h),h}union(e,n){let h=this.find(e),d=this.find(n);h!==d&&this.parent.set(h,d);}};function Ut(t){if(t.length===0)return [];let e=new gt,n=new Map;for(let s of t)n.set(s.id,s);let h=new Map;for(let s of t)if(s.groupIds&&s.groupIds.length>0)for(let r of s.groupIds){let i=h.get(r)||[];i.push(s.id),h.set(r,i);}for(let s of h.values())for(let r=1;r<s.length;r++)e.union(s[0],s[r]);let d=t.filter(s=>s.type==="frame");for(let s of d){let r=ft(s,t);for(let i of r)e.union(s.id,i.id);}for(let s of t)s.frameId&&n.has(s.frameId)&&e.union(s.id,s.frameId);for(let s of t)(s.type==="arrow"||s.type==="line")&&(s.startBinding?.elementId&&n.has(s.startBinding.elementId)&&e.union(s.id,s.startBinding.elementId),s.endBinding?.elementId&&n.has(s.endBinding.elementId)&&e.union(s.id,s.endBinding.elementId));let u=t.filter(s=>(!s.groupIds||s.groupIds.length===0)&&!s.frameId&&s.type!=="frame"),l=12;for(let s=0;s<u.length;s++){let r=u[s],i=D(r);for(let f=s+1;f<u.length;f++){let o=u[f],y=D(o),x=Math.max(0,Math.max(i.x,y.x)-Math.min(i.x+i.width,y.x+y.width)),g=Math.max(0,Math.max(i.y,y.y)-Math.min(i.y+i.height,y.y+y.height));x<=l&&g<=l&&(r.type==="text"||o.type==="text"||r.type==="sticky"||o.type==="sticky"||x===0&&g===0)&&e.union(r.id,o.id);}}let c=new Map;for(let s of t){let r=e.find(s.id),i=c.get(r)||[];i.push(s),c.set(r,i);}let a=[];for(let[s,r]of c.entries()){let i=V(r,4);a.push({id:s,elements:r,bbox:i});}return a}function It(t,e){let{orientation:n,margin:h=ht,baseScale:d=Nt}=e,u=Gt(n,h),{printableWidth:l,printableHeight:c}=u;if(t.length===0)return {pageGeometry:u,pages:[{pageIndex:0,slices:[]}],uniformScale:d};let s=V(t,20),r=s.width>0?Math.min(d,l/s.width):d,i=s.width*r,f=s.height*r,o=Math.max(0,(l-i)/2);if(f<=c){let k=Math.max(0,(c-f)/2);return {pageGeometry:u,pages:[{pageIndex:0,slices:[{elements:t,sourceBounds:{minX:s.minX,minY:s.minY,width:s.width,height:s.height},destRect:{x:o,y:k,width:i,height:f}}]}],uniformScale:r}}let y=Ut(t),x=c/r,g=[],
|
|
91
|
+
</svg>`}function _t(t){let e=t.split(";base64,"),n=e[0].split(":")[1],h=window.atob(e[1]),d=h.length,u=new Uint8Array(d);for(let l=0;l<d;++l)u[l]=h.charCodeAt(l);return new Blob([u],{type:n})}async function Ft(t,e={}){try{let n=await Bt(t,e),h=_t(n);return await navigator.clipboard.write([new ClipboardItem({"image/png":h})]),!0}catch(n){return console.warn("Clipboard copy failed:",n),false}}function ft(t,e){let n=D(t);return e.filter(h=>{if(h.id===t.id)return false;let d=D(h),u=d.x+d.width/2,l=d.y+d.height/2;return u>=n.x&&u<=n.x+n.width&&l>=n.y&&l<=n.y+n.height})}async function Dt(t,e,n={}){let{scale:h=2,backgroundColor:d=t.fillColor&&t.fillColor!=="transparent"?t.fillColor:"#ffffff",padding:u=0}=n,l=D(t),c=document.createElement("canvas");c.width=Math.max(10,(l.width+u*2)*h),c.height=Math.max(10,(l.height+u*2)*h);let a=c.getContext("2d");if(!a)throw new Error("Could not create canvas context");let s=n.isDark??(Z(d)||d==="transparent"&&typeof document<"u"&&document.documentElement.classList.contains("dark"));d&&d!=="transparent"&&(a.fillStyle=d,a.fillRect(0,0,c.width,c.height)),a.save(),a.scale(h,h),a.translate(-l.x+u,-l.y+u),a.beginPath(),a.rect(l.x,l.y,l.width,l.height),a.clip();let r=ft(t,e),i=r.filter(o=>o.type==="image"&&o.dataUrl);i.length>0&&await Promise.all(i.map(o=>new Promise(y=>{let x=new Image;x.crossOrigin="anonymous",x.onload=()=>y(),x.onerror=()=>y(),x.src=o.dataUrl;})));let f=[...r].sort((o,y)=>(o.zIndex??0)-(y.zIndex??0));for(let o of f)ot(a,o,1,false,s);return a.restore(),c.toDataURL("image/png")}var Ct=595.28,Rt=841.89,ht=24,Nt=.75;function Gt(t,e=ht){let n=t==="landscape",h=n?Rt:Ct,d=n?Ct:Rt;return {pageWidth:h,pageHeight:d,margin:e,printableWidth:Math.max(100,h-e*2),printableHeight:Math.max(100,d-e*2)}}var gt=class{parent=new Map;find(e){if(!this.parent.has(e))return this.parent.set(e,e),e;let n=this.parent.get(e);if(n===e)return e;let h=this.find(n);return this.parent.set(e,h),h}union(e,n){let h=this.find(e),d=this.find(n);h!==d&&this.parent.set(h,d);}};function Ut(t){if(t.length===0)return [];let e=new gt,n=new Map;for(let s of t)n.set(s.id,s);let h=new Map;for(let s of t)if(s.groupIds&&s.groupIds.length>0)for(let r of s.groupIds){let i=h.get(r)||[];i.push(s.id),h.set(r,i);}for(let s of h.values())for(let r=1;r<s.length;r++)e.union(s[0],s[r]);let d=t.filter(s=>s.type==="frame");for(let s of d){let r=ft(s,t);for(let i of r)e.union(s.id,i.id);}for(let s of t)s.frameId&&n.has(s.frameId)&&e.union(s.id,s.frameId);for(let s of t)(s.type==="arrow"||s.type==="line")&&(s.startBinding?.elementId&&n.has(s.startBinding.elementId)&&e.union(s.id,s.startBinding.elementId),s.endBinding?.elementId&&n.has(s.endBinding.elementId)&&e.union(s.id,s.endBinding.elementId));let u=t.filter(s=>(!s.groupIds||s.groupIds.length===0)&&!s.frameId&&s.type!=="frame"),l=12;for(let s=0;s<u.length;s++){let r=u[s],i=D(r);for(let f=s+1;f<u.length;f++){let o=u[f],y=D(o),x=Math.max(0,Math.max(i.x,y.x)-Math.min(i.x+i.width,y.x+y.width)),g=Math.max(0,Math.max(i.y,y.y)-Math.min(i.y+i.height,y.y+y.height));x<=l&&g<=l&&(r.type==="text"||o.type==="text"||r.type==="sticky"||o.type==="sticky"||x===0&&g===0)&&e.union(r.id,o.id);}}let c=new Map;for(let s of t){let r=e.find(s.id),i=c.get(r)||[];i.push(s),c.set(r,i);}let a=[];for(let[s,r]of c.entries()){let i=V(r,4);a.push({id:s,elements:r,bbox:i});}return a}function It(t,e){let{orientation:n,margin:h=ht,baseScale:d=Nt}=e,u=Gt(n,h),{printableWidth:l,printableHeight:c}=u;if(t.length===0)return {pageGeometry:u,pages:[{pageIndex:0,slices:[]}],uniformScale:d};let s=V(t,20),r=s.width>0?Math.min(d,l/s.width):d,i=s.width*r,f=s.height*r,o=Math.max(0,(l-i)/2);if(f<=c){let k=Math.max(0,(c-f)/2);return {pageGeometry:u,pages:[{pageIndex:0,slices:[{elements:t,sourceBounds:{minX:s.minX,minY:s.minY,width:s.width,height:s.height},destRect:{x:o,y:k,width:i,height:f}}]}],uniformScale:r}}let y=Ut(t),x=c/r,g=[],p=s.minY,m=0;for(;p<s.maxY;){let k=s.maxY-p;if(k<=x){let P=k,M=P*r,b=t.filter($=>{let T=D($);return T.y+T.height>=p&&T.y<=s.maxY});g.push({pageIndex:m,slices:[{elements:b.length>0?b:t,sourceBounds:{minX:s.minX,minY:p,width:s.width,height:P},destRect:{x:o,y:0,width:i,height:M}}]});break}let v=p+x,S=v,C=y.filter(P=>P.bbox.minY<v&&P.bbox.maxY>v);if(C.length>0){let P=Math.min(...C.map(b=>b.bbox.minY)),M=x*.55;P-p>=M?S=P:S=v;}let B=S-p,Y=B*r,w=t.filter(P=>{let M=D(P);return M.y+M.height>=p&&M.y<=S});g.push({pageIndex:m,slices:[{elements:w.length>0?w:t,sourceBounds:{minX:s.minX,minY:p,width:s.width,height:B},destRect:{x:o,y:0,width:i,height:Y}}]}),p=S,m++;}return {pageGeometry:u,pages:g,uniformScale:r}}var jt=2.5,Et=4096;function qt(t){if(!t||t==="transparent")return rgb(1,1,1);let e=t.replace("#","").trim();if(e.length===3&&(e=e.split("").map(u=>u+u).join("")),e.length!==6)return rgb(1,1,1);let n=parseInt(e.substring(0,2),16)/255,h=parseInt(e.substring(2,4),16)/255,d=parseInt(e.substring(4,6),16)/255;return rgb(Number.isFinite(n)?n:1,Number.isFinite(h)?h:1,Number.isFinite(d)?d:1)}async function zt(t){let e=t.filter(n=>n.type==="image"&&n.dataUrl);e.length!==0&&await Promise.all(e.map(n=>new Promise(h=>{let d=new Image;d.crossOrigin="anonymous",d.onload=()=>h(),d.onerror=()=>h(),d.src=n.dataUrl;})));}async function Zt(t,e,n){let{sourceBounds:h,elements:d}=t;if(h.width<=0||h.height<=0)return null;let u=jt,l=Math.max(h.width,h.height);l*u>Et&&(u=Math.max(1,Et/l));let c=Math.max(2,Math.round(h.width*u)),a=Math.max(2,Math.round(h.height*u)),s=document.createElement("canvas");s.width=c,s.height=a;let r=s.getContext("2d");if(!r)return null;n&&n!=="transparent"&&(r.fillStyle=n,r.fillRect(0,0,c,a)),r.save(),r.scale(u,u),r.translate(-h.minX,-h.minY);let i=[...d].sort((y,x)=>(y.zIndex??0)-(x.zIndex??0));for(let y of i)ot(r,y,1,false,e);r.restore();let f=await new Promise(y=>{s.toBlob(y,"image/png");});if(s.width=0,s.height=0,!f)return null;let o=await f.arrayBuffer();return new Uint8Array(o)}async function Vt(t,e={}){let{orientation:n="portrait",appearance:h="original",margin:d=ht,boardName:u="whiteboard",canvasBackground:l="#ffffff",isSelection:c=false,onProgress:a}=e;if(t.length===0)throw new Error("No elements to export");await zt(t);let s=false,r="#ffffff",i=rgb(1,1,1);h==="dark"?(s=true,r="#121212",i=rgb(.07,.07,.07)):h==="light"?(s=false,r="#ffffff",i=rgb(1,1,1)):(s=e.isDark??Z(l),r=l||"#ffffff",i=qt(r));let{pageGeometry:f,pages:o}=It(t,{orientation:n,margin:d}),y=await PDFDocument.create(),x=o.length,g=0;for(let v=0;v<o.length;v++){let S=o[v],C=y.addPage([f.pageWidth,f.pageHeight]);C.drawRectangle({x:0,y:0,width:f.pageWidth,height:f.pageHeight,color:i});for(let B of S.slices){let Y=await Zt(B,s,r);if(!Y)continue;let w=await y.embedPng(Y),P=f.margin+B.destRect.x,M=f.pageHeight-f.margin-B.destRect.y-B.destRect.height;C.drawImage(w,{x:P,y:M,width:B.destRect.width,height:B.destRect.height});}g++,a?.(g,x);}let p=await y.save(),k=`${(u||"whiteboard").toLowerCase().replace(/[^a-z0-9_-]/g,"-")||"whiteboard"}${c?"-selection":""}.pdf`;return await yt(p,k,{mimeType:"application/pdf",filters:[{name:"PDF Document",extensions:["pdf"]}],showToast:true}),{success:true,pageCount:x,filename:k}}export{Ft as copyImageToClipboard,Dt as exportFrameToPng,Bt as exportToPng,Ot as exportToSvg,Vt as exportWhiteboardToPdf,V as getElementsBoundingBox,ft as getFrameContainedElements,Z as isDarkColor,zt as preloadImageElements};
|