@arach/arc 0.1.0 → 0.2.3
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/arc.es.js +3057 -2887
- package/dist/arc.umd.js +73 -73
- package/package.json +2 -1
package/dist/arc.umd.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
(function(K,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],a):(K=typeof globalThis<"u"?globalThis:K||self,a(K.Arc={},K.ReactJSXRuntime,K.React))})(this,(function(K,a,b){"use strict";function Bo(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const O=Bo(b),Wo={width:1600,height:900},kn={enabled:!0,size:24,color:"#71717a",opacity:.1,type:"dots"},Uo=[{name:"Zinc",value:"#71717a"},{name:"Sky",value:"#38bdf8"},{name:"Violet",value:"#a78bfa"},{name:"Emerald",value:"#34d399"}],q={xs:{width:80,height:36},s:{width:95,height:42},m:{width:145,height:68},l:{width:210,height:85}},Xo={xpc:{color:"emerald",strokeWidth:2,label:"XPC"},http:{color:"amber",strokeWidth:2,label:"HTTP"},tailscale:{color:"zinc",strokeWidth:2,label:"Tailscale"},cloudkit:{color:"sky",strokeWidth:2,label:"CloudKit",dashed:!0},audio:{color:"emerald",strokeWidth:3,label:"audio"},peer:{color:"zinc",strokeWidth:1.5,dashed:!0}},jo=["top","right","bottom","left","bottomRight","bottomLeft"],Et=["violet","emerald","blue","amber","zinc","sky"],Go=["xs","s","m","l"],Me=0;function Vo(e,t){const n=e[t];if(!n)return null;const o=q[n.size]||q.m;return{...n,...o}}function Dt(e,t,n){const o=Vo(e,t);if(!o)return{x:0,y:0};switch(n){case"left":return{x:o.x-Me,y:o.y+o.height/2};case"right":return{x:o.x+o.width+Me,y:o.y+o.height/2};case"top":return{x:o.x+o.width/2,y:o.y-Me};case"bottom":return{x:o.x+o.width/2,y:o.y+o.height+Me};case"bottomRight":return{x:o.x+o.width+Me,y:o.y+o.height-15};case"bottomLeft":return{x:o.x-Me,y:o.y+o.height-15};case"topRight":return{x:o.x+o.width+Me,y:o.y+15};case"topLeft":return{x:o.x-Me,y:o.y+15};default:return{x:o.x+o.width/2,y:o.y+o.height/2}}}function Ko(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function qo(){return`node_${crypto.randomUUID().slice(0,8)}`}const Zo=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Jo=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase()),vn=e=>{const t=Jo(e);return t.charAt(0).toUpperCase()+t.slice(1)},wn=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim(),Qo=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Ro={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ei=b.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:r="",children:i,iconNode:s,...l},c)=>b.createElement("svg",{ref:c,...Ro,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:wn("lucide",r),...!i&&!Qo(l)&&{"aria-hidden":"true"},...l},[...s.map(([d,f])=>b.createElement(d,f)),...Array.isArray(i)?i:[i]]));const I=(e,t)=>{const n=b.forwardRef(({className:o,...r},i)=>b.createElement(ei,{ref:i,iconNode:t,className:wn(`lucide-${Zo(vn(e))}`,`lucide-${e}`,o),...r}));return n.displayName=vn(e),n};const ti=I("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const ni=I("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);const ri=I("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const oi=I("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);const Ot=I("box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);const ii=I("braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const si=I("camera",[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);const ai=I("chart-no-axes-column-increasing",[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V9",key:"uvy0l4"}],["path",{d:"M19 21V3",key:"11j9sm"}]]);const li=I("chart-pie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);const ci=I("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Cn=I("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Nn=I("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const zn=I("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const di=I("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);const ui=I("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);const hi=I("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);const fi=I("crop",[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]]);const pi=I("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);const gi=I("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Mn=I("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]);const yi=I("file-image",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);const mi=I("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]);const xi=I("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const bi=I("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const ki=I("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);const vi=I("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const _n=I("grid-3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const wi=I("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);const Ci=I("headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);const Ni=I("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const zi=I("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);const $n=I("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);const Mi=I("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const _i=I("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const $i=I("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Si=I("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const Ai=I("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const Ii=I("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);const Ei=I("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);const Di=I("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);const Oi=I("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);const Li=I("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]);const Ti=I("mouse-pointer-2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);const Pi=I("move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);const Fi=I("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);const Yi=I("palette",[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]);const Hi=I("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]);const Bi=I("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);const Sn=I("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Wi=I("redo-2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);const Ui=I("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);const Xi=I("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);const ji=I("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const Gi=I("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const An=I("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const Vi=I("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const Ki=I("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const qi=I("share",[["path",{d:"M12 2v13",key:"1km8f5"}],["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}]]);const Zi=I("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ji=I("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const Qi=I("speaker",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["circle",{cx:"12",cy:"14",r:"4",key:"1jruaj"}],["path",{d:"M12 14h.01",key:"1etili"}]]);const In=I("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Ri=I("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);const es=I("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const Lt=I("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const ts=I("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);const ns=I("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rs=I("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const os=I("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);const is=I("watch",[["path",{d:"M12 10v2.2l1.6 1",key:"n3r21l"}],["path",{d:"m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05",key:"18k57s"}],["path",{d:"m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05",key:"16ny36"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}]]);const ss=I("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);const as=I("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);const ls=I("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);const cs=I("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);const ds=I("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),En={Monitor:Oi,Server:Vi,Smartphone:Ji,Watch:is,Cloud:di,Cpu:hi,Database:pi,HardDrive:wi,Wifi:ss,Globe:vi,User:rs,Users:os,Lock:Si,Key:zi,Shield:Zi,Mic:Di,Camera:si,Speaker:Qi,Headphones:Ci,Code:ui,Terminal:es,FileCode:Mn,Folder:bi,Zap:ls,Activity:ti,BarChart:ai,PieChart:li,ArrowRight:ri,ArrowDown:ni,RefreshCw:Ui,Repeat:Xi,Box:Ot,Package:Fi,Layers:$n,Grid:_n,Settings:Ki,Bell:oi,Mail:Ai,MessageSquare:Ei,Search:An,Filter:ki,Download:gi,Upload:ns,Play:Bi,Pause:Hi,Square:In,Circle:zn},Dn=Object.keys(En);function On(e){return En[e]||Ot}const us="Box",Tt={talkie:{id:"talkie",name:"Talkie Docs",description:"Dark theme matching Talkie documentation",canvas:{background:"bg-zinc-950",border:"border-zinc-800",grid:{color:"rgb(113 113 122)",size:24,opacity:.1}},node:{background:"bg-zinc-900",border:"border-zinc-800",borderRadius:"rounded-xl",accentPosition:"left",accentWidth:4,textColor:"text-white",subtitleStyle:"colored",descriptionColor:"text-zinc-500",iconBackground:"bg-zinc-900",iconBorderStyle:"colored"},connector:{defaultDashed:!0,defaultStrokeWidth:2,arrowStyle:"filled",labelFont:"ui-monospace, monospace",labelSize:11}},blueprint:{id:"blueprint",name:"Blueprint",description:"Technical blueprint style with blue tones",canvas:{background:"bg-slate-900",border:"border-slate-700",grid:{color:"rgb(71 85 105)",size:20,opacity:.2}},node:{background:"bg-slate-800/80",border:"border-slate-600",borderRadius:"rounded-lg",accentPosition:"top",accentWidth:3,textColor:"text-slate-100",subtitleStyle:"muted",descriptionColor:"text-slate-400",iconBackground:"bg-slate-700/50",iconBorderStyle:"muted"},connector:{defaultDashed:!1,defaultStrokeWidth:2,arrowStyle:"filled",labelFont:"ui-sans-serif, system-ui",labelSize:10}},light:{id:"light",name:"Light Mode",description:"Clean light theme for documents",canvas:{background:"bg-white",border:"border-zinc-200",grid:{color:"rgb(161 161 170)",size:24,opacity:.15}},node:{background:"bg-white",border:"border-zinc-200",borderRadius:"rounded-xl",accentPosition:"left",accentWidth:4,textColor:"text-zinc-900",subtitleStyle:"colored",descriptionColor:"text-zinc-500",iconBackground:"bg-zinc-50",iconBorderStyle:"colored"},connector:{defaultDashed:!0,defaultStrokeWidth:2,arrowStyle:"filled",labelFont:"ui-monospace, monospace",labelSize:11}},minimal:{id:"minimal",name:"Minimal",description:"Simple and clean with subtle styling",canvas:{background:"bg-zinc-900",border:"border-zinc-800",grid:{color:"transparent",size:0,opacity:0}},node:{background:"bg-zinc-800/60",border:"border-zinc-700/50",borderRadius:"rounded-2xl",accentPosition:"none",accentWidth:0,textColor:"text-zinc-100",subtitleStyle:"muted",descriptionColor:"text-zinc-500",iconBackground:"bg-transparent",iconBorderStyle:"none"},connector:{defaultDashed:!1,defaultStrokeWidth:1.5,arrowStyle:"outline",labelFont:"ui-sans-serif, system-ui",labelSize:10}}},Ln="talkie";function Tn(e){return Tt[e]||Tt[Ln]}function hs(){return Object.values(Tt).map(e=>({id:e.id,name:e.name,description:e.description}))}const Pn=()=>({layout:{...Wo},grid:{...kn},nodes:{},nodeData:{},connectors:[],connectorStyles:{...Xo},groups:[],images:[],exportZone:null}),Pt={diagram:Pn(),editor:{selectedNodeIds:[],selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null,mode:"select",pendingConnector:null,pendingGroup:null,isDragging:!1,dragOffset:{x:0,y:0},dragNodeOffsets:{},template:Ln,zoom:1,viewMode:"2d"},meta:{filename:null,isDirty:!1,lastSaved:null},history:{past:[],future:[]}};function oe(e){return{...e,history:{past:[...e.history.past.slice(-49),e.diagram],future:[]},meta:{...e.meta,isDirty:!0}}}function fs(e,t){switch(t.type){case"node/add":{const{position:n,nodeData:o}=t,r=qo(),i=oe(e);return{...i,diagram:{...i.diagram,nodes:{...i.diagram.nodes,[r]:{x:n.x,y:n.y,size:"normal"}},nodeData:{...i.diagram.nodeData,[r]:{icon:us,name:"New Node",subtitle:"",description:"",color:"violet",...o}}},editor:{...i.editor,selectedNodeIds:[r],selectedConnectorIndex:null,mode:"select"}}}case"node/remove":{const{nodeId:n}=t,o=oe(e),{[n]:r,...i}=o.diagram.nodes,{[n]:s,...l}=o.diagram.nodeData,c=o.diagram.connectors.filter(d=>d.from!==n&&d.to!==n);return{...o,diagram:{...o.diagram,nodes:i,nodeData:l,connectors:c},editor:{...o.editor,selectedNodeIds:[],selectedConnectorIndex:null}}}case"node/move":{const{nodeId:n,x:o,y:r}=t;return{...e,diagram:{...e.diagram,nodes:{...e.diagram.nodes,[n]:{...e.diagram.nodes[n],x:o,y:r}}},meta:{...e.meta,isDirty:!0}}}case"nodes/move":{const{moves:n}=t,o={...e.diagram.nodes};for(const{nodeId:r,x:i,y:s}of n)o[r]&&(o[r]={...o[r],x:i,y:s});return{...e,diagram:{...e.diagram,nodes:o},meta:{...e.meta,isDirty:!0}}}case"node/update":{const{nodeId:n,updates:o}=t,r=oe(e);return{...r,diagram:{...r.diagram,nodeData:{...r.diagram.nodeData,[n]:{...r.diagram.nodeData[n],...o}}}}}case"node/resize":{const{nodeId:n,size:o,width:r,height:i}=t,s=oe(e),c={...s.diagram.nodes[n]};return o!==void 0&&(c.size=o,delete c.width,delete c.height),r!==void 0&&(c.width=r),i!==void 0&&(c.height=i),{...s,diagram:{...s.diagram,nodes:{...s.diagram.nodes,[n]:c}}}}case"node/updatePosition":{const{nodeId:n,updates:o}=t,r=oe(e),i=r.diagram.nodes[n];return{...r,diagram:{...r.diagram,nodes:{...r.diagram.nodes,[n]:{...i,...o}}}}}case"connector/add":{const{from:n,to:o,fromAnchor:r,toAnchor:i,style:s="http"}=t,l=oe(e);return{...l,diagram:{...l.diagram,connectors:[...l.diagram.connectors,{from:n,to:o,fromAnchor:r,toAnchor:i,style:s}]},editor:{...l.editor,selectedNodeIds:[],selectedConnectorIndex:l.diagram.connectors.length,mode:"select",pendingConnector:null}}}case"connector/remove":{const{index:n}=t,o=oe(e);return{...o,diagram:{...o.diagram,connectors:o.diagram.connectors.filter((r,i)=>i!==n)},editor:{...o.editor,selectedConnectorIndex:null}}}case"connector/update":{const{index:n,updates:o}=t,r=oe(e);return{...r,diagram:{...r.diagram,connectors:r.diagram.connectors.map((i,s)=>s===n?{...i,...o}:i)}}}case"connectorStyle/update":{const{styleName:n,updates:o}=t,r=oe(e);return{...r,diagram:{...r.diagram,connectorStyles:{...r.diagram.connectorStyles,[n]:{...r.diagram.connectorStyles[n],...o}}}}}case"connectorStyle/add":{const{styleName:n,style:o}=t,r=oe(e);return{...r,diagram:{...r.diagram,connectorStyles:{...r.diagram.connectorStyles,[n]:o}}}}case"connectorStyle/delete":{const{styleName:n}=t,o=oe(e),{[n]:r,...i}=o.diagram.connectorStyles;return{...o,diagram:{...o.diagram,connectorStyles:i}}}case"group/add":{const{group:n}=t,o=`group_${crypto.randomUUID().slice(0,8)}`,r=oe(e),i=r.diagram.groups||[];return{...r,diagram:{...r.diagram,groups:[...i,{id:o,...n}]},editor:{...r.editor,selectedGroupId:o,selectedNodeIds:[],selectedConnectorIndex:null}}}case"group/update":{const{groupId:n,updates:o}=t,r=oe(e),i=r.diagram.groups||[];return{...r,diagram:{...r.diagram,groups:i.map(s=>s.id===n?{...s,...o}:s)}}}case"group/remove":{const{groupId:n}=t,o=oe(e),r=o.diagram.groups||[];return{...o,diagram:{...o.diagram,groups:r.filter(i=>i.id!==n)},editor:{...o.editor,selectedGroupId:null}}}case"select/group":return{...e,editor:{...e.editor,selectedGroupId:t.groupId,selectedNodeIds:[],selectedConnectorIndex:null,selectedImageId:null}};case"image/add":{const{image:n}=t,o=`img_${crypto.randomUUID().slice(0,8)}`,r=oe(e),i=r.diagram.images||[];return{...r,diagram:{...r.diagram,images:[...i,{id:o,...n}]},editor:{...r.editor,selectedImageId:o,selectedNodeIds:[],selectedConnectorIndex:null,selectedGroupId:null}}}case"image/update":{const{imageId:n,updates:o}=t,r=oe(e),i=r.diagram.images||[];return{...r,diagram:{...r.diagram,images:i.map(s=>s.id===n?{...s,...o}:s)}}}case"image/remove":{const{imageId:n}=t,o=oe(e),r=o.diagram.images||[];return{...o,diagram:{...o.diagram,images:r.filter(i=>i.id!==n)},editor:{...o.editor,selectedImageId:null}}}case"select/image":return{...e,editor:{...e.editor,selectedImageId:t.imageId,selectedNodeIds:[],selectedConnectorIndex:null,selectedGroupId:null}};case"exportZone/set":{const{zone:n}=t;return{...e,diagram:{...e.diagram,exportZone:n},meta:{...e.meta,isDirty:!0}}}case"exportZone/clear":return{...e,diagram:{...e.diagram,exportZone:null},meta:{...e.meta,isDirty:!0}};case"select/node":{const{nodeId:n,addToSelection:o}=t;let r;return o?e.editor.selectedNodeIds.includes(n)?r=e.editor.selectedNodeIds.filter(i=>i!==n):r=[...e.editor.selectedNodeIds,n]:r=[n],{...e,editor:{...e.editor,selectedNodeIds:r,selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null}}}case"select/nodes":return{...e,editor:{...e.editor,selectedNodeIds:t.nodeIds,selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null}};case"select/connector":return{...e,editor:{...e.editor,selectedNodeIds:[],selectedConnectorIndex:t.index,selectedGroupId:null,selectedImageId:null}};case"select/clear":return{...e,editor:{...e.editor,selectedNodeIds:[],selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null}};case"mode/set":return{...e,editor:{...e.editor,mode:t.mode,pendingConnector:null,selectedNodeIds:[],selectedConnectorIndex:null}};case"pending/set":return{...e,editor:{...e.editor,pendingConnector:t.pendingConnector}};case"pending/clear":return{...e,editor:{...e.editor,pendingConnector:null}};case"drag/start":{const{offset:n,nodeOffsets:o,selectedIds:r}=t;return{...e,editor:{...e.editor,isDragging:!0,dragOffset:n,dragNodeOffsets:o||{},selectedNodeIds:r||e.editor.selectedNodeIds,selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null}}}case"drag/end":{const n=oe(e);return{...n,editor:{...n.editor,isDragging:!1,dragOffset:{x:0,y:0},dragNodeOffsets:{}}}}case"diagram/load":return{...e,diagram:t.diagram,meta:{filename:t.filename||null,isDirty:!1,lastSaved:null},history:{past:[],future:[]},editor:{...e.editor,selectedNodeIds:[],selectedConnectorIndex:null,mode:"select",pendingConnector:null}};case"diagram/new":return{...Pt,diagram:Pn()};case"diagram/saved":return{...e,meta:{...e.meta,filename:t.filename||e.meta.filename,isDirty:!1,lastSaved:new Date().toISOString()}};case"undo":{if(e.history.past.length===0)return e;const n=e.history.past[e.history.past.length-1],o=e.history.past.slice(0,-1);return{...e,diagram:n,history:{past:o,future:[e.diagram,...e.history.future]},meta:{...e.meta,isDirty:!0}}}case"redo":{if(e.history.future.length===0)return e;const n=e.history.future[0],o=e.history.future.slice(1);return{...e,diagram:n,history:{past:[...e.history.past,e.diagram],future:o},meta:{...e.meta,isDirty:!0}}}case"layout/update":{const n=oe(e);return{...n,diagram:{...n.diagram,layout:{...n.diagram.layout,...t.updates}}}}case"layout/expand":{const n=e.diagram.layout,o=Math.max(n.width,t.width||n.width),r=Math.max(n.height,t.height||n.height);return o===n.width&&r===n.height?e:{...e,diagram:{...e.diagram,layout:{...n,width:o,height:r}},meta:{...e.meta,isDirty:!0}}}case"grid/update":return{...e,diagram:{...e.diagram,grid:{...e.diagram.grid,...t.updates}}};case"template/set":{const n=Tn(t.templateId);return{...e,diagram:{...e.diagram,grid:{...e.diagram.grid,color:n.canvas.grid.color,size:n.canvas.grid.size,opacity:n.canvas.grid.opacity}},editor:{...e.editor,template:t.templateId},meta:{...e.meta,isDirty:!0}}}case"zoom/set":return{...e,editor:{...e.editor,zoom:Math.min(2,Math.max(.25,t.zoom))}};case"viewMode/set":return{...e,editor:{...e.editor,viewMode:t.viewMode}};default:return e}}const Fn=b.createContext(null);function Yn({children:e,initialDiagram:t}){const[n,o]=b.useReducer(fs,t?{...Pt,diagram:t}:Pt),r={addNode:b.useCallback((i,s)=>{o({type:"node/add",position:i,nodeData:s})},[]),removeNode:b.useCallback(i=>{o({type:"node/remove",nodeId:i})},[]),moveNode:b.useCallback((i,s,l)=>{o({type:"node/move",nodeId:i,x:s,y:l})},[]),moveNodes:b.useCallback(i=>{o({type:"nodes/move",moves:i})},[]),updateNode:b.useCallback((i,s)=>{o({type:"node/update",nodeId:i,updates:s})},[]),resizeNode:b.useCallback((i,s,l,c)=>{o({type:"node/resize",nodeId:i,size:s,width:l,height:c})},[]),updateNodePosition:b.useCallback((i,s)=>{o({type:"node/updatePosition",nodeId:i,updates:s})},[]),addConnector:b.useCallback((i,s,l,c,d)=>{o({type:"connector/add",from:i,to:s,fromAnchor:l,toAnchor:c,style:d})},[]),removeConnector:b.useCallback(i=>{o({type:"connector/remove",index:i})},[]),updateConnector:b.useCallback((i,s)=>{o({type:"connector/update",index:i,updates:s})},[]),addGroup:b.useCallback(i=>{o({type:"group/add",group:i})},[]),updateGroup:b.useCallback((i,s)=>{o({type:"group/update",groupId:i,updates:s})},[]),removeGroup:b.useCallback(i=>{o({type:"group/remove",groupId:i})},[]),addImage:b.useCallback(i=>{o({type:"image/add",image:i})},[]),updateImage:b.useCallback((i,s)=>{o({type:"image/update",imageId:i,updates:s})},[]),removeImage:b.useCallback(i=>{o({type:"image/remove",imageId:i})},[]),setExportZone:b.useCallback(i=>{o({type:"exportZone/set",zone:i})},[]),clearExportZone:b.useCallback(()=>{o({type:"exportZone/clear"})},[]),selectNode:b.useCallback((i,s=!1)=>{o({type:"select/node",nodeId:i,addToSelection:s})},[]),selectNodes:b.useCallback(i=>{o({type:"select/nodes",nodeIds:i})},[]),selectConnector:b.useCallback(i=>{o({type:"select/connector",index:i})},[]),selectGroup:b.useCallback(i=>{o({type:"select/group",groupId:i})},[]),selectImage:b.useCallback(i=>{o({type:"select/image",imageId:i})},[]),clearSelection:b.useCallback(()=>{o({type:"select/clear"})},[]),setMode:b.useCallback(i=>{o({type:"mode/set",mode:i})},[]),setPendingConnector:b.useCallback(i=>{o({type:"pending/set",pendingConnector:i})},[]),clearPendingConnector:b.useCallback(()=>{o({type:"pending/clear"})},[]),startDrag:b.useCallback((i,s,l,c)=>{o({type:"drag/start",nodeId:i,offset:s,nodeOffsets:l,selectedIds:c})},[]),endDrag:b.useCallback(()=>{o({type:"drag/end"})},[]),loadDiagram:b.useCallback((i,s)=>{o({type:"diagram/load",diagram:i,filename:s})},[]),newDiagram:b.useCallback(()=>{o({type:"diagram/new"})},[]),markSaved:b.useCallback(i=>{o({type:"diagram/saved",filename:i})},[]),undo:b.useCallback(()=>{o({type:"undo"})},[]),redo:b.useCallback(()=>{o({type:"redo"})},[]),updateLayout:b.useCallback(i=>{o({type:"layout/update",updates:i})},[]),expandLayout:b.useCallback((i,s)=>{o({type:"layout/expand",width:i,height:s})},[]),setTemplate:b.useCallback(i=>{o({type:"template/set",templateId:i})},[]),setZoom:b.useCallback(i=>{o({type:"zoom/set",zoom:i})},[]),zoomIn:b.useCallback(()=>{o({type:"zoom/set",zoom:n.editor.zoom*1.25})},[n.editor.zoom]),zoomOut:b.useCallback(()=>{o({type:"zoom/set",zoom:n.editor.zoom/1.25})},[n.editor.zoom]),resetZoom:b.useCallback(()=>{o({type:"zoom/set",zoom:1})},[]),setViewMode:b.useCallback(i=>{o({type:"viewMode/set",viewMode:i})},[])};return a.jsx(Fn.Provider,{value:{state:n,dispatch:o,actions:r},children:e})}function le(){const e=b.useContext(Fn);if(!e)throw new Error("useEditor must be used within an EditorProvider");return e}function ke(){const{state:e}=le();return e.diagram}function je(){const{state:e}=le();return e.editor}function Hn(){const{state:e}=le();return e.meta}function ps(){const{state:e}=le();return e.history}function Bn(){const{state:e}=le();return e.editor.template}function Ft(){const{state:e}=le();return e.editor.viewMode}const Wn="https://arc.jdi.sh";function gs({title:e,description:t,image:n,url:o}){b.useEffect(()=>{const r=document.title,i=c=>document.querySelector(`meta[property="${c}"]`)?.content,s={"og:title":i("og:title"),"og:description":i("og:description"),"og:image":i("og:image"),"og:url":i("og:url"),"twitter:title":i("twitter:title"),"twitter:description":i("twitter:description"),"twitter:image":i("twitter:image"),"twitter:url":i("twitter:url")},l=(c,d)=>{let f=document.querySelector(`meta[property="${c}"]`);f||(f=document.createElement("meta"),f.setAttribute("property",c),document.head.appendChild(f)),f.content=d};document.title=e,l("og:title",e),l("twitter:title",e);{l("og:description",t),l("twitter:description",t);const c=document.querySelector('meta[name="description"]');c&&(c.content=t)}{const c=n.startsWith("http")?n:`${Wn}${n}`;l("og:image",c),l("twitter:image",c)}{const c=o.startsWith("http")?o:`${Wn}${o}`;l("og:url",c),l("twitter:url",c)}return()=>{document.title=r,Object.entries(s).forEach(([c,d])=>{if(d){const f=document.querySelector(`meta[property="${c}"]`);f&&(f.content=d)}})}},[e,t,n,o])}function ys(){const{actions:e}=le(),t=Bn(),n=hs();return a.jsxs("div",{className:"relative group",children:[a.jsx("button",{className:"p-2 rounded-lg hover:bg-zinc-100 dark:hover:bg-zinc-800 text-zinc-600 dark:text-zinc-400 transition-colors",title:"Change template",children:a.jsx(Yi,{className:"w-4 h-4"})}),a.jsx("div",{className:"absolute left-0 top-full mt-1 opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-50",children:a.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-lg shadow-lg border border-zinc-200 dark:border-zinc-800 py-1 min-w-[180px]",children:[a.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-zinc-500 dark:text-zinc-500 uppercase tracking-wide",children:"Style Template"}),n.map(o=>a.jsxs("button",{onClick:()=>e.setTemplate(o.id),className:`
|
|
1
|
+
(function(q,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],a):(q=typeof globalThis<"u"?globalThis:q||self,a(q.Arc={},q.ReactJSXRuntime,q.React))})(this,(function(q,a,b){"use strict";function Bo(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const L=Bo(b),Wo={width:1600,height:900},wn={enabled:!0,size:24,color:"#71717a",opacity:.1,type:"dots"},Xo=[{name:"Zinc",value:"#71717a"},{name:"Sky",value:"#38bdf8"},{name:"Violet",value:"#a78bfa"},{name:"Emerald",value:"#34d399"}],J={xs:{width:80,height:36},s:{width:95,height:42},m:{width:145,height:68},l:{width:210,height:85}},Uo={xpc:{color:"emerald",strokeWidth:2,label:"XPC"},http:{color:"amber",strokeWidth:2,label:"HTTP"},tailscale:{color:"zinc",strokeWidth:2,label:"Tailscale"},cloudkit:{color:"sky",strokeWidth:2,label:"CloudKit",dashed:!0},audio:{color:"emerald",strokeWidth:3,label:"audio"},peer:{color:"zinc",strokeWidth:1.5,dashed:!0}},jo=["top","right","bottom","left","bottomRight","bottomLeft"],Lt=["violet","emerald","blue","amber","zinc","sky"],Go=["xs","s","m","l"],Ie=0;function Vo(e,t){const n=e[t];if(!n)return null;const o=J[n.size]||J.m;return{...n,...o}}function Pt(e,t,n){const o=Vo(e,t);if(!o)return{x:0,y:0};switch(n){case"left":return{x:o.x-Ie,y:o.y+o.height/2};case"right":return{x:o.x+o.width+Ie,y:o.y+o.height/2};case"top":return{x:o.x+o.width/2,y:o.y-Ie};case"bottom":return{x:o.x+o.width/2,y:o.y+o.height+Ie};case"bottomRight":return{x:o.x+o.width+Ie,y:o.y+o.height-15};case"bottomLeft":return{x:o.x-Ie,y:o.y+o.height-15};case"topRight":return{x:o.x+o.width+Ie,y:o.y+15};case"topLeft":return{x:o.x-Ie,y:o.y+15};default:return{x:o.x+o.width/2,y:o.y+o.height/2}}}function Ko(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function Zo(){return`node_${crypto.randomUUID().slice(0,8)}`}const qo=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Jo=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase()),Cn=e=>{const t=Jo(e);return t.charAt(0).toUpperCase()+t.slice(1)},Nn=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim(),Qo=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Ro={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ei=b.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:r="",children:i,iconNode:s,...l},c)=>b.createElement("svg",{ref:c,...Ro,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:Nn("lucide",r),...!i&&!Qo(l)&&{"aria-hidden":"true"},...l},[...s.map(([d,p])=>b.createElement(d,p)),...Array.isArray(i)?i:[i]]));const I=(e,t)=>{const n=b.forwardRef(({className:o,...r},i)=>b.createElement(ei,{ref:i,iconNode:t,className:Nn(`lucide-${qo(Cn(e))}`,`lucide-${e}`,o),...r}));return n.displayName=Cn(e),n};const ti=I("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const ni=I("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);const ri=I("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const oi=I("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);const Tt=I("box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);const ii=I("braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const si=I("camera",[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);const ai=I("chart-no-axes-column-increasing",[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V9",key:"uvy0l4"}],["path",{d:"M19 21V3",key:"11j9sm"}]]);const li=I("chart-pie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);const ci=I("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const zn=I("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Ft=I("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Mn=I("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const di=I("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);const ui=I("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);const hi=I("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);const fi=I("crop",[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]]);const pi=I("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);const gi=I("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const _n=I("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]);const yi=I("file-image",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);const mi=I("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]);const xi=I("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const bi=I("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const ki=I("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);const vi=I("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const Sn=I("grid-3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const wi=I("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);const Ci=I("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);const Ni=I("headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);const zi=I("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const Mi=I("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);const $n=I("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);const _i=I("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const Si=I("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const $i=I("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Ii=I("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const Ai=I("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const Ei=I("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);const Di=I("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);const Oi=I("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);const Li=I("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);const Pi=I("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]);const Ti=I("mouse-pointer-2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);const Fi=I("move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);const Yi=I("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);const Hi=I("palette",[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]);const Bi=I("panel-right",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const Wi=I("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]);const Xi=I("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);const In=I("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Ui=I("redo-2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);const ji=I("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);const Gi=I("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);const Vi=I("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const Ki=I("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const An=I("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const Zi=I("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const qi=I("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const Ji=I("share",[["path",{d:"M12 2v13",key:"1km8f5"}],["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}]]);const Qi=I("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ri=I("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const es=I("speaker",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["circle",{cx:"12",cy:"14",r:"4",key:"1jruaj"}],["path",{d:"M12 14h.01",key:"1etili"}]]);const En=I("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const ts=I("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);const ns=I("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const Yt=I("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const rs=I("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);const os=I("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const is=I("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const ss=I("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);const as=I("watch",[["path",{d:"M12 10v2.2l1.6 1",key:"n3r21l"}],["path",{d:"m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05",key:"18k57s"}],["path",{d:"m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05",key:"16ny36"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}]]);const ls=I("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);const cs=I("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);const ds=I("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);const us=I("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);const hs=I("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),Dn={Monitor:Li,Server:Zi,Smartphone:Ri,Watch:as,Cloud:di,Cpu:hi,Database:pi,HardDrive:Ci,Wifi:ls,Globe:vi,User:is,Users:ss,Lock:Ii,Key:Mi,Shield:Qi,Mic:Oi,Camera:si,Speaker:es,Headphones:Ni,Code:ui,Terminal:ns,FileCode:_n,Folder:bi,Zap:ds,Activity:ti,BarChart:ai,PieChart:li,ArrowRight:ri,ArrowDown:ni,RefreshCw:ji,Repeat:Gi,Box:Tt,Package:Yi,Layers:$n,Grid:Sn,Settings:qi,Bell:oi,Mail:Ai,MessageSquare:Di,Search:An,Filter:ki,Download:gi,Upload:os,Play:Xi,Pause:Wi,Square:En,Circle:Mn},On=Object.keys(Dn);function Ln(e){return Dn[e]||Tt}const fs="Box",Ht={talkie:{id:"talkie",name:"Talkie Docs",description:"Dark theme matching Talkie documentation",canvas:{background:"bg-zinc-950",border:"border-zinc-800",grid:{color:"rgb(113 113 122)",size:24,opacity:.1}},node:{background:"bg-zinc-900",border:"border-zinc-800",borderRadius:"rounded-xl",accentPosition:"left",accentWidth:4,textColor:"text-white",subtitleStyle:"colored",descriptionColor:"text-zinc-500",iconBackground:"bg-zinc-900",iconBorderStyle:"colored"},connector:{defaultDashed:!0,defaultStrokeWidth:2,arrowStyle:"filled",labelFont:"ui-monospace, monospace",labelSize:11}},blueprint:{id:"blueprint",name:"Blueprint",description:"Technical blueprint style with blue tones",canvas:{background:"bg-slate-900",border:"border-slate-700",grid:{color:"rgb(71 85 105)",size:20,opacity:.2}},node:{background:"bg-slate-800/80",border:"border-slate-600",borderRadius:"rounded-lg",accentPosition:"top",accentWidth:3,textColor:"text-slate-100",subtitleStyle:"muted",descriptionColor:"text-slate-400",iconBackground:"bg-slate-700/50",iconBorderStyle:"muted"},connector:{defaultDashed:!1,defaultStrokeWidth:2,arrowStyle:"filled",labelFont:"ui-sans-serif, system-ui",labelSize:10}},light:{id:"light",name:"Light Mode",description:"Clean light theme for documents",canvas:{background:"bg-white",border:"border-zinc-200",grid:{color:"rgb(161 161 170)",size:24,opacity:.15}},node:{background:"bg-white",border:"border-zinc-200",borderRadius:"rounded-xl",accentPosition:"left",accentWidth:4,textColor:"text-zinc-900",subtitleStyle:"colored",descriptionColor:"text-zinc-500",iconBackground:"bg-zinc-50",iconBorderStyle:"colored"},connector:{defaultDashed:!0,defaultStrokeWidth:2,arrowStyle:"filled",labelFont:"ui-monospace, monospace",labelSize:11}},minimal:{id:"minimal",name:"Minimal",description:"Simple and clean with subtle styling",canvas:{background:"bg-zinc-900",border:"border-zinc-800",grid:{color:"transparent",size:0,opacity:0}},node:{background:"bg-zinc-800/60",border:"border-zinc-700/50",borderRadius:"rounded-2xl",accentPosition:"none",accentWidth:0,textColor:"text-zinc-100",subtitleStyle:"muted",descriptionColor:"text-zinc-500",iconBackground:"bg-transparent",iconBorderStyle:"none"},connector:{defaultDashed:!1,defaultStrokeWidth:1.5,arrowStyle:"outline",labelFont:"ui-sans-serif, system-ui",labelSize:10}}},Pn="talkie";function Tn(e){return Ht[e]||Ht[Pn]}function ps(){return Object.values(Ht).map(e=>({id:e.id,name:e.name,description:e.description}))}const Fn=()=>({layout:{...Wo},grid:{...wn},nodes:{},nodeData:{},connectors:[],connectorStyles:{...Uo},groups:[],images:[],exportZone:null}),Bt={diagram:Fn(),editor:{selectedNodeIds:[],selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null,mode:"select",pendingConnector:null,pendingGroup:null,isDragging:!1,dragOffset:{x:0,y:0},dragNodeOffsets:{},template:Pn,zoom:1,viewMode:"2d"},meta:{filename:null,isDirty:!1,lastSaved:null},history:{past:[],future:[]}};function le(e){return{...e,history:{past:[...e.history.past.slice(-49),e.diagram],future:[]},meta:{...e.meta,isDirty:!0}}}function gs(e,t){switch(t.type){case"node/add":{const{position:n,nodeData:o}=t,r=Zo(),i=le(e);return{...i,diagram:{...i.diagram,nodes:{...i.diagram.nodes,[r]:{x:n.x,y:n.y,size:"normal"}},nodeData:{...i.diagram.nodeData,[r]:{icon:fs,name:"New Node",subtitle:"",description:"",color:"violet",...o}}},editor:{...i.editor,selectedNodeIds:[r],selectedConnectorIndex:null,mode:"select"}}}case"node/remove":{const{nodeId:n}=t,o=le(e),{[n]:r,...i}=o.diagram.nodes,{[n]:s,...l}=o.diagram.nodeData,c=o.diagram.connectors.filter(d=>d.from!==n&&d.to!==n);return{...o,diagram:{...o.diagram,nodes:i,nodeData:l,connectors:c},editor:{...o.editor,selectedNodeIds:[],selectedConnectorIndex:null}}}case"node/move":{const{nodeId:n,x:o,y:r}=t;return{...e,diagram:{...e.diagram,nodes:{...e.diagram.nodes,[n]:{...e.diagram.nodes[n],x:o,y:r}}},meta:{...e.meta,isDirty:!0}}}case"nodes/move":{const{moves:n}=t,o={...e.diagram.nodes};for(const{nodeId:r,x:i,y:s}of n)o[r]&&(o[r]={...o[r],x:i,y:s});return{...e,diagram:{...e.diagram,nodes:o},meta:{...e.meta,isDirty:!0}}}case"node/update":{const{nodeId:n,updates:o}=t,r=le(e);return{...r,diagram:{...r.diagram,nodeData:{...r.diagram.nodeData,[n]:{...r.diagram.nodeData[n],...o}}}}}case"node/resize":{const{nodeId:n,size:o,width:r,height:i}=t,s=le(e),c={...s.diagram.nodes[n]};return o!==void 0&&(c.size=o,delete c.width,delete c.height),r!==void 0&&(c.width=r),i!==void 0&&(c.height=i),{...s,diagram:{...s.diagram,nodes:{...s.diagram.nodes,[n]:c}}}}case"node/updatePosition":{const{nodeId:n,updates:o}=t,r=le(e),i=r.diagram.nodes[n];return{...r,diagram:{...r.diagram,nodes:{...r.diagram.nodes,[n]:{...i,...o}}}}}case"connector/add":{const{from:n,to:o,fromAnchor:r,toAnchor:i,style:s="http"}=t,l=le(e);return{...l,diagram:{...l.diagram,connectors:[...l.diagram.connectors,{from:n,to:o,fromAnchor:r,toAnchor:i,style:s}]},editor:{...l.editor,selectedNodeIds:[],selectedConnectorIndex:l.diagram.connectors.length,mode:"select",pendingConnector:null}}}case"connector/remove":{const{index:n}=t,o=le(e);return{...o,diagram:{...o.diagram,connectors:o.diagram.connectors.filter((r,i)=>i!==n)},editor:{...o.editor,selectedConnectorIndex:null}}}case"connector/update":{const{index:n,updates:o}=t,r=le(e);return{...r,diagram:{...r.diagram,connectors:r.diagram.connectors.map((i,s)=>s===n?{...i,...o}:i)}}}case"connectorStyle/update":{const{styleName:n,updates:o}=t,r=le(e);return{...r,diagram:{...r.diagram,connectorStyles:{...r.diagram.connectorStyles,[n]:{...r.diagram.connectorStyles[n],...o}}}}}case"connectorStyle/add":{const{styleName:n,style:o}=t,r=le(e);return{...r,diagram:{...r.diagram,connectorStyles:{...r.diagram.connectorStyles,[n]:o}}}}case"connectorStyle/delete":{const{styleName:n}=t,o=le(e),{[n]:r,...i}=o.diagram.connectorStyles;return{...o,diagram:{...o.diagram,connectorStyles:i}}}case"group/add":{const{group:n}=t,o=`group_${crypto.randomUUID().slice(0,8)}`,r=le(e),i=r.diagram.groups||[];return{...r,diagram:{...r.diagram,groups:[...i,{id:o,...n}]},editor:{...r.editor,selectedGroupId:o,selectedNodeIds:[],selectedConnectorIndex:null}}}case"group/update":{const{groupId:n,updates:o}=t,r=le(e),i=r.diagram.groups||[];return{...r,diagram:{...r.diagram,groups:i.map(s=>s.id===n?{...s,...o}:s)}}}case"group/remove":{const{groupId:n}=t,o=le(e),r=o.diagram.groups||[];return{...o,diagram:{...o.diagram,groups:r.filter(i=>i.id!==n)},editor:{...o.editor,selectedGroupId:null}}}case"select/group":return{...e,editor:{...e.editor,selectedGroupId:t.groupId,selectedNodeIds:[],selectedConnectorIndex:null,selectedImageId:null}};case"image/add":{const{image:n}=t,o=`img_${crypto.randomUUID().slice(0,8)}`,r=le(e),i=r.diagram.images||[];return{...r,diagram:{...r.diagram,images:[...i,{id:o,...n}]},editor:{...r.editor,selectedImageId:o,selectedNodeIds:[],selectedConnectorIndex:null,selectedGroupId:null}}}case"image/update":{const{imageId:n,updates:o}=t,r=le(e),i=r.diagram.images||[];return{...r,diagram:{...r.diagram,images:i.map(s=>s.id===n?{...s,...o}:s)}}}case"image/remove":{const{imageId:n}=t,o=le(e),r=o.diagram.images||[];return{...o,diagram:{...o.diagram,images:r.filter(i=>i.id!==n)},editor:{...o.editor,selectedImageId:null}}}case"select/image":return{...e,editor:{...e.editor,selectedImageId:t.imageId,selectedNodeIds:[],selectedConnectorIndex:null,selectedGroupId:null}};case"exportZone/set":{const{zone:n}=t;return{...e,diagram:{...e.diagram,exportZone:n},meta:{...e.meta,isDirty:!0}}}case"exportZone/clear":return{...e,diagram:{...e.diagram,exportZone:null},meta:{...e.meta,isDirty:!0}};case"select/node":{const{nodeId:n,addToSelection:o}=t;let r;return o?e.editor.selectedNodeIds.includes(n)?r=e.editor.selectedNodeIds.filter(i=>i!==n):r=[...e.editor.selectedNodeIds,n]:r=[n],{...e,editor:{...e.editor,selectedNodeIds:r,selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null}}}case"select/nodes":return{...e,editor:{...e.editor,selectedNodeIds:t.nodeIds,selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null}};case"select/connector":return{...e,editor:{...e.editor,selectedNodeIds:[],selectedConnectorIndex:t.index,selectedGroupId:null,selectedImageId:null}};case"select/clear":return{...e,editor:{...e.editor,selectedNodeIds:[],selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null}};case"mode/set":return{...e,editor:{...e.editor,mode:t.mode,pendingConnector:null,selectedNodeIds:[],selectedConnectorIndex:null}};case"pending/set":return{...e,editor:{...e.editor,pendingConnector:t.pendingConnector}};case"pending/clear":return{...e,editor:{...e.editor,pendingConnector:null}};case"drag/start":{const{offset:n,nodeOffsets:o,selectedIds:r}=t;return{...e,editor:{...e.editor,isDragging:!0,dragOffset:n,dragNodeOffsets:o||{},selectedNodeIds:r||e.editor.selectedNodeIds,selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null}}}case"drag/end":{const n=le(e);return{...n,editor:{...n.editor,isDragging:!1,dragOffset:{x:0,y:0},dragNodeOffsets:{}}}}case"diagram/load":return{...e,diagram:t.diagram,meta:{filename:t.filename||null,isDirty:!1,lastSaved:null},history:{past:[],future:[]},editor:{...e.editor,selectedNodeIds:[],selectedConnectorIndex:null,mode:"select",pendingConnector:null}};case"diagram/new":return{...Bt,diagram:Fn()};case"diagram/saved":return{...e,meta:{...e.meta,filename:t.filename||e.meta.filename,isDirty:!1,lastSaved:new Date().toISOString()}};case"undo":{if(e.history.past.length===0)return e;const n=e.history.past[e.history.past.length-1],o=e.history.past.slice(0,-1);return{...e,diagram:n,history:{past:o,future:[e.diagram,...e.history.future]},meta:{...e.meta,isDirty:!0}}}case"redo":{if(e.history.future.length===0)return e;const n=e.history.future[0],o=e.history.future.slice(1);return{...e,diagram:n,history:{past:[...e.history.past,e.diagram],future:o},meta:{...e.meta,isDirty:!0}}}case"layout/update":{const n=le(e);return{...n,diagram:{...n.diagram,layout:{...n.diagram.layout,...t.updates}}}}case"layout/expand":{const n=e.diagram.layout,o=Math.max(n.width,t.width||n.width),r=Math.max(n.height,t.height||n.height);return o===n.width&&r===n.height?e:{...e,diagram:{...e.diagram,layout:{...n,width:o,height:r}},meta:{...e.meta,isDirty:!0}}}case"grid/update":return{...e,diagram:{...e.diagram,grid:{...e.diagram.grid,...t.updates}}};case"template/set":{const n=Tn(t.templateId);return{...e,diagram:{...e.diagram,grid:{...e.diagram.grid,color:n.canvas.grid.color,size:n.canvas.grid.size,opacity:n.canvas.grid.opacity}},editor:{...e.editor,template:t.templateId},meta:{...e.meta,isDirty:!0}}}case"zoom/set":return{...e,editor:{...e.editor,zoom:Math.min(2,Math.max(.25,t.zoom))}};case"viewMode/set":return{...e,editor:{...e.editor,viewMode:t.viewMode}};default:return e}}const Yn=b.createContext(null);function Hn({children:e,initialDiagram:t}){const[n,o]=b.useReducer(gs,t?{...Bt,diagram:t}:Bt),r={addNode:b.useCallback((i,s)=>{o({type:"node/add",position:i,nodeData:s})},[]),removeNode:b.useCallback(i=>{o({type:"node/remove",nodeId:i})},[]),moveNode:b.useCallback((i,s,l)=>{o({type:"node/move",nodeId:i,x:s,y:l})},[]),moveNodes:b.useCallback(i=>{o({type:"nodes/move",moves:i})},[]),updateNode:b.useCallback((i,s)=>{o({type:"node/update",nodeId:i,updates:s})},[]),resizeNode:b.useCallback((i,s,l,c)=>{o({type:"node/resize",nodeId:i,size:s,width:l,height:c})},[]),updateNodePosition:b.useCallback((i,s)=>{o({type:"node/updatePosition",nodeId:i,updates:s})},[]),addConnector:b.useCallback((i,s,l,c,d)=>{o({type:"connector/add",from:i,to:s,fromAnchor:l,toAnchor:c,style:d})},[]),removeConnector:b.useCallback(i=>{o({type:"connector/remove",index:i})},[]),updateConnector:b.useCallback((i,s)=>{o({type:"connector/update",index:i,updates:s})},[]),addGroup:b.useCallback(i=>{o({type:"group/add",group:i})},[]),updateGroup:b.useCallback((i,s)=>{o({type:"group/update",groupId:i,updates:s})},[]),removeGroup:b.useCallback(i=>{o({type:"group/remove",groupId:i})},[]),addImage:b.useCallback(i=>{o({type:"image/add",image:i})},[]),updateImage:b.useCallback((i,s)=>{o({type:"image/update",imageId:i,updates:s})},[]),removeImage:b.useCallback(i=>{o({type:"image/remove",imageId:i})},[]),setExportZone:b.useCallback(i=>{o({type:"exportZone/set",zone:i})},[]),clearExportZone:b.useCallback(()=>{o({type:"exportZone/clear"})},[]),selectNode:b.useCallback((i,s=!1)=>{o({type:"select/node",nodeId:i,addToSelection:s})},[]),selectNodes:b.useCallback(i=>{o({type:"select/nodes",nodeIds:i})},[]),selectConnector:b.useCallback(i=>{o({type:"select/connector",index:i})},[]),selectGroup:b.useCallback(i=>{o({type:"select/group",groupId:i})},[]),selectImage:b.useCallback(i=>{o({type:"select/image",imageId:i})},[]),clearSelection:b.useCallback(()=>{o({type:"select/clear"})},[]),setMode:b.useCallback(i=>{o({type:"mode/set",mode:i})},[]),setPendingConnector:b.useCallback(i=>{o({type:"pending/set",pendingConnector:i})},[]),clearPendingConnector:b.useCallback(()=>{o({type:"pending/clear"})},[]),startDrag:b.useCallback((i,s,l,c)=>{o({type:"drag/start",nodeId:i,offset:s,nodeOffsets:l,selectedIds:c})},[]),endDrag:b.useCallback(()=>{o({type:"drag/end"})},[]),loadDiagram:b.useCallback((i,s)=>{o({type:"diagram/load",diagram:i,filename:s})},[]),newDiagram:b.useCallback(()=>{o({type:"diagram/new"})},[]),markSaved:b.useCallback(i=>{o({type:"diagram/saved",filename:i})},[]),undo:b.useCallback(()=>{o({type:"undo"})},[]),redo:b.useCallback(()=>{o({type:"redo"})},[]),updateLayout:b.useCallback(i=>{o({type:"layout/update",updates:i})},[]),expandLayout:b.useCallback((i,s)=>{o({type:"layout/expand",width:i,height:s})},[]),setTemplate:b.useCallback(i=>{o({type:"template/set",templateId:i})},[]),setZoom:b.useCallback(i=>{o({type:"zoom/set",zoom:i})},[]),zoomIn:b.useCallback(()=>{o({type:"zoom/set",zoom:n.editor.zoom*1.25})},[n.editor.zoom]),zoomOut:b.useCallback(()=>{o({type:"zoom/set",zoom:n.editor.zoom/1.25})},[n.editor.zoom]),resetZoom:b.useCallback(()=>{o({type:"zoom/set",zoom:1})},[]),setViewMode:b.useCallback(i=>{o({type:"viewMode/set",viewMode:i})},[])};return a.jsx(Yn.Provider,{value:{state:n,dispatch:o,actions:r},children:e})}function he(){const e=b.useContext(Yn);if(!e)throw new Error("useEditor must be used within an EditorProvider");return e}function Ne(){const{state:e}=he();return e.diagram}function Ve(){const{state:e}=he();return e.editor}function Bn(){const{state:e}=he();return e.meta}function ys(){const{state:e}=he();return e.history}function Wn(){const{state:e}=he();return e.editor.template}function Wt(){const{state:e}=he();return e.editor.viewMode}const Xn="https://arc.jdi.sh";function ms({title:e,description:t,image:n,url:o}){b.useEffect(()=>{const r=document.title,i=c=>document.querySelector(`meta[property="${c}"]`)?.content,s={"og:title":i("og:title"),"og:description":i("og:description"),"og:image":i("og:image"),"og:url":i("og:url"),"twitter:title":i("twitter:title"),"twitter:description":i("twitter:description"),"twitter:image":i("twitter:image"),"twitter:url":i("twitter:url")},l=(c,d)=>{let p=document.querySelector(`meta[property="${c}"]`);p||(p=document.createElement("meta"),p.setAttribute("property",c),document.head.appendChild(p)),p.content=d};document.title=e,l("og:title",e),l("twitter:title",e);{l("og:description",t),l("twitter:description",t);const c=document.querySelector('meta[name="description"]');c&&(c.content=t)}{const c=n.startsWith("http")?n:`${Xn}${n}`;l("og:image",c),l("twitter:image",c)}{const c=o.startsWith("http")?o:`${Xn}${o}`;l("og:url",c),l("twitter:url",c)}return()=>{document.title=r,Object.entries(s).forEach(([c,d])=>{if(d){const p=document.querySelector(`meta[property="${c}"]`);p&&(p.content=d)}})}},[e,t,n,o])}function xs(){const{actions:e}=he(),t=Wn(),n=ps();return a.jsxs("div",{className:"relative group",children:[a.jsx("button",{className:"p-2 rounded-lg hover:bg-zinc-100 dark:hover:bg-zinc-800 text-zinc-600 dark:text-zinc-400 transition-colors",title:"Change template",children:a.jsx(Hi,{className:"w-4 h-4"})}),a.jsx("div",{className:"absolute left-0 top-full mt-1 opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-50",children:a.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-lg shadow-lg border border-zinc-200 dark:border-zinc-800 py-1 min-w-[180px]",children:[a.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-zinc-500 dark:text-zinc-500 uppercase tracking-wide",children:"Style Template"}),n.map(o=>a.jsxs("button",{onClick:()=>e.setTemplate(o.id),className:`
|
|
2
2
|
w-full px-3 py-2 text-left text-sm transition-colors
|
|
3
3
|
${t===o.id?"bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"hover:bg-zinc-100 dark:hover:bg-zinc-800 text-zinc-700 dark:text-zinc-300"}
|
|
4
|
-
`,children:[a.jsx("div",{className:"font-medium",children:o.name}),a.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-500 mt-0.5",children:o.description})]},o.id))]})})]})}function
|
|
4
|
+
`,children:[a.jsx("div",{className:"font-medium",children:o.name}),a.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-500 mt-0.5",children:o.description})]},o.id))]})})]})}function dt({icon:e,label:t,onClick:n}){return a.jsx("button",{onClick:n,title:t,className:"p-2 rounded-lg text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-colors",children:a.jsx(e,{className:"w-4 h-4"})})}function bs({onNew:e,onOpen:t,onSave:n,onShare:o,isDark:r,onToggleTheme:i}){const s=Bn();return a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-white dark:bg-zinc-900 border-b border-zinc-200 dark:border-zinc-800",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(dt,{icon:mi,label:"New diagram",onClick:e}),a.jsx(dt,{icon:xi,label:"Open diagram",onClick:t}),a.jsx(dt,{icon:Ki,label:"Save diagram",onClick:n}),a.jsx("div",{className:"w-px h-5 bg-zinc-200 dark:bg-zinc-700 mx-1"}),a.jsx(xs,{})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.filename&&a.jsx("span",{className:"font-medium text-zinc-700 dark:text-zinc-300 truncate max-w-[200px]",children:s.filename}),s.isDirty&&a.jsxs("span",{className:"flex items-center gap-1 text-xs text-zinc-500",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500"}),"Edited"]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[i&&a.jsx(dt,{icon:r?ts:Pi,label:r?"Light mode":"Dark mode",onClick:i}),a.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-white bg-blue-500 hover:bg-blue-600 rounded-lg transition-colors",children:[a.jsx(Ji,{className:"w-4 h-4"}),"Share"]})]})]})}function ze({icon:e,label:t,onClick:n,active:o=!1,disabled:r=!1}){return a.jsx("button",{onClick:n,disabled:r,title:t,className:`
|
|
5
5
|
p-2 rounded-lg transition-all
|
|
6
6
|
${o?"bg-blue-500 text-white shadow-sm":"text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-700"}
|
|
7
7
|
${r?"opacity-30 cursor-not-allowed":""}
|
|
8
|
-
`,children:a.jsx(e,{className:"w-4 h-4",strokeWidth:2})})}function at(){return a.jsx("div",{className:"w-px h-6 bg-zinc-200 dark:bg-zinc-600 mx-0.5"})}function xs(){const{actions:e}=le(),t=je(),n=ps(),o=ke(),r=n.past.length>0,i=n.future.length>0,s=t.selectedNodeIds?.length>0||t.selectedConnectorIndex!==null||t.selectedGroupId!==null||t.selectedImageId!==null,l=o.exportZone!==null,c=()=>{if(t.selectedNodeIds?.length>0)for(const f of t.selectedNodeIds)e.removeNode(f);else t.selectedConnectorIndex!==null?e.removeConnector(t.selectedConnectorIndex):t.selectedGroupId!==null?e.removeGroup(t.selectedGroupId):t.selectedImageId!==null&&e.removeImage(t.selectedImageId)},d=()=>{if(t.selectedNodeIds?.length>0){let u=1/0,h=1/0,p=-1/0,g=-1/0;for(const x of t.selectedNodeIds){const k=o.nodes[x];if(!k)continue;const y=q[k.size]||q.m,m=y.width,C=y.height;u=Math.min(u,k.x),h=Math.min(h,k.y),p=Math.max(p,k.x+m),g=Math.max(g,k.y+C)}u!==1/0&&e.setExportZone({x:Math.max(0,Math.round(u-40)),y:Math.max(0,Math.round(h-40)),width:Math.round(p-u+80),height:Math.round(g-h+80)})}else if(l)e.clearExportZone();else{const{width:f,height:u}=o.layout,h=Math.min(800,f*.8),p=Math.min(600,u*.8);e.setExportZone({x:Math.round((f-h)/2),y:Math.round((u-p)/2),width:Math.round(h),height:Math.round(p)})}e.setMode("select")};return a.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20",children:a.jsxs("div",{className:"flex items-center gap-0.5 px-2 py-1.5 bg-white dark:bg-zinc-800 rounded-xl shadow-lg border border-zinc-200 dark:border-zinc-700",children:[a.jsx(ve,{icon:Ti,label:"Select (V)",onClick:()=>e.setMode("select"),active:t.mode==="select"}),a.jsx(ve,{icon:Pi,label:"Pan (H / Space)",onClick:()=>e.setMode("pan"),active:t.mode==="pan"}),a.jsx(at,{}),a.jsx(ve,{icon:Sn,label:"Add node (N)",onClick:()=>e.setMode("addNode"),active:t.mode==="addNode"}),a.jsx(ve,{icon:Mi,label:"Add connector (C)",onClick:()=>e.setMode("addConnector"),active:t.mode==="addConnector"}),a.jsx(ve,{icon:In,label:"Rectangle group (R)",onClick:()=>e.setMode("addRect"),active:t.mode==="addRect"}),a.jsx(ve,{icon:zn,label:"Circle group (O)",onClick:()=>e.setMode("addCircle"),active:t.mode==="addCircle"}),a.jsx(at,{}),a.jsx(ve,{icon:fi,label:t.selectedNodeIds?.length>0?"Crop to selection":l?"Clear export zone":"Set export zone",onClick:d,active:l}),a.jsx(at,{}),a.jsx(ve,{icon:ts,label:"Undo (⌘Z)",onClick:e.undo,disabled:!r}),a.jsx(ve,{icon:Wi,label:"Redo (⌘⇧Z)",onClick:e.redo,disabled:!i}),a.jsx(at,{}),a.jsx(ve,{icon:Lt,label:"Delete",onClick:c,disabled:!s})]})})}const Un=30*(Math.PI/180),Xn=Math.cos(Un),jn=Math.sin(Un);function T(e,t,n=0){return{screenX:(e-t)*Xn,screenY:-(e+t)*jn-n}}function Yt(e,t){const n=e/Xn,o=-t/jn,r=(n+o)/2,i=(o-n)/2;return{x:r,y:i}}function Oe(e,t,n,o=0,r=0,i=0){const s={frontBottom:T(e,0,0),rightBottom:T(e,t,0),backBottom:T(0,t,0),leftBottom:T(0,0,0),frontTop:T(e,0,n),rightTop:T(e,t,n),backTop:T(0,t,n),leftTop:T(0,0,n)},l=z=>({x:z.screenX+o,y:z.screenY+r}),c=Object.fromEntries(Object.entries(s).map(([z,_])=>[z,l(_)])),d=(z,_,N,E)=>{if(E<=0){const B=T(0,0,N),W=T(z,0,N),G=T(z,_,N),P=T(0,_,N);return`M ${B.screenX+o},${B.screenY+r} L ${W.screenX+o},${W.screenY+r} L ${G.screenX+o},${G.screenY+r} L ${P.screenX+o},${P.screenY+r} Z`}const S=Math.min(z,_)/2,w=Math.min(E,S),M=8,$=[],A=(B,W,G,P)=>{for(let ne=0;ne<=M;ne++){const Q=G+(P-G)*(ne/M),ye=B+w*Math.cos(Q),R=W+w*Math.sin(Q),U=T(ye,R,N);$.push(`${U.screenX+o},${U.screenY+r}`)}};return A(w,w,Math.PI,Math.PI*1.5),A(z-w,w,Math.PI*1.5,Math.PI*2),A(z-w,_-w,0,Math.PI*.5),A(w,_-w,Math.PI*.5,Math.PI),`M ${$[0]} L ${$.slice(1).join(" L ")} Z`},f=z=>`M ${z.map(_=>`${_.x},${_.y}`).join(" L ")} Z`,u=(z,_,N,E,S,w)=>{const $=[];for(let G=0;G<6;G++){const P=S+(w-S)*(G/6),ne=S+(w-S)*((G+1)/6),Q=(P+ne)/2,ye=Math.cos(Q),R=Math.sin(Q),Z=ye*-.577+R*-.577+0*.577,H=.3+Math.max(0,Z+.4)*.5,Ae=T(z+N*Math.cos(P),_+N*Math.sin(P),0),X=T(z+N*Math.cos(ne),_+N*Math.sin(ne),0),xe=T(z+N*Math.cos(P),_+N*Math.sin(P),E),Xe=T(z+N*Math.cos(ne),_+N*Math.sin(ne),E),bn=`M ${Ae.screenX+o},${Ae.screenY+r} L ${X.screenX+o},${X.screenY+r} L ${Xe.screenX+o},${Xe.screenY+r} L ${xe.screenX+o},${xe.screenY+r} Z`;$.push({path:bn,intensity:H})}return $},h=Math.min(i,Math.min(e,t)/2),p=d(e,t,n,h);let g,x,k,y,m,C;if(h>0){const z=[{x:T(0,h,0).screenX+o,y:T(0,h,0).screenY+r},{x:T(0,t-h,0).screenX+o,y:T(0,t-h,0).screenY+r},{x:T(0,t-h,n).screenX+o,y:T(0,t-h,n).screenY+r},{x:T(0,h,n).screenX+o,y:T(0,h,n).screenY+r}];g=f(z);const _=[{x:T(h,0,0).screenX+o,y:T(h,0,0).screenY+r},{x:T(e-h,0,0).screenX+o,y:T(e-h,0,0).screenY+r},{x:T(e-h,0,n).screenX+o,y:T(e-h,0,n).screenY+r},{x:T(h,0,n).screenX+o,y:T(h,0,n).screenY+r}];x=f(_),k=u(h,h,h,n,Math.PI,Math.PI*1.5),y=u(e-h,h,h,n,Math.PI*1.5,Math.PI*2),m=u(h,t-h,h,n,Math.PI*.5,Math.PI),C=u(e-h,t-h,h,n,0,Math.PI*.5)}else{const z=[c.leftBottom,c.backBottom,c.backTop,c.leftTop],_=[c.leftBottom,c.frontBottom,c.frontTop,c.leftTop];g=f(z),x=f(_),k=[],y=[],m=[],C=[]}const v=`M ${c.leftBottom.x},${c.leftBottom.y} L ${c.frontBottom.x},${c.frontBottom.y} L ${c.rightBottom.x},${c.rightBottom.y} L ${c.backBottom.x},${c.backBottom.y} Z`;return{top:p,left:g,right:x,cornerFrontLeft:k,cornerFrontRight:y,cornerBackLeft:m,cornerBackRight:C,outline:v}}function Gn(e,t=60,n=50){return{top:`hsl(${e}, ${t}%, ${Math.min(n+15,95)}%)`,right:`hsl(${e}, ${t}%, ${n}%)`,left:`hsl(${e}, ${t}%, ${Math.max(n-15,15)}%)`}}const Ge={violet:{hue:270,saturation:60,lightness:55},blue:{hue:220,saturation:70,lightness:50},cyan:{hue:190,saturation:80,lightness:45},emerald:{hue:155,saturation:65,lightness:45},amber:{hue:40,saturation:90,lightness:50},rose:{hue:350,saturation:70,lightness:55},slate:{hue:220,saturation:15,lightness:50},zinc:{hue:240,saturation:5,lightness:50}};function Vn(e){const t=Ge[e]||Ge.slate;return Gn(t.hue,t.saturation,t.lightness)}function bs(e,t,n,o=0,r=0){const i=[T(0,0,0),T(e,0,0),T(0,t,0),T(e,t,0),T(0,0,n),T(e,0,n),T(0,t,n),T(e,t,n)],s=i.map(h=>h.screenX+o),l=i.map(h=>h.screenY+r),c=Math.min(...s),d=Math.max(...s),f=Math.min(...l),u=Math.max(...l);return{minX:c,minY:f,maxX:d,maxY:u,width:d-c,height:u-f}}const Ht=.1,Bt=4,Kn=1.15;function ks(e={}){const{initialZoom:t=1,initialPan:n={x:0,y:0},panModeActive:o=!1,onTransformChange:r}=e,[i,s]=b.useState({zoom:t,pan:n,isPanning:!1}),l=b.useRef(null),c=b.useRef(!1),d=b.useRef({x:0,y:0}),f=b.useRef(!1),u=b.useCallback((w,M)=>{s($=>{const A=Math.min(Bt,Math.max(Ht,w));if(M&&l.current){const B=l.current.getBoundingClientRect(),W=M.x-B.left,G=M.y-B.top,P=(W-$.pan.x)/$.zoom,ne=(G-$.pan.y)/$.zoom,Q=W-P*A,ye=G-ne*A;return{...$,zoom:A,pan:{x:Q,y:ye}}}return{...$,zoom:A}})},[]),h=b.useCallback(w=>{s(M=>({...M,pan:w}))},[]),p=b.useCallback(w=>{s(M=>{const $=Math.min(Bt,M.zoom*Kn);if(w&&l.current){const A=l.current.getBoundingClientRect(),B=w.x-A.left,W=w.y-A.top,G=(B-M.pan.x)/M.zoom,P=(W-M.pan.y)/M.zoom;return{...M,zoom:$,pan:{x:B-G*$,y:W-P*$}}}return{...M,zoom:$}})},[]),g=b.useCallback(w=>{s(M=>{const $=Math.max(Ht,M.zoom/Kn);if(w&&l.current){const A=l.current.getBoundingClientRect(),B=w.x-A.left,W=w.y-A.top,G=(B-M.pan.x)/M.zoom,P=(W-M.pan.y)/M.zoom;return{...M,zoom:$,pan:{x:B-G*$,y:W-P*$}}}return{...M,zoom:$}})},[]),x=b.useCallback(()=>{s({zoom:1,pan:{x:0,y:0},isPanning:!1})},[]),k=b.useCallback((w,M=40)=>{if(!l.current)return;const $=l.current.getBoundingClientRect(),A=($.width-M*2)/w.width,B=($.height-M*2)/w.height,W=Math.min(A,B,1),G=($.width-w.width*W)/2,P=($.height-w.height*W)/2;s({zoom:W,pan:{x:G,y:P},isPanning:!1})},[]),y=b.useCallback(w=>{if(w.preventDefault(),w.ctrlKey||w.metaKey){const $=-w.deltaY*.01,A=i.zoom*(1+$);u(A,{x:w.clientX,y:w.clientY})}else s($=>({...$,pan:{x:$.pan.x-w.deltaX,y:$.pan.y-w.deltaY}}))},[i.zoom,u]),m=b.useCallback(w=>{(w.button===1||w.button===0&&f.current||w.button===0&&o)&&(w.preventDefault(),c.current=!0,d.current={x:w.clientX,y:w.clientY},s($=>({...$,isPanning:!0})),w.target.setPointerCapture(w.pointerId))},[o]),C=b.useCallback(w=>{if(!c.current)return;const M=w.clientX-d.current.x,$=w.clientY-d.current.y;d.current={x:w.clientX,y:w.clientY},s(A=>({...A,pan:{x:A.pan.x+M,y:A.pan.y+$}}))},[]),v=b.useCallback(()=>{c.current=!1,s(w=>({...w,isPanning:!1}))},[]),z=b.useCallback(w=>{w.code==="Space"&&!w.repeat&&(f.current=!0)},[]),_=b.useCallback(w=>{w.code==="Space"&&(f.current=!1)},[]);b.useEffect(()=>{const w=l.current;if(w)return w.addEventListener("wheel",y,{passive:!1}),w.addEventListener("pointerdown",m),w.addEventListener("pointermove",C),w.addEventListener("pointerup",v),w.addEventListener("pointerleave",v),window.addEventListener("keydown",z),window.addEventListener("keyup",_),()=>{w.removeEventListener("wheel",y),w.removeEventListener("pointerdown",m),w.removeEventListener("pointermove",C),w.removeEventListener("pointerup",v),w.removeEventListener("pointerleave",v),window.removeEventListener("keydown",z),window.removeEventListener("keyup",_)}},[y,m,C,v,z,_]),b.useEffect(()=>{r?.({zoom:i.zoom,pan:i.pan})},[i.zoom,i.pan,r]);const N=b.useCallback(w=>{if(!l.current)return w;const M=l.current.getBoundingClientRect();return{x:(w.x-M.left-i.pan.x)/i.zoom,y:(w.y-M.top-i.pan.y)/i.zoom}},[i.zoom,i.pan]),E=b.useCallback(w=>{if(!l.current)return w;const M=l.current.getBoundingClientRect();return{x:w.x*i.zoom+i.pan.x+M.left,y:w.y*i.zoom+i.pan.y+M.top}},[i.zoom,i.pan]),S={transform:`translate(${i.pan.x}px, ${i.pan.y}px) scale(${i.zoom})`,transformOrigin:"0 0",transition:i.isPanning?"none":"transform 0.1s ease-out"};return{containerRef:l,zoom:i.zoom,pan:i.pan,isPanning:i.isPanning,setZoom:u,setPan:h,zoomIn:p,zoomOut:g,resetTransform:x,fitToView:k,screenToCanvas:N,canvasToScreen:E,transformStyle:S}}const vs={left:{violet:"border-l-4 border-l-violet-500",emerald:"border-l-4 border-l-emerald-500",blue:"border-l-4 border-l-blue-500",amber:"border-l-4 border-l-amber-500",zinc:"border-l-4 border-l-zinc-500",sky:"border-l-4 border-l-sky-500"},top:{violet:"border-t-3 border-t-violet-500",emerald:"border-t-3 border-t-emerald-500",blue:"border-t-3 border-t-blue-500",amber:"border-t-3 border-t-amber-500",zinc:"border-t-3 border-t-zinc-500",sky:"border-t-3 border-t-sky-500"},none:{violet:"",emerald:"",blue:"",amber:"",zinc:"",sky:""}},ws={colored:{violet:"border-violet-500/50",emerald:"border-emerald-500/50",blue:"border-blue-500/50",amber:"border-amber-500/50",zinc:"border-zinc-600",sky:"border-sky-500/50"},muted:{violet:"border-zinc-600",emerald:"border-zinc-600",blue:"border-zinc-600",amber:"border-zinc-600",zinc:"border-zinc-600",sky:"border-zinc-600"},none:{violet:"border-transparent",emerald:"border-transparent",blue:"border-transparent",amber:"border-transparent",zinc:"border-transparent",sky:"border-transparent"}},Cs={violet:"text-violet-400",emerald:"text-emerald-400",blue:"text-blue-400",amber:"text-amber-400",zinc:"text-zinc-400",sky:"text-sky-400"},Ns={colored:{violet:"text-violet-400",emerald:"text-emerald-400",blue:"text-blue-400",amber:"text-amber-400",zinc:"text-zinc-500",sky:"text-sky-400"},muted:{violet:"text-zinc-500",emerald:"text-zinc-500",blue:"text-zinc-500",amber:"text-zinc-500",zinc:"text-zinc-500",sky:"text-zinc-500"}};function zs({nodeId:e,node:t,data:n,layout:o,template:r,isSelected:i,onPointerDown:s,onClick:l,onMouseEnter:c,onMouseLeave:d}){const f=On(n.icon),u=t.size||"m",h=n.color||"violet",p=q[u]||q.m,g=t.width||p.width,x=t.height||p.height,k=u==="l",y=u==="s"||u==="xs",m=u==="xs",C=t.x/o.width*100,v=t.y/o.height*100,z=g/o.width*100,_=x/o.height*100,N=r?.node||{},E=N.accentPosition||"left",S=vs[E]?.[h]||"",w=N.iconBorderStyle||"colored",M=ws[w]?.[h]||"",$=N.subtitleStyle||"colored",A=Ns[$]?.[h]||"text-zinc-500",B=r?.canvas?.background?.includes("white")?"ring-offset-white":"ring-offset-zinc-950";return a.jsx("div",{className:"absolute cursor-move select-none pointer-events-auto",style:{left:`${C}%`,top:`${v}%`,width:`${z}%`,height:`${_}%`},onMouseEnter:c,onMouseLeave:d,onPointerDown:W=>s(W,e),onClick:W=>{W.stopPropagation(),l(e,W)},children:a.jsxs("div",{className:`
|
|
8
|
+
`,children:a.jsx(e,{className:"w-4 h-4",strokeWidth:2})})}function Ke(){return a.jsx("div",{className:"w-px h-6 bg-zinc-200 dark:bg-zinc-600 mx-0.5"})}function ks(){const{actions:e}=he(),t=Ve(),n=ys(),o=Ne(),[r,i]=b.useState({x:0,y:0}),[s,l]=b.useState(!1),c=b.useRef(null),d=b.useCallback(y=>{y.preventDefault(),y.stopPropagation(),y.target.setPointerCapture(y.pointerId),l(!0),c.current={startX:y.clientX,startY:y.clientY,startPosX:r.x,startPosY:r.y}},[r]),p=b.useCallback(y=>{if(!s||!c.current)return;const v=y.clientX-c.current.startX,w=y.clientY-c.current.startY;i({x:c.current.startPosX+v,y:c.current.startPosY+w})},[s]),u=b.useCallback(()=>{l(!1),c.current=null},[]),h=n.past.length>0,f=n.future.length>0,g=t.selectedNodeIds?.length>0||t.selectedConnectorIndex!==null||t.selectedGroupId!==null||t.selectedImageId!==null,x=o.exportZone!==null,k=()=>{if(t.selectedNodeIds?.length>0)for(const y of t.selectedNodeIds)e.removeNode(y);else t.selectedConnectorIndex!==null?e.removeConnector(t.selectedConnectorIndex):t.selectedGroupId!==null?e.removeGroup(t.selectedGroupId):t.selectedImageId!==null&&e.removeImage(t.selectedImageId)},m=()=>{if(t.selectedNodeIds?.length>0){let v=1/0,w=1/0,N=-1/0,_=-1/0;for(const C of t.selectedNodeIds){const M=o.nodes[C];if(!M)continue;const $=J[M.size]||J.m,S=$.width,E=$.height;v=Math.min(v,M.x),w=Math.min(w,M.y),N=Math.max(N,M.x+S),_=Math.max(_,M.y+E)}v!==1/0&&e.setExportZone({x:Math.max(0,Math.round(v-40)),y:Math.max(0,Math.round(w-40)),width:Math.round(N-v+80),height:Math.round(_-w+80)})}else if(x)e.clearExportZone();else{const{width:y,height:v}=o.layout,w=Math.min(800,y*.8),N=Math.min(600,v*.8);e.setExportZone({x:Math.round((y-w)/2),y:Math.round((v-N)/2),width:Math.round(w),height:Math.round(N)})}e.setMode("select")};return a.jsx("div",{className:"absolute top-4 left-1/2 z-20",style:{transform:`translate(calc(-50% + ${r.x}px), ${r.y}px)`},onPointerMove:p,onPointerUp:u,onPointerLeave:u,children:a.jsxs("div",{className:`flex items-center gap-0.5 px-2 py-1.5 bg-white dark:bg-zinc-800 rounded-xl shadow-lg border border-zinc-200 dark:border-zinc-700 ${s?"cursor-grabbing":""}`,children:[a.jsx("div",{className:"p-1.5 cursor-grab hover:bg-zinc-100 dark:hover:bg-zinc-700 rounded-lg mr-0.5 touch-none",onPointerDown:d,children:a.jsx(wi,{className:"w-4 h-4 text-zinc-400",strokeWidth:2})}),a.jsx(Ke,{}),a.jsx(ze,{icon:Ti,label:"Select (V)",onClick:()=>e.setMode("select"),active:t.mode==="select"}),a.jsx(ze,{icon:Fi,label:"Pan (H / Space)",onClick:()=>e.setMode("pan"),active:t.mode==="pan"}),a.jsx(Ke,{}),a.jsx(ze,{icon:In,label:"Add node (N)",onClick:()=>e.setMode("addNode"),active:t.mode==="addNode"}),a.jsx(ze,{icon:_i,label:"Add connector (C)",onClick:()=>e.setMode("addConnector"),active:t.mode==="addConnector"}),a.jsx(ze,{icon:En,label:"Rectangle group (R)",onClick:()=>e.setMode("addRect"),active:t.mode==="addRect"}),a.jsx(ze,{icon:Mn,label:"Circle group (O)",onClick:()=>e.setMode("addCircle"),active:t.mode==="addCircle"}),a.jsx(Ke,{}),a.jsx(ze,{icon:fi,label:t.selectedNodeIds?.length>0?"Crop to selection":x?"Clear export zone":"Set export zone",onClick:m,active:x}),a.jsx(Ke,{}),a.jsx(ze,{icon:rs,label:"Undo (⌘Z)",onClick:e.undo,disabled:!h}),a.jsx(ze,{icon:Ui,label:"Redo (⌘⇧Z)",onClick:e.redo,disabled:!f}),a.jsx(Ke,{}),a.jsx(ze,{icon:Yt,label:"Delete",onClick:k,disabled:!g})]})})}const Un=30*(Math.PI/180),jn=Math.cos(Un),Gn=Math.sin(Un);function F(e,t,n=0){return{screenX:(e-t)*jn,screenY:-(e+t)*Gn-n}}function Xt(e,t){const n=e/jn,o=-t/Gn,r=(n+o)/2,i=(o-n)/2;return{x:r,y:i}}function Te(e,t,n,o=0,r=0,i=0){const s={frontBottom:F(e,0,0),rightBottom:F(e,t,0),backBottom:F(0,t,0),leftBottom:F(0,0,0),frontTop:F(e,0,n),rightTop:F(e,t,n),backTop:F(0,t,n),leftTop:F(0,0,n)},l=N=>({x:N.screenX+o,y:N.screenY+r}),c=Object.fromEntries(Object.entries(s).map(([N,_])=>[N,l(_)])),d=(N,_,C,M)=>{if(M<=0){const V=F(0,0,C),R=F(N,0,C),K=F(N,_,C),H=F(0,_,C);return`M ${V.screenX+o},${V.screenY+r} L ${R.screenX+o},${R.screenY+r} L ${K.screenX+o},${K.screenY+r} L ${H.screenX+o},${H.screenY+r} Z`}const $=Math.min(N,_)/2,S=Math.min(M,$),E=8,T=[],O=(V,R,K,H)=>{for(let te=0;te<=E;te++){const de=K+(H-K)*(te/E),ve=V+S*Math.cos(de),se=R+S*Math.sin(de),re=F(ve,se,C);T.push(`${re.screenX+o},${re.screenY+r}`)}};return O(S,S,Math.PI,Math.PI*1.5),O(N-S,S,Math.PI*1.5,Math.PI*2),O(N-S,_-S,0,Math.PI*.5),O(S,_-S,Math.PI*.5,Math.PI),`M ${T[0]} L ${T.slice(1).join(" L ")} Z`},p=N=>`M ${N.map(_=>`${_.x},${_.y}`).join(" L ")} Z`,u=(N,_,C,M,$,S)=>{const T=[];for(let K=0;K<6;K++){const H=$+(S-$)*(K/6),te=$+(S-$)*((K+1)/6),de=(H+te)/2,ve=Math.cos(de),se=Math.sin(de),z=ve*-.577+se*-.577+0*.577,B=.3+Math.max(0,z+.4)*.5,W=F(N+C*Math.cos(H),_+C*Math.sin(H),0),G=F(N+C*Math.cos(te),_+C*Math.sin(te),0),Q=F(N+C*Math.cos(H),_+C*Math.sin(H),M),Y=F(N+C*Math.cos(te),_+C*Math.sin(te),M),me=`M ${W.screenX+o},${W.screenY+r} L ${G.screenX+o},${G.screenY+r} L ${Y.screenX+o},${Y.screenY+r} L ${Q.screenX+o},${Q.screenY+r} Z`;T.push({path:me,intensity:B})}return T},h=Math.min(i,Math.min(e,t)/2),f=d(e,t,n,h);let g,x,k,m,y,v;if(h>0){const N=[{x:F(0,h,0).screenX+o,y:F(0,h,0).screenY+r},{x:F(0,t-h,0).screenX+o,y:F(0,t-h,0).screenY+r},{x:F(0,t-h,n).screenX+o,y:F(0,t-h,n).screenY+r},{x:F(0,h,n).screenX+o,y:F(0,h,n).screenY+r}];g=p(N);const _=[{x:F(h,0,0).screenX+o,y:F(h,0,0).screenY+r},{x:F(e-h,0,0).screenX+o,y:F(e-h,0,0).screenY+r},{x:F(e-h,0,n).screenX+o,y:F(e-h,0,n).screenY+r},{x:F(h,0,n).screenX+o,y:F(h,0,n).screenY+r}];x=p(_),k=u(h,h,h,n,Math.PI,Math.PI*1.5),m=u(e-h,h,h,n,Math.PI*1.5,Math.PI*2),y=u(h,t-h,h,n,Math.PI*.5,Math.PI),v=u(e-h,t-h,h,n,0,Math.PI*.5)}else{const N=[c.leftBottom,c.backBottom,c.backTop,c.leftTop],_=[c.leftBottom,c.frontBottom,c.frontTop,c.leftTop];g=p(N),x=p(_),k=[],m=[],y=[],v=[]}const w=`M ${c.leftBottom.x},${c.leftBottom.y} L ${c.frontBottom.x},${c.frontBottom.y} L ${c.rightBottom.x},${c.rightBottom.y} L ${c.backBottom.x},${c.backBottom.y} Z`;return{top:f,left:g,right:x,cornerFrontLeft:k,cornerFrontRight:m,cornerBackLeft:y,cornerBackRight:v,outline:w}}function Vn(e,t=60,n=50){return{top:`hsl(${e}, ${t}%, ${Math.min(n+15,95)}%)`,right:`hsl(${e}, ${t}%, ${n}%)`,left:`hsl(${e}, ${t}%, ${Math.max(n-15,15)}%)`}}const Ze={violet:{hue:270,saturation:60,lightness:55},blue:{hue:220,saturation:70,lightness:50},cyan:{hue:190,saturation:80,lightness:45},emerald:{hue:155,saturation:65,lightness:45},amber:{hue:40,saturation:90,lightness:50},rose:{hue:350,saturation:70,lightness:55},slate:{hue:220,saturation:15,lightness:50},zinc:{hue:240,saturation:5,lightness:50}};function Kn(e){const t=Ze[e]||Ze.slate;return Vn(t.hue,t.saturation,t.lightness)}function vs(e,t,n,o=0,r=0){const i=[F(0,0,0),F(e,0,0),F(0,t,0),F(e,t,0),F(0,0,n),F(e,0,n),F(0,t,n),F(e,t,n)],s=i.map(h=>h.screenX+o),l=i.map(h=>h.screenY+r),c=Math.min(...s),d=Math.max(...s),p=Math.min(...l),u=Math.max(...l);return{minX:c,minY:p,maxX:d,maxY:u,width:d-c,height:u-p}}const ws=.25,Cs=2,Ns=.05,zs=Array.from({length:36},(e,t)=>Math.round((.25+t*.05)*100)/100);function Ms(e={}){const{initialZoom:t=1,initialPan:n={x:0,y:0},panModeActive:o=!1,onTransformChange:r,contentSize:i,zoomLevels:s,zoomStep:l=Ns}=e,c=s||zs,d=c[0]??ws,p=c[c.length-1]??Cs,u=t==="fit",h=typeof t=="number"?t:1,[f,g]=b.useState({zoom:h,pan:n,isPanning:!1}),x=b.useRef(h),k=b.useRef(null),m=b.useRef(!1),y=b.useRef({x:0,y:0}),v=b.useRef(!1),w=b.useCallback(z=>{let D=c[0],B=Math.abs(z-D);for(const W of c){const G=Math.abs(z-W);G<B&&(B=G,D=W)}return D},[c]),N=b.useCallback((z,D)=>{g(B=>{const W=Math.min(p,Math.max(d,z));if(D&&k.current){const G=k.current.getBoundingClientRect(),Q=D.x-G.left,Y=D.y-G.top,me=(Q-B.pan.x)/B.zoom,ee=(Y-B.pan.y)/B.zoom,ct=Q-me*W,vn=Y-ee*W;return{...B,zoom:W,pan:{x:ct,y:vn}}}return{...B,zoom:W}})},[d,p]),_=b.useCallback(z=>{g(D=>({...D,pan:z}))},[]),C=b.useCallback(z=>{for(const D of c)if(D>z+.001)return D;return c[c.length-1]},[c]),M=b.useCallback(z=>{for(let D=c.length-1;D>=0;D--)if(c[D]<z-.001)return c[D];return c[0]},[c]),$=b.useCallback(z=>{g(D=>{const B=C(D.zoom);if(z&&k.current){const W=k.current.getBoundingClientRect(),G=z.x-W.left,Q=z.y-W.top,Y=(G-D.pan.x)/D.zoom,me=(Q-D.pan.y)/D.zoom;return{...D,zoom:B,pan:{x:G-Y*B,y:Q-me*B}}}return{...D,zoom:B}})},[C]),S=b.useCallback(z=>{g(D=>{const B=M(D.zoom);if(z&&k.current){const W=k.current.getBoundingClientRect(),G=z.x-W.left,Q=z.y-W.top,Y=(G-D.pan.x)/D.zoom,me=(Q-D.pan.y)/D.zoom;return{...D,zoom:B,pan:{x:G-Y*B,y:Q-me*B}}}return{...D,zoom:B}})},[M]),E=b.useCallback(()=>{g({zoom:x.current,pan:{x:0,y:0},isPanning:!1})},[]),T=b.useCallback((z,D=40)=>{if(!k.current)return;const B=k.current.getBoundingClientRect(),W=(B.width-D*2)/z.width,G=(B.height-D*2)/z.height,Q=Math.min(W,G,1),Y=w(Q),me=(B.width-z.width*Y)/2,ee=(B.height-z.height*Y)/2;return g({zoom:Y,pan:{x:me,y:ee},isPanning:!1}),Y},[w]),O=b.useCallback(z=>{if(z.preventDefault(),z.stopPropagation(),z.ctrlKey||z.metaKey){const B=-z.deltaY*.01,W=f.zoom*(1+B);N(W,{x:z.clientX,y:z.clientY})}else g(B=>({...B,pan:{x:B.pan.x-z.deltaX,y:B.pan.y-z.deltaY}}))},[f.zoom,N]),V=b.useCallback(z=>{(z.button===1||z.button===0&&v.current||z.button===0&&o)&&(z.preventDefault(),m.current=!0,y.current={x:z.clientX,y:z.clientY},g(B=>({...B,isPanning:!0})),z.target.setPointerCapture(z.pointerId))},[o]),R=b.useCallback(z=>{if(!m.current)return;const D=z.clientX-y.current.x,B=z.clientY-y.current.y;y.current={x:z.clientX,y:z.clientY},g(W=>({...W,pan:{x:W.pan.x+D,y:W.pan.y+B}}))},[]),K=b.useCallback(()=>{m.current=!1,g(z=>({...z,isPanning:!1}))},[]),H=b.useCallback(z=>{z.code==="Space"&&!z.repeat&&(v.current=!0)},[]),te=b.useCallback(z=>{z.code==="Space"&&(v.current=!1)},[]);b.useEffect(()=>{const z=k.current;if(z)return z.addEventListener("wheel",O,{passive:!1}),z.addEventListener("pointerdown",V),z.addEventListener("pointermove",R),z.addEventListener("pointerup",K),z.addEventListener("pointerleave",K),window.addEventListener("keydown",H),window.addEventListener("keyup",te),()=>{z.removeEventListener("wheel",O),z.removeEventListener("pointerdown",V),z.removeEventListener("pointermove",R),z.removeEventListener("pointerup",K),z.removeEventListener("pointerleave",K),window.removeEventListener("keydown",H),window.removeEventListener("keyup",te)}},[O,V,R,K,H,te]),b.useEffect(()=>{r?.({zoom:f.zoom,pan:f.pan})},[f.zoom,f.pan,r]);const de=b.useRef(!1);b.useEffect(()=>{if(u&&i&&k.current&&!de.current){de.current=!0;const z=k.current.getBoundingClientRect(),D=40,B=(z.width-D*2)/i.width,W=(z.height-D*2)/i.height,G=Math.min(B,W,1),Q=w(G);x.current=Q;const Y=(z.width-i.width*Q)/2,me=(z.height-i.height*Q)/2;g({zoom:Q,pan:{x:Y,y:me},isPanning:!1})}},[u,i,w]);const ve=b.useCallback(z=>{if(!k.current)return z;const D=k.current.getBoundingClientRect();return{x:(z.x-D.left-f.pan.x)/f.zoom,y:(z.y-D.top-f.pan.y)/f.zoom}},[f.zoom,f.pan]),se=b.useCallback(z=>{if(!k.current)return z;const D=k.current.getBoundingClientRect();return{x:z.x*f.zoom+f.pan.x+D.left,y:z.y*f.zoom+f.pan.y+D.top}},[f.zoom,f.pan]),re={transform:`translate(${f.pan.x}px, ${f.pan.y}px) scale(${f.zoom})`,transformOrigin:"0 0",transition:f.isPanning?"none":"transform 0.1s ease-out"};return{containerRef:k,zoom:f.zoom,pan:f.pan,isPanning:f.isPanning,minZoom:d,maxZoom:p,setZoom:N,setPan:_,zoomIn:$,zoomOut:S,resetTransform:E,fitToView:T,screenToCanvas:ve,canvasToScreen:se,transformStyle:re}}const _s={left:{violet:"border-l-4 border-l-violet-500",emerald:"border-l-4 border-l-emerald-500",blue:"border-l-4 border-l-blue-500",amber:"border-l-4 border-l-amber-500",zinc:"border-l-4 border-l-zinc-500",sky:"border-l-4 border-l-sky-500"},top:{violet:"border-t-3 border-t-violet-500",emerald:"border-t-3 border-t-emerald-500",blue:"border-t-3 border-t-blue-500",amber:"border-t-3 border-t-amber-500",zinc:"border-t-3 border-t-zinc-500",sky:"border-t-3 border-t-sky-500"},none:{violet:"",emerald:"",blue:"",amber:"",zinc:"",sky:""}},Ss={colored:{violet:"border-violet-500/50",emerald:"border-emerald-500/50",blue:"border-blue-500/50",amber:"border-amber-500/50",zinc:"border-zinc-600",sky:"border-sky-500/50"},muted:{violet:"border-zinc-600",emerald:"border-zinc-600",blue:"border-zinc-600",amber:"border-zinc-600",zinc:"border-zinc-600",sky:"border-zinc-600"},none:{violet:"border-transparent",emerald:"border-transparent",blue:"border-transparent",amber:"border-transparent",zinc:"border-transparent",sky:"border-transparent"}},$s={violet:"text-violet-400",emerald:"text-emerald-400",blue:"text-blue-400",amber:"text-amber-400",zinc:"text-zinc-400",sky:"text-sky-400"},Is={colored:{violet:"text-violet-400",emerald:"text-emerald-400",blue:"text-blue-400",amber:"text-amber-400",zinc:"text-zinc-500",sky:"text-sky-400"},muted:{violet:"text-zinc-500",emerald:"text-zinc-500",blue:"text-zinc-500",amber:"text-zinc-500",zinc:"text-zinc-500",sky:"text-zinc-500"}};function As({nodeId:e,node:t,data:n,layout:o,template:r,isSelected:i,onPointerDown:s,onClick:l,onMouseEnter:c,onMouseLeave:d}){const p=Ln(n.icon),u=t.size||"m",h=n.color||"violet",f=J[u]||J.m,g=t.width||f.width,x=t.height||f.height,k=u==="l",m=u==="s"||u==="xs",y=u==="xs",v=t.x/o.width*100,w=t.y/o.height*100,N=g/o.width*100,_=x/o.height*100,C=r?.node||{},M=C.accentPosition||"left",$=_s[M]?.[h]||"",S=C.iconBorderStyle||"colored",E=Ss[S]?.[h]||"",T=C.subtitleStyle||"colored",O=Is[T]?.[h]||"text-zinc-500",V=r?.canvas?.background?.includes("white")?"ring-offset-white":"ring-offset-zinc-950";return a.jsx("div",{className:"absolute cursor-move select-none pointer-events-auto",style:{left:`${v}%`,top:`${w}%`,width:`${N}%`,height:`${_}%`},onMouseEnter:c,onMouseLeave:d,onPointerDown:R=>s(R,e),onClick:R=>{R.stopPropagation(),l(e,R)},children:a.jsxs("div",{className:`
|
|
9
9
|
relative h-full
|
|
10
|
-
${
|
|
11
|
-
border ${
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
${k?"px-5 py-4":
|
|
10
|
+
${C.background||"bg-zinc-900"}
|
|
11
|
+
border ${C.border||"border-zinc-800"}
|
|
12
|
+
${C.borderRadius||"rounded-xl"}
|
|
13
|
+
${$}
|
|
14
|
+
${k?"px-5 py-4":m?"px-3 py-2.5":"px-4 py-3"}
|
|
15
15
|
transition-all duration-150
|
|
16
|
-
${i?`ring-2 ring-blue-500 ring-offset-2 ${
|
|
16
|
+
${i?`ring-2 ring-blue-500 ring-offset-2 ${V}`:""}
|
|
17
17
|
`,children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:`
|
|
18
18
|
flex-shrink-0 rounded-lg
|
|
19
|
-
${k?"w-12 h-12":
|
|
19
|
+
${k?"w-12 h-12":m?"w-8 h-8":"w-10 h-10"}
|
|
20
20
|
flex items-center justify-center
|
|
21
|
-
${
|
|
22
|
-
border ${
|
|
23
|
-
`,children:a.jsx(
|
|
21
|
+
${C.iconBackground||"bg-zinc-900"}
|
|
22
|
+
border ${E}
|
|
23
|
+
`,children:a.jsx(p,{className:`${k?"w-6 h-6":m?"w-4 h-4":"w-5 h-5"} ${$s[h]}`})}),a.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[a.jsx("div",{className:`font-semibold ${C.textColor||"text-white"} ${k?"text-base":m?"text-xs":"text-sm"}`,children:n.name}),n.subtitle&&a.jsx("div",{className:`font-mono ${O} ${y?"text-[8px]":m?"text-[9px]":"text-[11px]"}`,children:n.subtitle})]})]}),n.description&&!m&&!y&&a.jsx("div",{className:`mt-2 ${C.descriptionColor||"text-zinc-500"} ${k?"text-xs":"text-[11px]"}`,children:n.description})]})})}const Fe={emerald:"#34d399",amber:"#fbbf24",zinc:"#71717a",sky:"#38bdf8",violet:"#a78bfa",blue:"#60a5fa"};function Es({id:e,color:t}){return a.jsx("marker",{id:e,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto",markerUnits:"userSpaceOnUse",children:a.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:Fe[t]})})}function Ds({id:e,color:t}){return a.jsx("marker",{id:e,markerWidth:"8",markerHeight:"6",refX:"1",refY:"3",orient:"auto",markerUnits:"userSpaceOnUse",children:a.jsx("polygon",{points:"8 0, 0 3, 8 6",fill:Fe[t]})})}function Os(){return{dx:0,dy:0}}function Zn({x:e,y:t,color:n,size:o=4}){const r=Os();return a.jsx("circle",{cx:e+r.dx,cy:t+r.dy,r:o,fill:Fe[n]||Fe.zinc,className:"pointer-events-none"})}function ut(e,t){const n=Math.abs(t)*.5;switch(e){case"top":return{dx:0,dy:-n};case"bottom":return{dx:0,dy:n};case"left":return{dx:-n,dy:0};case"right":return{dx:n,dy:0};case"bottomRight":return{dx:n*.7,dy:n*.7};case"bottomLeft":return{dx:-n*.7,dy:n*.7};default:return{dx:0,dy:0}}}function Ls(e,t,n,o,r,i=50){const s=t.x-e.x,l=t.y-e.y,c=Math.sqrt(s*s+l*l);if(r==="natural"||r==="down"||r==="up"){const x=ut(n,c),k=ut(o,c),m=i/50,y=e.x+x.dx*m,v=e.y+x.dy*m,w=t.x+k.dx*m,N=t.y+k.dy*m;return`M ${e.x} ${e.y} C ${y} ${v}, ${w} ${N}, ${t.x} ${t.y}`}if(n==="right"&&o==="left"||n==="left"&&o==="right"){const x=(e.x+t.x)/2;return`M ${e.x} ${e.y} C ${x} ${e.y}, ${x} ${t.y}, ${t.x} ${t.y}`}if(n==="bottom"&&o==="top"||n==="top"&&o==="bottom"){const x=(e.y+t.y)/2;return`M ${e.x} ${e.y} C ${e.x} ${x}, ${t.x} ${x}, ${t.x} ${t.y}`}const d=ut(n,c),p=ut(o,c),u=e.x+d.dx,h=e.y+d.dy,f=t.x+p.dx,g=t.y+p.dy;return`M ${e.x} ${e.y} C ${u} ${h}, ${f} ${g}, ${t.x} ${t.y}`}function Ps({connector:e,nodes:t,connectorStyles:n,isSelected:o,onClick:r,index:i}){const s=n[e.style];if(!s)return null;const l=Pt(t,e.from,e.fromAnchor),c=Pt(t,e.to,e.toAnchor),d=Ko(l,c),p=e.curveDepth??40,u=Ls(l,c,e.fromAnchor,e.toAnchor,e.curve,p),h=Fe[s.color]||Fe.zinc,f=s.showArrow!==!1,g=s.showEndpoints!==!1,x=s.bidirectional===!0,k=s.animated!==!1&&s.dashed,m=e.fromAnchor==="bottom"||e.fromAnchor==="top";let y,v,w;e.curve==="down"?(y=d.x,v=Math.max(l.y,c.y)+60,w="middle"):m?(y=l.x+12,v=d.y,w="start"):(y=d.x,v=Math.min(l.y,c.y)-8,w="middle");const N=s.dashed?"8 4":void 0;let _,C;f&&(x?(_=`url(#arrow-start-${s.color})`,C=`url(#arrow-${s.color})`):C=`url(#arrow-${s.color})`);const M=k?x?"animate-dash-bidirectional":"animate-dash-forward":"";return a.jsxs("g",{className:"cursor-pointer",onClick:$=>{$.stopPropagation(),r(i)},children:[a.jsx("path",{d:u,fill:"none",stroke:"transparent",strokeWidth:20}),o&&a.jsx("path",{d:u,fill:"none",stroke:"#3b82f6",strokeWidth:s.strokeWidth+6,strokeOpacity:.3,strokeDasharray:N}),a.jsx("path",{d:u,fill:"none",stroke:h,strokeWidth:s.strokeWidth,strokeDasharray:N,markerStart:_,markerEnd:C,strokeLinecap:"round",strokeLinejoin:"round",className:M}),g&&a.jsxs(a.Fragment,{children:[a.jsx(Zn,{x:l.x,y:l.y,color:s.color,size:4}),a.jsx(Zn,{x:c.x,y:c.y,color:s.color,size:4})]}),s.label&&s.label.length>0&&!e.curve&&a.jsx("text",{x:y,y:v,textAnchor:w,fill:h,fontSize:"11",fontFamily:"ui-monospace, monospace",fontWeight:"500",children:s.label})]})}function Ts({layout:e,nodes:t,connectors:n,connectorStyles:o,selectedConnectorIndex:r,onConnectorClick:i}){const s=[...new Set(n.map(l=>o[l.style]?.color).filter(Boolean))];return a.jsxs(a.Fragment,{children:[a.jsx("style",{children:`
|
|
24
24
|
@keyframes dash-forward {
|
|
25
25
|
0% {
|
|
26
26
|
stroke-dashoffset: 0;
|
|
@@ -49,32 +49,32 @@
|
|
|
49
49
|
.animate-dash-bidirectional {
|
|
50
50
|
animation: dash-bidirectional 2s linear infinite;
|
|
51
51
|
}
|
|
52
|
-
`}),a.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",children:[a.jsx("defs",{children:s.map(l=>a.jsxs(b.Fragment,{children:[a.jsx(
|
|
52
|
+
`}),a.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",children:[a.jsx("defs",{children:s.map(l=>a.jsxs(b.Fragment,{children:[a.jsx(Es,{id:`arrow-${l}`,color:l}),a.jsx(Ds,{id:`arrow-start-${l}`,color:l})]},l))}),a.jsx("g",{className:"pointer-events-auto",children:n.map((l,c)=>a.jsx(Ps,{index:c,connector:l,nodes:t,connectorStyles:o,isSelected:r===c,onClick:i},c))})]})]})}function Fs({layout:e,nodes:t,visibleNodeId:n,onAnchorClick:o,pendingConnector:r}){if(!n)return null;const i=["top","right","bottom","left"];return a.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",children:a.jsx("g",{className:"pointer-events-auto",children:i.map(s=>{const l=Pt(t,n,s),c=r?.from===n&&r?.fromAnchor===s;return a.jsxs("g",{children:[a.jsx("circle",{cx:l.x,cy:l.y,r:12,fill:"transparent",className:"cursor-pointer",onClick:d=>{d.stopPropagation(),o(n,s)}}),a.jsx("circle",{cx:l.x,cy:l.y,r:c?7:5,className:`
|
|
53
53
|
${c?"fill-blue-500":"fill-blue-400 hover:fill-blue-500"}
|
|
54
54
|
transition-all duration-150
|
|
55
|
-
`,style:{pointerEvents:"none"}}),a.jsx("circle",{cx:l.x,cy:l.y,r:2,className:"fill-white",style:{pointerEvents:"none"}})]},s)})})})}const Zn={violet:{fill:"rgba(139, 92, 246, 0.1)",stroke:"rgba(139, 92, 246, 0.5)"},emerald:{fill:"rgba(52, 211, 153, 0.1)",stroke:"rgba(52, 211, 153, 0.5)"},blue:{fill:"rgba(96, 165, 250, 0.1)",stroke:"rgba(96, 165, 250, 0.5)"},amber:{fill:"rgba(251, 191, 36, 0.1)",stroke:"rgba(251, 191, 36, 0.5)"},zinc:{fill:"rgba(113, 113, 122, 0.1)",stroke:"rgba(113, 113, 122, 0.5)"},sky:{fill:"rgba(56, 189, 248, 0.1)",stroke:"rgba(56, 189, 248, 0.5)"}};function Ds({group:e,isSelected:t,onClick:n,onDragStart:o,onResize:r}){const i=Zn[e.color]||Zn.zinc,{x:s,y:l,width:c,height:d,type:f,label:u}=e,h=g=>{g.stopPropagation(),n(e.id),o(e.id,g)},p=(g,x)=>{g.stopPropagation(),r(e.id,x,g)};return a.jsxs("g",{className:"cursor-move",children:[f==="circle"?a.jsx("ellipse",{cx:s+c/2,cy:l+d/2,rx:c/2,ry:d/2,fill:i.fill,stroke:t?"#3b82f6":i.stroke,strokeWidth:t?2:1.5,strokeDasharray:e.dashed?"8 4":void 0,onMouseDown:h}):a.jsx("rect",{x:s,y:l,width:c,height:d,rx:12,ry:12,fill:i.fill,stroke:t?"#3b82f6":i.stroke,strokeWidth:t?2:1.5,strokeDasharray:e.dashed?"8 4":void 0,onMouseDown:h}),u&&a.jsx("text",{x:s+12,y:l+20,fill:i.stroke,fontSize:"12",fontWeight:"500",fontFamily:"ui-sans-serif, system-ui, sans-serif",style:{pointerEvents:"none"},children:u}),t&&a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:s,cy:l,r:5,fill:"#3b82f6",className:"cursor-nwse-resize",onMouseDown:g=>p(g,"nw")}),a.jsx("circle",{cx:s+c,cy:l,r:5,fill:"#3b82f6",className:"cursor-nesw-resize",onMouseDown:g=>p(g,"ne")}),a.jsx("circle",{cx:s,cy:l+d,r:5,fill:"#3b82f6",className:"cursor-nesw-resize",onMouseDown:g=>p(g,"sw")}),a.jsx("circle",{cx:s+c,cy:l+d,r:5,fill:"#3b82f6",className:"cursor-nwse-resize",onMouseDown:g=>p(g,"se")})]})]})}function Os({layout:e,groups:t,selectedGroupId:n,onGroupClick:o,onGroupUpdate:r,screenToCanvas:i}){const[s,l]=b.useState(null),c=b.useCallback((h,p)=>{const g=t.find(k=>k.id===h);if(!g)return;const x=i({x:p.clientX,y:p.clientY});l({groupId:h,type:"move",startX:x.x,startY:x.y,originalX:g.x,originalY:g.y})},[t,i]),d=b.useCallback((h,p,g)=>{const x=t.find(y=>y.id===h);if(!x)return;const k=i({x:g.clientX,y:g.clientY});l({groupId:h,type:"resize",corner:p,startX:k.x,startY:k.y,originalX:x.x,originalY:x.y,originalWidth:x.width,originalHeight:x.height})},[t,i]),f=b.useCallback(h=>{if(!s)return;const p=i({x:h.clientX,y:h.clientY}),g=p.x-s.startX,x=p.y-s.startY;if(s.type==="move")r(s.groupId,{x:Math.round(s.originalX+g),y:Math.round(s.originalY+x)});else if(s.type==="resize"){let k=s.originalX,y=s.originalY,m=s.originalWidth,C=s.originalHeight;s.corner.includes("w")&&(k=s.originalX+g,m=s.originalWidth-g),s.corner.includes("e")&&(m=s.originalWidth+g),s.corner.includes("n")&&(y=s.originalY+x,C=s.originalHeight-x),s.corner.includes("s")&&(C=s.originalHeight+x),m>=40&&C>=40&&r(s.groupId,{x:Math.round(k),y:Math.round(y),width:Math.round(m),height:Math.round(C)})}},[s,i,r]),u=b.useCallback(()=>{l(null)},[]);return!t||t.length===0?null:a.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",onMouseMove:s?f:void 0,onMouseUp:s?u:void 0,onMouseLeave:s?u:void 0,style:{pointerEvents:s?"auto":"none"},children:a.jsx("g",{className:"pointer-events-auto",children:t.map(h=>a.jsx(Ds,{group:h,isSelected:n===h.id,onClick:o,onDragStart:c,onResize:d},h.id))})})}function Ls({image:e,isSelected:t,onClick:n,onDragStart:o,onResize:r}){const{x:i,y:s,width:l,height:c,src:d,opacity:f=1}=e,u=p=>{p.stopPropagation(),n(e.id),o(e.id,p)},h=(p,g)=>{p.stopPropagation(),r(e.id,g,p)};return a.jsxs("g",{className:"cursor-move",children:[a.jsx("image",{href:d,x:i,y:s,width:l,height:c,preserveAspectRatio:"xMidYMid meet",onMouseDown:u,style:{cursor:"move",opacity:f}}),t&&a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:i,y:s,width:l,height:c,fill:"none",stroke:"#3b82f6",strokeWidth:2,strokeDasharray:"4 2",style:{pointerEvents:"none"}}),a.jsx("circle",{cx:i,cy:s,r:5,fill:"#3b82f6",className:"cursor-nwse-resize",onMouseDown:p=>h(p,"nw")}),a.jsx("circle",{cx:i+l,cy:s,r:5,fill:"#3b82f6",className:"cursor-nesw-resize",onMouseDown:p=>h(p,"ne")}),a.jsx("circle",{cx:i,cy:s+c,r:5,fill:"#3b82f6",className:"cursor-nesw-resize",onMouseDown:p=>h(p,"sw")}),a.jsx("circle",{cx:i+l,cy:s+c,r:5,fill:"#3b82f6",className:"cursor-nwse-resize",onMouseDown:p=>h(p,"se")})]})]})}function Ts({layout:e,images:t,selectedImageId:n,onImageClick:o,onImageUpdate:r,screenToCanvas:i}){const[s,l]=b.useState(null),c=b.useCallback((h,p)=>{const g=t.find(k=>k.id===h);if(!g)return;const x=i({x:p.clientX,y:p.clientY});l({imageId:h,type:"move",startX:x.x,startY:x.y,originalX:g.x,originalY:g.y})},[t,i]),d=b.useCallback((h,p,g)=>{const x=t.find(y=>y.id===h);if(!x)return;const k=i({x:g.clientX,y:g.clientY});l({imageId:h,type:"resize",corner:p,startX:k.x,startY:k.y,originalX:x.x,originalY:x.y,originalWidth:x.width,originalHeight:x.height,aspectRatio:x.width/x.height})},[t,i]),f=b.useCallback(h=>{if(!s)return;const p=i({x:h.clientX,y:h.clientY}),g=p.x-s.startX,x=p.y-s.startY;if(s.type==="move")r(s.imageId,{x:Math.round(s.originalX+g),y:Math.round(s.originalY+x)});else if(s.type==="resize"){let k=s.originalX,y=s.originalY,m=s.originalWidth,C=s.originalHeight;const v=!h.shiftKey;if(s.corner.includes("e")&&(m=s.originalWidth+g),s.corner.includes("w")&&(k=s.originalX+g,m=s.originalWidth-g),s.corner.includes("s")&&(C=s.originalHeight+x),s.corner.includes("n")&&(y=s.originalY+x,C=s.originalHeight-x),v&&s.aspectRatio){if(s.corner==="se"||s.corner==="nw"){const z=Math.abs(m-s.originalWidth),_=Math.abs(C-s.originalHeight);z>_?C=m/s.aspectRatio:m=C*s.aspectRatio}else if(s.corner==="sw"||s.corner==="ne"){const z=Math.abs(m-s.originalWidth),_=Math.abs(C-s.originalHeight);z>_?C=m/s.aspectRatio:m=C*s.aspectRatio}}m>=20&&C>=20&&r(s.imageId,{x:Math.round(k),y:Math.round(y),width:Math.round(m),height:Math.round(C)})}},[s,i,r]),u=b.useCallback(()=>{l(null)},[]);return!t||t.length===0?null:a.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",onMouseMove:s?f:void 0,onMouseUp:s?u:void 0,onMouseLeave:s?u:void 0,style:{pointerEvents:s?"auto":"none"},children:a.jsx("g",{className:"pointer-events-auto",children:t.map(h=>a.jsx(Ls,{image:h,isSelected:n===h.id,onClick:o,onDragStart:c,onResize:d},h.id))})})}const ct={violet:"#8b5cf6",emerald:"#34d399",blue:"#60a5fa",amber:"#fbbf24",zinc:"#71717a",sky:"#38bdf8"};function Ps({diagram:e,viewportBounds:t,onViewportChange:n,width:o=160,height:r=100}){const i=b.useRef(null),s=e.layout,l=o/s.width,c=r/s.height,d=Math.min(l,c),f=s.width*d,u=s.height*d,h=(t?.x||0)*d,p=(t?.y||0)*d,g=(t?.width||s.width)*d,x=(t?.height||s.height)*d,k=b.useCallback(y=>{if(!i.current||!n)return;const m=i.current.getBoundingClientRect(),C=y.clientX-m.left,v=y.clientY-m.top,z=C/d,_=v/d;n({x:z-(t?.width||s.width)/2,y:_-(t?.height||s.height)/2})},[d,n,t,s]);return a.jsx("div",{ref:i,className:"absolute bottom-4 left-4 bg-white dark:bg-zinc-900 rounded-lg shadow-lg border border-zinc-200 dark:border-zinc-700 overflow-hidden cursor-pointer",style:{width:f+8,height:u+8,padding:4},onClick:k,children:a.jsxs("svg",{width:f,height:u,viewBox:`0 0 ${s.width} ${s.height}`,className:"bg-zinc-50 dark:bg-zinc-800 rounded",children:[(e.groups||[]).map(y=>a.jsx("rect",{x:y.x,y:y.y,width:y.width,height:y.height,fill:ct[y.color]||ct.zinc,opacity:.2,rx:4},y.id)),(e.images||[]).map(y=>a.jsx("rect",{x:y.x,y:y.y,width:y.width,height:y.height,fill:"#9ca3af",opacity:.3},y.id)),e.connectors.map((y,m)=>{const C=e.nodes[y.from],v=e.nodes[y.to];if(!C||!v)return null;const z=C.x+50,_=C.y+25,N=v.x+50,E=v.y+25;return a.jsx("line",{x1:z,y1:_,x2:N,y2:E,stroke:"#9ca3af",strokeWidth:2/d,opacity:.5},m)}),Object.entries(e.nodes).map(([y,m])=>{const C=e.nodeData[y];if(!C)return null;const v=ct[C.color]||ct.zinc,z=m.size||"m",_=z==="l"?210:z==="s"?95:z==="xs"?80:145,N=z==="l"?85:z==="s"?42:z==="xs"?36:68;return a.jsx("rect",{x:m.x,y:m.y,width:m.width||_,height:m.height||N,fill:v,rx:4},y)}),a.jsx("rect",{x:h/d,y:p/d,width:g/d,height:x/d,fill:"none",stroke:"#3b82f6",strokeWidth:2/d,strokeDasharray:`${4/d} ${2/d}`})]})})}function Fs({layout:e,exportZone:t,isEditing:n,onZoneUpdate:o,onZoneClear:r,screenToCanvas:i}){const[s,l]=b.useState(null),c=b.useRef(null),d=b.useCallback((y,m)=>{if(!t||!n)return;m.stopPropagation(),m.target.setPointerCapture(m.pointerId);const C=i({x:m.clientX,y:m.clientY});l({type:"resize",corner:y,startX:C.x,startY:C.y,originalX:t.x,originalY:t.y,originalWidth:t.width,originalHeight:t.height})},[t,n,i]),f=b.useCallback(y=>{if(!t||!n)return;y.stopPropagation(),y.target.setPointerCapture(y.pointerId);const m=i({x:y.clientX,y:y.clientY});l({type:"move",startX:m.x,startY:m.y,originalX:t.x,originalY:t.y})},[t,n,i]),u=b.useCallback(y=>{if(!s||!t)return;const m=i({x:y.clientX,y:y.clientY}),C=m.x-s.startX,v=m.y-s.startY;if(s.type==="move")o({...t,x:Math.max(0,Math.round(s.originalX+C)),y:Math.max(0,Math.round(s.originalY+v))});else if(s.type==="resize"){let z=s.originalX,_=s.originalY,N=s.originalWidth,E=s.originalHeight;s.corner.includes("w")&&(z=s.originalX+C,N=s.originalWidth-C),s.corner.includes("e")&&(N=s.originalWidth+C),s.corner.includes("n")&&(_=s.originalY+v,E=s.originalHeight-v),s.corner.includes("s")&&(E=s.originalHeight+v),N>=50&&E>=50&&o({x:Math.max(0,Math.round(z)),y:Math.max(0,Math.round(_)),width:Math.round(N),height:Math.round(E)})}},[s,t,i,o]),h=b.useCallback(y=>{y.target.releasePointerCapture&&y.target.releasePointerCapture(y.pointerId),l(null)},[]);if(!t)return null;const{x:p,y:g,width:x,height:k}=t;return a.jsxs("svg",{ref:c,className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",style:{pointerEvents:"none"},children:[a.jsx("defs",{children:a.jsxs("mask",{id:"exportZoneMask",children:[a.jsx("rect",{x:0,y:0,width:e.width,height:e.height,fill:"white"}),a.jsx("rect",{x:p,y:g,width:x,height:k,fill:"black"})]})}),a.jsx("rect",{x:0,y:0,width:e.width,height:e.height,fill:"rgba(0,0,0,0.3)",mask:"url(#exportZoneMask)",style:{pointerEvents:"none"}}),n&&a.jsx("rect",{x:p,y:g,width:x,height:k,fill:"transparent",style:{pointerEvents:"auto",cursor:"move"},onPointerDown:f,onPointerMove:u,onPointerUp:h}),a.jsx("rect",{x:p,y:g,width:x,height:k,fill:"none",stroke:"#10b981",strokeWidth:2,strokeDasharray:"8 4",style:{pointerEvents:"none"}}),a.jsxs("text",{x:p+8,y:g-8,fill:"#10b981",fontSize:"12",fontWeight:"600",fontFamily:"ui-sans-serif, system-ui, sans-serif",style:{pointerEvents:"none"},children:["Export Zone (",x," x ",k,")"]}),n&&a.jsx("g",{children:[{cx:p,cy:g,cursor:"nwse-resize",corner:"nw"},{cx:p+x,cy:g,cursor:"nesw-resize",corner:"ne"},{cx:p,cy:g+k,cursor:"nesw-resize",corner:"sw"},{cx:p+x,cy:g+k,cursor:"nwse-resize",corner:"se"},{cx:p+x/2,cy:g,cursor:"ns-resize",corner:"n",r:5},{cx:p+x/2,cy:g+k,cursor:"ns-resize",corner:"s",r:5},{cx:p,cy:g+k/2,cursor:"ew-resize",corner:"w",r:5},{cx:p+x,cy:g+k/2,cursor:"ew-resize",corner:"e",r:5}].map(({cx:y,cy:m,cursor:C,corner:v,r:z=6})=>a.jsx("circle",{cx:y,cy:m,r:z,fill:"#10b981",style:{pointerEvents:"auto",cursor:C},onPointerDown:_=>d(v,_),onPointerMove:u,onPointerUp:h},v))})]})}function Ys({grid:e,viewportBounds:t,containerSize:n,zoom:o}){if(!e?.enabled)return null;const{size:r=24,color:i="#71717a",opacity:s=.1,type:l="dots"}=e,c=r*o,d=t.x%r*o,f=t.y%r*o,u=b.useMemo(()=>{const h={position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",opacity:s,backgroundPosition:`${-d}px ${-f}px`,backgroundSize:`${c}px ${c}px`};return l==="dots"?{...h,backgroundImage:`radial-gradient(circle, ${i} 1px, transparent 1px)`}:{...h,backgroundImage:`linear-gradient(${i} 1px, transparent 1px), linear-gradient(90deg, ${i} 1px, transparent 1px)`}},[l,i,c,d,f,s]);return a.jsx("div",{className:"infinite-grid",style:u})}function Hs({zoom:e,onZoomIn:t,onZoomOut:n,onReset:o,onFitToView:r}){const i=Math.round(e*100);return a.jsxs("div",{className:"absolute bottom-3 right-3 flex items-center gap-1 bg-white dark:bg-zinc-800 rounded-lg shadow-lg border border-zinc-200 dark:border-zinc-700 p-1",children:[a.jsx("button",{onClick:n,disabled:e<=Ht,className:"p-1.5 rounded hover:bg-zinc-100 dark:hover:bg-zinc-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",title:"Zoom out (scroll down)",children:a.jsx(ds,{className:"w-4 h-4 text-zinc-600 dark:text-zinc-400"})}),a.jsxs("button",{onClick:o,className:"px-2 py-1 text-xs font-medium text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-700 rounded min-w-[48px] transition-colors",title:"Reset to 100%",children:[i,"%"]}),a.jsx("button",{onClick:t,disabled:e>=Bt,className:"p-1.5 rounded hover:bg-zinc-100 dark:hover:bg-zinc-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",title:"Zoom in (scroll up)",children:a.jsx(cs,{className:"w-4 h-4 text-zinc-600 dark:text-zinc-400"})}),a.jsx("div",{className:"w-px h-4 bg-zinc-200 dark:bg-zinc-700 mx-0.5"}),a.jsx("button",{onClick:r,className:"p-1.5 rounded hover:bg-zinc-100 dark:hover:bg-zinc-700 transition-colors",title:"Fit to view",children:a.jsx(Ii,{className:"w-4 h-4 text-zinc-600 dark:text-zinc-400"})})]})}function Bs({viewMode:e,onViewModeChange:t}){return a.jsxs("div",{className:"absolute bottom-3 right-44 flex items-center gap-1 bg-white dark:bg-zinc-800 rounded-lg shadow-lg border border-zinc-200 dark:border-zinc-700 p-1",children:[a.jsx("button",{onClick:()=>t("2d"),className:`p-1.5 rounded transition-colors ${e==="2d"?"bg-violet-100 dark:bg-violet-900/50 text-violet-600 dark:text-violet-400":"hover:bg-zinc-100 dark:hover:bg-zinc-700 text-zinc-600 dark:text-zinc-400"}`,title:"2D View",children:a.jsx($n,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>t("isometric"),className:`p-1.5 rounded transition-colors ${e==="isometric"?"bg-violet-100 dark:bg-violet-900/50 text-violet-600 dark:text-violet-400":"hover:bg-zinc-100 dark:hover:bg-zinc-700 text-zinc-600 dark:text-zinc-400"}`,title:"Isometric View",children:a.jsx(Ot,{className:"w-4 h-4"})})]})}const Ws=25,Us=50,Xs=6;function dt(e,t){const n=20+t*50;return`hsl(${e.hue}, ${e.saturation}%, ${n}%)`}function js({nodes:e,nodeData:t,selectedNodeIds:n,onNodeClick:o,onNodePointerDown:r,originX:i=400,originY:s=500}){const l=b.useMemo(()=>Object.entries(e).filter(([c])=>t[c]).sort(([,c],[,d])=>{const f=c.x+c.y+(c.z||0),u=d.x+d.y+(d.z||0);return f-u}),[e,t]);return a.jsxs("svg",{className:"absolute inset-0 w-full h-full",style:{overflow:"visible"},children:[l.map(([c,d])=>{const f=t[c];if(!f)return null;const u=q[d.size]||q.m,p=(d.width||u.width)*.8,g=d.isoDepth??Us,x=d.isoHeight??Ws,k=d.z??0,y=T(d.x,d.y,k),m=i+y.screenX,C=s+y.screenY,v=Oe(p,g,x,m,C,Xs),z=Ge[f.color]||Ge.violet,_=Vn(f.color),N=n.includes(c),E=T(d.x+p/2,d.y+g/2,k+x),S=i+E.screenX,w=s+E.screenY;return a.jsxs("g",{className:"cursor-pointer",onClick:()=>o?.(c),onPointerDown:M=>r?.(M,c),children:[N&&a.jsxs("g",{filter:"url(#selection-glow)",children:[a.jsx("path",{d:v.top,fill:"rgba(59, 130, 246, 0.3)"}),a.jsx("path",{d:v.right,fill:"rgba(59, 130, 246, 0.2)"}),a.jsx("path",{d:v.left,fill:"rgba(59, 130, 246, 0.15)"})]}),v.cornerBackLeft?.map((M,$)=>a.jsx("path",{d:M.path,fill:dt(z,M.intensity)},`cbl-${$}`)),v.cornerBackRight?.map((M,$)=>a.jsx("path",{d:M.path,fill:dt(z,M.intensity)},`cbr-${$}`)),a.jsx("path",{d:v.left,fill:_.left,stroke:N?"#3b82f6":"rgba(0,0,0,0.3)",strokeWidth:N?2:.5}),a.jsx("path",{d:v.right,fill:_.right,stroke:N?"#3b82f6":"rgba(0,0,0,0.3)",strokeWidth:N?2:.5}),v.cornerFrontLeft?.map((M,$)=>a.jsx("path",{d:M.path,fill:dt(z,M.intensity)},`cfl-${$}`)),v.cornerFrontRight?.map((M,$)=>a.jsx("path",{d:M.path,fill:dt(z,M.intensity)},`cfr-${$}`)),a.jsx("path",{d:v.top,fill:_.top,stroke:N?"#3b82f6":"rgba(255,255,255,0.1)",strokeWidth:N?2:.5}),a.jsx("text",{x:S,y:w-5,textAnchor:"middle",className:"fill-white text-xs font-semibold pointer-events-none",style:{textShadow:"0 1px 2px rgba(0,0,0,0.8)",fontSize:"11px"},children:f.name})]},c)}),a.jsx("defs",{children:a.jsxs("filter",{id:"selection-glow",x:"-50%",y:"-50%",width:"200%",height:"200%",children:[a.jsx("feGaussianBlur",{stdDeviation:"4",result:"blur"}),a.jsxs("feMerge",{children:[a.jsx("feMergeNode",{in:"blur"}),a.jsx("feMergeNode",{in:"SourceGraphic"})]})]})})]})}const Gs=25,Vs=50,Wt={emerald:"#34d399",amber:"#fbbf24",zinc:"#71717a",sky:"#38bdf8",violet:"#a78bfa",blue:"#60a5fa"};function Jn(e,t,n,o){const r=q[e.size]||q.m,s=(e.width||r.width)*.8,l=e.isoDepth??Vs,c=e.isoHeight??Gs,d=e.z??0;let f,u,h;switch(t){case"left":f=e.x,u=e.y+l/2,h=d+c/2;break;case"right":f=e.x+s/2,u=e.y,h=d+c/2;break;case"top":f=e.x+s/2,u=e.y+l/2,h=d+c;break;case"bottom":f=e.x+s/2,u=e.y+l/2,h=d;break;case"topLeft":f=e.x,u=e.y+l,h=d+c;break;case"topRight":f=e.x+s,u=e.y,h=d+c;break;case"bottomLeft":f=e.x,u=e.y+l,h=d;break;case"bottomRight":f=e.x+s,u=e.y,h=d;break;default:f=e.x+s/2,u=e.y+l/2,h=d+c}const p=T(f,u,h);return{x:n+p.screenX,y:o+p.screenY}}function Ks(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.sqrt(n*n+o*o),i=(e.x+t.x)/2,s=(e.y+t.y)/2,l=-o/r*r*.2,c=n/r*r*.2;return`M ${e.x} ${e.y} Q ${i+l} ${s+c}, ${t.x} ${t.y}`}function qs({nodes:e,nodeData:t,connectors:n,connectorStyles:o,selectedConnectorIndex:r,onConnectorClick:i,originX:s=400,originY:l=500}){return a.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",style:{overflow:"visible"},children:[a.jsx("defs",{children:Object.entries(Wt).map(([c,d])=>a.jsx("marker",{id:`iso-arrow-${c}`,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto",markerUnits:"userSpaceOnUse",children:a.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:d})},c))}),a.jsx("g",{className:"pointer-events-auto",children:n.map((c,d)=>{const f=o[c.style];if(!f)return null;const u=e[c.from],h=e[c.to];if(!u||!h||!t[c.from]||!t[c.to])return null;const p=Jn(u,c.fromAnchor,s,l),g=Jn(h,c.toAnchor,s,l),x=Ks(p,g),k=Wt[f.color]||Wt.zinc,y=r===d,m=f.showArrow!==!1,C=f.dashed?"8 4":void 0;return a.jsxs("g",{className:"cursor-pointer",onClick:v=>{v.stopPropagation(),i?.(d)},children:[a.jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:20}),y&&a.jsx("path",{d:x,fill:"none",stroke:"#3b82f6",strokeWidth:f.strokeWidth+6,strokeOpacity:.3,strokeDasharray:C}),a.jsx("path",{d:x,fill:"none",stroke:k,strokeWidth:f.strokeWidth,strokeDasharray:C,markerEnd:m?`url(#iso-arrow-${f.color})`:void 0,strokeLinecap:"round",strokeLinejoin:"round",style:{filter:"drop-shadow(0 2px 4px rgba(0,0,0,0.3))"}}),a.jsx("circle",{cx:p.x,cy:p.y,r:4,fill:k}),a.jsx("circle",{cx:g.x,cy:g.y,r:4,fill:k}),f.label&&a.jsx("text",{x:(p.x+g.x)/2,y:(p.y+g.y)/2-10,textAnchor:"middle",fill:k,fontSize:"10",fontFamily:"ui-monospace, monospace",fontWeight:"500",style:{textShadow:"0 1px 2px rgba(0,0,0,0.8)"},children:f.label})]},d)})})]})}const Zs={defaultViewMode:"2d",enableViewModeToggle:!1,enableZoom:!0,enablePan:!0,enableDrag:!0,enableSelection:!0,showZoomControls:!0,showMiniMap:!0,showGrid:!0};function Qn({onViewportChange:e,embedConfig:t}){const{actions:n}=le(),o=ke(),r=je(),i=Bn(),s=Ft(),l=Tn(i),[c,d]=b.useState(null),f={...Zs,...t},{containerRef:u,zoom:h,pan:p,isPanning:g,zoomIn:x,zoomOut:k,resetTransform:y,fitToView:m,setPan:C,screenToCanvas:v,transformStyle:z}=ks({initialZoom:1,initialPan:{x:0,y:0},panModeActive:r.mode==="pan"}),_=b.useRef(null),N=b.useRef(s);b.useEffect(()=>{if(N.current!==s)if(N.current=s,s==="isometric"&&u.current){const D=o.layout.width/2,F=o.layout.height-100,Y=Object.keys(o.nodes);if(Y.length>0){let j=1/0,V=1/0,ee=-1/0,ae=-1/0;const ue=.866,J=.5;for(const mu of Y){const De=o.nodes[mu];if(!De)continue;const xu=De.z||0,bu=De.isoHeight||25,Yo=D+(De.x-De.y)*ue,Ho=F-(De.x+De.y)*J-xu-bu;j=Math.min(j,Yo-50),ee=Math.max(ee,Yo+50),V=Math.min(V,Ho-20),ae=Math.max(ae,Ho+50)}const re=(j+ee)/2,pe=(V+ae)/2,me=u.current.getBoundingClientRect(),be=me.width/2-re,Ee=me.height/2-pe;C({x:be,y:Ee})}}else s==="2d"&&y()},[s,o.nodes,o.layout,u,C,y]);const E=b.useCallback((D,F)=>{if(r.mode!=="select"||g||!f.enableSelection&&!f.enableDrag)return;D.target instanceof Element&&D.target.setPointerCapture?.(D.pointerId);const Y=v({x:D.clientX,y:D.clientY}),j=D.shiftKey;let V=Y;if(s==="isometric"){const J=o.layout.width/2,re=o.layout.height-100;V=Yt(Y.x-J,Y.y-re)}let ee;j?r.selectedNodeIds.includes(F)?ee=r.selectedNodeIds.filter(J=>J!==F):ee=[...r.selectedNodeIds,F]:ee=r.selectedNodeIds.includes(F)?r.selectedNodeIds:[F];const ae={};for(const J of ee){const re=o.nodes[J];re&&(ae[J]={x:V.x-re.x,y:V.y-re.y})}const ue=o.nodes[F];if(!f.enableDrag){n.selectNodes(ee);return}n.startDrag(F,{x:V.x-ue.x,y:V.y-ue.y},ae,ee)},[r.mode,r.selectedNodeIds,g,o.nodes,o.layout,n,v,s,f.enableDrag,f.enableSelection]),S=b.useCallback(D=>{if(!r.isDragging||r.selectedNodeIds.length===0||g)return;const F=v({x:D.clientX,y:D.clientY});let Y=F;if(s==="isometric"){const ue=o.layout.width/2,J=o.layout.height-100;Y=Yt(F.x-ue,F.y-J)}const j=r.selectedNodeIds.map(ue=>{const J=r.dragNodeOffsets?.[ue]||r.dragOffset,re=Math.round(Y.x-J.x),pe=Math.round(Y.y-J.y);return{nodeId:ue,x:re,y:pe}});n.moveNodes(j);const V=200;let ee=o.layout.width,ae=o.layout.height;for(const ue of j){const J=o.nodes[ue.nodeId],re=q[J?.size]||q.m,pe=J?.width||re.width,me=J?.height||re.height,be=ue.x+pe+V,Ee=ue.y+me+V;be>ee&&(ee=be),Ee>ae&&(ae=Ee)}s==="2d"&&(ee>o.layout.width||ae>o.layout.height)&&n.expandLayout(ee,ae)},[r.isDragging,r.selectedNodeIds,r.dragOffset,r.dragNodeOffsets,g,o.nodes,o.layout,n,v,s]),w=b.useCallback(()=>{r.isDragging&&n.endDrag()},[r.isDragging,n]),M=b.useCallback((D,F)=>{g||r.mode==="addConnector"&&d(D)},[r.mode,g]),$=b.useCallback((D,F)=>{r.mode==="addConnector"&&(r.pendingConnector?r.pendingConnector.from!==D&&(n.addConnector(r.pendingConnector.from,D,r.pendingConnector.fromAnchor,F,"http"),d(null)):n.setPendingConnector({from:D,fromAnchor:F}))},[r.mode,r.pendingConnector,n]),A=b.useCallback(D=>{if(g)return;const F=D.target;if(!(!F.classList.contains("canvas-bg")&&F!==_.current))if(r.mode==="addNode"){const Y=v({x:D.clientX,y:D.clientY}),j=Math.round(Y.x-q.m.width/2),V=Math.round(Y.y-q.m.height/2);n.addNode({x:Math.max(0,j),y:Math.max(0,V)})}else r.mode==="addConnector"&&(n.clearPendingConnector(),d(null))},[r.mode,g,n,v]),B=b.useCallback(D=>{r.mode==="select"&&!g&&n.selectConnector(D)},[r.mode,g,n]),W=b.useCallback(D=>{r.mode==="select"&&!g&&n.selectGroup(D)},[r.mode,g,n]),G=b.useCallback(D=>{r.mode==="select"&&!g&&n.selectImage(D)},[r.mode,g,n]),P=b.useCallback(D=>{D.preventDefault(),D.stopPropagation();const Y=Array.from(D.dataTransfer.files).filter(V=>V.type.startsWith("image/")||V.name.endsWith(".svg"));if(Y.length===0)return;const j=v({x:D.clientX,y:D.clientY});Y.forEach((V,ee)=>{const ae=new FileReader;ae.onload=ue=>{const J=ue.target?.result,re=new Image;re.onload=()=>{let pe=re.width,me=re.height;const be=300;if(pe>be||me>be){const Ee=Math.min(be/pe,be/me);pe=Math.round(pe*Ee),me=Math.round(me*Ee)}n.addImage({src:J,name:V.name,x:Math.round(j.x+ee*20),y:Math.round(j.y+ee*20),width:pe,height:me,opacity:1})},re.src=J},ae.readAsDataURL(V)})},[v,n]),ne=b.useCallback(D=>{D.preventDefault(),D.stopPropagation()},[]),[Q,ye]=b.useState({width:800,height:600}),R=b.useCallback(()=>{if(u.current){const D=u.current.getBoundingClientRect();ye({width:D.width,height:D.height})}},[u]);b.useEffect(()=>(R(),window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)),[R]);const U={x:-p.x/h,y:-p.y/h,width:Q.width/h,height:Q.height/h};b.useEffect(()=>{e?.(U)},[U.x,U.y,U.width,U.height,e]),b.useEffect(()=>{if(s!=="2d")return;const D=U.x+U.width,F=U.y+U.height,Y=100;if(D>o.layout.width-Y||F>o.layout.height-Y){const j=Math.max(o.layout.width,D+Y),V=Math.max(o.layout.height,F+Y);(j>o.layout.width||V>o.layout.height)&&n.expandLayout(j,V)}},[s,U.x,U.y,U.width,U.height,o.layout.width,o.layout.height,n]);const Z=b.useCallback(D=>{const F=-(D.x*h)+Q.width/2,Y=-(D.y*h)+Q.height/2;C({x:F,y:Y})},[h,Q,C]),se=b.useCallback(D=>{n.setExportZone(D)},[n]),[H,Ae]=b.useState(null),[X,xe]=b.useState(null),Xe=b.useCallback(D=>{const F=D.target,Y=F.classList.contains("canvas-bg")||F===_.current;if(r.mode==="addRect"||r.mode==="addCircle"){const j=v({x:D.clientX,y:D.clientY});Ae({type:r.mode==="addRect"?"rect":"circle",startX:j.x,startY:j.y,currentX:j.x,currentY:j.y})}else if(r.mode==="select"&&Y&&!g){const j=v({x:D.clientX,y:D.clientY});xe({startX:j.x,startY:j.y,currentX:j.x,currentY:j.y})}},[r.mode,v,g]),bn=b.useCallback(D=>{if(H){const F=v({x:D.clientX,y:D.clientY});Ae(Y=>Y?{...Y,currentX:F.x,currentY:F.y}:null)}if(X){const F=v({x:D.clientX,y:D.clientY});xe(Y=>Y?{...Y,currentX:F.x,currentY:F.y}:null)}},[H,X,v]),gu=b.useCallback(()=>{if(H){const D=Math.min(H.startX,H.currentX),F=Math.min(H.startY,H.currentY),Y=Math.abs(H.currentX-H.startX),j=Math.abs(H.currentY-H.startY);Y>20&&j>20&&n.addGroup({x:Math.round(D),y:Math.round(F),width:Math.round(Y),height:Math.round(j),type:H.type==="circle"?"circle":"rect",color:"zinc",label:"",dashed:!0}),Ae(null),n.setMode("select")}if(X){const D=Math.min(X.startX,X.currentX),F=Math.min(X.startY,X.currentY),Y=Math.abs(X.currentX-X.startX),j=Math.abs(X.currentY-X.startY);if(Y>5||j>5){const V=[];for(const[ee,ae]of Object.entries(o.nodes)){if(!o.nodeData[ee])continue;const J=q[ae.size]||q.m,re=J.width,pe=J.height,me=ae.x,be=ae.y;me<D+Y&&me+re>D&&be<F+j&&be+pe>F&&V.push(ee)}V.length>0?n.selectNodes(V):n.clearSelection()}else n.clearSelection();xe(null)}},[H,X,o.nodes,o.nodeData,n]),Po=r.mode==="addConnector"?c||r.pendingConnector?.from:null,yu=()=>g?"cursor-grabbing":r.mode==="pan"?"cursor-grab":r.mode==="addNode"?"cursor-crosshair":r.mode==="addConnector"?"cursor-pointer":r.mode==="addRect"||r.mode==="addCircle"?"cursor-crosshair":"cursor-default",Fo=(()=>{switch(r.mode){case"addNode":return"Click to place node";case"addConnector":return"Click nodes to connect";case"pan":return"Drag to pan canvas";case"addRect":return"Draw rectangle group";case"addCircle":return"Draw circle group";default:return null}})();return a.jsxs("div",{className:"relative w-full h-full",children:[a.jsxs("div",{ref:u,className:`
|
|
55
|
+
`,style:{pointerEvents:"none"}}),a.jsx("circle",{cx:l.x,cy:l.y,r:2,className:"fill-white",style:{pointerEvents:"none"}})]},s)})})})}const qn={violet:{fill:"rgba(139, 92, 246, 0.1)",stroke:"rgba(139, 92, 246, 0.5)"},emerald:{fill:"rgba(52, 211, 153, 0.1)",stroke:"rgba(52, 211, 153, 0.5)"},blue:{fill:"rgba(96, 165, 250, 0.1)",stroke:"rgba(96, 165, 250, 0.5)"},amber:{fill:"rgba(251, 191, 36, 0.1)",stroke:"rgba(251, 191, 36, 0.5)"},zinc:{fill:"rgba(113, 113, 122, 0.1)",stroke:"rgba(113, 113, 122, 0.5)"},sky:{fill:"rgba(56, 189, 248, 0.1)",stroke:"rgba(56, 189, 248, 0.5)"}};function Ys({group:e,isSelected:t,onClick:n,onDragStart:o,onResize:r}){const i=qn[e.color]||qn.zinc,{x:s,y:l,width:c,height:d,type:p,label:u}=e,h=g=>{g.stopPropagation(),n(e.id),o(e.id,g)},f=(g,x)=>{g.stopPropagation(),r(e.id,x,g)};return a.jsxs("g",{className:"cursor-move",children:[p==="circle"?a.jsx("ellipse",{cx:s+c/2,cy:l+d/2,rx:c/2,ry:d/2,fill:i.fill,stroke:t?"#3b82f6":i.stroke,strokeWidth:t?2:1.5,strokeDasharray:e.dashed?"8 4":void 0,onMouseDown:h}):a.jsx("rect",{x:s,y:l,width:c,height:d,rx:12,ry:12,fill:i.fill,stroke:t?"#3b82f6":i.stroke,strokeWidth:t?2:1.5,strokeDasharray:e.dashed?"8 4":void 0,onMouseDown:h}),u&&a.jsx("text",{x:s+12,y:l+20,fill:i.stroke,fontSize:"12",fontWeight:"500",fontFamily:"ui-sans-serif, system-ui, sans-serif",style:{pointerEvents:"none"},children:u}),t&&a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:s,cy:l,r:5,fill:"#3b82f6",className:"cursor-nwse-resize",onMouseDown:g=>f(g,"nw")}),a.jsx("circle",{cx:s+c,cy:l,r:5,fill:"#3b82f6",className:"cursor-nesw-resize",onMouseDown:g=>f(g,"ne")}),a.jsx("circle",{cx:s,cy:l+d,r:5,fill:"#3b82f6",className:"cursor-nesw-resize",onMouseDown:g=>f(g,"sw")}),a.jsx("circle",{cx:s+c,cy:l+d,r:5,fill:"#3b82f6",className:"cursor-nwse-resize",onMouseDown:g=>f(g,"se")})]})]})}function Hs({layout:e,groups:t,selectedGroupId:n,onGroupClick:o,onGroupUpdate:r,screenToCanvas:i}){const[s,l]=b.useState(null),c=b.useCallback((h,f)=>{const g=t.find(k=>k.id===h);if(!g)return;const x=i({x:f.clientX,y:f.clientY});l({groupId:h,type:"move",startX:x.x,startY:x.y,originalX:g.x,originalY:g.y})},[t,i]),d=b.useCallback((h,f,g)=>{const x=t.find(m=>m.id===h);if(!x)return;const k=i({x:g.clientX,y:g.clientY});l({groupId:h,type:"resize",corner:f,startX:k.x,startY:k.y,originalX:x.x,originalY:x.y,originalWidth:x.width,originalHeight:x.height})},[t,i]),p=b.useCallback(h=>{if(!s)return;const f=i({x:h.clientX,y:h.clientY}),g=f.x-s.startX,x=f.y-s.startY;if(s.type==="move")r(s.groupId,{x:Math.round(s.originalX+g),y:Math.round(s.originalY+x)});else if(s.type==="resize"){let k=s.originalX,m=s.originalY,y=s.originalWidth,v=s.originalHeight;s.corner.includes("w")&&(k=s.originalX+g,y=s.originalWidth-g),s.corner.includes("e")&&(y=s.originalWidth+g),s.corner.includes("n")&&(m=s.originalY+x,v=s.originalHeight-x),s.corner.includes("s")&&(v=s.originalHeight+x),y>=40&&v>=40&&r(s.groupId,{x:Math.round(k),y:Math.round(m),width:Math.round(y),height:Math.round(v)})}},[s,i,r]),u=b.useCallback(()=>{l(null)},[]);return!t||t.length===0?null:a.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",onMouseMove:s?p:void 0,onMouseUp:s?u:void 0,onMouseLeave:s?u:void 0,style:{pointerEvents:s?"auto":"none"},children:a.jsx("g",{className:"pointer-events-auto",children:t.map(h=>a.jsx(Ys,{group:h,isSelected:n===h.id,onClick:o,onDragStart:c,onResize:d},h.id))})})}function Bs({image:e,isSelected:t,onClick:n,onDragStart:o,onResize:r}){const{x:i,y:s,width:l,height:c,src:d,opacity:p=1}=e,u=f=>{f.stopPropagation(),n(e.id),o(e.id,f)},h=(f,g)=>{f.stopPropagation(),r(e.id,g,f)};return a.jsxs("g",{className:"cursor-move",children:[a.jsx("image",{href:d,x:i,y:s,width:l,height:c,preserveAspectRatio:"xMidYMid meet",onMouseDown:u,style:{cursor:"move",opacity:p}}),t&&a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:i,y:s,width:l,height:c,fill:"none",stroke:"#3b82f6",strokeWidth:2,strokeDasharray:"4 2",style:{pointerEvents:"none"}}),a.jsx("circle",{cx:i,cy:s,r:5,fill:"#3b82f6",className:"cursor-nwse-resize",onMouseDown:f=>h(f,"nw")}),a.jsx("circle",{cx:i+l,cy:s,r:5,fill:"#3b82f6",className:"cursor-nesw-resize",onMouseDown:f=>h(f,"ne")}),a.jsx("circle",{cx:i,cy:s+c,r:5,fill:"#3b82f6",className:"cursor-nesw-resize",onMouseDown:f=>h(f,"sw")}),a.jsx("circle",{cx:i+l,cy:s+c,r:5,fill:"#3b82f6",className:"cursor-nwse-resize",onMouseDown:f=>h(f,"se")})]})]})}function Ws({layout:e,images:t,selectedImageId:n,onImageClick:o,onImageUpdate:r,screenToCanvas:i}){const[s,l]=b.useState(null),c=b.useCallback((h,f)=>{const g=t.find(k=>k.id===h);if(!g)return;const x=i({x:f.clientX,y:f.clientY});l({imageId:h,type:"move",startX:x.x,startY:x.y,originalX:g.x,originalY:g.y})},[t,i]),d=b.useCallback((h,f,g)=>{const x=t.find(m=>m.id===h);if(!x)return;const k=i({x:g.clientX,y:g.clientY});l({imageId:h,type:"resize",corner:f,startX:k.x,startY:k.y,originalX:x.x,originalY:x.y,originalWidth:x.width,originalHeight:x.height,aspectRatio:x.width/x.height})},[t,i]),p=b.useCallback(h=>{if(!s)return;const f=i({x:h.clientX,y:h.clientY}),g=f.x-s.startX,x=f.y-s.startY;if(s.type==="move")r(s.imageId,{x:Math.round(s.originalX+g),y:Math.round(s.originalY+x)});else if(s.type==="resize"){let k=s.originalX,m=s.originalY,y=s.originalWidth,v=s.originalHeight;const w=!h.shiftKey;if(s.corner.includes("e")&&(y=s.originalWidth+g),s.corner.includes("w")&&(k=s.originalX+g,y=s.originalWidth-g),s.corner.includes("s")&&(v=s.originalHeight+x),s.corner.includes("n")&&(m=s.originalY+x,v=s.originalHeight-x),w&&s.aspectRatio){if(s.corner==="se"||s.corner==="nw"){const N=Math.abs(y-s.originalWidth),_=Math.abs(v-s.originalHeight);N>_?v=y/s.aspectRatio:y=v*s.aspectRatio}else if(s.corner==="sw"||s.corner==="ne"){const N=Math.abs(y-s.originalWidth),_=Math.abs(v-s.originalHeight);N>_?v=y/s.aspectRatio:y=v*s.aspectRatio}}y>=20&&v>=20&&r(s.imageId,{x:Math.round(k),y:Math.round(m),width:Math.round(y),height:Math.round(v)})}},[s,i,r]),u=b.useCallback(()=>{l(null)},[]);return!t||t.length===0?null:a.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",onMouseMove:s?p:void 0,onMouseUp:s?u:void 0,onMouseLeave:s?u:void 0,style:{pointerEvents:s?"auto":"none"},children:a.jsx("g",{className:"pointer-events-auto",children:t.map(h=>a.jsx(Bs,{image:h,isSelected:n===h.id,onClick:o,onDragStart:c,onResize:d},h.id))})})}const ht={violet:"#8b5cf6",emerald:"#34d399",blue:"#60a5fa",amber:"#fbbf24",zinc:"#71717a",sky:"#38bdf8"};function Xs({diagram:e,viewportBounds:t,onViewportChange:n,width:o=160,height:r=100}){const i=b.useRef(null),s=e.layout,l=o/s.width,c=r/s.height,d=Math.min(l,c),p=s.width*d,u=s.height*d,h=(t?.x||0)*d,f=(t?.y||0)*d,g=(t?.width||s.width)*d,x=(t?.height||s.height)*d,k=b.useCallback(m=>{if(!i.current||!n)return;const y=i.current.getBoundingClientRect(),v=m.clientX-y.left,w=m.clientY-y.top,N=v/d,_=w/d;n({x:N-(t?.width||s.width)/2,y:_-(t?.height||s.height)/2})},[d,n,t,s]);return a.jsx("div",{ref:i,className:"absolute bottom-4 left-4 bg-white dark:bg-zinc-900 rounded-lg shadow-lg border border-zinc-200 dark:border-zinc-700 overflow-hidden cursor-pointer",style:{width:p+8,height:u+8,padding:4},onClick:k,children:a.jsxs("svg",{width:p,height:u,viewBox:`0 0 ${s.width} ${s.height}`,className:"bg-zinc-50 dark:bg-zinc-800 rounded",children:[(e.groups||[]).map(m=>a.jsx("rect",{x:m.x,y:m.y,width:m.width,height:m.height,fill:ht[m.color]||ht.zinc,opacity:.2,rx:4},m.id)),(e.images||[]).map(m=>a.jsx("rect",{x:m.x,y:m.y,width:m.width,height:m.height,fill:"#9ca3af",opacity:.3},m.id)),e.connectors.map((m,y)=>{const v=e.nodes[m.from],w=e.nodes[m.to];if(!v||!w)return null;const N=v.x+50,_=v.y+25,C=w.x+50,M=w.y+25;return a.jsx("line",{x1:N,y1:_,x2:C,y2:M,stroke:"#9ca3af",strokeWidth:2/d,opacity:.5},y)}),Object.entries(e.nodes).map(([m,y])=>{const v=e.nodeData[m];if(!v)return null;const w=ht[v.color]||ht.zinc,N=y.size||"m",_=N==="l"?210:N==="s"?95:N==="xs"?80:145,C=N==="l"?85:N==="s"?42:N==="xs"?36:68;return a.jsx("rect",{x:y.x,y:y.y,width:y.width||_,height:y.height||C,fill:w,rx:4},m)}),a.jsx("rect",{x:h/d,y:f/d,width:g/d,height:x/d,fill:"none",stroke:"#3b82f6",strokeWidth:2/d,strokeDasharray:`${4/d} ${2/d}`})]})})}function Us({layout:e,exportZone:t,isEditing:n,onZoneUpdate:o,onZoneClear:r,screenToCanvas:i}){const[s,l]=b.useState(null),c=b.useRef(null),d=b.useCallback((m,y)=>{if(!t||!n)return;y.stopPropagation(),y.target.setPointerCapture(y.pointerId);const v=i({x:y.clientX,y:y.clientY});l({type:"resize",corner:m,startX:v.x,startY:v.y,originalX:t.x,originalY:t.y,originalWidth:t.width,originalHeight:t.height})},[t,n,i]),p=b.useCallback(m=>{if(!t||!n)return;m.stopPropagation(),m.target.setPointerCapture(m.pointerId);const y=i({x:m.clientX,y:m.clientY});l({type:"move",startX:y.x,startY:y.y,originalX:t.x,originalY:t.y})},[t,n,i]),u=b.useCallback(m=>{if(!s||!t)return;const y=i({x:m.clientX,y:m.clientY}),v=y.x-s.startX,w=y.y-s.startY;if(s.type==="move")o({...t,x:Math.max(0,Math.round(s.originalX+v)),y:Math.max(0,Math.round(s.originalY+w))});else if(s.type==="resize"){let N=s.originalX,_=s.originalY,C=s.originalWidth,M=s.originalHeight;s.corner.includes("w")&&(N=s.originalX+v,C=s.originalWidth-v),s.corner.includes("e")&&(C=s.originalWidth+v),s.corner.includes("n")&&(_=s.originalY+w,M=s.originalHeight-w),s.corner.includes("s")&&(M=s.originalHeight+w),C>=50&&M>=50&&o({x:Math.max(0,Math.round(N)),y:Math.max(0,Math.round(_)),width:Math.round(C),height:Math.round(M)})}},[s,t,i,o]),h=b.useCallback(m=>{m.target.releasePointerCapture&&m.target.releasePointerCapture(m.pointerId),l(null)},[]);if(!t)return null;const{x:f,y:g,width:x,height:k}=t;return a.jsxs("svg",{ref:c,className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",style:{pointerEvents:"none"},children:[a.jsx("defs",{children:a.jsxs("mask",{id:"exportZoneMask",children:[a.jsx("rect",{x:0,y:0,width:e.width,height:e.height,fill:"white"}),a.jsx("rect",{x:f,y:g,width:x,height:k,fill:"black"})]})}),a.jsx("rect",{x:0,y:0,width:e.width,height:e.height,fill:"rgba(0,0,0,0.3)",mask:"url(#exportZoneMask)",style:{pointerEvents:"none"}}),n&&a.jsx("rect",{x:f,y:g,width:x,height:k,fill:"transparent",style:{pointerEvents:"auto",cursor:"move"},onPointerDown:p,onPointerMove:u,onPointerUp:h}),a.jsx("rect",{x:f,y:g,width:x,height:k,fill:"none",stroke:"#10b981",strokeWidth:2,strokeDasharray:"8 4",style:{pointerEvents:"none"}}),a.jsxs("text",{x:f+8,y:g-8,fill:"#10b981",fontSize:"12",fontWeight:"600",fontFamily:"ui-sans-serif, system-ui, sans-serif",style:{pointerEvents:"none"},children:["Export Zone (",x," x ",k,")"]}),n&&a.jsx("g",{children:[{cx:f,cy:g,cursor:"nwse-resize",corner:"nw"},{cx:f+x,cy:g,cursor:"nesw-resize",corner:"ne"},{cx:f,cy:g+k,cursor:"nesw-resize",corner:"sw"},{cx:f+x,cy:g+k,cursor:"nwse-resize",corner:"se"},{cx:f+x/2,cy:g,cursor:"ns-resize",corner:"n",r:5},{cx:f+x/2,cy:g+k,cursor:"ns-resize",corner:"s",r:5},{cx:f,cy:g+k/2,cursor:"ew-resize",corner:"w",r:5},{cx:f+x,cy:g+k/2,cursor:"ew-resize",corner:"e",r:5}].map(({cx:m,cy:y,cursor:v,corner:w,r:N=6})=>a.jsx("circle",{cx:m,cy:y,r:N,fill:"#10b981",style:{pointerEvents:"auto",cursor:v},onPointerDown:_=>d(w,_),onPointerMove:u,onPointerUp:h},w))})]})}function js({grid:e,viewportBounds:t,containerSize:n,zoom:o}){if(!e?.enabled)return null;const{size:r=24,color:i="#71717a",opacity:s=.1,type:l="dots"}=e,c=r*o,d=t.x%r*o,p=t.y%r*o,u=b.useMemo(()=>{const h={position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",opacity:s,backgroundPosition:`${-d}px ${-p}px`,backgroundSize:`${c}px ${c}px`};return l==="dots"?{...h,backgroundImage:`radial-gradient(circle, ${i} 1px, transparent 1px)`}:{...h,backgroundImage:`linear-gradient(${i} 1px, transparent 1px), linear-gradient(90deg, ${i} 1px, transparent 1px)`}},[l,i,c,d,p,s]);return a.jsx("div",{className:"infinite-grid",style:u})}function Gs({zoom:e,minZoom:t,maxZoom:n,onZoomIn:o,onZoomOut:r,onZoomChange:i,onReset:s,onFitToView:l}){const c=Math.round(e*100),[d,p]=b.useState(!1),[u,h]=b.useState(""),f=b.useRef(null),g=b.useRef(null);b.useEffect(()=>{d&&f.current&&(f.current.focus(),f.current.select())},[d]);const x=b.useCallback(()=>{const v=parseInt(u,10);if(!isNaN(v)){const N=Math.min(Math.max(v,t*100),n*100)/100;i(N)}p(!1)},[u,t,n,i]),k=b.useCallback(()=>{p(!1),h("")},[]),m=b.useCallback(v=>{v.key==="Enter"?(v.preventDefault(),x()):v.key==="Escape"&&(v.preventDefault(),k())},[x,k]),y=b.useCallback(()=>{if(g.current!==null){clearTimeout(g.current),g.current=null,s();return}g.current=window.setTimeout(()=>{g.current=null,h(String(c)),p(!0)},200)},[c,s]);return b.useEffect(()=>()=>{g.current!==null&&clearTimeout(g.current)},[]),a.jsxs("div",{className:"absolute bottom-3 right-3 flex items-center gap-1 bg-white dark:bg-zinc-800 rounded-lg shadow-lg border border-zinc-200 dark:border-zinc-700 p-1",children:[a.jsx("button",{onClick:r,disabled:e<=t,className:"p-1.5 rounded hover:bg-zinc-100 dark:hover:bg-zinc-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",title:"Zoom out (scroll down)",children:a.jsx(hs,{className:"w-4 h-4 text-zinc-600 dark:text-zinc-400"})}),d?a.jsxs("div",{className:"relative",children:[a.jsx("input",{ref:f,type:"text",value:u,onChange:v=>h(v.target.value),onKeyDown:m,onBlur:x,className:"w-[48px] px-1 py-0.5 text-xs font-medium text-zinc-600 dark:text-zinc-400 bg-zinc-100 dark:bg-zinc-700 rounded border border-zinc-300 dark:border-zinc-600 text-center outline-none focus:border-blue-500","aria-label":"Zoom percentage"}),a.jsx("span",{className:"absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-zinc-400 pointer-events-none",children:"%"})]}):a.jsxs("button",{onClick:y,className:"px-2 py-1 text-xs font-medium text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-700 rounded min-w-[48px] transition-colors",title:"Click to edit, double-click to reset",children:[c,"%"]}),a.jsx("button",{onClick:o,disabled:e>=n,className:"p-1.5 rounded hover:bg-zinc-100 dark:hover:bg-zinc-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",title:"Zoom in (scroll up)",children:a.jsx(us,{className:"w-4 h-4 text-zinc-600 dark:text-zinc-400"})}),a.jsx("div",{className:"w-px h-4 bg-zinc-200 dark:bg-zinc-700 mx-0.5"}),a.jsx("button",{onClick:l,className:"p-1.5 rounded hover:bg-zinc-100 dark:hover:bg-zinc-700 transition-colors",title:"Fit to view",children:a.jsx(Ei,{className:"w-4 h-4 text-zinc-600 dark:text-zinc-400"})})]})}function Vs({viewMode:e,onViewModeChange:t}){return a.jsxs("div",{className:"absolute bottom-3 right-44 flex items-center gap-1 bg-white dark:bg-zinc-800 rounded-lg shadow-lg border border-zinc-200 dark:border-zinc-700 p-1",children:[a.jsx("button",{onClick:()=>t("2d"),className:`p-1.5 rounded transition-colors ${e==="2d"?"bg-violet-100 dark:bg-violet-900/50 text-violet-600 dark:text-violet-400":"hover:bg-zinc-100 dark:hover:bg-zinc-700 text-zinc-600 dark:text-zinc-400"}`,title:"2D View",children:a.jsx($n,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>t("isometric"),className:`p-1.5 rounded transition-colors ${e==="isometric"?"bg-violet-100 dark:bg-violet-900/50 text-violet-600 dark:text-violet-400":"hover:bg-zinc-100 dark:hover:bg-zinc-700 text-zinc-600 dark:text-zinc-400"}`,title:"Isometric View",children:a.jsx(Tt,{className:"w-4 h-4"})})]})}const Ks=25,Zs=50,qs=6;function ft(e,t){const n=20+t*50;return`hsl(${e.hue}, ${e.saturation}%, ${n}%)`}function Js({nodes:e,nodeData:t,selectedNodeIds:n,onNodeClick:o,onNodePointerDown:r,originX:i=400,originY:s=500}){const l=b.useMemo(()=>Object.entries(e).filter(([c])=>t[c]).sort(([,c],[,d])=>{const p=c.x+c.y+(c.z||0),u=d.x+d.y+(d.z||0);return p-u}),[e,t]);return a.jsxs("svg",{className:"absolute inset-0 w-full h-full",style:{overflow:"visible"},children:[l.map(([c,d])=>{const p=t[c];if(!p)return null;const u=J[d.size]||J.m,f=(d.width||u.width)*.8,g=d.isoDepth??Zs,x=d.isoHeight??Ks,k=d.z??0,m=F(d.x,d.y,k),y=i+m.screenX,v=s+m.screenY,w=Te(f,g,x,y,v,qs),N=Ze[p.color]||Ze.violet,_=Kn(p.color),C=n.includes(c),M=F(d.x+f/2,d.y+g/2,k+x),$=i+M.screenX,S=s+M.screenY;return a.jsxs("g",{className:"cursor-pointer",onClick:()=>o?.(c),onPointerDown:E=>r?.(E,c),children:[C&&a.jsxs("g",{filter:"url(#selection-glow)",children:[a.jsx("path",{d:w.top,fill:"rgba(59, 130, 246, 0.3)"}),a.jsx("path",{d:w.right,fill:"rgba(59, 130, 246, 0.2)"}),a.jsx("path",{d:w.left,fill:"rgba(59, 130, 246, 0.15)"})]}),w.cornerBackLeft?.map((E,T)=>a.jsx("path",{d:E.path,fill:ft(N,E.intensity)},`cbl-${T}`)),w.cornerBackRight?.map((E,T)=>a.jsx("path",{d:E.path,fill:ft(N,E.intensity)},`cbr-${T}`)),a.jsx("path",{d:w.left,fill:_.left,stroke:C?"#3b82f6":"rgba(0,0,0,0.3)",strokeWidth:C?2:.5}),a.jsx("path",{d:w.right,fill:_.right,stroke:C?"#3b82f6":"rgba(0,0,0,0.3)",strokeWidth:C?2:.5}),w.cornerFrontLeft?.map((E,T)=>a.jsx("path",{d:E.path,fill:ft(N,E.intensity)},`cfl-${T}`)),w.cornerFrontRight?.map((E,T)=>a.jsx("path",{d:E.path,fill:ft(N,E.intensity)},`cfr-${T}`)),a.jsx("path",{d:w.top,fill:_.top,stroke:C?"#3b82f6":"rgba(255,255,255,0.1)",strokeWidth:C?2:.5}),a.jsx("text",{x:$,y:S-5,textAnchor:"middle",className:"fill-white text-xs font-semibold pointer-events-none",style:{textShadow:"0 1px 2px rgba(0,0,0,0.8)",fontSize:"11px"},children:p.name})]},c)}),a.jsx("defs",{children:a.jsxs("filter",{id:"selection-glow",x:"-50%",y:"-50%",width:"200%",height:"200%",children:[a.jsx("feGaussianBlur",{stdDeviation:"4",result:"blur"}),a.jsxs("feMerge",{children:[a.jsx("feMergeNode",{in:"blur"}),a.jsx("feMergeNode",{in:"SourceGraphic"})]})]})})]})}const Qs=25,Rs=50,Ut={emerald:"#34d399",amber:"#fbbf24",zinc:"#71717a",sky:"#38bdf8",violet:"#a78bfa",blue:"#60a5fa"};function Jn(e,t,n,o){const r=J[e.size]||J.m,s=(e.width||r.width)*.8,l=e.isoDepth??Rs,c=e.isoHeight??Qs,d=e.z??0;let p,u,h;switch(t){case"left":p=e.x,u=e.y+l/2,h=d+c/2;break;case"right":p=e.x+s/2,u=e.y,h=d+c/2;break;case"top":p=e.x+s/2,u=e.y+l/2,h=d+c;break;case"bottom":p=e.x+s/2,u=e.y+l/2,h=d;break;case"topLeft":p=e.x,u=e.y+l,h=d+c;break;case"topRight":p=e.x+s,u=e.y,h=d+c;break;case"bottomLeft":p=e.x,u=e.y+l,h=d;break;case"bottomRight":p=e.x+s,u=e.y,h=d;break;default:p=e.x+s/2,u=e.y+l/2,h=d+c}const f=F(p,u,h);return{x:n+f.screenX,y:o+f.screenY}}function ea(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.sqrt(n*n+o*o),i=(e.x+t.x)/2,s=(e.y+t.y)/2,l=-o/r*r*.2,c=n/r*r*.2;return`M ${e.x} ${e.y} Q ${i+l} ${s+c}, ${t.x} ${t.y}`}function ta({nodes:e,nodeData:t,connectors:n,connectorStyles:o,selectedConnectorIndex:r,onConnectorClick:i,originX:s=400,originY:l=500}){return a.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",style:{overflow:"visible"},children:[a.jsx("defs",{children:Object.entries(Ut).map(([c,d])=>a.jsx("marker",{id:`iso-arrow-${c}`,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto",markerUnits:"userSpaceOnUse",children:a.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:d})},c))}),a.jsx("g",{className:"pointer-events-auto",children:n.map((c,d)=>{const p=o[c.style];if(!p)return null;const u=e[c.from],h=e[c.to];if(!u||!h||!t[c.from]||!t[c.to])return null;const f=Jn(u,c.fromAnchor,s,l),g=Jn(h,c.toAnchor,s,l),x=ea(f,g),k=Ut[p.color]||Ut.zinc,m=r===d,y=p.showArrow!==!1,v=p.dashed?"8 4":void 0;return a.jsxs("g",{className:"cursor-pointer",onClick:w=>{w.stopPropagation(),i?.(d)},children:[a.jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:20}),m&&a.jsx("path",{d:x,fill:"none",stroke:"#3b82f6",strokeWidth:p.strokeWidth+6,strokeOpacity:.3,strokeDasharray:v}),a.jsx("path",{d:x,fill:"none",stroke:k,strokeWidth:p.strokeWidth,strokeDasharray:v,markerEnd:y?`url(#iso-arrow-${p.color})`:void 0,strokeLinecap:"round",strokeLinejoin:"round",style:{filter:"drop-shadow(0 2px 4px rgba(0,0,0,0.3))"}}),a.jsx("circle",{cx:f.x,cy:f.y,r:4,fill:k}),a.jsx("circle",{cx:g.x,cy:g.y,r:4,fill:k}),p.label&&a.jsx("text",{x:(f.x+g.x)/2,y:(f.y+g.y)/2-10,textAnchor:"middle",fill:k,fontSize:"10",fontFamily:"ui-monospace, monospace",fontWeight:"500",style:{textShadow:"0 1px 2px rgba(0,0,0,0.8)"},children:p.label})]},d)})})]})}const na={defaultViewMode:"2d",enableViewModeToggle:!1,enableZoom:!0,enablePan:!0,enableDrag:!0,enableSelection:!0,showZoomControls:!0,showMiniMap:!0,showGrid:!0};function Qn({onViewportChange:e,embedConfig:t,zoomConfig:n}){const{actions:o}=he(),r=Ne(),i=Ve(),s=Wn(),l=Wt(),c=Tn(s),[d,p]=b.useState(null),u={...na,...t},{containerRef:h,zoom:f,pan:g,isPanning:x,minZoom:k,maxZoom:m,setZoom:y,zoomIn:v,zoomOut:w,resetTransform:N,fitToView:_,setPan:C,screenToCanvas:M,transformStyle:$}=Ms({initialZoom:n?.defaultZoom??1,initialPan:{x:0,y:0},panModeActive:i.mode==="pan",contentSize:r.layout,zoomLevels:n?.zoomLevels,zoomStep:n?.zoomStep}),S=b.useRef(null),E=b.useRef(l);b.useEffect(()=>{if(E.current!==l)if(E.current=l,l==="isometric"&&h.current){const A=r.layout.width/2,X=r.layout.height-100,U=Object.keys(r.nodes);if(U.length>0){let j=1/0,Z=1/0,oe=-1/0,ue=-1/0;const ge=.866,ne=.5;for(const Nu of U){const Pe=r.nodes[Nu];if(!Pe)continue;const zu=Pe.z||0,Mu=Pe.isoHeight||25,Yo=A+(Pe.x-Pe.y)*ge,Ho=X-(Pe.x+Pe.y)*ne-zu-Mu;j=Math.min(j,Yo-50),oe=Math.max(oe,Yo+50),Z=Math.min(Z,Ho-20),ue=Math.max(ue,Ho+50)}const ae=(j+oe)/2,be=(Z+ue)/2,we=h.current.getBoundingClientRect(),Ce=we.width/2-ae,Le=we.height/2-be;C({x:Ce,y:Le})}}else l==="2d"&&N()},[l,r.nodes,r.layout,h,C,N]);const T=b.useCallback((A,X)=>{if(i.mode!=="select"||x||!u.enableSelection&&!u.enableDrag)return;A.target instanceof Element&&A.target.setPointerCapture?.(A.pointerId);const U=M({x:A.clientX,y:A.clientY}),j=A.shiftKey;let Z=U;if(l==="isometric"){const ne=r.layout.width/2,ae=r.layout.height-100;Z=Xt(U.x-ne,U.y-ae)}let oe;j?i.selectedNodeIds.includes(X)?oe=i.selectedNodeIds.filter(ne=>ne!==X):oe=[...i.selectedNodeIds,X]:oe=i.selectedNodeIds.includes(X)?i.selectedNodeIds:[X];const ue={};for(const ne of oe){const ae=r.nodes[ne];ae&&(ue[ne]={x:Z.x-ae.x,y:Z.y-ae.y})}const ge=r.nodes[X];if(!u.enableDrag){o.selectNodes(oe);return}o.startDrag(X,{x:Z.x-ge.x,y:Z.y-ge.y},ue,oe)},[i.mode,i.selectedNodeIds,x,r.nodes,r.layout,o,M,l,u.enableDrag,u.enableSelection]),O=b.useCallback(A=>{if(!i.isDragging||i.selectedNodeIds.length===0||x)return;const X=M({x:A.clientX,y:A.clientY});let U=X;if(l==="isometric"){const ge=r.layout.width/2,ne=r.layout.height-100;U=Xt(X.x-ge,X.y-ne)}const j=i.selectedNodeIds.map(ge=>{const ne=i.dragNodeOffsets?.[ge]||i.dragOffset,ae=Math.round(U.x-ne.x),be=Math.round(U.y-ne.y);return{nodeId:ge,x:ae,y:be}});o.moveNodes(j);const Z=200;let oe=r.layout.width,ue=r.layout.height;for(const ge of j){const ne=r.nodes[ge.nodeId],ae=J[ne?.size]||J.m,be=ne?.width||ae.width,we=ne?.height||ae.height,Ce=ge.x+be+Z,Le=ge.y+we+Z;Ce>oe&&(oe=Ce),Le>ue&&(ue=Le)}l==="2d"&&(oe>r.layout.width||ue>r.layout.height)&&o.expandLayout(oe,ue)},[i.isDragging,i.selectedNodeIds,i.dragOffset,i.dragNodeOffsets,x,r.nodes,r.layout,o,M,l]),V=b.useCallback(()=>{i.isDragging&&o.endDrag()},[i.isDragging,o]),R=b.useCallback((A,X)=>{x||i.mode==="addConnector"&&p(A)},[i.mode,x]),K=b.useCallback((A,X)=>{i.mode==="addConnector"&&(i.pendingConnector?i.pendingConnector.from!==A&&(o.addConnector(i.pendingConnector.from,A,i.pendingConnector.fromAnchor,X,"http"),p(null)):o.setPendingConnector({from:A,fromAnchor:X}))},[i.mode,i.pendingConnector,o]),H=b.useCallback(A=>{if(x)return;const X=A.target;if(!(!X.classList.contains("canvas-bg")&&X!==S.current))if(i.mode==="addNode"){const U=M({x:A.clientX,y:A.clientY}),j=Math.round(U.x-J.m.width/2),Z=Math.round(U.y-J.m.height/2);o.addNode({x:Math.max(0,j),y:Math.max(0,Z)})}else i.mode==="addConnector"&&(o.clearPendingConnector(),p(null))},[i.mode,x,o,M]),te=b.useCallback(A=>{i.mode==="select"&&!x&&o.selectConnector(A)},[i.mode,x,o]),de=b.useCallback(A=>{i.mode==="select"&&!x&&o.selectGroup(A)},[i.mode,x,o]),ve=b.useCallback(A=>{i.mode==="select"&&!x&&o.selectImage(A)},[i.mode,x,o]),se=b.useCallback(A=>{A.preventDefault(),A.stopPropagation();const U=Array.from(A.dataTransfer.files).filter(Z=>Z.type.startsWith("image/")||Z.name.endsWith(".svg"));if(U.length===0)return;const j=M({x:A.clientX,y:A.clientY});U.forEach((Z,oe)=>{const ue=new FileReader;ue.onload=ge=>{const ne=ge.target?.result,ae=new Image;ae.onload=()=>{let be=ae.width,we=ae.height;const Ce=300;if(be>Ce||we>Ce){const Le=Math.min(Ce/be,Ce/we);be=Math.round(be*Le),we=Math.round(we*Le)}o.addImage({src:ne,name:Z.name,x:Math.round(j.x+oe*20),y:Math.round(j.y+oe*20),width:be,height:we,opacity:1})},ae.src=ne},ue.readAsDataURL(Z)})},[M,o]),re=b.useCallback(A=>{A.preventDefault(),A.stopPropagation()},[]),[z,D]=b.useState({width:800,height:600}),B=b.useCallback(()=>{if(h.current){const A=h.current.getBoundingClientRect();D({width:A.width,height:A.height})}},[h]);b.useEffect(()=>(B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)),[B]);const W={x:-g.x/f,y:-g.y/f,width:z.width/f,height:z.height/f};b.useEffect(()=>{e?.(W)},[W.x,W.y,W.width,W.height,e]),b.useEffect(()=>{if(l!=="2d")return;const A=W.x+W.width,X=W.y+W.height,U=100;if(A>r.layout.width-U||X>r.layout.height-U){const j=Math.max(r.layout.width,A+U),Z=Math.max(r.layout.height,X+U);(j>r.layout.width||Z>r.layout.height)&&o.expandLayout(j,Z)}},[l,W.x,W.y,W.width,W.height,r.layout.width,r.layout.height,o]);const G=b.useCallback(A=>{const X=-(A.x*f)+z.width/2,U=-(A.y*f)+z.height/2;C({x:X,y:U})},[f,z,C]),Q=b.useCallback(A=>{o.setExportZone(A)},[o]),[Y,me]=b.useState(null),[ee,ct]=b.useState(null),vn=b.useCallback(A=>{const X=A.target,U=X.classList.contains("canvas-bg")||X===S.current;if(i.mode==="addRect"||i.mode==="addCircle"){const j=M({x:A.clientX,y:A.clientY});me({type:i.mode==="addRect"?"rect":"circle",startX:j.x,startY:j.y,currentX:j.x,currentY:j.y})}else if(i.mode==="select"&&U&&!x){const j=M({x:A.clientX,y:A.clientY});ct({startX:j.x,startY:j.y,currentX:j.x,currentY:j.y})}},[i.mode,M,x]),vu=b.useCallback(A=>{if(Y){const X=M({x:A.clientX,y:A.clientY});me(U=>U?{...U,currentX:X.x,currentY:X.y}:null)}if(ee){const X=M({x:A.clientX,y:A.clientY});ct(U=>U?{...U,currentX:X.x,currentY:X.y}:null)}},[Y,ee,M]),wu=b.useCallback(()=>{if(Y){const A=Math.min(Y.startX,Y.currentX),X=Math.min(Y.startY,Y.currentY),U=Math.abs(Y.currentX-Y.startX),j=Math.abs(Y.currentY-Y.startY);U>20&&j>20&&o.addGroup({x:Math.round(A),y:Math.round(X),width:Math.round(U),height:Math.round(j),type:Y.type==="circle"?"circle":"rect",color:"zinc",label:"",dashed:!0}),me(null),o.setMode("select")}if(ee){const A=Math.min(ee.startX,ee.currentX),X=Math.min(ee.startY,ee.currentY),U=Math.abs(ee.currentX-ee.startX),j=Math.abs(ee.currentY-ee.startY);if(U>5||j>5){const Z=[];for(const[oe,ue]of Object.entries(r.nodes)){if(!r.nodeData[oe])continue;const ne=J[ue.size]||J.m,ae=ne.width,be=ne.height,we=ue.x,Ce=ue.y;we<A+U&&we+ae>A&&Ce<X+j&&Ce+be>X&&Z.push(oe)}Z.length>0?o.selectNodes(Z):o.clearSelection()}else o.clearSelection();ct(null)}},[Y,ee,r.nodes,r.nodeData,o]),To=i.mode==="addConnector"?d||i.pendingConnector?.from:null,Cu=()=>x?"cursor-grabbing":i.mode==="pan"?"cursor-grab":i.mode==="addNode"?"cursor-crosshair":i.mode==="addConnector"?"cursor-pointer":i.mode==="addRect"||i.mode==="addCircle"?"cursor-crosshair":"cursor-default",Fo=(()=>{switch(i.mode){case"addNode":return"Click to place node";case"addConnector":return"Click nodes to connect";case"pan":return"Drag to pan canvas";case"addRect":return"Draw rectangle group";case"addCircle":return"Draw circle group";default:return null}})();return a.jsxs("div",{className:"relative w-full h-full",children:[a.jsxs("div",{ref:h,className:`
|
|
56
56
|
w-full h-full overflow-hidden
|
|
57
|
-
${
|
|
58
|
-
${
|
|
59
|
-
`,style:{touchAction:"none"},onDrop:
|
|
60
|
-
`))},[o,n,e]);const{current:d}=
|
|
61
|
-
`))},[JSON.stringify(t)])}const c=O.useCallback(d=>{r||s(d)},[]);return[l,c]}function ut(e,...t){const n=new URL(`https://base-ui.com/production-error/${e}`);return t.forEach(o=>n.searchParams.append("args[]",o)),`Base UI error #${e}; visit ${n} for the full message.`}function ht(e,t,n,o){const r=Ve(tr).current;return ta(r,e,t,n,o)&&nr(r,[e,t,n,o]),r.callback}function ea(e){const t=Ve(tr).current;return na(t,e)&&nr(t,e),t.callback}function tr(){return{callback:null,cleanup:null,refs:[]}}function ta(e,t,n,o,r){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==o||e.refs[3]!==r}function na(e,t){return e.refs.length!==t.length||e.refs.some((n,o)=>n!==t[o])}function nr(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const o=Array(t.length).fill(null);for(let r=0;r<t.length;r+=1){const i=t[r];if(i!=null)switch(typeof i){case"function":{const s=i(n);typeof s=="function"&&(o[r]=s);break}case"object":{i.current=n;break}}}e.cleanup=()=>{for(let r=0;r<t.length;r+=1){const i=t[r];if(i!=null)switch(typeof i){case"function":{const s=o[r];typeof s=="function"?s():i(null);break}case"object":{i.current=null;break}}}}}}}const ra=parseInt(O.version,10);function oa(e){return ra>=e}function rr(e){if(!O.isValidElement(e))return null;const t=e,n=t.props;return(oa(19)?n?.ref:t.ref)??null}function Xt(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function ia(e,t){const n={};for(const o in e){const r=e[o];if(t?.hasOwnProperty(o)){const i=t[o](r);i!=null&&Object.assign(n,i);continue}r===!0?n[`data-${o.toLowerCase()}`]="":r&&(n[`data-${o.toLowerCase()}`]=r.toString())}return n}function sa(e,t){return typeof e=="function"?e(t):e}function aa(e,t){return typeof e=="function"?e(t):e}const Ke={};function or(e,t,n,o,r){let i={...jt(e,Ke)};return t&&(i=ft(i,t)),n&&(i=ft(i,n)),o&&(i=ft(i,o)),i}function la(e){if(e.length===0)return Ke;if(e.length===1)return jt(e[0],Ke);let t={...jt(e[0],Ke)};for(let n=1;n<e.length;n+=1)t=ft(t,e[n]);return t}function ft(e,t){return ir(t)?t(e):ca(e,t)}function ca(e,t){if(!t)return e;for(const n in t){const o=t[n];switch(n){case"style":{e[n]=Xt(e.style,o);break}case"className":{e[n]=sr(e.className,o);break}default:da(n,o)?e[n]=ua(e[n],o):e[n]=o}}return e}function da(e,t){const n=e.charCodeAt(0),o=e.charCodeAt(1),r=e.charCodeAt(2);return n===111&&o===110&&r>=65&&r<=90&&(typeof t=="function"||typeof t>"u")}function ir(e){return typeof e=="function"}function jt(e,t){return ir(e)?e(t):e??Ke}function ua(e,t){return t?e?n=>{if(ha(n)){const r=n;Gt(r);const i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}const o=t(n);return e?.(n),o}:t:e}function Gt(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function sr(e,t){return t?e?t+" "+e:t:e}function ha(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}const pt=Object.freeze([]),Ne=Object.freeze({});function gt(e,t,n={}){const o=t.render,r=fa(t,n);if(n.enabled===!1)return null;const i=n.state??Ne;return pa(e,o,r,i)}function fa(e,t={}){const{className:n,style:o,render:r}=e,{state:i=Ne,ref:s,props:l,stateAttributesMapping:c,enabled:d=!0}=t,f=d?sa(n,i):void 0,u=d?aa(o,i):void 0,h=d?ia(i,c):Ne,p=d?Xt(h,Array.isArray(l)?la(l):l)??Ne:Ne;return typeof document<"u"&&(d?Array.isArray(s)?p.ref=ea([p.ref,rr(r),...s]):p.ref=ht(p.ref,rr(r),s):ht(null,null)),d?(f!==void 0&&(p.className=sr(p.className,f)),u!==void 0&&(p.style=Xt(p.style,u)),p):Ne}function pa(e,t,n,o){if(t){if(typeof t=="function")return t(n,o);const r=or(n,t.props);return r.ref=n.ref,O.cloneElement(t,r)}if(e&&typeof e=="string")return ga(e,n);throw new Error(process.env.NODE_ENV!=="production"?"Base UI: Render element or function are not defined.":ut(8))}function ga(e,t){return e==="button"?b.createElement("button",{type:"button",...t,key:t.key}):e==="img"?b.createElement("img",{alt:"",...t,key:t.key}):O.createElement(e,t)}const _e=typeof document<"u"?O.useLayoutEffect:()=>{},Vt=O.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});process.env.NODE_ENV!=="production"&&(Vt.displayName="CompositeListContext");function ya(){return O.useContext(Vt)}function ma(e){const{children:t,elementsRef:n,labelsRef:o,onMapChange:r}=e,i=we(r),s=O.useRef(0),l=Ve(ba).current,c=Ve(xa).current,[d,f]=O.useState(0),u=O.useRef(d),h=we((y,m)=>{c.set(y,m??null),u.current+=1,f(u.current)}),p=we(y=>{c.delete(y),u.current+=1,f(u.current)}),g=O.useMemo(()=>{const y=new Map;return Array.from(c.keys()).filter(C=>C.isConnected).sort(ka).forEach((C,v)=>{const z=c.get(C)??{};y.set(C,{...z,index:v})}),y},[c,d]);_e(()=>{if(typeof MutationObserver!="function"||g.size===0)return;const y=new MutationObserver(m=>{const C=new Set,v=z=>C.has(z)?C.delete(z):C.add(z);m.forEach(z=>{z.removedNodes.forEach(v),z.addedNodes.forEach(v)}),C.size===0&&(u.current+=1,f(u.current))});return g.forEach((m,C)=>{C.parentElement&&y.observe(C.parentElement,{childList:!0})}),()=>{y.disconnect()}},[g]),_e(()=>{u.current===d&&(n.current.length!==g.size&&(n.current.length=g.size),o&&o.current.length!==g.size&&(o.current.length=g.size),s.current=g.size),i(g)},[i,g,n,o,d]),_e(()=>()=>{n.current=[]},[n]),_e(()=>()=>{o&&(o.current=[])},[o]);const x=we(y=>(l.add(y),()=>{l.delete(y)}));_e(()=>{l.forEach(y=>y(g))},[l,g]);const k=O.useMemo(()=>({register:h,unregister:p,subscribeMapChange:x,elementsRef:n,labelsRef:o,nextIndexRef:s}),[h,p,x,n,o,s]);return a.jsx(Vt.Provider,{value:k,children:t})}function xa(){return new Map}function ba(){return new Set}function ka(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}function va(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function wa(){return typeof window<"u"}function Ca(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Kt(e){return wa()?e instanceof HTMLElement||e instanceof Ca(e).HTMLElement:!1}const qt="ArrowLeft",Zt="ArrowRight",Na="ArrowUp",za="ArrowDown";function Te(e){e.preventDefault(),e.stopPropagation()}const ar=Math.floor;function yt(e,t,n){return Math.floor(e/t)!==n}function mt(e,t){return t<0||t>=e.current.length}function Ma(e,t){return ge(e,{disabledIndices:t})}function _a(e,t){return ge(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function ge(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:o,amount:r=1}={}){let i=t;do i+=n?-r:r;while(i>=0&&i<=e.current.length-1&&qe(e,i,o));return i}function $a(e,{event:t,orientation:n,loopFocus:o,rtl:r,cols:i,disabledIndices:s,minIndex:l,maxIndex:c,prevIndex:d,stopEvent:f=!1}){let u=d;const h=[],p={};let g=!1;{let y=null,m=-1;e.current.forEach((C,v)=>{if(C==null)return;const z=C.closest('[role="row"]');z&&(g=!0),(z!==y||m===-1)&&(y=z,m+=1,h[m]=[]),h[m].push(v),p[v]=m})}const x=g&&h.length>0&&h.some(y=>y.length!==i);function k(y){if(!x||d===-1)return;const m=p[d];if(m==null)return;const C=h[m].indexOf(d);let v=y==="up"?m-1:m+1;o&&(v<0?v=h.length-1:v>=h.length&&(v=0));const z=new Set;for(;v>=0&&v<h.length&&!z.has(v);){z.add(v);const _=h[v];if(_.length===0){v=y==="up"?v-1:v+1;continue}const N=Math.min(C,_.length-1);for(let E=N;E>=0;E-=1){const S=_[E];if(!qe(e,S,s))return S}v=y==="up"?v-1:v+1,o&&(v<0?v=h.length-1:v>=h.length&&(v=0))}}if(t.key===Na){const y=k("up");if(y!==void 0)f&&Te(t),u=y;else{if(f&&Te(t),d===-1)u=c;else if(u=ge(e,{startingIndex:u,amount:i,decrement:!0,disabledIndices:s}),o&&(d-i<l||u<0)){const m=d%i,C=c%i,v=c-(C-m);C===m?u=c:u=C>m?v:v-i}mt(e,u)&&(u=d)}}if(t.key===za){const y=k("down");y!==void 0?(f&&Te(t),u=y):(f&&Te(t),d===-1?u=l:(u=ge(e,{startingIndex:d,amount:i,disabledIndices:s}),o&&d+i>c&&(u=ge(e,{startingIndex:d%i-i,amount:i,disabledIndices:s}))),mt(e,u)&&(u=d))}if(n==="both"){const y=ar(d/i);t.key===(r?qt:Zt)&&(f&&Te(t),d%i!==i-1?(u=ge(e,{startingIndex:d,disabledIndices:s}),o&&yt(u,i,y)&&(u=ge(e,{startingIndex:d-d%i-1,disabledIndices:s}))):o&&(u=ge(e,{startingIndex:d-d%i-1,disabledIndices:s})),yt(u,i,y)&&(u=d)),t.key===(r?Zt:qt)&&(f&&Te(t),d%i!==0?(u=ge(e,{startingIndex:d,decrement:!0,disabledIndices:s}),o&&yt(u,i,y)&&(u=ge(e,{startingIndex:d+(i-d%i),decrement:!0,disabledIndices:s}))):o&&(u=ge(e,{startingIndex:d+(i-d%i),decrement:!0,disabledIndices:s})),yt(u,i,y)&&(u=d));const m=ar(c/i)===y;mt(e,u)&&(o&&m?u=t.key===(r?Zt:qt)?c:ge(e,{startingIndex:d-d%i-1,disabledIndices:s}):u=d)}return u}function Sa(e,t,n){const o=[];let r=0;return e.forEach(({width:i,height:s},l)=>{if(i>t&&process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV!=="production"?`[Floating UI]: Invalid grid - item width at index ${l} is greater than grid columns`:ut(29,l));let c=!1;for(n&&(r=0);!c;){const d=[];for(let f=0;f<i;f+=1)for(let u=0;u<s;u+=1)d.push(r+f+u*t);r%t+i<=t&&d.every(f=>o[f]==null)?(d.forEach(f=>{o[f]=l}),c=!0):r+=1}}),[...o]}function Aa(e,t,n,o,r){if(e===-1)return-1;const i=n.indexOf(e),s=t[e];switch(r){case"tl":return i;case"tr":return s?i+s.width-1:i;case"bl":return s?i+(s.height-1)*o:i;case"br":return n.lastIndexOf(e);default:return-1}}function Ia(e,t){return t.flatMap((n,o)=>e.includes(n)?[o]:[])}function qe(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const o=e.current[t];return o?o.hasAttribute("disabled")||o.getAttribute("aria-disabled")==="true":!1}const Ze="ArrowUp",Pe="ArrowDown",xt="ArrowLeft",Je="ArrowRight",bt="Home",kt="End",lr=new Set([xt,Je]),Ea=new Set([xt,Je,bt,kt]),cr=new Set([Ze,Pe]),Da=new Set([Ze,Pe,bt,kt]),dr=new Set([...lr,...cr]),Oa=new Set([...dr,bt,kt]),La="Shift",Ta="Control",Pa="Alt",Fa="Meta",Ya=new Set([La,Ta,Pa,Fa]);function Ha(e){return Kt(e)&&e.tagName==="INPUT"}function ur(e){return!!(Ha(e)&&e.selectionStart!=null||Kt(e)&&e.tagName==="TEXTAREA")}function hr(e,t,n,o){if(!e||!t||!t.scrollTo)return;let r=e.scrollLeft,i=e.scrollTop;const s=e.clientWidth<e.scrollWidth,l=e.clientHeight<e.scrollHeight;if(s&&o!=="vertical"){const c=fr(e,t,"left"),d=vt(e),f=vt(t);n==="ltr"&&(c+t.offsetWidth+f.scrollMarginRight>e.scrollLeft+e.clientWidth-d.scrollPaddingRight?r=c+t.offsetWidth+f.scrollMarginRight-e.clientWidth+d.scrollPaddingRight:c-f.scrollMarginLeft<e.scrollLeft+d.scrollPaddingLeft&&(r=c-f.scrollMarginLeft-d.scrollPaddingLeft)),n==="rtl"&&(c-f.scrollMarginRight<e.scrollLeft+d.scrollPaddingLeft?r=c-f.scrollMarginLeft-d.scrollPaddingLeft:c+t.offsetWidth+f.scrollMarginRight>e.scrollLeft+e.clientWidth-d.scrollPaddingRight&&(r=c+t.offsetWidth+f.scrollMarginRight-e.clientWidth+d.scrollPaddingRight))}if(l&&o!=="horizontal"){const c=fr(e,t,"top"),d=vt(e),f=vt(t);c-f.scrollMarginTop<e.scrollTop+d.scrollPaddingTop?i=c-f.scrollMarginTop-d.scrollPaddingTop:c+t.offsetHeight+f.scrollMarginBottom>e.scrollTop+e.clientHeight-d.scrollPaddingBottom&&(i=c+t.offsetHeight+f.scrollMarginBottom-e.clientHeight+d.scrollPaddingBottom)}e.scrollTo({left:r,top:i,behavior:"auto"})}function fr(e,t,n){const o=n==="left"?"offsetLeft":"offsetTop";let r=0;for(;t.offsetParent&&(r+=t[o],t.offsetParent!==e);)t=t.offsetParent;return r}function vt(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}const Ba="data-composite-item-active",Wa=[];function Ua(e){const{itemSizes:t,cols:n=1,loopFocus:o=!0,dense:r=!1,orientation:i="both",direction:s,highlightedIndex:l,onHighlightedIndexChange:c,rootRef:d,enableHomeAndEndKeys:f=!1,stopEventPropagation:u=!1,disabledIndices:h,modifierKeys:p=Wa}=e,[g,x]=O.useState(0),k=n>1,y=O.useRef(null),m=ht(y,d),C=O.useRef([]),v=O.useRef(!1),z=l??g,_=we((S,w=!1)=>{if((c??x)(S),w){const M=C.current[S];hr(y.current,M,s,i)}}),N=we(S=>{if(S.size===0||v.current)return;v.current=!0;const w=Array.from(S.keys()),M=w.find(A=>A?.hasAttribute(Ba))??null,$=M?w.indexOf(M):-1;$!==-1&&_($),hr(y.current,M,s,i)}),E=O.useMemo(()=>({"aria-orientation":i==="both"?void 0:i,ref:m,onFocus(S){!y.current||!ur(S.target)||S.target.setSelectionRange(0,S.target.value.length??0)},onKeyDown(S){const w=f?Oa:dr;if(!w.has(S.key)||Xa(S,p)||!y.current)return;const $=s==="rtl",A=$?xt:Je,B={horizontal:A,vertical:Pe,both:A}[i],W=$?Je:xt,G={horizontal:W,vertical:Ze,both:W}[i];if(ur(S.target)&&!va(S.target)){const Z=S.target.selectionStart,se=S.target.selectionEnd,H=S.target.value??"";if(Z==null||S.shiftKey||Z!==se||S.key!==G&&Z<H.length||S.key!==B&&Z>0)return}let P=z;const ne=Ma(C,h),Q=_a(C,h);if(k){const Z=t||Array.from({length:C.current.length},()=>({width:1,height:1})),se=Sa(Z,n,r),H=se.findIndex(X=>X!=null&&!qe(C,X,h)),Ae=se.reduce((X,xe,Xe)=>xe!=null&&!qe(C,xe,h)?Xe:X,-1);P=se[$a({current:se.map(X=>X?C.current[X]:null)},{event:S,orientation:i,loopFocus:o,cols:n,disabledIndices:Ia([...h||C.current.map((X,xe)=>qe(C,xe)?xe:void 0),void 0],se),minIndex:H,maxIndex:Ae,prevIndex:Aa(z>Q?ne:z,Z,se,n,S.key===Pe?"bl":S.key===Je?"tr":"tl"),rtl:$})]}const ye={horizontal:[A],vertical:[Pe],both:[A,Pe]}[i],R={horizontal:[W],vertical:[Ze],both:[W,Ze]}[i],U=k?w:{horizontal:f?Ea:lr,vertical:f?Da:cr,both:w}[i];f&&(S.key===bt?P=ne:S.key===kt&&(P=Q)),P===z&&(ye.includes(S.key)||R.includes(S.key))&&(o&&P===Q&&ye.includes(S.key)?P=ne:o&&P===ne&&R.includes(S.key)?P=Q:P=ge(C,{startingIndex:P,decrement:R.includes(S.key),disabledIndices:h})),P!==z&&!mt(C,P)&&(u&&S.stopPropagation(),U.has(S.key)&&S.preventDefault(),_(P,!0),queueMicrotask(()=>{C.current[P]?.focus()}))}}),[n,r,s,h,C,f,z,k,t,o,m,p,_,i,u]);return O.useMemo(()=>({props:E,highlightedIndex:z,onHighlightedIndexChange:_,elementsRef:C,disabledIndices:h,onMapChange:N,relayKeyboardEvent:E.onKeyDown}),[E,z,_,C,h,N])}function Xa(e,t){for(const n of Ya.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}const Jt=O.createContext(void 0);process.env.NODE_ENV!=="production"&&(Jt.displayName="CompositeRootContext");function pr(e=!1){const t=O.useContext(Jt);if(t===void 0&&!e)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.":ut(16));return t}const gr=O.createContext(void 0);process.env.NODE_ENV!=="production"&&(gr.displayName="DirectionContext");function ja(){return O.useContext(gr)?.direction??"ltr"}function Ga(e){const{render:t,className:n,refs:o=pt,props:r=pt,state:i=Ne,stateAttributesMapping:s,highlightedIndex:l,onHighlightedIndexChange:c,orientation:d,dense:f,itemSizes:u,loopFocus:h,cols:p,enableHomeAndEndKeys:g,onMapChange:x,stopEventPropagation:k=!0,rootRef:y,disabledIndices:m,modifierKeys:C,highlightItemOnHover:v=!1,tag:z="div",..._}=e,N=ja(),{props:E,highlightedIndex:S,onHighlightedIndexChange:w,elementsRef:M,onMapChange:$,relayKeyboardEvent:A}=Ua({itemSizes:u,cols:p,loopFocus:h,dense:f,orientation:d,highlightedIndex:l,onHighlightedIndexChange:c,rootRef:y,stopEventPropagation:k,enableHomeAndEndKeys:g,direction:N,disabledIndices:m,modifierKeys:C}),B=gt(z,e,{state:i,ref:o,props:[E,...r,_],stateAttributesMapping:s}),W=O.useMemo(()=>({highlightedIndex:S,onHighlightedIndexChange:w,highlightItemOnHover:v,relayKeyboardEvent:A}),[S,w,v,A]);return a.jsx(Jt.Provider,{value:W,children:a.jsx(ma,{elementsRef:M,onMapChange:G=>{x?.(G),$(G)},children:B})})}const yr=O.createContext(void 0);process.env.NODE_ENV!=="production"&&(yr.displayName="ToolbarRootContext");function Va(e){return O.useContext(yr)}const Qt=O.createContext(void 0);process.env.NODE_ENV!=="production"&&(Qt.displayName="ToggleGroupContext");function Ka(e=!0){const t=O.useContext(Qt);if(t===void 0&&!e)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: ToggleGroupContext is missing. ToggleGroup parts must be placed within <ToggleGroup>.":ut(7));return t}let qa=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const mr={multiple(e){return e?{[qa.multiple]:""}:null}},xr=O.forwardRef(function(t,n){const{defaultValue:o,disabled:r=!1,loopFocus:i=!0,onValueChange:s,orientation:l="horizontal",multiple:c=!1,value:d,className:f,render:u,...h}=t,p=Va(),g=O.useMemo(()=>{if(d===void 0)return o??[]},[d,o]),x=(p?.disabled??!1)||r,[k,y]=er({controlled:d,default:g,name:"ToggleGroup",state:"value"}),m=we((N,E,S)=>{let w;if(c?(w=k.slice(),E?w.push(N):w.splice(k.indexOf(N),1)):w=E?[N]:[],Array.isArray(w)){if(s?.(w,S),S.isCanceled)return;y(w)}}),C=O.useMemo(()=>({disabled:x,multiple:c,orientation:l}),[x,l,c]),v=O.useMemo(()=>({disabled:x,orientation:l,setGroupValue:m,value:k}),[x,l,m,k]),z={role:"group"},_=gt("div",t,{enabled:!!p,state:C,ref:n,props:[z,h],stateAttributesMapping:mr});return a.jsx(Qt.Provider,{value:v,children:p?_:a.jsx(Ga,{render:u,className:f,state:C,refs:[n],props:[z,h],stateAttributesMapping:mr,loopFocus:i})})});process.env.NODE_ENV!=="production"&&(xr.displayName="ToggleGroup");const Za={...O};let br=0;function Ja(e,t="mui"){const[n,o]=O.useState(e),r=e||n;return O.useEffect(()=>{n==null&&(br+=1,o(`${t}-${br}`))},[n,t]),r}const kr=Za.useId;function Qa(e,t){if(kr!==void 0){const n=kr();return e??`${t}-${n}`}return Ja(e,t)}function Ra(e){return Qa(e,"base-ui")}let Rt;process.env.NODE_ENV!=="production"&&(Rt=new Set);function vr(...e){if(process.env.NODE_ENV!=="production"){const t=e.join(" ");Rt.has(t)||(Rt.add(t),console.error(`Base UI: ${t}`))}}function el(e){const{focusableWhenDisabled:t,disabled:n,composite:o=!1,tabIndex:r=0,isNativeButton:i}=e,s=o&&t!==!1,l=o&&t===!1;return{props:O.useMemo(()=>{const d={onKeyDown(f){n&&t&&f.key!=="Tab"&&f.preventDefault()}};return o||(d.tabIndex=r,!i&&n&&(d.tabIndex=t?r:-1)),(i&&(t||s)||!i&&n)&&(d["aria-disabled"]=n),i&&(!t||l)&&(d.disabled=n),d},[o,n,t,s,l,i,r])}}function tl(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:o=0,native:r=!0}=e,i=O.useRef(null),s=pr(!0)!==void 0,l=we(()=>{const h=i.current;return!!(h?.tagName==="A"&&h?.href)}),{props:c}=el({focusableWhenDisabled:n,disabled:t,composite:s,tabIndex:o,isNativeButton:r});process.env.NODE_ENV!=="production"&&O.useEffect(()=>{if(!i.current)return;const h=i.current.tagName==="BUTTON";r?h||vr("A component that acts as a button was not rendered as a native <button>, which does not match the default. Ensure that the element passed to the `render` prop of the component is a real <button>, or set the `nativeButton` prop on the component to `false`."):h&&vr("A component that acts as a button was rendered as a native <button>, which does not match the default. Ensure that the element passed to the `render` prop of the component is not a real <button>, or set the `nativeButton` prop on the component to `true`.")},[r]);const d=O.useCallback(()=>{const h=i.current;nl(h)&&s&&t&&c.disabled===void 0&&h.disabled&&(h.disabled=!1)},[t,c.disabled,s]);_e(d,[d]);const f=O.useCallback((h={})=>{const{onClick:p,onMouseDown:g,onKeyUp:x,onKeyDown:k,onPointerDown:y,...m}=h;return or({type:r?"button":void 0,onClick(v){if(t){v.preventDefault();return}p?.(v)},onMouseDown(v){t||g?.(v)},onKeyDown(v){if(t||(Gt(v),k?.(v)),v.baseUIHandlerPrevented)return;const z=v.target===v.currentTarget&&!r&&!l()&&!t,_=v.key==="Enter",N=v.key===" ";z&&((N||_)&&v.preventDefault(),_&&p?.(v))},onKeyUp(v){t||(Gt(v),x?.(v)),!v.baseUIHandlerPrevented&&v.target===v.currentTarget&&!r&&!t&&v.key===" "&&p?.(v)},onPointerDown(v){if(t){v.preventDefault();return}y?.(v)}},r?void 0:{role:"button"},c,m)},[t,c,r,l]),u=we(h=>{i.current=h,d()});return{getButtonProps:f,buttonRef:u}}function nl(e){return Kt(e)&&e.tagName==="BUTTON"}let rl=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function ol(e={}){const{label:t,metadata:n,textRef:o,indexGuessBehavior:r,index:i}=e,{register:s,unregister:l,subscribeMapChange:c,elementsRef:d,labelsRef:f,nextIndexRef:u}=ya(),h=O.useRef(-1),[p,g]=O.useState(i??(r===rl.GuessFromOrder?()=>{if(h.current===-1){const y=u.current;u.current+=1,h.current=y}return h.current}:-1)),x=O.useRef(null),k=O.useCallback(y=>{if(x.current=y,p!==-1&&y!==null&&(d.current[p]=y,f)){const m=t!==void 0;f.current[p]=m?t:o?.current?.textContent??y.textContent}},[p,d,f,t,o]);return _e(()=>{if(i!=null)return;const y=x.current;if(y)return s(y,n),()=>{l(y)}},[i,s,l,n]),_e(()=>{if(i==null)return c(y=>{const m=x.current?y.get(x.current)?.index:null;m!=null&&g(m)})},[i,c,g]),O.useMemo(()=>({ref:k,index:p}),[p,k])}function il(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:o}=pr(),{ref:r,index:i}=ol(e),s=n===i,l=O.useRef(null),c=ht(r,l);return{compositeProps:O.useMemo(()=>({tabIndex:s?0:-1,onFocus(){o(i)},onMouseMove(){const f=l.current;if(!t||!f)return;const u=f.hasAttribute("disabled")||f.ariaDisabled==="true";!s&&!u&&f.focus()}}),[s,o,i,t]),compositeRef:c,index:i}}function sl(e){const{render:t,className:n,state:o=Ne,props:r=pt,refs:i=pt,metadata:s,stateAttributesMapping:l,tag:c="div",...d}=e,{compositeProps:f,compositeRef:u}=il({metadata:s});return gt(c,e,{state:o,ref:[...i,u],props:[f,...r,d],stateAttributesMapping:l})}const al="none";function ll(e,t,n,o){let r=!1,i=!1;const s=Ne;return{reason:e,event:t??new Event("base-ui"),cancel(){r=!0},allowPropagation(){i=!0},get isCanceled(){return r},get isPropagationAllowed(){return i},trigger:n,...s}}const wr=O.forwardRef(function(t,n){const{className:o,defaultPressed:r=!1,disabled:i=!1,form:s,onPressedChange:l,pressed:c,render:d,type:f,value:u,nativeButton:h=!0,...p}=t,g=Ra(u||void 0),x=Ka(),k=x?.value??[],y=x?void 0:r,m=(i||x?.disabled)??!1,[C,v]=er({controlled:x?k?.indexOf(g)>-1:c,default:y,name:"Toggle",state:"pressed"}),z=we(($,A)=>{g&&x?.setGroupValue?.(g,$,A),l?.($,A)}),{getButtonProps:_,buttonRef:N}=tl({disabled:m,native:h}),E=O.useMemo(()=>({disabled:m,pressed:C}),[m,C]),S=[N,n],w=[{"aria-pressed":C,onClick($){const A=!C,B=ll(al,$.nativeEvent);z(A,B),!B.isCanceled&&v(A)}},p,_],M=gt("button",t,{enabled:!x,state:E,ref:S,props:w});return x?a.jsx(sl,{tag:"button",render:d,className:o,state:E,refs:S,props:w}):M});process.env.NODE_ENV!=="production"&&(wr.displayName="Toggle");function cl({value:e,onChange:t}){const[n,o]=b.useState(""),r=n?Dn.filter(i=>i.toLowerCase().includes(n.toLowerCase())):Dn;return a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"relative",children:[a.jsx(An,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400"}),a.jsx("input",{type:"text",placeholder:"Search icons...",value:n,onChange:i=>o(i.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]}),a.jsx("div",{className:"grid grid-cols-6 gap-1 max-h-40 overflow-y-auto p-1 bg-zinc-50 dark:bg-zinc-800/50 rounded-lg",children:r.map(i=>{const s=On(i),l=e===i;return a.jsx("button",{onClick:()=>t(i),title:i,className:`
|
|
57
|
+
${c.canvas.background}
|
|
58
|
+
${Cu()}
|
|
59
|
+
`,style:{touchAction:"none"},onDrop:se,onDragOver:re,children:[u.showGrid&&a.jsx(js,{grid:r.grid,viewportBounds:W,containerSize:z,zoom:f}),a.jsx("div",{style:$,children:a.jsxs("div",{ref:S,className:"relative canvas-bg",style:{width:r.layout.width,height:r.layout.height},onClick:H,onMouseDown:vn,onMouseMove:vu,onMouseUp:wu,onPointerMove:O,onPointerUp:V,onPointerLeave:V,children:[a.jsx(Hs,{layout:r.layout,groups:r.groups||[],selectedGroupId:i.selectedGroupId,onGroupClick:de,onGroupUpdate:o.updateGroup,screenToCanvas:M}),a.jsx(Ws,{layout:r.layout,images:r.images||[],selectedImageId:i.selectedImageId,onImageClick:ve,onImageUpdate:o.updateImage,screenToCanvas:M}),Y&&a.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${r.layout.width} ${r.layout.height}`,children:Y.type==="circle"?a.jsx("ellipse",{cx:(Y.startX+Y.currentX)/2,cy:(Y.startY+Y.currentY)/2,rx:Math.abs(Y.currentX-Y.startX)/2,ry:Math.abs(Y.currentY-Y.startY)/2,fill:"rgba(113, 113, 122, 0.1)",stroke:"rgba(113, 113, 122, 0.5)",strokeWidth:"2",strokeDasharray:"8 4"}):a.jsx("rect",{x:Math.min(Y.startX,Y.currentX),y:Math.min(Y.startY,Y.currentY),width:Math.abs(Y.currentX-Y.startX),height:Math.abs(Y.currentY-Y.startY),rx:12,fill:"rgba(113, 113, 122, 0.1)",stroke:"rgba(113, 113, 122, 0.5)",strokeWidth:"2",strokeDasharray:"8 4"})}),ee&&a.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${r.layout.width} ${r.layout.height}`,children:a.jsx("rect",{x:Math.min(ee.startX,ee.currentX),y:Math.min(ee.startY,ee.currentY),width:Math.abs(ee.currentX-ee.startX),height:Math.abs(ee.currentY-ee.startY),fill:"rgba(59, 130, 246, 0.1)",stroke:"rgba(59, 130, 246, 0.8)",strokeWidth:"1",strokeDasharray:"4 2"})}),l==="2d"?a.jsxs(a.Fragment,{children:[a.jsx(Ts,{layout:r.layout,nodes:r.nodes,connectors:r.connectors,connectorStyles:r.connectorStyles,selectedConnectorIndex:i.selectedConnectorIndex,onConnectorClick:te}),To&&a.jsx(Fs,{layout:r.layout,nodes:r.nodes,visibleNodeId:To,onAnchorClick:K,pendingConnector:i.pendingConnector}),a.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Object.entries(r.nodes).map(([A,X])=>{const U=r.nodeData[A];return U?a.jsx(As,{nodeId:A,node:X,data:U,layout:r.layout,template:c,isSelected:i.selectedNodeIds.includes(A),onPointerDown:T,onClick:R,onMouseEnter:()=>i.mode==="addConnector"&&p(A),onMouseLeave:()=>i.mode==="addConnector"&&p(null)},A):null})})]}):a.jsxs(a.Fragment,{children:[a.jsx(ta,{nodes:r.nodes,nodeData:r.nodeData,connectors:r.connectors,connectorStyles:r.connectorStyles,selectedConnectorIndex:i.selectedConnectorIndex,onConnectorClick:te,originX:r.layout.width/2,originY:r.layout.height-100}),a.jsx(Js,{nodes:r.nodes,nodeData:r.nodeData,selectedNodeIds:i.selectedNodeIds,onNodeClick:A=>o.selectNode(A),onNodePointerDown:T,originX:r.layout.width/2,originY:r.layout.height-100})]}),a.jsx(Us,{layout:r.layout,exportZone:r.exportZone,isEditing:i.mode==="select",onZoneUpdate:Q,onZoneClear:o.clearExportZone,screenToCanvas:M})]})})]}),Fo&&a.jsx("div",{className:`absolute top-2 left-2 px-2 py-1 rounded text-white text-xs font-medium ${i.mode==="pan"?"bg-zinc-600":"bg-blue-500"}`,children:Fo}),i.pendingConnector&&a.jsx("div",{className:"absolute top-2 right-2 px-2 py-1 rounded bg-amber-500 text-white text-xs font-medium",children:"Select target anchor"}),u.showZoomControls&&a.jsx(Gs,{zoom:f,minZoom:k,maxZoom:m,onZoomIn:()=>v(),onZoomOut:()=>w(),onZoomChange:A=>y(A),onReset:N,onFitToView:()=>_(r.layout)}),u.enableViewModeToggle&&a.jsx(Vs,{viewMode:l,onViewModeChange:o.setViewMode}),u.showMiniMap&&l==="2d"&&a.jsx(Xs,{diagram:r,viewportBounds:W,onViewportChange:G})]})}const Rn={};function qe(e,t){const n=L.useRef(Rn);return n.current===Rn&&(n.current=e(t)),n}const jt=L[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],ra=jt&&jt!==L.useLayoutEffect?jt:e=>e();function Me(e){const t=qe(oa).current;return t.next=e,ra(t.effect),t.trampoline}function oa(){const e={next:void 0,callback:ia,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function ia(){if(process.env.NODE_ENV!=="production")throw new Error("Base UI: Cannot call an event handler while rendering.")}function er({controlled:e,default:t,name:n,state:o="value"}){const{current:r}=L.useRef(e!==void 0),[i,s]=L.useState(t),l=r?e:i;if(process.env.NODE_ENV!=="production"){L.useEffect(()=>{r!==(e!==void 0)&&console.error([`Base UI: A component is changing the ${r?"":"un"}controlled ${o} state of ${n} to be ${r?"un":""}controlled.`,"Elements should not switch from uncontrolled to controlled (or vice versa).",`Decide between using a controlled or uncontrolled ${n} element for the lifetime of the component.`,"The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.","More info: https://fb.me/react-controlled-components"].join(`
|
|
60
|
+
`))},[o,n,e]);const{current:d}=L.useRef(t);L.useEffect(()=>{!r&&JSON.stringify(d)!==JSON.stringify(t)&&console.error([`Base UI: A component is changing the default ${o} state of an uncontrolled ${n} after being initialized. To suppress this warning opt to use a controlled ${n}.`].join(`
|
|
61
|
+
`))},[JSON.stringify(t)])}const c=L.useCallback(d=>{r||s(d)},[]);return[l,c]}function pt(e,...t){const n=new URL(`https://base-ui.com/production-error/${e}`);return t.forEach(o=>n.searchParams.append("args[]",o)),`Base UI error #${e}; visit ${n} for the full message.`}function gt(e,t,n,o){const r=qe(tr).current;return aa(r,e,t,n,o)&&nr(r,[e,t,n,o]),r.callback}function sa(e){const t=qe(tr).current;return la(t,e)&&nr(t,e),t.callback}function tr(){return{callback:null,cleanup:null,refs:[]}}function aa(e,t,n,o,r){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==o||e.refs[3]!==r}function la(e,t){return e.refs.length!==t.length||e.refs.some((n,o)=>n!==t[o])}function nr(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const o=Array(t.length).fill(null);for(let r=0;r<t.length;r+=1){const i=t[r];if(i!=null)switch(typeof i){case"function":{const s=i(n);typeof s=="function"&&(o[r]=s);break}case"object":{i.current=n;break}}}e.cleanup=()=>{for(let r=0;r<t.length;r+=1){const i=t[r];if(i!=null)switch(typeof i){case"function":{const s=o[r];typeof s=="function"?s():i(null);break}case"object":{i.current=null;break}}}}}}}const ca=parseInt(L.version,10);function da(e){return ca>=e}function rr(e){if(!L.isValidElement(e))return null;const t=e,n=t.props;return(da(19)?n?.ref:t.ref)??null}function Gt(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function ua(e,t){const n={};for(const o in e){const r=e[o];if(t?.hasOwnProperty(o)){const i=t[o](r);i!=null&&Object.assign(n,i);continue}r===!0?n[`data-${o.toLowerCase()}`]="":r&&(n[`data-${o.toLowerCase()}`]=r.toString())}return n}function ha(e,t){return typeof e=="function"?e(t):e}function fa(e,t){return typeof e=="function"?e(t):e}const Je={};function or(e,t,n,o,r){let i={...Vt(e,Je)};return t&&(i=yt(i,t)),n&&(i=yt(i,n)),o&&(i=yt(i,o)),i}function pa(e){if(e.length===0)return Je;if(e.length===1)return Vt(e[0],Je);let t={...Vt(e[0],Je)};for(let n=1;n<e.length;n+=1)t=yt(t,e[n]);return t}function yt(e,t){return ir(t)?t(e):ga(e,t)}function ga(e,t){if(!t)return e;for(const n in t){const o=t[n];switch(n){case"style":{e[n]=Gt(e.style,o);break}case"className":{e[n]=sr(e.className,o);break}default:ya(n,o)?e[n]=ma(e[n],o):e[n]=o}}return e}function ya(e,t){const n=e.charCodeAt(0),o=e.charCodeAt(1),r=e.charCodeAt(2);return n===111&&o===110&&r>=65&&r<=90&&(typeof t=="function"||typeof t>"u")}function ir(e){return typeof e=="function"}function Vt(e,t){return ir(e)?e(t):e??Je}function ma(e,t){return t?e?n=>{if(xa(n)){const r=n;Kt(r);const i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}const o=t(n);return e?.(n),o}:t:e}function Kt(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function sr(e,t){return t?e?t+" "+e:t:e}function xa(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}const mt=Object.freeze([]),Se=Object.freeze({});function xt(e,t,n={}){const o=t.render,r=ba(t,n);if(n.enabled===!1)return null;const i=n.state??Se;return ka(e,o,r,i)}function ba(e,t={}){const{className:n,style:o,render:r}=e,{state:i=Se,ref:s,props:l,stateAttributesMapping:c,enabled:d=!0}=t,p=d?ha(n,i):void 0,u=d?fa(o,i):void 0,h=d?ua(i,c):Se,f=d?Gt(h,Array.isArray(l)?pa(l):l)??Se:Se;return typeof document<"u"&&(d?Array.isArray(s)?f.ref=sa([f.ref,rr(r),...s]):f.ref=gt(f.ref,rr(r),s):gt(null,null)),d?(p!==void 0&&(f.className=sr(f.className,p)),u!==void 0&&(f.style=Gt(f.style,u)),f):Se}function ka(e,t,n,o){if(t){if(typeof t=="function")return t(n,o);const r=or(n,t.props);return r.ref=n.ref,L.cloneElement(t,r)}if(e&&typeof e=="string")return va(e,n);throw new Error(process.env.NODE_ENV!=="production"?"Base UI: Render element or function are not defined.":pt(8))}function va(e,t){return e==="button"?b.createElement("button",{type:"button",...t,key:t.key}):e==="img"?b.createElement("img",{alt:"",...t,key:t.key}):L.createElement(e,t)}const Ae=typeof document<"u"?L.useLayoutEffect:()=>{},Zt=L.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});process.env.NODE_ENV!=="production"&&(Zt.displayName="CompositeListContext");function wa(){return L.useContext(Zt)}function Ca(e){const{children:t,elementsRef:n,labelsRef:o,onMapChange:r}=e,i=Me(r),s=L.useRef(0),l=qe(za).current,c=qe(Na).current,[d,p]=L.useState(0),u=L.useRef(d),h=Me((m,y)=>{c.set(m,y??null),u.current+=1,p(u.current)}),f=Me(m=>{c.delete(m),u.current+=1,p(u.current)}),g=L.useMemo(()=>{const m=new Map;return Array.from(c.keys()).filter(v=>v.isConnected).sort(Ma).forEach((v,w)=>{const N=c.get(v)??{};m.set(v,{...N,index:w})}),m},[c,d]);Ae(()=>{if(typeof MutationObserver!="function"||g.size===0)return;const m=new MutationObserver(y=>{const v=new Set,w=N=>v.has(N)?v.delete(N):v.add(N);y.forEach(N=>{N.removedNodes.forEach(w),N.addedNodes.forEach(w)}),v.size===0&&(u.current+=1,p(u.current))});return g.forEach((y,v)=>{v.parentElement&&m.observe(v.parentElement,{childList:!0})}),()=>{m.disconnect()}},[g]),Ae(()=>{u.current===d&&(n.current.length!==g.size&&(n.current.length=g.size),o&&o.current.length!==g.size&&(o.current.length=g.size),s.current=g.size),i(g)},[i,g,n,o,d]),Ae(()=>()=>{n.current=[]},[n]),Ae(()=>()=>{o&&(o.current=[])},[o]);const x=Me(m=>(l.add(m),()=>{l.delete(m)}));Ae(()=>{l.forEach(m=>m(g))},[l,g]);const k=L.useMemo(()=>({register:h,unregister:f,subscribeMapChange:x,elementsRef:n,labelsRef:o,nextIndexRef:s}),[h,f,x,n,o,s]);return a.jsx(Zt.Provider,{value:k,children:t})}function Na(){return new Map}function za(){return new Set}function Ma(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}function _a(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function Sa(){return typeof window<"u"}function $a(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function qt(e){return Sa()?e instanceof HTMLElement||e instanceof $a(e).HTMLElement:!1}const Jt="ArrowLeft",Qt="ArrowRight",Ia="ArrowUp",Aa="ArrowDown";function Ye(e){e.preventDefault(),e.stopPropagation()}const ar=Math.floor;function bt(e,t,n){return Math.floor(e/t)!==n}function kt(e,t){return t<0||t>=e.current.length}function Ea(e,t){return ke(e,{disabledIndices:t})}function Da(e,t){return ke(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function ke(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:o,amount:r=1}={}){let i=t;do i+=n?-r:r;while(i>=0&&i<=e.current.length-1&&Qe(e,i,o));return i}function Oa(e,{event:t,orientation:n,loopFocus:o,rtl:r,cols:i,disabledIndices:s,minIndex:l,maxIndex:c,prevIndex:d,stopEvent:p=!1}){let u=d;const h=[],f={};let g=!1;{let m=null,y=-1;e.current.forEach((v,w)=>{if(v==null)return;const N=v.closest('[role="row"]');N&&(g=!0),(N!==m||y===-1)&&(m=N,y+=1,h[y]=[]),h[y].push(w),f[w]=y})}const x=g&&h.length>0&&h.some(m=>m.length!==i);function k(m){if(!x||d===-1)return;const y=f[d];if(y==null)return;const v=h[y].indexOf(d);let w=m==="up"?y-1:y+1;o&&(w<0?w=h.length-1:w>=h.length&&(w=0));const N=new Set;for(;w>=0&&w<h.length&&!N.has(w);){N.add(w);const _=h[w];if(_.length===0){w=m==="up"?w-1:w+1;continue}const C=Math.min(v,_.length-1);for(let M=C;M>=0;M-=1){const $=_[M];if(!Qe(e,$,s))return $}w=m==="up"?w-1:w+1,o&&(w<0?w=h.length-1:w>=h.length&&(w=0))}}if(t.key===Ia){const m=k("up");if(m!==void 0)p&&Ye(t),u=m;else{if(p&&Ye(t),d===-1)u=c;else if(u=ke(e,{startingIndex:u,amount:i,decrement:!0,disabledIndices:s}),o&&(d-i<l||u<0)){const y=d%i,v=c%i,w=c-(v-y);v===y?u=c:u=v>y?w:w-i}kt(e,u)&&(u=d)}}if(t.key===Aa){const m=k("down");m!==void 0?(p&&Ye(t),u=m):(p&&Ye(t),d===-1?u=l:(u=ke(e,{startingIndex:d,amount:i,disabledIndices:s}),o&&d+i>c&&(u=ke(e,{startingIndex:d%i-i,amount:i,disabledIndices:s}))),kt(e,u)&&(u=d))}if(n==="both"){const m=ar(d/i);t.key===(r?Jt:Qt)&&(p&&Ye(t),d%i!==i-1?(u=ke(e,{startingIndex:d,disabledIndices:s}),o&&bt(u,i,m)&&(u=ke(e,{startingIndex:d-d%i-1,disabledIndices:s}))):o&&(u=ke(e,{startingIndex:d-d%i-1,disabledIndices:s})),bt(u,i,m)&&(u=d)),t.key===(r?Qt:Jt)&&(p&&Ye(t),d%i!==0?(u=ke(e,{startingIndex:d,decrement:!0,disabledIndices:s}),o&&bt(u,i,m)&&(u=ke(e,{startingIndex:d+(i-d%i),decrement:!0,disabledIndices:s}))):o&&(u=ke(e,{startingIndex:d+(i-d%i),decrement:!0,disabledIndices:s})),bt(u,i,m)&&(u=d));const y=ar(c/i)===m;kt(e,u)&&(o&&y?u=t.key===(r?Qt:Jt)?c:ke(e,{startingIndex:d-d%i-1,disabledIndices:s}):u=d)}return u}function La(e,t,n){const o=[];let r=0;return e.forEach(({width:i,height:s},l)=>{if(i>t&&process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV!=="production"?`[Floating UI]: Invalid grid - item width at index ${l} is greater than grid columns`:pt(29,l));let c=!1;for(n&&(r=0);!c;){const d=[];for(let p=0;p<i;p+=1)for(let u=0;u<s;u+=1)d.push(r+p+u*t);r%t+i<=t&&d.every(p=>o[p]==null)?(d.forEach(p=>{o[p]=l}),c=!0):r+=1}}),[...o]}function Pa(e,t,n,o,r){if(e===-1)return-1;const i=n.indexOf(e),s=t[e];switch(r){case"tl":return i;case"tr":return s?i+s.width-1:i;case"bl":return s?i+(s.height-1)*o:i;case"br":return n.lastIndexOf(e);default:return-1}}function Ta(e,t){return t.flatMap((n,o)=>e.includes(n)?[o]:[])}function Qe(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const o=e.current[t];return o?o.hasAttribute("disabled")||o.getAttribute("aria-disabled")==="true":!1}const Re="ArrowUp",He="ArrowDown",vt="ArrowLeft",et="ArrowRight",wt="Home",Ct="End",lr=new Set([vt,et]),Fa=new Set([vt,et,wt,Ct]),cr=new Set([Re,He]),Ya=new Set([Re,He,wt,Ct]),dr=new Set([...lr,...cr]),Ha=new Set([...dr,wt,Ct]),Ba="Shift",Wa="Control",Xa="Alt",Ua="Meta",ja=new Set([Ba,Wa,Xa,Ua]);function Ga(e){return qt(e)&&e.tagName==="INPUT"}function ur(e){return!!(Ga(e)&&e.selectionStart!=null||qt(e)&&e.tagName==="TEXTAREA")}function hr(e,t,n,o){if(!e||!t||!t.scrollTo)return;let r=e.scrollLeft,i=e.scrollTop;const s=e.clientWidth<e.scrollWidth,l=e.clientHeight<e.scrollHeight;if(s&&o!=="vertical"){const c=fr(e,t,"left"),d=Nt(e),p=Nt(t);n==="ltr"&&(c+t.offsetWidth+p.scrollMarginRight>e.scrollLeft+e.clientWidth-d.scrollPaddingRight?r=c+t.offsetWidth+p.scrollMarginRight-e.clientWidth+d.scrollPaddingRight:c-p.scrollMarginLeft<e.scrollLeft+d.scrollPaddingLeft&&(r=c-p.scrollMarginLeft-d.scrollPaddingLeft)),n==="rtl"&&(c-p.scrollMarginRight<e.scrollLeft+d.scrollPaddingLeft?r=c-p.scrollMarginLeft-d.scrollPaddingLeft:c+t.offsetWidth+p.scrollMarginRight>e.scrollLeft+e.clientWidth-d.scrollPaddingRight&&(r=c+t.offsetWidth+p.scrollMarginRight-e.clientWidth+d.scrollPaddingRight))}if(l&&o!=="horizontal"){const c=fr(e,t,"top"),d=Nt(e),p=Nt(t);c-p.scrollMarginTop<e.scrollTop+d.scrollPaddingTop?i=c-p.scrollMarginTop-d.scrollPaddingTop:c+t.offsetHeight+p.scrollMarginBottom>e.scrollTop+e.clientHeight-d.scrollPaddingBottom&&(i=c+t.offsetHeight+p.scrollMarginBottom-e.clientHeight+d.scrollPaddingBottom)}e.scrollTo({left:r,top:i,behavior:"auto"})}function fr(e,t,n){const o=n==="left"?"offsetLeft":"offsetTop";let r=0;for(;t.offsetParent&&(r+=t[o],t.offsetParent!==e);)t=t.offsetParent;return r}function Nt(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}const Va="data-composite-item-active",Ka=[];function Za(e){const{itemSizes:t,cols:n=1,loopFocus:o=!0,dense:r=!1,orientation:i="both",direction:s,highlightedIndex:l,onHighlightedIndexChange:c,rootRef:d,enableHomeAndEndKeys:p=!1,stopEventPropagation:u=!1,disabledIndices:h,modifierKeys:f=Ka}=e,[g,x]=L.useState(0),k=n>1,m=L.useRef(null),y=gt(m,d),v=L.useRef([]),w=L.useRef(!1),N=l??g,_=Me(($,S=!1)=>{if((c??x)($),S){const E=v.current[$];hr(m.current,E,s,i)}}),C=Me($=>{if($.size===0||w.current)return;w.current=!0;const S=Array.from($.keys()),E=S.find(O=>O?.hasAttribute(Va))??null,T=E?S.indexOf(E):-1;T!==-1&&_(T),hr(m.current,E,s,i)}),M=L.useMemo(()=>({"aria-orientation":i==="both"?void 0:i,ref:y,onFocus($){!m.current||!ur($.target)||$.target.setSelectionRange(0,$.target.value.length??0)},onKeyDown($){const S=p?Ha:dr;if(!S.has($.key)||qa($,f)||!m.current)return;const T=s==="rtl",O=T?vt:et,V={horizontal:O,vertical:He,both:O}[i],R=T?et:vt,K={horizontal:R,vertical:Re,both:R}[i];if(ur($.target)&&!_a($.target)){const z=$.target.selectionStart,D=$.target.selectionEnd,B=$.target.value??"";if(z==null||$.shiftKey||z!==D||$.key!==K&&z<B.length||$.key!==V&&z>0)return}let H=N;const te=Ea(v,h),de=Da(v,h);if(k){const z=t||Array.from({length:v.current.length},()=>({width:1,height:1})),D=La(z,n,r),B=D.findIndex(G=>G!=null&&!Qe(v,G,h)),W=D.reduce((G,Q,Y)=>Q!=null&&!Qe(v,Q,h)?Y:G,-1);H=D[Oa({current:D.map(G=>G?v.current[G]:null)},{event:$,orientation:i,loopFocus:o,cols:n,disabledIndices:Ta([...h||v.current.map((G,Q)=>Qe(v,Q)?Q:void 0),void 0],D),minIndex:B,maxIndex:W,prevIndex:Pa(N>de?te:N,z,D,n,$.key===He?"bl":$.key===et?"tr":"tl"),rtl:T})]}const ve={horizontal:[O],vertical:[He],both:[O,He]}[i],se={horizontal:[R],vertical:[Re],both:[R,Re]}[i],re=k?S:{horizontal:p?Fa:lr,vertical:p?Ya:cr,both:S}[i];p&&($.key===wt?H=te:$.key===Ct&&(H=de)),H===N&&(ve.includes($.key)||se.includes($.key))&&(o&&H===de&&ve.includes($.key)?H=te:o&&H===te&&se.includes($.key)?H=de:H=ke(v,{startingIndex:H,decrement:se.includes($.key),disabledIndices:h})),H!==N&&!kt(v,H)&&(u&&$.stopPropagation(),re.has($.key)&&$.preventDefault(),_(H,!0),queueMicrotask(()=>{v.current[H]?.focus()}))}}),[n,r,s,h,v,p,N,k,t,o,y,f,_,i,u]);return L.useMemo(()=>({props:M,highlightedIndex:N,onHighlightedIndexChange:_,elementsRef:v,disabledIndices:h,onMapChange:C,relayKeyboardEvent:M.onKeyDown}),[M,N,_,v,h,C])}function qa(e,t){for(const n of ja.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}const Rt=L.createContext(void 0);process.env.NODE_ENV!=="production"&&(Rt.displayName="CompositeRootContext");function pr(e=!1){const t=L.useContext(Rt);if(t===void 0&&!e)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.":pt(16));return t}const gr=L.createContext(void 0);process.env.NODE_ENV!=="production"&&(gr.displayName="DirectionContext");function Ja(){return L.useContext(gr)?.direction??"ltr"}function Qa(e){const{render:t,className:n,refs:o=mt,props:r=mt,state:i=Se,stateAttributesMapping:s,highlightedIndex:l,onHighlightedIndexChange:c,orientation:d,dense:p,itemSizes:u,loopFocus:h,cols:f,enableHomeAndEndKeys:g,onMapChange:x,stopEventPropagation:k=!0,rootRef:m,disabledIndices:y,modifierKeys:v,highlightItemOnHover:w=!1,tag:N="div",..._}=e,C=Ja(),{props:M,highlightedIndex:$,onHighlightedIndexChange:S,elementsRef:E,onMapChange:T,relayKeyboardEvent:O}=Za({itemSizes:u,cols:f,loopFocus:h,dense:p,orientation:d,highlightedIndex:l,onHighlightedIndexChange:c,rootRef:m,stopEventPropagation:k,enableHomeAndEndKeys:g,direction:C,disabledIndices:y,modifierKeys:v}),V=xt(N,e,{state:i,ref:o,props:[M,...r,_],stateAttributesMapping:s}),R=L.useMemo(()=>({highlightedIndex:$,onHighlightedIndexChange:S,highlightItemOnHover:w,relayKeyboardEvent:O}),[$,S,w,O]);return a.jsx(Rt.Provider,{value:R,children:a.jsx(Ca,{elementsRef:E,onMapChange:K=>{x?.(K),T(K)},children:V})})}const yr=L.createContext(void 0);process.env.NODE_ENV!=="production"&&(yr.displayName="ToolbarRootContext");function Ra(e){return L.useContext(yr)}const en=L.createContext(void 0);process.env.NODE_ENV!=="production"&&(en.displayName="ToggleGroupContext");function el(e=!0){const t=L.useContext(en);if(t===void 0&&!e)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: ToggleGroupContext is missing. ToggleGroup parts must be placed within <ToggleGroup>.":pt(7));return t}let tl=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const mr={multiple(e){return e?{[tl.multiple]:""}:null}},xr=L.forwardRef(function(t,n){const{defaultValue:o,disabled:r=!1,loopFocus:i=!0,onValueChange:s,orientation:l="horizontal",multiple:c=!1,value:d,className:p,render:u,...h}=t,f=Ra(),g=L.useMemo(()=>{if(d===void 0)return o??[]},[d,o]),x=(f?.disabled??!1)||r,[k,m]=er({controlled:d,default:g,name:"ToggleGroup",state:"value"}),y=Me((C,M,$)=>{let S;if(c?(S=k.slice(),M?S.push(C):S.splice(k.indexOf(C),1)):S=M?[C]:[],Array.isArray(S)){if(s?.(S,$),$.isCanceled)return;m(S)}}),v=L.useMemo(()=>({disabled:x,multiple:c,orientation:l}),[x,l,c]),w=L.useMemo(()=>({disabled:x,orientation:l,setGroupValue:y,value:k}),[x,l,y,k]),N={role:"group"},_=xt("div",t,{enabled:!!f,state:v,ref:n,props:[N,h],stateAttributesMapping:mr});return a.jsx(en.Provider,{value:w,children:f?_:a.jsx(Qa,{render:u,className:p,state:v,refs:[n],props:[N,h],stateAttributesMapping:mr,loopFocus:i})})});process.env.NODE_ENV!=="production"&&(xr.displayName="ToggleGroup");const nl={...L};let br=0;function rl(e,t="mui"){const[n,o]=L.useState(e),r=e||n;return L.useEffect(()=>{n==null&&(br+=1,o(`${t}-${br}`))},[n,t]),r}const kr=nl.useId;function ol(e,t){if(kr!==void 0){const n=kr();return e??`${t}-${n}`}return rl(e,t)}function il(e){return ol(e,"base-ui")}let tn;process.env.NODE_ENV!=="production"&&(tn=new Set);function vr(...e){if(process.env.NODE_ENV!=="production"){const t=e.join(" ");tn.has(t)||(tn.add(t),console.error(`Base UI: ${t}`))}}function sl(e){const{focusableWhenDisabled:t,disabled:n,composite:o=!1,tabIndex:r=0,isNativeButton:i}=e,s=o&&t!==!1,l=o&&t===!1;return{props:L.useMemo(()=>{const d={onKeyDown(p){n&&t&&p.key!=="Tab"&&p.preventDefault()}};return o||(d.tabIndex=r,!i&&n&&(d.tabIndex=t?r:-1)),(i&&(t||s)||!i&&n)&&(d["aria-disabled"]=n),i&&(!t||l)&&(d.disabled=n),d},[o,n,t,s,l,i,r])}}function al(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:o=0,native:r=!0}=e,i=L.useRef(null),s=pr(!0)!==void 0,l=Me(()=>{const h=i.current;return!!(h?.tagName==="A"&&h?.href)}),{props:c}=sl({focusableWhenDisabled:n,disabled:t,composite:s,tabIndex:o,isNativeButton:r});process.env.NODE_ENV!=="production"&&L.useEffect(()=>{if(!i.current)return;const h=i.current.tagName==="BUTTON";r?h||vr("A component that acts as a button was not rendered as a native <button>, which does not match the default. Ensure that the element passed to the `render` prop of the component is a real <button>, or set the `nativeButton` prop on the component to `false`."):h&&vr("A component that acts as a button was rendered as a native <button>, which does not match the default. Ensure that the element passed to the `render` prop of the component is not a real <button>, or set the `nativeButton` prop on the component to `true`.")},[r]);const d=L.useCallback(()=>{const h=i.current;ll(h)&&s&&t&&c.disabled===void 0&&h.disabled&&(h.disabled=!1)},[t,c.disabled,s]);Ae(d,[d]);const p=L.useCallback((h={})=>{const{onClick:f,onMouseDown:g,onKeyUp:x,onKeyDown:k,onPointerDown:m,...y}=h;return or({type:r?"button":void 0,onClick(w){if(t){w.preventDefault();return}f?.(w)},onMouseDown(w){t||g?.(w)},onKeyDown(w){if(t||(Kt(w),k?.(w)),w.baseUIHandlerPrevented)return;const N=w.target===w.currentTarget&&!r&&!l()&&!t,_=w.key==="Enter",C=w.key===" ";N&&((C||_)&&w.preventDefault(),_&&f?.(w))},onKeyUp(w){t||(Kt(w),x?.(w)),!w.baseUIHandlerPrevented&&w.target===w.currentTarget&&!r&&!t&&w.key===" "&&f?.(w)},onPointerDown(w){if(t){w.preventDefault();return}m?.(w)}},r?void 0:{role:"button"},c,y)},[t,c,r,l]),u=Me(h=>{i.current=h,d()});return{getButtonProps:p,buttonRef:u}}function ll(e){return qt(e)&&e.tagName==="BUTTON"}let cl=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function dl(e={}){const{label:t,metadata:n,textRef:o,indexGuessBehavior:r,index:i}=e,{register:s,unregister:l,subscribeMapChange:c,elementsRef:d,labelsRef:p,nextIndexRef:u}=wa(),h=L.useRef(-1),[f,g]=L.useState(i??(r===cl.GuessFromOrder?()=>{if(h.current===-1){const m=u.current;u.current+=1,h.current=m}return h.current}:-1)),x=L.useRef(null),k=L.useCallback(m=>{if(x.current=m,f!==-1&&m!==null&&(d.current[f]=m,p)){const y=t!==void 0;p.current[f]=y?t:o?.current?.textContent??m.textContent}},[f,d,p,t,o]);return Ae(()=>{if(i!=null)return;const m=x.current;if(m)return s(m,n),()=>{l(m)}},[i,s,l,n]),Ae(()=>{if(i==null)return c(m=>{const y=x.current?m.get(x.current)?.index:null;y!=null&&g(y)})},[i,c,g]),L.useMemo(()=>({ref:k,index:f}),[f,k])}function ul(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:o}=pr(),{ref:r,index:i}=dl(e),s=n===i,l=L.useRef(null),c=gt(r,l);return{compositeProps:L.useMemo(()=>({tabIndex:s?0:-1,onFocus(){o(i)},onMouseMove(){const p=l.current;if(!t||!p)return;const u=p.hasAttribute("disabled")||p.ariaDisabled==="true";!s&&!u&&p.focus()}}),[s,o,i,t]),compositeRef:c,index:i}}function hl(e){const{render:t,className:n,state:o=Se,props:r=mt,refs:i=mt,metadata:s,stateAttributesMapping:l,tag:c="div",...d}=e,{compositeProps:p,compositeRef:u}=ul({metadata:s});return xt(c,e,{state:o,ref:[...i,u],props:[p,...r,d],stateAttributesMapping:l})}const fl="none";function pl(e,t,n,o){let r=!1,i=!1;const s=Se;return{reason:e,event:t??new Event("base-ui"),cancel(){r=!0},allowPropagation(){i=!0},get isCanceled(){return r},get isPropagationAllowed(){return i},trigger:n,...s}}const wr=L.forwardRef(function(t,n){const{className:o,defaultPressed:r=!1,disabled:i=!1,form:s,onPressedChange:l,pressed:c,render:d,type:p,value:u,nativeButton:h=!0,...f}=t,g=il(u||void 0),x=el(),k=x?.value??[],m=x?void 0:r,y=(i||x?.disabled)??!1,[v,w]=er({controlled:x?k?.indexOf(g)>-1:c,default:m,name:"Toggle",state:"pressed"}),N=Me((T,O)=>{g&&x?.setGroupValue?.(g,T,O),l?.(T,O)}),{getButtonProps:_,buttonRef:C}=al({disabled:y,native:h}),M=L.useMemo(()=>({disabled:y,pressed:v}),[y,v]),$=[C,n],S=[{"aria-pressed":v,onClick(T){const O=!v,V=pl(fl,T.nativeEvent);N(O,V),!V.isCanceled&&w(O)}},f,_],E=xt("button",t,{enabled:!x,state:M,ref:$,props:S});return x?a.jsx(hl,{tag:"button",render:d,className:o,state:M,refs:$,props:S}):E});process.env.NODE_ENV!=="production"&&(wr.displayName="Toggle");function gl({value:e,onChange:t}){const[n,o]=b.useState(""),r=n?On.filter(i=>i.toLowerCase().includes(n.toLowerCase())):On;return a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"relative",children:[a.jsx(An,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400"}),a.jsx("input",{type:"text",placeholder:"Search icons...",value:n,onChange:i=>o(i.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]}),a.jsx("div",{className:"grid grid-cols-6 gap-1 max-h-40 overflow-y-auto p-1 bg-zinc-50 dark:bg-zinc-800/50 rounded-lg",children:r.map(i=>{const s=Ln(i),l=e===i;return a.jsx("button",{onClick:()=>t(i),title:i,className:`
|
|
62
62
|
p-2 rounded-lg transition-colors
|
|
63
63
|
${l?"bg-blue-500 text-white":"hover:bg-zinc-200 dark:hover:bg-zinc-700 text-zinc-600 dark:text-zinc-400"}
|
|
64
|
-
`,children:a.jsx(s,{className:"w-5 h-5 mx-auto"})},i)})}),a.jsxs("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 text-center",children:["Selected: ",e]})]})}const
|
|
64
|
+
`,children:a.jsx(s,{className:"w-5 h-5 mx-auto"})},i)})}),a.jsxs("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 text-center",children:["Selected: ",e]})]})}const yl={violet:"bg-violet-500",emerald:"bg-emerald-500",blue:"bg-blue-500",amber:"bg-amber-500",zinc:"bg-zinc-500",sky:"bg-sky-500"};function ml({value:e,onChange:t}){return a.jsx("div",{className:"flex items-center gap-2",children:Lt.map(n=>a.jsx("button",{onClick:()=>t(n),title:n,className:`
|
|
65
65
|
w-7 h-7 rounded-full transition-all
|
|
66
|
-
${
|
|
66
|
+
${yl[n]}
|
|
67
67
|
${e===n?"ring-2 ring-offset-2 ring-blue-500 dark:ring-offset-zinc-900 scale-110":"hover:scale-110"}
|
|
68
|
-
`},n))})}const Cr=25,Nr=50;function
|
|
68
|
+
`},n))})}const Cr=25,Nr=50;function tt({label:e,value:t,onChange:n,placeholder:o,type:r="text",className:i=""}){return a.jsxs("div",{className:i,children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:e}),a.jsx("input",{type:r,value:t||"",onChange:s=>n(r==="number"?parseInt(s.target.value)||0:s.target.value),placeholder:o,className:"w-full px-3 py-1.5 text-sm rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]})}const zr={xs:"XS",s:"S",m:"M",l:"L"};function xl({value:e,onChange:t}){return a.jsx(xr,{value:e?[e]:["m"],onValueChange:n=>{n.length>0&&t(n[0])},className:"flex gap-1 bg-zinc-100 dark:bg-zinc-800 p-1 rounded-lg",children:Go.map(n=>a.jsx(wr,{value:n,"aria-label":`Size ${zr[n]}`,className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors uppercase
|
|
69
69
|
data-[pressed]:bg-blue-500 data-[pressed]:text-white
|
|
70
70
|
hover:bg-zinc-200 dark:hover:bg-zinc-700
|
|
71
|
-
text-zinc-600 dark:text-zinc-400`,children:zr[n]||n},n))})}function
|
|
71
|
+
text-zinc-600 dark:text-zinc-400`,children:zr[n]||n},n))})}function bl({nodeId:e}){const{actions:t}=he(),n=Ne(),o=Wt(),r=n.nodes[e],i=n.nodeData[e];if(!r||!i)return null;const s=(y,v)=>{t.updateNode(e,{[y]:v})},l=y=>{t.resizeNode(e,y)},c=(y,v)=>{y==="width"?t.resizeNode(e,void 0,v,void 0):t.resizeNode(e,void 0,void 0,v)},d=(y,v)=>{t.updateNodePosition(e,{[y]:v})},p=J[r.size]||J.m,u=r.width||p.width,h=r.height||p.height,f=r.width!==void 0||r.height!==void 0,g=o==="isometric",x=r.z??0,k=r.isoHeight??Cr,m=r.isoDepth??Nr;return a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-900 dark:text-white",children:"Node Properties"}),a.jsx(tt,{label:"Name",value:i.name,onChange:y=>s("name",y),placeholder:"Node name"}),a.jsx(tt,{label:"Subtitle",value:i.subtitle,onChange:y=>s("subtitle",y),placeholder:"e.g., Swift, TypeScript"}),a.jsx(tt,{label:"Description",value:i.description,onChange:y=>s("description",y),placeholder:"Brief description"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Size"}),a.jsx(xl,{value:r.size,onChange:l}),a.jsxs("div",{className:"flex gap-2 mt-2",children:[a.jsx(tt,{label:"W",type:"number",value:u,onChange:y=>c("width",y),className:"flex-1"}),a.jsx(tt,{label:"H",type:"number",value:h,onChange:y=>c("height",y),className:"flex-1"})]}),f&&a.jsx("button",{onClick:()=>t.resizeNode(e,r.size||"m"),className:"mt-1 text-xs text-blue-500 hover:text-blue-600",children:"Reset to preset"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Color"}),a.jsx(ml,{value:i.color,onChange:y=>s("color",y)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Icon"}),a.jsx(gl,{value:i.icon,onChange:y=>s("icon",y)})]}),g&&a.jsxs("div",{className:"pt-3 border-t border-zinc-200 dark:border-zinc-700",children:[a.jsxs("h4",{className:"text-xs font-semibold text-zinc-700 dark:text-zinc-300 mb-3 flex items-center gap-2",children:[a.jsx("span",{className:"w-4 h-4 rounded bg-gradient-to-br from-violet-500 to-blue-500"}),"3D Properties"]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Elevation (Z)"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"range",min:"0",max:"200",value:x,onChange:y=>d("z",parseInt(y.target.value)),className:"flex-1 h-1.5 bg-zinc-200 dark:bg-zinc-700 rounded-lg appearance-none cursor-pointer accent-violet-500"}),a.jsx("input",{type:"number",value:x,onChange:y=>d("z",parseInt(y.target.value)||0),className:"w-14 px-2 py-1 text-xs text-center rounded border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Box Height"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"range",min:"10",max:"100",value:k,onChange:y=>d("isoHeight",parseInt(y.target.value)),className:"flex-1 h-1.5 bg-zinc-200 dark:bg-zinc-700 rounded-lg appearance-none cursor-pointer accent-violet-500"}),a.jsx("input",{type:"number",value:k,onChange:y=>d("isoHeight",parseInt(y.target.value)||Cr),className:"w-14 px-2 py-1 text-xs text-center rounded border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Box Depth"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"range",min:"20",max:"120",value:m,onChange:y=>d("isoDepth",parseInt(y.target.value)),className:"flex-1 h-1.5 bg-zinc-200 dark:bg-zinc-700 rounded-lg appearance-none cursor-pointer accent-violet-500"}),a.jsx("input",{type:"number",value:m,onChange:y=>d("isoDepth",parseInt(y.target.value)||Nr),className:"w-14 px-2 py-1 text-xs text-center rounded border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]})]}),(r.z!==void 0||r.isoHeight!==void 0||r.isoDepth!==void 0)&&a.jsx("button",{onClick:()=>{t.updateNodePosition(e,{z:void 0,isoHeight:void 0,isoDepth:void 0})},className:"text-xs text-blue-500 hover:text-blue-600",children:"Reset to defaults"})]})]}),a.jsx("div",{className:"pt-2 border-t border-zinc-200 dark:border-zinc-700",children:a.jsxs("div",{className:"text-xs text-zinc-400 space-y-1",children:[a.jsxs("div",{children:["Position: (",r.x,", ",r.y,")",g&&`, Z: ${x}`]}),a.jsxs("div",{children:["ID: ",e]})]})})]})}function Be({label:e,value:t,onChange:n,options:o}){return a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:e}),a.jsx("select",{value:t,onChange:r=>n(r.target.value),className:"w-full px-3 py-1.5 text-sm rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800",children:o.map(r=>a.jsx("option",{value:r.value,children:r.label},r.value))})]})}function kl({connectorIndex:e}){const{actions:t,dispatch:n}=he(),o=Ne(),r=o.connectors[e];if(!r)return null;const i=o.connectorStyles[r.style],s=(u,h)=>{t.updateConnector(e,{[u]:h})},l=(u,h)=>{n({type:"connectorStyle/update",styleName:r.style,updates:{[u]:h}})},c=Object.keys(o.connectorStyles).map(u=>({value:u,label:`${u} (${o.connectorStyles[u].label||u})`})),d=jo.map(u=>({value:u,label:u})),p=Object.keys(o.nodes).map(u=>({value:u,label:o.nodeData[u]?.name||u}));return a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-900 dark:text-white",children:"Connector Properties"}),a.jsx(Be,{label:"Style",value:r.style,onChange:u=>s("style",u),options:c}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsx(Be,{label:"From Node",value:r.from,onChange:u=>s("from",u),options:p}),a.jsx(Be,{label:"From Anchor",value:r.fromAnchor,onChange:u=>s("fromAnchor",u),options:d})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsx(Be,{label:"To Node",value:r.to,onChange:u=>s("to",u),options:p}),a.jsx(Be,{label:"To Anchor",value:r.toAnchor,onChange:u=>s("toAnchor",u),options:d})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Be,{label:"Path Style",value:r.curve||"auto",onChange:u=>s("curve",u==="auto"?void 0:u),options:[{value:"auto",label:"Auto (based on anchors)"},{value:"natural",label:"Natural Curve"}]}),r.curve==="natural"&&a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:["Curve Tension: ",r.curveDepth??50,"%"]}),a.jsx("input",{type:"range",min:"20",max:"100",value:r.curveDepth??50,onChange:u=>s("curveDepth",parseInt(u.target.value)),className:"w-full"})]})]}),a.jsxs("div",{className:"pt-3 border-t border-zinc-200 dark:border-zinc-700 space-y-2",children:[a.jsx("div",{className:"text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Style Options"}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:i?.showArrow!==!1,onChange:u=>l("showArrow",u.target.checked),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Show arrow"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:i?.showEndpoints!==!1,onChange:u=>l("showEndpoints",u.target.checked),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Show endpoint dots"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:i?.dashed===!0,onChange:u=>l("dashed",u.target.checked),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Dashed line"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:i?.bidirectional===!0,onChange:u=>l("bidirectional",u.target.checked),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Bidirectional (arrows at both ends)"})]}),i?.dashed&&a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:i?.animated!==!1,onChange:u=>l("animated",u.target.checked),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Animated motion"})]})]}),a.jsx("div",{className:"pt-2 border-t border-zinc-200 dark:border-zinc-700",children:a.jsxs("div",{className:"text-xs text-zinc-400",children:["Index: ",e," | Style: ",r.style]})})]})}function nt({label:e,value:t,onChange:n,placeholder:o,type:r="text",className:i=""}){return a.jsxs("div",{className:i,children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:e}),a.jsx("input",{type:r,value:t||"",onChange:s=>n(r==="number"?parseInt(s.target.value)||0:s.target.value),placeholder:o,className:"w-full px-3 py-1.5 text-sm rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]})}function vl({value:e,onChange:t}){return a.jsx("div",{className:"flex flex-wrap gap-2",children:Lt.map(n=>a.jsx("button",{onClick:()=>t(n),className:`
|
|
72
72
|
w-6 h-6 rounded-full transition-all
|
|
73
73
|
${e===n?"ring-2 ring-offset-2 ring-blue-500":""}
|
|
74
|
-
`,style:{backgroundColor:{violet:"#8b5cf6",emerald:"#34d399",blue:"#60a5fa",amber:"#fbbf24",zinc:"#71717a",sky:"#38bdf8"}[n]}},n))})}function
|
|
74
|
+
`,style:{backgroundColor:{violet:"#8b5cf6",emerald:"#34d399",blue:"#60a5fa",amber:"#fbbf24",zinc:"#71717a",sky:"#38bdf8"}[n]}},n))})}function wl({value:e,onChange:t}){return a.jsx("div",{className:"flex gap-2",children:["rect","circle"].map(n=>a.jsx("button",{onClick:()=>t(n),className:`
|
|
75
75
|
flex-1 py-1.5 text-xs font-medium rounded-lg transition-colors capitalize
|
|
76
76
|
${e===n?"bg-blue-500 text-white":"bg-zinc-100 dark:bg-zinc-800 hover:bg-zinc-200 dark:hover:bg-zinc-700"}
|
|
77
|
-
`,children:n==="rect"?"Rectangle":"Circle"},n))})}function
|
|
77
|
+
`,children:n==="rect"?"Rectangle":"Circle"},n))})}function Cl({groupId:e}){const{actions:t}=he(),o=Ne().groups?.find(i=>i.id===e);if(!o)return null;const r=(i,s)=>{t.updateGroup(e,{[i]:s})};return a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-900 dark:text-white",children:"Group Properties"}),a.jsx(nt,{label:"Label",value:o.label,onChange:i=>r("label",i),placeholder:"Group label"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Shape"}),a.jsx(wl,{value:o.type,onChange:i=>r("type",i)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Color"}),a.jsx(vl,{value:o.color,onChange:i=>r("color",i)})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"dashed",checked:o.dashed??!0,onChange:i=>r("dashed",i.target.checked),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("label",{htmlFor:"dashed",className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Dashed border"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Dimensions"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx(nt,{label:"X",type:"number",value:o.x,onChange:i=>r("x",i)}),a.jsx(nt,{label:"Y",type:"number",value:o.y,onChange:i=>r("y",i)}),a.jsx(nt,{label:"Width",type:"number",value:o.width,onChange:i=>r("width",i)}),a.jsx(nt,{label:"Height",type:"number",value:o.height,onChange:i=>r("height",i)})]})]}),a.jsx("div",{className:"pt-2 border-t border-zinc-200 dark:border-zinc-700",children:a.jsxs("div",{className:"text-xs text-zinc-400",children:["ID: ",e]})})]})}function Nl({imageId:e}){const{actions:t}=he(),r=(Ne().images||[]).find(l=>l.id===e);if(!r)return null;const i=l=>{t.updateImage(e,l)},s=()=>{t.removeImage(e)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"font-semibold text-sm text-zinc-900 dark:text-zinc-100",children:"Image"}),a.jsx("button",{onClick:s,className:"p-1.5 text-red-500 hover:bg-red-100 dark:hover:bg-red-900/30 rounded",title:"Delete image",children:a.jsx(Yt,{size:16})})]}),a.jsx("div",{className:"border border-zinc-200 dark:border-zinc-700 rounded-lg p-2 bg-zinc-50 dark:bg-zinc-800",children:a.jsx("img",{src:r.src,alt:r.name||"Dropped image",className:"w-full h-auto max-h-32 object-contain"})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-600 dark:text-zinc-400 mb-1",children:"Name"}),a.jsx("input",{type:"text",value:r.name||"",onChange:l=>i({name:l.target.value}),className:`w-full px-2 py-1.5 text-sm border border-zinc-200 dark:border-zinc-700 rounded
|
|
78
78
|
bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100
|
|
79
79
|
focus:outline-none focus:ring-2 focus:ring-blue-500`,placeholder:"Image name"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-600 dark:text-zinc-400 mb-1",children:"X"}),a.jsx("input",{type:"number",value:r.x,onChange:l=>i({x:parseInt(l.target.value)||0}),className:`w-full px-2 py-1.5 text-sm border border-zinc-200 dark:border-zinc-700 rounded
|
|
80
80
|
bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100
|
|
@@ -84,89 +84,89 @@
|
|
|
84
84
|
bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100
|
|
85
85
|
focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-600 dark:text-zinc-400 mb-1",children:"Height"}),a.jsx("input",{type:"number",value:r.height,onChange:l=>i({height:parseInt(l.target.value)||100}),className:`w-full px-2 py-1.5 text-sm border border-zinc-200 dark:border-zinc-700 rounded
|
|
86
86
|
bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100
|
|
87
|
-
focus:outline-none focus:ring-2 focus:ring-blue-500`})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-600 dark:text-zinc-400 mb-1",children:"Opacity"}),a.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:r.opacity??1,onChange:l=>i({opacity:parseFloat(l.target.value)}),className:"w-full"}),a.jsxs("div",{className:"text-xs text-zinc-500 text-right",children:[Math.round((r.opacity??1)*100),"%"]})]})]})}function
|
|
87
|
+
focus:outline-none focus:ring-2 focus:ring-blue-500`})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-600 dark:text-zinc-400 mb-1",children:"Opacity"}),a.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:r.opacity??1,onChange:l=>i({opacity:parseFloat(l.target.value)}),className:"w-full"}),a.jsxs("div",{className:"text-xs text-zinc-500 text-right",children:[Math.round((r.opacity??1)*100),"%"]})]})]})}function zl(){const{dispatch:e}=he(),n=Ne().grid||wn,o=r=>{e({type:"grid/update",updates:r})};return a.jsxs("div",{className:"space-y-4 pt-4 border-t border-zinc-200 dark:border-zinc-700",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Sn,{className:"w-4 h-4 text-zinc-500"}),a.jsx("h3",{className:"text-sm font-semibold text-zinc-900 dark:text-white",children:"Grid Settings"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:n.enabled,onChange:r=>o({enabled:r.target.checked}),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Show grid"})]}),n.enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Grid Type"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>o({type:"dots"}),className:`
|
|
88
88
|
flex-1 px-3 py-1.5 text-xs rounded border transition-colors
|
|
89
89
|
${n.type==="dots"?"bg-blue-50 dark:bg-blue-900/30 border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300":"border-zinc-200 dark:border-zinc-700 text-zinc-600 dark:text-zinc-400 hover:bg-zinc-50 dark:hover:bg-zinc-800"}
|
|
90
90
|
`,children:"Dots"}),a.jsx("button",{onClick:()=>o({type:"lines"}),className:`
|
|
91
91
|
flex-1 px-3 py-1.5 text-xs rounded border transition-colors
|
|
92
92
|
${n.type==="lines"?"bg-blue-50 dark:bg-blue-900/30 border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300":"border-zinc-200 dark:border-zinc-700 text-zinc-600 dark:text-zinc-400 hover:bg-zinc-50 dark:hover:bg-zinc-800"}
|
|
93
|
-
`,children:"Lines"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:["Grid Size: ",n.size,"px"]}),a.jsx("input",{type:"range",min:"10",max:"50",value:n.size,onChange:r=>o({size:parseInt(r.target.value)}),className:"w-full"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Grid Color"}),a.jsxs("div",{className:"flex gap-2",children:[
|
|
93
|
+
`,children:"Lines"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:["Grid Size: ",n.size,"px"]}),a.jsx("input",{type:"range",min:"10",max:"50",value:n.size,onChange:r=>o({size:parseInt(r.target.value)}),className:"w-full"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Grid Color"}),a.jsxs("div",{className:"flex gap-2",children:[Xo.map(({name:r,value:i})=>a.jsx("button",{onClick:()=>o({color:i}),className:`
|
|
94
94
|
w-6 h-6 rounded-full border-2 transition-all
|
|
95
95
|
${n.color===i?"ring-2 ring-offset-2 ring-blue-500 dark:ring-offset-zinc-900":"border-transparent"}
|
|
96
|
-
`,style:{backgroundColor:i},title:r},i)),a.jsx("input",{type:"color",value:n.color,onChange:r=>o({color:r.target.value}),className:"w-6 h-6 rounded cursor-pointer border-0 p-0",title:"Custom color"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:["Opacity: ",Math.round(n.opacity*100),"%"]}),a.jsx("input",{type:"range",min:"5",max:"50",value:n.opacity*100,onChange:r=>o({opacity:parseInt(r.target.value)/100}),className:"w-full"})]})]})]})}const
|
|
97
|
-
w-6 h-6 rounded-full ${
|
|
96
|
+
`,style:{backgroundColor:i},title:r},i)),a.jsx("input",{type:"color",value:n.color,onChange:r=>o({color:r.target.value}),className:"w-6 h-6 rounded cursor-pointer border-0 p-0",title:"Custom color"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:["Opacity: ",Math.round(n.opacity*100),"%"]}),a.jsx("input",{type:"range",min:"5",max:"50",value:n.opacity*100,onChange:r=>o({opacity:parseInt(r.target.value)/100}),className:"w-full"})]})]})]})}const nn={violet:"bg-violet-500",emerald:"bg-emerald-500",blue:"bg-blue-500",amber:"bg-amber-500",zinc:"bg-zinc-500",sky:"bg-sky-500"};function Ml({styleName:e,style:t,onUpdate:n,onDelete:o,connectorsUsingStyle:r}){const[i,s]=b.useState(!1);return a.jsxs("div",{className:"border border-zinc-200 dark:border-zinc-700 rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>s(!i),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-zinc-50 dark:hover:bg-zinc-800/50",children:[i?a.jsx(zn,{className:"w-4 h-4 text-zinc-400"}):a.jsx(Ft,{className:"w-4 h-4 text-zinc-400"}),a.jsx("div",{className:`w-3 h-3 rounded-full ${nn[t.color]}`}),a.jsx("span",{className:"text-sm font-medium text-zinc-900 dark:text-white flex-1",children:e}),a.jsxs("span",{className:"text-xs text-zinc-400",children:[r," connection",r!==1?"s":""]})]}),i&&a.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-3 border-t border-zinc-200 dark:border-zinc-700",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Label"}),a.jsx("input",{type:"text",value:t.label||"",onChange:l=>n({label:l.target.value}),placeholder:"Optional label",className:"w-full px-2 py-1.5 text-sm rounded border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Color"}),a.jsx("div",{className:"flex gap-1.5",children:Lt.map(l=>a.jsx("button",{onClick:()=>n({color:l}),className:`
|
|
97
|
+
w-6 h-6 rounded-full ${nn[l]}
|
|
98
98
|
${t.color===l?"ring-2 ring-offset-2 ring-blue-500 dark:ring-offset-zinc-900":""}
|
|
99
|
-
`},l))})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:["Stroke Width: ",t.strokeWidth||2]}),a.jsx("input",{type:"range",min:"1",max:"6",value:t.strokeWidth||2,onChange:l=>n({strokeWidth:parseInt(l.target.value)}),className:"w-full"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.dashed===!0,onChange:l=>n({dashed:l.target.checked}),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Dashed"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.showArrow!==!1,onChange:l=>n({showArrow:l.target.checked}),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Show arrow"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.showEndpoints!==!1,onChange:l=>n({showEndpoints:l.target.checked}),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Show endpoint dots"})]})]}),r===0&&a.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 text-xs text-red-600 dark:text-red-400 hover:text-red-700",children:[a.jsx(
|
|
99
|
+
`},l))})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:["Stroke Width: ",t.strokeWidth||2]}),a.jsx("input",{type:"range",min:"1",max:"6",value:t.strokeWidth||2,onChange:l=>n({strokeWidth:parseInt(l.target.value)}),className:"w-full"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.dashed===!0,onChange:l=>n({dashed:l.target.checked}),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Dashed"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.showArrow!==!1,onChange:l=>n({showArrow:l.target.checked}),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Show arrow"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.showEndpoints!==!1,onChange:l=>n({showEndpoints:l.target.checked}),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Show endpoint dots"})]})]}),r===0&&a.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 text-xs text-red-600 dark:text-red-400 hover:text-red-700",children:[a.jsx(Yt,{className:"w-3.5 h-3.5"}),"Delete style"]})]})]})}function _l(){const{dispatch:e,actions:t}=he(),n=Ne(),[o,r]=b.useState(""),[i,s]=b.useState(!0),l={};for(const u of Object.keys(n.connectorStyles))l[u]=n.connectors.filter(h=>h.style===u).length;const c=(u,h)=>{e({type:"connectorStyle/update",styleName:u,updates:h})},d=()=>{if(!o.trim())return;const u=o.toLowerCase().replace(/[^a-z0-9]/g,"");!u||n.connectorStyles[u]||(e({type:"connectorStyle/add",styleName:u,style:{color:"zinc",strokeWidth:2,label:o,dashed:!1,showArrow:!0,showEndpoints:!0}}),r(""))},p=u=>{e({type:"connectorStyle/delete",styleName:u})};return a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-900 dark:text-white",children:"Connector Styles"}),a.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Define reusable styles for connectors. Click a style to edit it."}),a.jsx("div",{className:"space-y-2",children:Object.entries(n.connectorStyles).map(([u,h])=>a.jsx(Ml,{styleName:u,style:h,onUpdate:f=>c(u,f),onDelete:()=>p(u),connectorsUsingStyle:l[u]||0},u))}),a.jsxs("div",{className:"pt-3 border-t border-zinc-200 dark:border-zinc-700",children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Add New Style"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:o,onChange:u=>r(u.target.value),onKeyDown:u=>u.key==="Enter"&&d(),placeholder:"Style name...",className:"flex-1 px-2 py-1.5 text-sm rounded border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"}),a.jsx("button",{onClick:d,disabled:!o.trim(),className:"px-3 py-1.5 text-sm bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed",children:a.jsx(In,{className:"w-4 h-4"})})]})]}),a.jsxs("div",{className:"pt-4 mt-4 border-t border-zinc-200 dark:border-zinc-700",children:[a.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-2 text-sm font-semibold text-zinc-900 dark:text-white mb-2",children:[i?a.jsx(zn,{className:"w-4 h-4"}):a.jsx(Ft,{className:"w-4 h-4"}),"Connections (",n.connectors.length,")"]}),i&&a.jsx("div",{className:"space-y-1",children:n.connectors.map((u,h)=>{const f=n.nodeData[u.from]?.name||u.from,g=n.nodeData[u.to]?.name||u.to,x=n.connectorStyles[u.style];return a.jsxs("button",{onClick:()=>t.selectConnector(h),className:"w-full flex items-center gap-2 px-2 py-1.5 text-left text-xs rounded hover:bg-zinc-100 dark:hover:bg-zinc-800",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${nn[x?.color]||"bg-zinc-400"}`}),a.jsxs("span",{className:"text-zinc-600 dark:text-zinc-400 truncate",children:[f," → ",g]}),a.jsx("span",{className:"text-zinc-400 dark:text-zinc-500 ml-auto",children:u.style})]},h)})})]}),a.jsx(zl,{})]})}function Sl(){const e=Ve(),[t,n]=b.useState(!1),[o,r]=b.useState(!1),i=b.useRef(!1),s=e.selectedNodeIds?.length>0,l=e.selectedConnectorIndex!==null,c=e.selectedGroupId!==null,d=e.selectedImageId!==null,p=s||l||c||d,u=e.selectedNodeIds?.[0];b.useEffect(()=>{p&&!i.current&&t&&!o&&n(!1),i.current=p},[p,t,o]);const h=()=>{const f=!t;n(f),r(f)};return a.jsxs(a.Fragment,{children:[t&&a.jsx("button",{onClick:()=>{n(!1),r(!1)},className:"absolute right-4 top-4 z-20 p-2 bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg shadow-lg hover:bg-zinc-50 dark:hover:bg-zinc-700 transition-all",title:"Show inspector",children:a.jsx(Bi,{className:"w-4 h-4 text-zinc-500"})}),a.jsxs("div",{className:`flex-shrink-0 bg-white dark:bg-zinc-900 border-l border-zinc-200 dark:border-zinc-800 transition-all duration-300 ease-in-out relative ${t?"w-0 overflow-hidden border-l-0":"w-72 overflow-y-auto"}`,children:[!t&&a.jsx("button",{onClick:h,className:"absolute top-4 -left-3 z-10 p-1.5 bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-lg shadow-sm hover:bg-zinc-50 dark:hover:bg-zinc-700 transition-all",title:"Hide inspector",children:a.jsx(Ft,{className:"w-4 h-4 text-zinc-500"})}),a.jsxs("div",{className:`p-4 ${t?"opacity-0":"opacity-100"} transition-opacity duration-200`,children:[s&&a.jsxs(a.Fragment,{children:[e.selectedNodeIds.length>1&&a.jsxs("div",{className:"mb-3 px-2 py-1 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 text-xs rounded",children:[e.selectedNodeIds.length," nodes selected"]}),a.jsx(bl,{nodeId:u})]}),l&&a.jsx(kl,{connectorIndex:e.selectedConnectorIndex}),c&&a.jsx(Cl,{groupId:e.selectedGroupId}),d&&a.jsx(Nl,{imageId:e.selectedImageId}),!p&&a.jsx(_l,{})]})]})]})}function Mr(e,t,n,o,r){switch(r){case"left":return{x:e,y:t+o/2};case"right":return{x:e+n,y:t+o/2};case"top":return{x:e+n/2,y:t};case"bottom":return{x:e+n/2,y:t+o};case"bottomRight":return{x:e+n,y:t+o-15};case"bottomLeft":return{x:e,y:t+o-15};case"topRight":return{x:e+n,y:t+15};case"topLeft":return{x:e,y:t+15};default:return{x:e+n/2,y:t+o/2}}}function $l(e,t,n,o){const r=t.x-e.x,i=t.y-e.y;let s=e.x,l=e.y,c=t.x,d=t.y;const p=Math.min(Math.abs(r),Math.abs(i),50);return n==="right"||n==="bottomRight"||n==="topRight"?s=e.x+p:n==="left"||n==="bottomLeft"||n==="topLeft"?s=e.x-p:n==="bottom"?l=e.y+p:n==="top"&&(l=e.y-p),o==="left"||o==="bottomLeft"||o==="topLeft"?c=t.x-p:o==="right"||o==="bottomRight"||o==="topRight"?c=t.x+p:o==="top"?d=t.y-p:o==="bottom"&&(d=t.y+p),`M ${e.x} ${e.y} C ${s} ${l}, ${c} ${d}, ${t.x} ${t.y}`}const rn={violet:{bg:"#8b5cf6",text:"#ffffff"},emerald:{bg:"#34d399",text:"#ffffff"},blue:{bg:"#60a5fa",text:"#ffffff"},amber:{bg:"#fbbf24",text:"#1f2937"},zinc:{bg:"#71717a",text:"#ffffff"},sky:{bg:"#38bdf8",text:"#ffffff"}},_r={violet:{fill:"rgba(139, 92, 246, 0.1)",stroke:"rgba(139, 92, 246, 0.5)"},emerald:{fill:"rgba(52, 211, 153, 0.1)",stroke:"rgba(52, 211, 153, 0.5)"},blue:{fill:"rgba(96, 165, 250, 0.1)",stroke:"rgba(96, 165, 250, 0.5)"},amber:{fill:"rgba(251, 191, 36, 0.1)",stroke:"rgba(251, 191, 36, 0.5)"},zinc:{fill:"rgba(113, 113, 122, 0.1)",stroke:"rgba(113, 113, 122, 0.5)"},sky:{fill:"rgba(56, 189, 248, 0.1)",stroke:"rgba(56, 189, 248, 0.5)"}};function on(e,t={}){const{backgroundColor:n="#ffffff",includeGrid:o=!1,padding:r=20}=t,i=e.exportZone||{x:0,y:0,width:e.layout.width,height:e.layout.height},s=`${i.x-r} ${i.y-r} ${i.width+r*2} ${i.height+r*2}`,l=i.width+r*2,c=i.height+r*2;let d=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${c}" viewBox="${s}">
|
|
100
100
|
`;if(d+=` <rect x="${i.x-r}" y="${i.y-r}" width="${i.width+r*2}" height="${i.height+r*2}" fill="${n}"/>
|
|
101
|
-
`,o&&e.grid?.enabled){const h=e.grid.size||20,
|
|
101
|
+
`,o&&e.grid?.enabled){const h=e.grid.size||20,f=e.grid.color||"#e5e7eb";d+=` <defs>
|
|
102
102
|
`,d+=` <pattern id="grid" width="${h}" height="${h}" patternUnits="userSpaceOnUse">
|
|
103
|
-
`,e.grid.type==="dots"?d+=` <circle cx="${h/2}" cy="${h/2}" r="1" fill="${
|
|
104
|
-
`:d+=` <path d="M ${h} 0 L 0 0 0 ${h}" fill="none" stroke="${
|
|
103
|
+
`,e.grid.type==="dots"?d+=` <circle cx="${h/2}" cy="${h/2}" r="1" fill="${f}"/>
|
|
104
|
+
`:d+=` <path d="M ${h} 0 L 0 0 0 ${h}" fill="none" stroke="${f}" stroke-width="0.5"/>
|
|
105
105
|
`,d+=` </pattern>
|
|
106
106
|
`,d+=` </defs>
|
|
107
107
|
`,d+=` <rect x="${i.x-r}" y="${i.y-r}" width="${i.width+r*2}" height="${i.height+r*2}" fill="url(#grid)"/>
|
|
108
|
-
`}const
|
|
109
|
-
`:d+=` <rect x="${h.x}" y="${h.y}" width="${h.width}" height="${h.height}" rx="12" fill="${
|
|
110
|
-
`,h.label&&(d+=` <text x="${h.x+12}" y="${h.y+20}" fill="${
|
|
108
|
+
`}const p=e.groups||[];for(const h of p){const f=_r[h.color]||_r.zinc;h.type==="circle"?d+=` <ellipse cx="${h.x+h.width/2}" cy="${h.y+h.height/2}" rx="${h.width/2}" ry="${h.height/2}" fill="${f.fill}" stroke="${f.stroke}" stroke-width="1.5"${h.dashed?' stroke-dasharray="8 4"':""}/>
|
|
109
|
+
`:d+=` <rect x="${h.x}" y="${h.y}" width="${h.width}" height="${h.height}" rx="12" fill="${f.fill}" stroke="${f.stroke}" stroke-width="1.5"${h.dashed?' stroke-dasharray="8 4"':""}/>
|
|
110
|
+
`,h.label&&(d+=` <text x="${h.x+12}" y="${h.y+20}" fill="${f.stroke}" font-size="12" font-weight="500" font-family="ui-sans-serif, system-ui, sans-serif">${zt(h.label)}</text>
|
|
111
111
|
`)}const u=e.images||[];for(const h of u)d+=` <image href="${h.src}" x="${h.x}" y="${h.y}" width="${h.width}" height="${h.height}" opacity="${h.opacity??1}" preserveAspectRatio="xMidYMid meet"/>
|
|
112
|
-
`;for(const h of e.connectors){const
|
|
113
|
-
`,d+=` <circle cx="${
|
|
114
|
-
`,
|
|
115
|
-
`}}for(const[h,
|
|
116
|
-
`;const
|
|
117
|
-
`,g.subtitle&&
|
|
118
|
-
`)}return d+="</svg>",d}async function
|
|
112
|
+
`;for(const h of e.connectors){const f=e.nodes[h.from],g=e.nodes[h.to];if(!f||!g)continue;e.nodeData[h.from],e.nodeData[h.to];const x=J[f.size]||J.m,k=J[g.size]||J.m,m=e.connectorStyles?.[h.style]||{color:"zinc",strokeWidth:2},y=rn[m.color]?.bg||"#71717a",v=Mr(f.x,f.y,f.width||x.width,f.height||x.height,h.fromAnchor),w=Mr(g.x,g.y,g.width||k.width,g.height||k.height,h.toAnchor),N=$l(v,w,h.fromAnchor,h.toAnchor);if(d+=` <path d="${N}" fill="none" stroke="${y}" stroke-width="${m.strokeWidth||2}"${m.dashed?' stroke-dasharray="6 3"':""}/>
|
|
113
|
+
`,d+=` <circle cx="${w.x}" cy="${w.y}" r="4" fill="${y}"/>
|
|
114
|
+
`,m.label){const _=(v.x+w.x)/2,C=(v.y+w.y)/2;d+=` <text x="${_}" y="${C-8}" text-anchor="middle" fill="${y}" font-size="10" font-family="ui-sans-serif, system-ui, sans-serif">${zt(m.label)}</text>
|
|
115
|
+
`}}for(const[h,f]of Object.entries(e.nodes)){const g=e.nodeData[h];if(!g)continue;const x=J[f.size]||J.m,k=f.width||x.width,m=f.height||x.height,y=rn[g.color]||rn.zinc;d+=` <rect x="${f.x}" y="${f.y}" width="${k}" height="${m}" rx="12" fill="${y.bg}"/>
|
|
116
|
+
`;const v=f.size==="xs"?10:f.size==="s"?11:13;d+=` <text x="${f.x+k/2}" y="${f.y+m/2+v/3}" text-anchor="middle" fill="${y.text}" font-size="${v}" font-weight="600" font-family="ui-sans-serif, system-ui, sans-serif">${zt(g.name||"Node")}</text>
|
|
117
|
+
`,g.subtitle&&m>=60&&(d+=` <text x="${f.x+k/2}" y="${f.y+m/2+v+8}" text-anchor="middle" fill="${y.text}" opacity="0.8" font-size="${v-2}" font-family="ui-sans-serif, system-ui, sans-serif">${zt(g.subtitle)}</text>
|
|
118
|
+
`)}return d+="</svg>",d}async function Il(e,t={}){const{scale:n=2,backgroundColor:o="#ffffff"}=t,r=on(e,{backgroundColor:o,...t}),i=new Blob([r],{type:"image/svg+xml;charset=utf-8"}),s=URL.createObjectURL(i);return new Promise((l,c)=>{const d=new Image;d.onload=()=>{const p=document.createElement("canvas");p.width=d.width*n,p.height=d.height*n;const u=p.getContext("2d");u.scale(n,n),u.drawImage(d,0,0),URL.revokeObjectURL(s),p.toBlob(h=>{h?l(h):c(new Error("Failed to generate PNG"))},"image/png")},d.onerror=()=>{URL.revokeObjectURL(s),c(new Error("Failed to load SVG"))},d.src=s})}function Al(e){const t={l:e.layout,n:e.nodes,d:e.nodeData,c:e.connectors,s:e.connectorStyles,g:e.groups,i:e.images,e:e.exportZone},n=JSON.stringify(t),o=btoa(encodeURIComponent(n));return`${window.location.origin+window.location.pathname}#/view/${o}`}function Sr(e,t,n){const o=e instanceof Blob?e:new Blob([e],{type:n}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}function zt(e){return e?e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}function El(e){const t=e.exportZone||{x:0,y:0,width:e.layout.width,height:e.layout.height},n=50,o={},r={};for(const[d,p]of Object.entries(e.nodes)){const u=e.nodeData[d];if(!u)continue;const h=J[p.size]||J.m,f=p.x+(p.width||h.width),g=p.y+(p.height||h.height);p.x<t.x+t.width+n&&f>t.x-n&&p.y<t.y+t.height+n&&g>t.y-n&&(o[d]={x:p.x-t.x,y:p.y-t.y,size:p.size||"m"},r[d]={icon:u.icon||"Box",name:u.name||"Node",...u.subtitle&&{subtitle:u.subtitle},...u.description&&{description:u.description},color:u.color||"zinc"})}const i=e.connectors.filter(d=>o[d.from]&&o[d.to]).map(d=>({from:d.from,to:d.to,fromAnchor:d.fromAnchor,toAnchor:d.toAnchor,style:d.style,...d.curve&&{curve:d.curve}})),s=new Set(i.map(d=>d.style)),l={};for(const d of s){const p=e.connectorStyles?.[d];p&&(l[d]={color:p.color||"zinc",strokeWidth:p.strokeWidth||2,...p.label&&{label:p.label},...p.dashed&&{dashed:!0}})}const c={layout:{width:t.width,height:t.height},nodes:o,nodeData:r,connectors:i,connectorStyles:l};return`import type { ArcDiagramData } from '../ArcDiagram'
|
|
119
119
|
|
|
120
|
-
const diagram: ArcDiagramData = ${
|
|
120
|
+
const diagram: ArcDiagramData = ${Mt(c)}
|
|
121
121
|
|
|
122
122
|
export default diagram
|
|
123
|
-
`}function
|
|
124
|
-
${e.map(i=>`${o}${
|
|
123
|
+
`}function Mt(e,t=0){const n=" ".repeat(t),o=" ".repeat(t+1);if(e==null)return"null";if(typeof e=="string")return`'${e.replace(/'/g,"\\'")}'`;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.length===0?"[]":`[
|
|
124
|
+
${e.map(i=>`${o}${Mt(i,t+1)}`).join(`,
|
|
125
125
|
`)},
|
|
126
|
-
${n}]`;if(typeof e=="object"){const r=Object.entries(e);return r.length===0?"{}":r.every(([,l])=>typeof l!="object"||l===null)&&JSON.stringify(e).length<80&&t>0?`{ ${r.map(([c,d])=>`${c}: ${
|
|
127
|
-
${r.map(([l,c])=>{const d=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(l)?l:`'${l}'`;return`${o}${d}: ${
|
|
126
|
+
${n}]`;if(typeof e=="object"){const r=Object.entries(e);return r.length===0?"{}":r.every(([,l])=>typeof l!="object"||l===null)&&JSON.stringify(e).length<80&&t>0?`{ ${r.map(([c,d])=>`${c}: ${Mt(d,t+1)}`).join(", ")} }`:`{
|
|
127
|
+
${r.map(([l,c])=>{const d=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(l)?l:`'${l}'`;return`${o}${d}: ${Mt(c,t+1)}`}).join(`,
|
|
128
128
|
`)},
|
|
129
|
-
${n}}`}return String(e)}async function
|
|
129
|
+
${n}}`}return String(e)}async function Dl(e,t="diagram.json"){const n=JSON.stringify(e,null,2),o=new Blob([n],{type:"application/json"});try{if("showSaveFilePicker"in window){const s=await window.showSaveFilePicker({suggestedName:t,types:[{description:"Arc Diagram",accept:{"application/json":[".json"]}}]}),l=await s.createWritable();return await l.write(o),await l.close(),s.name}}catch(s){if(s.name==="AbortError")return null;console.error("Save failed:",s)}const r=URL.createObjectURL(o),i=document.createElement("a");return i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r),t}async function Ol(){try{if("showOpenFilePicker"in window){const[e]=await window.showOpenFilePicker({types:[{description:"Arc Diagram",accept:{"application/json":[".json"]}}]}),n=await(await e.getFile()).text();return{diagram:JSON.parse(n),filename:e.name}}}catch(e){if(e.name==="AbortError")return null;console.error("Load failed:",e)}return new Promise(e=>{const t=document.createElement("input");t.type="file",t.accept=".json",t.onchange=async n=>{const o=n.target.files?.[0];if(!o){e(null);return}try{const r=await o.text(),i=JSON.parse(r);e({diagram:i,filename:o.name})}catch(r){console.error("Parse error:",r),e(null)}},t.click()})}async function sn(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){return console.error("Copy failed:",t),!1}}function rt({icon:e,label:t,description:n,onClick:o,loading:r=!1,success:i=!1,secondary:s=!1}){return a.jsxs("button",{onClick:o,disabled:r,className:`
|
|
130
130
|
w-full flex items-start gap-3 p-3 rounded-lg text-left transition-colors
|
|
131
131
|
${s?"bg-zinc-50 dark:bg-zinc-800/50 hover:bg-zinc-100 dark:hover:bg-zinc-800":"bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 hover:border-blue-300 dark:hover:border-blue-600"}
|
|
132
132
|
${r?"opacity-60 cursor-wait":""}
|
|
133
133
|
`,children:[a.jsx("div",{className:`
|
|
134
134
|
p-2 rounded-lg
|
|
135
135
|
${i?"bg-green-100 dark:bg-green-900/30":"bg-zinc-100 dark:bg-zinc-700"}
|
|
136
|
-
`,children:r?a.jsx($i,{className:"w-5 h-5 animate-spin text-zinc-500"}):i?a.jsx(ci,{className:"w-5 h-5 text-green-600 dark:text-green-400"}):a.jsx(e,{className:"w-5 h-5 text-zinc-600 dark:text-zinc-400"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"font-medium text-sm text-zinc-900 dark:text-zinc-100",children:i?"Done!":t}),a.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 mt-0.5",children:n})]})]})}function Sl({diagram:e,cropBounds:t,onCropChange:n}){const o=b.useRef(null),[r,i]=b.useState(null),[s,l]=b.useState(null),c=450,d=250,f=Math.min(c/e.layout.width,d/e.layout.height)*.9,u=e.layout.width*f,h=e.layout.height*f,p=t.x*f,g=t.y*f,x=t.width*f,k=t.height*f,y=b.useCallback(_=>{if(!o.current)return{x:0,y:0};const N=o.current.getBoundingClientRect();return{x:(_.clientX-N.left-(c-u)/2)/f,y:(_.clientY-N.top-(d-h)/2)/f}},[f,u,h]),m=b.useCallback((_,N)=>{_.preventDefault(),_.stopPropagation(),i(N),l({mouse:y(_),bounds:{...t}})},[t,y]),C=b.useCallback(_=>{if(!r||!s)return;const N=y(_),E=N.x-s.mouse.x,S=N.y-s.mouse.y,{bounds:w}=s;let M={...w};if(r==="move")M.x=Math.max(0,Math.min(e.layout.width-w.width,w.x+E)),M.y=Math.max(0,Math.min(e.layout.height-w.height,w.y+S));else{if(r.includes("w")){const $=w.x+E,A=w.width-E;A>=50&&$>=0&&(M.x=$,M.width=A)}if(r.includes("e")){const $=w.width+E;$>=50&&w.x+$<=e.layout.width&&(M.width=$)}if(r.includes("n")){const $=w.y+S,A=w.height-S;A>=50&&$>=0&&(M.y=$,M.height=A)}if(r.includes("s")){const $=w.height+S;$>=50&&w.y+$<=e.layout.height&&(M.height=$)}}n({x:Math.round(M.x),y:Math.round(M.y),width:Math.round(M.width),height:Math.round(M.height)})},[r,s,e.layout,y,n]),v=b.useCallback(()=>{i(null),l(null)},[]),z=b.useMemo(()=>nn(e,{backgroundColor:"#f4f4f5",padding:0}),[e]);return a.jsxs("div",{ref:o,className:"relative bg-zinc-200 dark:bg-zinc-700 rounded-lg overflow-hidden select-none",style:{width:c,height:d},onMouseMove:r?C:void 0,onMouseUp:r?v:void 0,onMouseLeave:r?v:void 0,children:[a.jsxs("div",{className:"absolute",style:{left:(c-u)/2,top:(d-h)/2,width:u,height:h},children:[a.jsx("div",{className:"w-full h-full opacity-40",dangerouslySetInnerHTML:{__html:z},style:{pointerEvents:"none"}}),a.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${u} ${h}`,children:[a.jsx("defs",{children:a.jsxs("mask",{id:"cropMask",children:[a.jsx("rect",{width:"100%",height:"100%",fill:"white"}),a.jsx("rect",{x:p,y:g,width:x,height:k,fill:"black"})]})}),a.jsx("rect",{width:"100%",height:"100%",fill:"rgba(0,0,0,0.5)",mask:"url(#cropMask)"}),a.jsx("rect",{x:p,y:g,width:x,height:k,fill:"none",stroke:"#3b82f6",strokeWidth:2,className:"cursor-move",onMouseDown:_=>m(_,"move")}),[{x:p,y:g,cursor:"nwse-resize",type:"nw"},{x:p+x,y:g,cursor:"nesw-resize",type:"ne"},{x:p,y:g+k,cursor:"nesw-resize",type:"sw"},{x:p+x,y:g+k,cursor:"nwse-resize",type:"se"}].map(({x:_,y:N,cursor:E,type:S})=>a.jsx("circle",{cx:_,cy:N,r:6,fill:"#3b82f6",className:`cursor-${E}`,style:{cursor:E},onMouseDown:w=>m(w,S)},S))]})]}),a.jsxs("div",{className:"absolute bottom-2 right-2 px-2 py-1 bg-black/60 rounded text-xs text-white font-mono",children:[Math.round(t.width)," × ",Math.round(t.height)]})]})}function Al({diagram:e,viewportBounds:t,onClose:n}){const[o,r]=b.useState(()=>{if(t&&t.width>0)return{x:Math.max(0,Math.round(t.x)),y:Math.max(0,Math.round(t.y)),width:Math.round(Math.min(t.width,e.layout.width)),height:Math.round(Math.min(t.height,e.layout.height))};const A=Math.min(800,e.layout.width*.8),B=Math.min(600,e.layout.height*.8);return{x:Math.round((e.layout.width-A)/2),y:Math.round((e.layout.height-B)/2),width:Math.round(A),height:Math.round(B)}}),[i,s]=b.useState(!1),[l,c]=b.useState(!1),[d,f]=b.useState(!1),[u,h]=b.useState(!1),[p,g]=b.useState(!1),[x,k]=b.useState(!1),[y,m]=b.useState(!1),C=b.useMemo(()=>({...e,exportZone:o}),[e,o]),v=b.useMemo(()=>JSON.stringify(C,null,2),[C]),z=b.useMemo(()=>Ml(C),[C]),_=b.useMemo(()=>zl(C),[C]),N=async()=>{await rn(v)&&(s(!0),setTimeout(()=>s(!1),2e3))},E=async()=>{await rn(z)&&(c(!0),setTimeout(()=>c(!1),2e3))},S=async()=>{await rn(_)&&(f(!0),setTimeout(()=>f(!1),2e3))},w=async()=>{h(!0);try{const A=nn(C,{backgroundColor:"#ffffff"});$r(A,"diagram.svg","image/svg+xml"),k(!0),setTimeout(()=>k(!1),2e3)}finally{h(!1)}},M=async()=>{g(!0);try{const A=await Nl(C,{scale:2,backgroundColor:"#ffffff"});$r(A,"diagram.png","image/png"),m(!0),setTimeout(()=>m(!1),2e3)}catch(A){console.error("PNG generation failed:",A)}finally{g(!1)}},$=()=>{r({x:0,y:0,width:e.layout.width,height:e.layout.height})};return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",children:a.jsxs("div",{className:"w-full max-w-xl bg-zinc-100 dark:bg-zinc-900 rounded-2xl shadow-2xl overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-white dark:bg-zinc-800 border-b border-zinc-200 dark:border-zinc-700",children:[a.jsx("h2",{className:"text-lg font-semibold text-zinc-900 dark:text-white",children:"Share"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:$,className:"flex items-center gap-1 px-2 py-1 text-xs text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-700 rounded transition-colors",title:"Reset to full canvas",children:[a.jsx(ji,{className:"w-3 h-3"}),"Reset"]}),a.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-zinc-100 dark:hover:bg-zinc-700 transition-colors",children:a.jsx(as,{className:"w-5 h-5"})})]})]}),a.jsx("div",{className:"p-4 flex justify-center",children:a.jsx(Sl,{diagram:e,cropBounds:o,onCropChange:r})}),a.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx(et,{icon:Mn,label:"Copy TypeScript",description:"ArcDiagram format",onClick:E,success:l}),a.jsx(et,{icon:ii,label:"Copy JSON",description:"Raw data",onClick:N,success:i})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx(et,{icon:yi,label:"Download SVG",description:"Vector",onClick:w,loading:u,success:x,secondary:!0}),a.jsx(et,{icon:Ni,label:"Download PNG",description:"2x resolution",onClick:M,loading:p,success:y,secondary:!0})]}),a.jsx(et,{icon:_i,label:"Copy Link",description:"Shareable URL with embedded data",onClick:S,success:d,secondary:!0})]})]})})}function Il({onDelete:e,onUndo:t,onRedo:n,onSave:o,onNew:r,onEscape:i,onSetMode:s}){const l=b.useCallback(c=>{if(c.target.tagName==="INPUT"||c.target.tagName==="TEXTAREA"){c.key==="Escape"&&c.target.blur();return}const d=c.metaKey||c.ctrlKey;if((c.key==="Delete"||c.key==="Backspace")&&!d){c.preventDefault(),e?.();return}if(c.key==="Escape"){c.preventDefault(),i?.();return}if(d&&c.key==="z"&&!c.shiftKey){c.preventDefault(),t?.();return}if(d&&c.key==="z"&&c.shiftKey){c.preventDefault(),n?.();return}if(d&&c.key==="s"){c.preventDefault(),o?.();return}if(d&&c.key==="n"){c.preventDefault(),r?.();return}if(!d&&!c.shiftKey&&!c.altKey)switch(c.key.toLowerCase()){case"v":c.preventDefault(),s?.("select");return;case"h":c.preventDefault(),s?.("pan");return;case"n":c.preventDefault(),s?.("addNode");return;case"c":c.preventDefault(),s?.("addConnector");return}},[e,t,n,o,r,i,s]);b.useEffect(()=>(window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)),[l])}const El={layout:{width:1600,height:900},grid:{enabled:!0,size:24,color:"#71717a",opacity:.1,type:"dots"},nodes:{talkie:{x:50,y:45,size:"l"},talkieLive:{x:50,y:155,size:"m"},talkieEngine:{x:50,y:255,size:"m"},talkieServer:{x:360,y:55,size:"m"},iCloud:{x:380,y:255,size:"m"},iPhone:{x:600,y:55,size:"m"},watch:{x:620,y:155,size:"s"}},nodeData:{talkie:{icon:"Monitor",name:"Talkie",subtitle:"Swift/SwiftUI",description:"UI, Workflows, Data, Orchestration",color:"violet"},talkieLive:{icon:"Mic",name:"TalkieLive",subtitle:"Swift",description:"Ears & Hands",color:"emerald"},talkieEngine:{icon:"Cpu",name:"TalkieEngine",subtitle:"Swift",description:"Local Brain",color:"blue"},talkieServer:{icon:"Server",name:"TalkieServer",subtitle:"TypeScript",description:"iOS Bridge",color:"amber"},iCloud:{icon:"Cloud",name:"iCloud",subtitle:"CloudKit",description:"Memo Sync",color:"sky"},iPhone:{icon:"Smartphone",name:"iPhone",subtitle:"iOS",description:"Voice Capture",color:"zinc"},watch:{icon:"Watch",name:"Watch",subtitle:"watchOS",color:"zinc"}},connectors:[{from:"talkie",to:"talkieLive",fromAnchor:"bottom",toAnchor:"top",style:"xpc"},{from:"talkieLive",to:"talkieEngine",fromAnchor:"bottom",toAnchor:"top",style:"audio"},{from:"talkie",to:"talkieServer",fromAnchor:"right",toAnchor:"left",style:"http"},{from:"talkieServer",to:"iPhone",fromAnchor:"right",toAnchor:"left",style:"tailscale"},{from:"iPhone",to:"watch",fromAnchor:"bottom",toAnchor:"top",style:"peer"},{from:"talkie",to:"iCloud",fromAnchor:"bottomRight",toAnchor:"left",style:"cloudkit",curve:"natural"},{from:"iPhone",to:"iCloud",fromAnchor:"bottomLeft",toAnchor:"right",style:"cloudkit",curve:"natural"}],connectorStyles:{xpc:{color:"sky",strokeWidth:2,label:"",dashed:!0},http:{color:"amber",strokeWidth:2,label:"HTTP",dashed:!0},tailscale:{color:"sky",strokeWidth:2,label:"Tailscale",dashed:!0},cloudkit:{color:"sky",strokeWidth:2,label:"",dashed:!0},audio:{color:"sky",strokeWidth:2,label:"",dashed:!0},peer:{color:"sky",strokeWidth:2,label:"",dashed:!0}}};function Dl({isDark:e,onToggleTheme:t}){const{actions:n}=le(),o=ke(),r=je(),i=Hn(),[s,l]=b.useState(!1),[c,d]=b.useState(null);gs({title:"Arc Editor | Visual Diagram Builder",description:"Drag-and-drop diagram builder with real-time preview and JSON export.",image:"/og-editor.png",url:"/editor"});const f=b.useCallback(()=>{i.isDirty&&!window.confirm("Discard unsaved changes?")||n.newDiagram()},[i.isDirty,n]),u=b.useCallback(async()=>{if(i.isDirty&&!window.confirm("Discard unsaved changes?"))return;const k=await $l();k&&n.loadDiagram(k.diagram,k.filename)},[i.isDirty,n]),h=b.useCallback(async()=>{const k=await _l(o,i.filename||"diagram.json");k&&n.markSaved(k)},[o,i.filename,n]),p=b.useCallback(()=>{l(!0)},[]),g=b.useCallback(()=>{if(r.selectedNodeIds?.length>0)for(const k of r.selectedNodeIds)n.removeNode(k);else r.selectedConnectorIndex!==null?n.removeConnector(r.selectedConnectorIndex):r.selectedGroupId!==null&&n.removeGroup(r.selectedGroupId)},[r.selectedNodeIds,r.selectedConnectorIndex,r.selectedGroupId,n]),x=b.useCallback(()=>{r.pendingConnector?n.clearPendingConnector():r.mode!=="select"?n.setMode("select"):n.clearSelection()},[r.mode,r.pendingConnector,n]);return Il({onDelete:g,onUndo:n.undo,onRedo:n.redo,onSave:h,onNew:f,onEscape:x,onSetMode:n.setMode}),a.jsxs("div",{className:"flex flex-col h-screen bg-zinc-100 dark:bg-zinc-950",children:[a.jsx(ms,{onNew:f,onOpen:u,onSave:h,onShare:p,isDark:e,onToggleTheme:t}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[a.jsxs("div",{className:"flex-1 relative p-4 overflow-hidden",children:[a.jsx("div",{className:"w-full h-full rounded-xl overflow-hidden border border-zinc-200 dark:border-zinc-800 shadow-sm",children:a.jsx(Qn,{onViewportChange:d,embedConfig:{enableViewModeToggle:!0}})}),a.jsx(xs,{})]}),a.jsx(wl,{})]}),s&&a.jsx(Al,{diagram:o,viewportBounds:c,onClose:()=>l(!1)})]})}function Ol({isDark:e,onToggleTheme:t}){return a.jsx(Yn,{initialDiagram:El,children:a.jsx(Dl,{isDark:e,onToggleTheme:t})})}const Sr='"JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace',Ll={blue:{top:"#3b82f6",side:"#2563eb",front:"#1d4ed8"},violet:{top:"#8b5cf6",side:"#7c3aed",front:"#6d28d9"},cyan:{top:"#06b6d4",side:"#0891b2",front:"#0e7490"},emerald:{top:"#10b981",side:"#059669",front:"#047857"},amber:{top:"#f59e0b",side:"#d97706",front:"#b45309"},rose:{top:"#f43f5e",side:"#e11d48",front:"#be123c"},slate:{top:"#475569",side:"#334155",front:"#1e293b"}},Tl={blue:{top:"#93c5fd",side:"#60a5fa",front:"#3b82f6"},violet:{top:"#c4b5fd",side:"#a78bfa",front:"#8b5cf6"},cyan:{top:"#67e8f9",side:"#22d3ee",front:"#06b6d4"},emerald:{top:"#6ee7b7",side:"#34d399",front:"#10b981"},amber:{top:"#fcd34d",side:"#fbbf24",front:"#f59e0b"},rose:{top:"#fda4af",side:"#fb7185",front:"#f43f5e"},slate:{top:"#e2e8f0",side:"#cbd5e1",front:"#94a3b8"}};function Nt(e,t,n){const o=d=>{const f=d.replace("#","");return{r:parseInt(f.substring(0,2),16),g:parseInt(f.substring(2,4),16),b:parseInt(f.substring(4,6),16)}},r=o(e),i=o(t),s=Math.round(r.r+(i.r-r.r)*n),l=Math.round(r.g+(i.g-r.g)*n),c=Math.round(r.b+(i.b-r.b)*n);return`rgb(${s},${l},${c})`}function Pl({x:e,y:t,z:n,children:o,fontSize:r=8,color:i="#1e293b"}){const s=T(e,t,n);return a.jsx("g",{transform:`translate(${s.screenX}, ${s.screenY})`,children:a.jsx("g",{transform:"matrix(0.866, -0.5, 0.866, 0.5, 0, 0)",children:a.jsx("text",{x:0,y:0,textAnchor:"middle",fill:i,fontSize:r,fontWeight:500,fontFamily:Sr,style:{textTransform:"uppercase",letterSpacing:"0.08em"},children:o})})})}function Fl({width:e,depth:t,elevation:n,color:o,opacity:r,borderColor:i,theme:s,isGround:l}){const d=Oe(e,t,l?8:2,0,0),f=T(0,0,n);return a.jsxs("g",{transform:`translate(${f.screenX}, ${f.screenY})`,children:[l&&a.jsx("g",{transform:"translate(4, 4)",opacity:.2,children:a.jsx("path",{d:d.top,fill:"#000"})}),a.jsx("path",{d:d.top,fill:o,opacity:r}),l&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:d.left,fill:s==="dark"?"#0f172a":"#cbd5e1",opacity:.8}),a.jsx("path",{d:d.right,fill:s==="dark"?"#1e293b":"#94a3b8",opacity:.8})]}),a.jsx("path",{d:d.top,fill:"none",stroke:i||(s==="dark"?"#475569":"#94a3b8"),strokeWidth:l?1.5:.75,opacity:l?1:.6})]})}function Yl({config:e,options:t={},className:n,style:o}){const{interactive:r=!0,animate:i=!0,showLabels:s=!0}=t,{theme:l,canvas:c,origin:d,tiers:f,floorSize:u,nodes:h,cornerRadius:p=0}=e,g=l==="dark"?Ll:Tl,x=l==="dark"?"#0f172a":"#fafafa",k=l==="dark"?"#e2e8f0":"#1e293b",y=l==="dark"?"#64748b":"#94a3b8",[m,C]=b.useState(new Set);b.useEffect(()=>{i?(C(new Set),f.forEach((N,E)=>{setTimeout(()=>{C(S=>new Set([...S,E]))},E*150+100)})):C(new Set(f.map((N,E)=>E)))},[e.id,i,f.length]);const[v,z]=b.useState(null),_=[...h].sort((N,E)=>{const S=f[N.tier]?.elevation||0,w=f[E.tier]?.elevation||0;if(S!==w)return S-w;const M=N.x+N.width+(N.y+N.depth);return E.x+E.width+(E.y+E.depth)-M});return a.jsx("div",{className:n,style:{display:"inline-block",...o},children:a.jsxs("svg",{width:c.width,height:c.height,style:{backgroundColor:x},children:[a.jsxs("defs",{children:[a.jsx("pattern",{id:`grid-${e.id}`,width:"24",height:"24",patternUnits:"userSpaceOnUse",children:a.jsx("circle",{cx:"12",cy:"12",r:"0.5",fill:l==="dark"?"#1e293b":"#e2e8f0"})}),a.jsx("filter",{id:`glow-${e.id}`,x:"-20%",y:"-20%",width:"140%",height:"140%",children:a.jsx("feDropShadow",{dx:"0",dy:"4",stdDeviation:"8",floodColor:l==="dark"?"#60a5fa":"#3b82f6",floodOpacity:"0.3"})})]}),a.jsx("rect",{width:"100%",height:"100%",fill:`url(#grid-${e.id})`,opacity:"0.5"}),a.jsx("g",{transform:`translate(${d.x}, ${d.y})`,children:f.map((N,E)=>{const S=_.filter(P=>P.tier===E),w=m.has(E),M=r&&v===E,$=w?0:60,A=w?1:0,B=M?1.02:1,W=r&&v!==null&&!M,G=T(u.width/2,u.depth/2,N.elevation);return a.jsxs("g",{onMouseEnter:()=>r&&z(E),onMouseLeave:()=>r&&z(null),style:{transform:`translate(${G.screenX}px, ${G.screenY+$}px) scale(${B}) translate(${-G.screenX}px, ${-G.screenY}px)`,transition:"transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease-out",opacity:A*(W?.5:1),filter:M?`url(#glow-${e.id})`:"none",cursor:r?"pointer":"default"},children:[a.jsx(Fl,{width:u.width,depth:u.depth,elevation:E===0?-2:N.elevation,color:N.floorColor||(l==="dark"?"#0f172a":"#f8fafc"),opacity:N.floorOpacity||(E===0?.95:.5),borderColor:N.borderColor,theme:l,isGround:E===0}),S.map((P,ne)=>{const Q=N.elevation+5,ye=T(P.x,P.y,Q),R=Oe(P.width,P.depth,P.height,ye.screenX,ye.screenY,p),U=g[P.color]||g.slate;return a.jsxs("g",{opacity:P.opacity??1,children:[R.cornerBackRight?.map((Z,se)=>a.jsx("path",{d:Z.path,fill:Nt(U.front,U.side,Z.intensity)},`cbr-${se}`)),R.cornerBackLeft?.map((Z,se)=>a.jsx("path",{d:Z.path,fill:Nt(U.side,U.front,Z.intensity)},`cbl-${se}`)),a.jsx("path",{d:R.left,fill:U.side}),a.jsx("path",{d:R.right,fill:U.front}),R.cornerFrontRight?.map((Z,se)=>a.jsx("path",{d:Z.path,fill:Nt(U.front,U.side,Z.intensity)},`cfr-${se}`)),R.cornerFrontLeft?.map((Z,se)=>a.jsx("path",{d:Z.path,fill:Nt(U.front,U.side,Z.intensity)},`cfl-${se}`)),a.jsx("path",{d:R.top,fill:U.top}),a.jsx("path",{d:R.top,fill:"none",stroke:"rgba(255,255,255,0.15)",strokeWidth:"0.5",strokeLinejoin:"round"}),s&&P.label&&a.jsx(Pl,{x:P.x+P.width/2,y:P.y+P.depth/2,z:Q+P.height+2,fontSize:P.width>70?8:7,color:k,children:P.label})]},ne)}),s&&a.jsx("text",{x:T(-25,u.depth/2,N.elevation+15).screenX-35,y:T(-25,u.depth/2,N.elevation+15).screenY,fill:y,fontSize:9,fontWeight:500,fontFamily:Sr,opacity:.6,style:{letterSpacing:"0.05em"},children:N.name})]},E)})})]})})}const Ar='"JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace',Hl={blue:{top:"#3b82f6",side:"#2563eb",front:"#1d4ed8"},violet:{top:"#8b5cf6",side:"#7c3aed",front:"#6d28d9"},cyan:{top:"#06b6d4",side:"#0891b2",front:"#0e7490"},emerald:{top:"#10b981",side:"#059669",front:"#047857"},amber:{top:"#f59e0b",side:"#d97706",front:"#b45309"},rose:{top:"#f43f5e",side:"#e11d48",front:"#be123c"},slate:{top:"#475569",side:"#334155",front:"#1e293b"}},Bl={blue:{top:"#93c5fd",side:"#60a5fa",front:"#3b82f6"},violet:{top:"#c4b5fd",side:"#a78bfa",front:"#8b5cf6"},cyan:{top:"#67e8f9",side:"#22d3ee",front:"#06b6d4"},emerald:{top:"#6ee7b7",side:"#34d399",front:"#10b981"},amber:{top:"#fcd34d",side:"#fbbf24",front:"#f59e0b"},rose:{top:"#fda4af",side:"#fb7185",front:"#f43f5e"},slate:{top:"#e2e8f0",side:"#cbd5e1",front:"#94a3b8"}};function zt(e,t,n){const o=d=>{const f=d.replace("#","");return{r:parseInt(f.substring(0,2),16),g:parseInt(f.substring(2,4),16),b:parseInt(f.substring(4,6),16)}},r=o(e),i=o(t),s=Math.round(r.r+(i.r-r.r)*n),l=Math.round(r.g+(i.g-r.g)*n),c=Math.round(r.b+(i.b-r.b)*n);return`rgb(${s},${l},${c})`}function Ir(e){const{theme:t,canvas:n,origin:o,tiers:r,floorSize:i,nodes:s,cornerRadius:l=0}=e,c=t==="dark"?Hl:Bl,d=t==="dark"?"#0f172a":"#fafafa",f=t==="dark"?"#e2e8f0":"#1e293b",u=t==="dark"?"#64748b":"#94a3b8",h=[...s].sort((g,x)=>{const k=r[g.tier]?.elevation||0,y=r[x.tier]?.elevation||0;return k!==y?k-y:x.x+x.width+(x.y+x.depth)-(g.x+g.width+(g.y+g.depth))});let p=`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width}" height="${n.height}" style="background:${d}">`;p+=`<defs>
|
|
136
|
+
`,children:r?a.jsx($i,{className:"w-5 h-5 animate-spin text-zinc-500"}):i?a.jsx(ci,{className:"w-5 h-5 text-green-600 dark:text-green-400"}):a.jsx(e,{className:"w-5 h-5 text-zinc-600 dark:text-zinc-400"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"font-medium text-sm text-zinc-900 dark:text-zinc-100",children:i?"Done!":t}),a.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 mt-0.5",children:n})]})]})}function Ll({diagram:e,cropBounds:t,onCropChange:n}){const o=b.useRef(null),[r,i]=b.useState(null),[s,l]=b.useState(null),c=450,d=250,p=Math.min(c/e.layout.width,d/e.layout.height)*.9,u=e.layout.width*p,h=e.layout.height*p,f=t.x*p,g=t.y*p,x=t.width*p,k=t.height*p,m=b.useCallback(_=>{if(!o.current)return{x:0,y:0};const C=o.current.getBoundingClientRect();return{x:(_.clientX-C.left-(c-u)/2)/p,y:(_.clientY-C.top-(d-h)/2)/p}},[p,u,h]),y=b.useCallback((_,C)=>{_.preventDefault(),_.stopPropagation(),i(C),l({mouse:m(_),bounds:{...t}})},[t,m]),v=b.useCallback(_=>{if(!r||!s)return;const C=m(_),M=C.x-s.mouse.x,$=C.y-s.mouse.y,{bounds:S}=s;let E={...S};if(r==="move")E.x=Math.max(0,Math.min(e.layout.width-S.width,S.x+M)),E.y=Math.max(0,Math.min(e.layout.height-S.height,S.y+$));else{if(r.includes("w")){const T=S.x+M,O=S.width-M;O>=50&&T>=0&&(E.x=T,E.width=O)}if(r.includes("e")){const T=S.width+M;T>=50&&S.x+T<=e.layout.width&&(E.width=T)}if(r.includes("n")){const T=S.y+$,O=S.height-$;O>=50&&T>=0&&(E.y=T,E.height=O)}if(r.includes("s")){const T=S.height+$;T>=50&&S.y+T<=e.layout.height&&(E.height=T)}}n({x:Math.round(E.x),y:Math.round(E.y),width:Math.round(E.width),height:Math.round(E.height)})},[r,s,e.layout,m,n]),w=b.useCallback(()=>{i(null),l(null)},[]),N=b.useMemo(()=>on(e,{backgroundColor:"#f4f4f5",padding:0}),[e]);return a.jsxs("div",{ref:o,className:"relative bg-zinc-200 dark:bg-zinc-700 rounded-lg overflow-hidden select-none",style:{width:c,height:d},onMouseMove:r?v:void 0,onMouseUp:r?w:void 0,onMouseLeave:r?w:void 0,children:[a.jsxs("div",{className:"absolute",style:{left:(c-u)/2,top:(d-h)/2,width:u,height:h},children:[a.jsx("div",{className:"w-full h-full opacity-40",dangerouslySetInnerHTML:{__html:N},style:{pointerEvents:"none"}}),a.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${u} ${h}`,children:[a.jsx("defs",{children:a.jsxs("mask",{id:"cropMask",children:[a.jsx("rect",{width:"100%",height:"100%",fill:"white"}),a.jsx("rect",{x:f,y:g,width:x,height:k,fill:"black"})]})}),a.jsx("rect",{width:"100%",height:"100%",fill:"rgba(0,0,0,0.5)",mask:"url(#cropMask)"}),a.jsx("rect",{x:f,y:g,width:x,height:k,fill:"none",stroke:"#3b82f6",strokeWidth:2,className:"cursor-move",onMouseDown:_=>y(_,"move")}),[{x:f,y:g,cursor:"nwse-resize",type:"nw"},{x:f+x,y:g,cursor:"nesw-resize",type:"ne"},{x:f,y:g+k,cursor:"nesw-resize",type:"sw"},{x:f+x,y:g+k,cursor:"nwse-resize",type:"se"}].map(({x:_,y:C,cursor:M,type:$})=>a.jsx("circle",{cx:_,cy:C,r:6,fill:"#3b82f6",className:`cursor-${M}`,style:{cursor:M},onMouseDown:S=>y(S,$)},$))]})]}),a.jsxs("div",{className:"absolute bottom-2 right-2 px-2 py-1 bg-black/60 rounded text-xs text-white font-mono",children:[Math.round(t.width)," × ",Math.round(t.height)]})]})}function Pl({diagram:e,viewportBounds:t,onClose:n}){const[o,r]=b.useState(()=>{if(t&&t.width>0)return{x:Math.max(0,Math.round(t.x)),y:Math.max(0,Math.round(t.y)),width:Math.round(Math.min(t.width,e.layout.width)),height:Math.round(Math.min(t.height,e.layout.height))};const O=Math.min(800,e.layout.width*.8),V=Math.min(600,e.layout.height*.8);return{x:Math.round((e.layout.width-O)/2),y:Math.round((e.layout.height-V)/2),width:Math.round(O),height:Math.round(V)}}),[i,s]=b.useState(!1),[l,c]=b.useState(!1),[d,p]=b.useState(!1),[u,h]=b.useState(!1),[f,g]=b.useState(!1),[x,k]=b.useState(!1),[m,y]=b.useState(!1),v=b.useMemo(()=>({...e,exportZone:o}),[e,o]),w=b.useMemo(()=>JSON.stringify(v,null,2),[v]),N=b.useMemo(()=>El(v),[v]),_=b.useMemo(()=>Al(v),[v]),C=async()=>{await sn(w)&&(s(!0),setTimeout(()=>s(!1),2e3))},M=async()=>{await sn(N)&&(c(!0),setTimeout(()=>c(!1),2e3))},$=async()=>{await sn(_)&&(p(!0),setTimeout(()=>p(!1),2e3))},S=async()=>{h(!0);try{const O=on(v,{backgroundColor:"#ffffff"});Sr(O,"diagram.svg","image/svg+xml"),k(!0),setTimeout(()=>k(!1),2e3)}finally{h(!1)}},E=async()=>{g(!0);try{const O=await Il(v,{scale:2,backgroundColor:"#ffffff"});Sr(O,"diagram.png","image/png"),y(!0),setTimeout(()=>y(!1),2e3)}catch(O){console.error("PNG generation failed:",O)}finally{g(!1)}},T=()=>{r({x:0,y:0,width:e.layout.width,height:e.layout.height})};return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",children:a.jsxs("div",{className:"w-full max-w-xl bg-zinc-100 dark:bg-zinc-900 rounded-2xl shadow-2xl overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-white dark:bg-zinc-800 border-b border-zinc-200 dark:border-zinc-700",children:[a.jsx("h2",{className:"text-lg font-semibold text-zinc-900 dark:text-white",children:"Share"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:T,className:"flex items-center gap-1 px-2 py-1 text-xs text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-700 rounded transition-colors",title:"Reset to full canvas",children:[a.jsx(Vi,{className:"w-3 h-3"}),"Reset"]}),a.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-zinc-100 dark:hover:bg-zinc-700 transition-colors",children:a.jsx(cs,{className:"w-5 h-5"})})]})]}),a.jsx("div",{className:"p-4 flex justify-center",children:a.jsx(Ll,{diagram:e,cropBounds:o,onCropChange:r})}),a.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx(rt,{icon:_n,label:"Copy TypeScript",description:"ArcDiagram format",onClick:M,success:l}),a.jsx(rt,{icon:ii,label:"Copy JSON",description:"Raw data",onClick:C,success:i})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx(rt,{icon:yi,label:"Download SVG",description:"Vector",onClick:S,loading:u,success:x,secondary:!0}),a.jsx(rt,{icon:zi,label:"Download PNG",description:"2x resolution",onClick:E,loading:f,success:m,secondary:!0})]}),a.jsx(rt,{icon:Si,label:"Copy Link",description:"Shareable URL with embedded data",onClick:$,success:d,secondary:!0})]})]})})}function Tl({onDelete:e,onUndo:t,onRedo:n,onSave:o,onNew:r,onEscape:i,onSetMode:s}){const l=b.useCallback(c=>{if(c.target.tagName==="INPUT"||c.target.tagName==="TEXTAREA"){c.key==="Escape"&&c.target.blur();return}const d=c.metaKey||c.ctrlKey;if((c.key==="Delete"||c.key==="Backspace")&&!d){c.preventDefault(),e?.();return}if(c.key==="Escape"){c.preventDefault(),i?.();return}if(d&&c.key==="z"&&!c.shiftKey){c.preventDefault(),t?.();return}if(d&&c.key==="z"&&c.shiftKey){c.preventDefault(),n?.();return}if(d&&c.key==="s"){c.preventDefault(),o?.();return}if(d&&c.key==="n"){c.preventDefault(),r?.();return}if(!d&&!c.shiftKey&&!c.altKey)switch(c.key.toLowerCase()){case"v":c.preventDefault(),s?.("select");return;case"h":c.preventDefault(),s?.("pan");return;case"n":c.preventDefault(),s?.("addNode");return;case"c":c.preventDefault(),s?.("addConnector");return}},[e,t,n,o,r,i,s]);b.useEffect(()=>(window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)),[l])}const Fl={layout:{width:1600,height:900},grid:{enabled:!0,size:24,color:"#71717a",opacity:.1,type:"dots"},nodes:{talkie:{x:50,y:45,size:"l"},talkieLive:{x:50,y:155,size:"m"},talkieEngine:{x:50,y:255,size:"m"},talkieServer:{x:360,y:55,size:"m"},iCloud:{x:380,y:255,size:"m"},iPhone:{x:600,y:55,size:"m"},watch:{x:620,y:155,size:"s"}},nodeData:{talkie:{icon:"Monitor",name:"Talkie",subtitle:"Swift/SwiftUI",description:"UI, Workflows, Data, Orchestration",color:"violet"},talkieLive:{icon:"Mic",name:"TalkieLive",subtitle:"Swift",description:"Ears & Hands",color:"emerald"},talkieEngine:{icon:"Cpu",name:"TalkieEngine",subtitle:"Swift",description:"Local Brain",color:"blue"},talkieServer:{icon:"Server",name:"TalkieServer",subtitle:"TypeScript",description:"iOS Bridge",color:"amber"},iCloud:{icon:"Cloud",name:"iCloud",subtitle:"CloudKit",description:"Memo Sync",color:"sky"},iPhone:{icon:"Smartphone",name:"iPhone",subtitle:"iOS",description:"Voice Capture",color:"zinc"},watch:{icon:"Watch",name:"Watch",subtitle:"watchOS",color:"zinc"}},connectors:[{from:"talkie",to:"talkieLive",fromAnchor:"bottom",toAnchor:"top",style:"xpc"},{from:"talkieLive",to:"talkieEngine",fromAnchor:"bottom",toAnchor:"top",style:"audio"},{from:"talkie",to:"talkieServer",fromAnchor:"right",toAnchor:"left",style:"http"},{from:"talkieServer",to:"iPhone",fromAnchor:"right",toAnchor:"left",style:"tailscale"},{from:"iPhone",to:"watch",fromAnchor:"bottom",toAnchor:"top",style:"peer"},{from:"talkie",to:"iCloud",fromAnchor:"bottomRight",toAnchor:"left",style:"cloudkit",curve:"natural"},{from:"iPhone",to:"iCloud",fromAnchor:"bottomLeft",toAnchor:"right",style:"cloudkit",curve:"natural"}],connectorStyles:{xpc:{color:"sky",strokeWidth:2,label:"",dashed:!0},http:{color:"amber",strokeWidth:2,label:"HTTP",dashed:!0},tailscale:{color:"sky",strokeWidth:2,label:"Tailscale",dashed:!0},cloudkit:{color:"sky",strokeWidth:2,label:"",dashed:!0},audio:{color:"sky",strokeWidth:2,label:"",dashed:!0},peer:{color:"sky",strokeWidth:2,label:"",dashed:!0}}};function Yl({isDark:e,onToggleTheme:t}){const{actions:n}=he(),o=Ne(),r=Ve(),i=Bn(),[s,l]=b.useState(!1),[c,d]=b.useState(null);ms({title:"Arc Editor | Visual Diagram Builder",description:"Drag-and-drop diagram builder with real-time preview and JSON export.",image:"/og-editor.png",url:"/editor"});const p=b.useCallback(()=>{i.isDirty&&!window.confirm("Discard unsaved changes?")||n.newDiagram()},[i.isDirty,n]),u=b.useCallback(async()=>{if(i.isDirty&&!window.confirm("Discard unsaved changes?"))return;const k=await Ol();k&&n.loadDiagram(k.diagram,k.filename)},[i.isDirty,n]),h=b.useCallback(async()=>{const k=await Dl(o,i.filename||"diagram.json");k&&n.markSaved(k)},[o,i.filename,n]),f=b.useCallback(()=>{l(!0)},[]),g=b.useCallback(()=>{if(r.selectedNodeIds?.length>0)for(const k of r.selectedNodeIds)n.removeNode(k);else r.selectedConnectorIndex!==null?n.removeConnector(r.selectedConnectorIndex):r.selectedGroupId!==null&&n.removeGroup(r.selectedGroupId)},[r.selectedNodeIds,r.selectedConnectorIndex,r.selectedGroupId,n]),x=b.useCallback(()=>{r.pendingConnector?n.clearPendingConnector():r.mode!=="select"?n.setMode("select"):n.clearSelection()},[r.mode,r.pendingConnector,n]);return Tl({onDelete:g,onUndo:n.undo,onRedo:n.redo,onSave:h,onNew:p,onEscape:x,onSetMode:n.setMode}),a.jsxs("div",{className:"flex flex-col h-screen bg-zinc-100 dark:bg-zinc-950",children:[a.jsx(bs,{onNew:p,onOpen:u,onSave:h,onShare:f,isDark:e,onToggleTheme:t}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[a.jsxs("div",{className:"flex-1 relative p-4 overflow-hidden",children:[a.jsx("div",{className:"w-full h-full rounded-xl overflow-hidden border border-zinc-200 dark:border-zinc-800 shadow-sm",children:a.jsx(Qn,{onViewportChange:d,embedConfig:{enableViewModeToggle:!0}})}),a.jsx(ks,{})]}),a.jsx(Sl,{})]}),s&&a.jsx(Pl,{diagram:o,viewportBounds:c,onClose:()=>l(!1)})]})}function Hl({isDark:e,onToggleTheme:t}){return a.jsx(Hn,{initialDiagram:Fl,children:a.jsx(Yl,{isDark:e,onToggleTheme:t})})}const $r='"JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace',Bl={blue:{top:"#3b82f6",side:"#2563eb",front:"#1d4ed8"},violet:{top:"#8b5cf6",side:"#7c3aed",front:"#6d28d9"},cyan:{top:"#06b6d4",side:"#0891b2",front:"#0e7490"},emerald:{top:"#10b981",side:"#059669",front:"#047857"},amber:{top:"#f59e0b",side:"#d97706",front:"#b45309"},rose:{top:"#f43f5e",side:"#e11d48",front:"#be123c"},slate:{top:"#475569",side:"#334155",front:"#1e293b"}},Wl={blue:{top:"#93c5fd",side:"#60a5fa",front:"#3b82f6"},violet:{top:"#c4b5fd",side:"#a78bfa",front:"#8b5cf6"},cyan:{top:"#67e8f9",side:"#22d3ee",front:"#06b6d4"},emerald:{top:"#6ee7b7",side:"#34d399",front:"#10b981"},amber:{top:"#fcd34d",side:"#fbbf24",front:"#f59e0b"},rose:{top:"#fda4af",side:"#fb7185",front:"#f43f5e"},slate:{top:"#e2e8f0",side:"#cbd5e1",front:"#94a3b8"}};function _t(e,t,n){const o=d=>{const p=d.replace("#","");return{r:parseInt(p.substring(0,2),16),g:parseInt(p.substring(2,4),16),b:parseInt(p.substring(4,6),16)}},r=o(e),i=o(t),s=Math.round(r.r+(i.r-r.r)*n),l=Math.round(r.g+(i.g-r.g)*n),c=Math.round(r.b+(i.b-r.b)*n);return`rgb(${s},${l},${c})`}function Xl({x:e,y:t,z:n,children:o,fontSize:r=8,color:i="#1e293b"}){const s=F(e,t,n);return a.jsx("g",{transform:`translate(${s.screenX}, ${s.screenY})`,children:a.jsx("g",{transform:"matrix(0.866, -0.5, 0.866, 0.5, 0, 0)",children:a.jsx("text",{x:0,y:0,textAnchor:"middle",fill:i,fontSize:r,fontWeight:500,fontFamily:$r,style:{textTransform:"uppercase",letterSpacing:"0.08em"},children:o})})})}function Ul({width:e,depth:t,elevation:n,color:o,opacity:r,borderColor:i,theme:s,isGround:l}){const d=Te(e,t,l?8:2,0,0),p=F(0,0,n);return a.jsxs("g",{transform:`translate(${p.screenX}, ${p.screenY})`,children:[l&&a.jsx("g",{transform:"translate(4, 4)",opacity:.2,children:a.jsx("path",{d:d.top,fill:"#000"})}),a.jsx("path",{d:d.top,fill:o,opacity:r}),l&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:d.left,fill:s==="dark"?"#0f172a":"#cbd5e1",opacity:.8}),a.jsx("path",{d:d.right,fill:s==="dark"?"#1e293b":"#94a3b8",opacity:.8})]}),a.jsx("path",{d:d.top,fill:"none",stroke:i||(s==="dark"?"#475569":"#94a3b8"),strokeWidth:l?1.5:.75,opacity:l?1:.6})]})}function jl({config:e,options:t={},className:n,style:o}){const{interactive:r=!0,animate:i=!0,showLabels:s=!0}=t,{theme:l,canvas:c,origin:d,tiers:p,floorSize:u,nodes:h,cornerRadius:f=0}=e,g=l==="dark"?Bl:Wl,x=l==="dark"?"#0f172a":"#fafafa",k=l==="dark"?"#e2e8f0":"#1e293b",m=l==="dark"?"#64748b":"#94a3b8",[y,v]=b.useState(new Set);b.useEffect(()=>{i?(v(new Set),p.forEach((C,M)=>{setTimeout(()=>{v($=>new Set([...$,M]))},M*150+100)})):v(new Set(p.map((C,M)=>M)))},[e.id,i,p.length]);const[w,N]=b.useState(null),_=[...h].sort((C,M)=>{const $=p[C.tier]?.elevation||0,S=p[M.tier]?.elevation||0;if($!==S)return $-S;const E=C.x+C.width+(C.y+C.depth);return M.x+M.width+(M.y+M.depth)-E});return a.jsx("div",{className:n,style:{display:"inline-block",...o},children:a.jsxs("svg",{width:c.width,height:c.height,style:{backgroundColor:x},children:[a.jsxs("defs",{children:[a.jsx("pattern",{id:`grid-${e.id}`,width:"24",height:"24",patternUnits:"userSpaceOnUse",children:a.jsx("circle",{cx:"12",cy:"12",r:"0.5",fill:l==="dark"?"#1e293b":"#e2e8f0"})}),a.jsx("filter",{id:`glow-${e.id}`,x:"-20%",y:"-20%",width:"140%",height:"140%",children:a.jsx("feDropShadow",{dx:"0",dy:"4",stdDeviation:"8",floodColor:l==="dark"?"#60a5fa":"#3b82f6",floodOpacity:"0.3"})})]}),a.jsx("rect",{width:"100%",height:"100%",fill:`url(#grid-${e.id})`,opacity:"0.5"}),a.jsx("g",{transform:`translate(${d.x}, ${d.y})`,children:p.map((C,M)=>{const $=_.filter(H=>H.tier===M),S=y.has(M),E=r&&w===M,T=S?0:60,O=S?1:0,V=E?1.02:1,R=r&&w!==null&&!E,K=F(u.width/2,u.depth/2,C.elevation);return a.jsxs("g",{onMouseEnter:()=>r&&N(M),onMouseLeave:()=>r&&N(null),style:{transform:`translate(${K.screenX}px, ${K.screenY+T}px) scale(${V}) translate(${-K.screenX}px, ${-K.screenY}px)`,transition:"transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease-out",opacity:O*(R?.5:1),filter:E?`url(#glow-${e.id})`:"none",cursor:r?"pointer":"default"},children:[a.jsx(Ul,{width:u.width,depth:u.depth,elevation:M===0?-2:C.elevation,color:C.floorColor||(l==="dark"?"#0f172a":"#f8fafc"),opacity:C.floorOpacity||(M===0?.95:.5),borderColor:C.borderColor,theme:l,isGround:M===0}),$.map((H,te)=>{const de=C.elevation+5,ve=F(H.x,H.y,de),se=Te(H.width,H.depth,H.height,ve.screenX,ve.screenY,f),re=g[H.color]||g.slate;return a.jsxs("g",{opacity:H.opacity??1,children:[se.cornerBackRight?.map((z,D)=>a.jsx("path",{d:z.path,fill:_t(re.front,re.side,z.intensity)},`cbr-${D}`)),se.cornerBackLeft?.map((z,D)=>a.jsx("path",{d:z.path,fill:_t(re.side,re.front,z.intensity)},`cbl-${D}`)),a.jsx("path",{d:se.left,fill:re.side}),a.jsx("path",{d:se.right,fill:re.front}),se.cornerFrontRight?.map((z,D)=>a.jsx("path",{d:z.path,fill:_t(re.front,re.side,z.intensity)},`cfr-${D}`)),se.cornerFrontLeft?.map((z,D)=>a.jsx("path",{d:z.path,fill:_t(re.front,re.side,z.intensity)},`cfl-${D}`)),a.jsx("path",{d:se.top,fill:re.top}),a.jsx("path",{d:se.top,fill:"none",stroke:"rgba(255,255,255,0.15)",strokeWidth:"0.5",strokeLinejoin:"round"}),s&&H.label&&a.jsx(Xl,{x:H.x+H.width/2,y:H.y+H.depth/2,z:de+H.height+2,fontSize:H.width>70?8:7,color:k,children:H.label})]},te)}),s&&a.jsx("text",{x:F(-25,u.depth/2,C.elevation+15).screenX-35,y:F(-25,u.depth/2,C.elevation+15).screenY,fill:m,fontSize:9,fontWeight:500,fontFamily:$r,opacity:.6,style:{letterSpacing:"0.05em"},children:C.name})]},M)})})]})})}const Ir='"JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace',Gl={blue:{top:"#3b82f6",side:"#2563eb",front:"#1d4ed8"},violet:{top:"#8b5cf6",side:"#7c3aed",front:"#6d28d9"},cyan:{top:"#06b6d4",side:"#0891b2",front:"#0e7490"},emerald:{top:"#10b981",side:"#059669",front:"#047857"},amber:{top:"#f59e0b",side:"#d97706",front:"#b45309"},rose:{top:"#f43f5e",side:"#e11d48",front:"#be123c"},slate:{top:"#475569",side:"#334155",front:"#1e293b"}},Vl={blue:{top:"#93c5fd",side:"#60a5fa",front:"#3b82f6"},violet:{top:"#c4b5fd",side:"#a78bfa",front:"#8b5cf6"},cyan:{top:"#67e8f9",side:"#22d3ee",front:"#06b6d4"},emerald:{top:"#6ee7b7",side:"#34d399",front:"#10b981"},amber:{top:"#fcd34d",side:"#fbbf24",front:"#f59e0b"},rose:{top:"#fda4af",side:"#fb7185",front:"#f43f5e"},slate:{top:"#e2e8f0",side:"#cbd5e1",front:"#94a3b8"}};function St(e,t,n){const o=d=>{const p=d.replace("#","");return{r:parseInt(p.substring(0,2),16),g:parseInt(p.substring(2,4),16),b:parseInt(p.substring(4,6),16)}},r=o(e),i=o(t),s=Math.round(r.r+(i.r-r.r)*n),l=Math.round(r.g+(i.g-r.g)*n),c=Math.round(r.b+(i.b-r.b)*n);return`rgb(${s},${l},${c})`}function Ar(e){const{theme:t,canvas:n,origin:o,tiers:r,floorSize:i,nodes:s,cornerRadius:l=0}=e,c=t==="dark"?Gl:Vl,d=t==="dark"?"#0f172a":"#fafafa",p=t==="dark"?"#e2e8f0":"#1e293b",u=t==="dark"?"#64748b":"#94a3b8",h=[...s].sort((g,x)=>{const k=r[g.tier]?.elevation||0,m=r[x.tier]?.elevation||0;return k!==m?k-m:x.x+x.width+(x.y+x.depth)-(g.x+g.width+(g.y+g.depth))});let f=`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width}" height="${n.height}" style="background:${d}">`;f+=`<defs>
|
|
137
137
|
<pattern id="grid" width="24" height="24" patternUnits="userSpaceOnUse">
|
|
138
138
|
<circle cx="12" cy="12" r="0.5" fill="${t==="dark"?"#1e293b":"#e2e8f0"}"/>
|
|
139
139
|
</pattern>
|
|
140
|
-
</defs>`,
|
|
140
|
+
</defs>`,f+='<rect width="100%" height="100%" fill="url(#grid)" opacity="0.5"/>',f+=`<g transform="translate(${o.x},${o.y})">`;for(let g=0;g<r.length;g++){const x=r[g],k=h.filter(C=>C.tier===g),m=g===0?8:2,y=Te(i.width,i.depth,m,0,0),v=F(0,0,g===0?-2:x.elevation),w=x.floorColor||(t==="dark"?"#0f172a":"#f8fafc"),N=x.floorOpacity||(g===0?.95:.5);f+=`<g transform="translate(${v.screenX},${v.screenY})">`,g===0&&(f+=`<g transform="translate(4,4)" opacity="0.2"><path d="${y.top}" fill="#000"/></g>`),f+=`<path d="${y.top}" fill="${w}" opacity="${N}"/>`,g===0&&(f+=`<path d="${y.left}" fill="${t==="dark"?"#0f172a":"#cbd5e1"}" opacity="0.8"/>`,f+=`<path d="${y.right}" fill="${t==="dark"?"#1e293b":"#94a3b8"}" opacity="0.8"/>`),f+=`<path d="${y.top}" fill="none" stroke="${x.borderColor||(t==="dark"?"#475569":"#94a3b8")}" stroke-width="${g===0?1.5:.75}" opacity="${g===0?1:.6}"/>`,f+="</g>";for(const C of k){const M=x.elevation+5,$=F(C.x,C.y,M),S=Te(C.width,C.depth,C.height,$.screenX,$.screenY,l),E=c[C.color]||c.slate,T=C.opacity??1;if(f+=`<g opacity="${T}">`,S.cornerBackRight)for(const O of S.cornerBackRight)f+=`<path d="${O.path}" fill="${St(E.front,E.side,O.intensity)}"/>`;if(S.cornerBackLeft)for(const O of S.cornerBackLeft)f+=`<path d="${O.path}" fill="${St(E.side,E.front,O.intensity)}"/>`;if(f+=`<path d="${S.left}" fill="${E.side}"/>`,f+=`<path d="${S.right}" fill="${E.front}"/>`,S.cornerFrontRight)for(const O of S.cornerFrontRight)f+=`<path d="${O.path}" fill="${St(E.front,E.side,O.intensity)}"/>`;if(S.cornerFrontLeft)for(const O of S.cornerFrontLeft)f+=`<path d="${O.path}" fill="${St(E.front,E.side,O.intensity)}"/>`;if(f+=`<path d="${S.top}" fill="${E.top}"/>`,f+=`<path d="${S.top}" fill="none" stroke="rgba(255,255,255,0.15)" stroke-width="0.5" stroke-linejoin="round"/>`,C.label){const O=F(C.x+C.width/2,C.y+C.depth/2,M+C.height+2),V=C.width>70?8:7;f+=`<g transform="translate(${O.screenX},${O.screenY})">`,f+='<g transform="matrix(0.866,-0.5,0.866,0.5,0,0)">',f+=`<text x="0" y="0" text-anchor="middle" fill="${p}" font-size="${V}" font-weight="500" font-family="${Ir}" style="text-transform:uppercase;letter-spacing:0.08em">${C.label}</text>`,f+="</g></g>"}f+="</g>"}const _=F(-25,i.depth/2,x.elevation+15);f+=`<text x="${_.screenX-35}" y="${_.screenY}" fill="${u}" font-size="9" font-weight="500" font-family="${Ir}" opacity="0.6" style="letter-spacing:0.05em">${x.name}</text>`}return f+="</g></svg>",f}function Kl(e,t){e.innerHTML=Ar(t)}function Er(e){return typeof e>"u"||e===null}function Zl(e){return typeof e=="object"&&e!==null}function ql(e){return Array.isArray(e)?e:Er(e)?[]:[e]}function Jl(e,t){var n,o,r,i;if(t)for(i=Object.keys(t),n=0,o=i.length;n<o;n+=1)r=i[n],e[r]=t[r];return e}function Ql(e,t){var n="",o;for(o=0;o<t;o+=1)n+=e;return n}function Rl(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var ec=Er,tc=Zl,nc=ql,rc=Ql,oc=Rl,ic=Jl,ce={isNothing:ec,isObject:tc,toArray:nc,repeat:rc,isNegativeZero:oc,extend:ic};function Dr(e,t){var n="",o=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
|
|
141
141
|
|
|
142
|
-
`+e.mark.snippet),o+" "+n):o}function
|
|
143
|
-
`+l;for(d=
|
|
144
|
-
`,l+=
|
|
145
|
-
`,c=1;c<=t.linesAfter&&!(s+c>=r.length);c++)d=
|
|
146
|
-
`;return l.replace(/\n$/,"")}var
|
|
147
|
-
\r`;function
|
|
148
|
-
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"
":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}function
|
|
149
|
-
`,t-1))}function
|
|
150
|
-
`,i?1+c:c):r===
|
|
151
|
-
`);break}for(o?
|
|
152
|
-
`,i?1+c:c)):d?(d=!1,e.result+=
|
|
153
|
-
`,c+1)):c===0?i&&(e.result+=" "):e.result+=
|
|
154
|
-
`,c):e.result+=
|
|
155
|
-
`,i?1+c:c),i=!0,s=!0,c=0,n=e.position;!
|
|
156
|
-
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new
|
|
142
|
+
`+e.mark.snippet),o+" "+n):o}function ot(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=Dr(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}ot.prototype=Object.create(Error.prototype),ot.prototype.constructor=ot,ot.prototype.toString=function(t){return this.name+": "+Dr(this,t)};var ye=ot;function an(e,t,n,o,r){var i="",s="",l=Math.floor(r/2)-1;return o-t>l&&(i=" ... ",t=o-l+i.length),n-o>l&&(s=" ...",n=o+l-s.length),{str:i+e.slice(t,n).replace(/\t/g,"→")+s,pos:o-t+i.length}}function ln(e,t){return ce.repeat(" ",t-e.length)+e}function sc(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,o=[0],r=[],i,s=-1;i=n.exec(e.buffer);)r.push(i.index),o.push(i.index+i[0].length),e.position<=i.index&&s<0&&(s=o.length-2);s<0&&(s=o.length-1);var l="",c,d,p=Math.min(e.line+t.linesAfter,r.length).toString().length,u=t.maxLength-(t.indent+p+3);for(c=1;c<=t.linesBefore&&!(s-c<0);c++)d=an(e.buffer,o[s-c],r[s-c],e.position-(o[s]-o[s-c]),u),l=ce.repeat(" ",t.indent)+ln((e.line-c+1).toString(),p)+" | "+d.str+`
|
|
143
|
+
`+l;for(d=an(e.buffer,o[s],r[s],e.position,u),l+=ce.repeat(" ",t.indent)+ln((e.line+1).toString(),p)+" | "+d.str+`
|
|
144
|
+
`,l+=ce.repeat("-",t.indent+p+3+d.pos)+`^
|
|
145
|
+
`,c=1;c<=t.linesAfter&&!(s+c>=r.length);c++)d=an(e.buffer,o[s+c],r[s+c],e.position-(o[s]-o[s+c]),u),l+=ce.repeat(" ",t.indent)+ln((e.line+c+1).toString(),p)+" | "+d.str+`
|
|
146
|
+
`;return l.replace(/\n$/,"")}var ac=sc,lc=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],cc=["scalar","sequence","mapping"];function dc(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(o){t[String(o)]=n})}),t}function uc(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(lc.indexOf(n)===-1)throw new ye('Unknown option "'+n+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(n){return n},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=dc(t.styleAliases||null),cc.indexOf(this.kind)===-1)throw new ye('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var fe=uc;function Or(e,t){var n=[];return e[t].forEach(function(o){var r=n.length;n.forEach(function(i,s){i.tag===o.tag&&i.kind===o.kind&&i.multi===o.multi&&(r=s)}),n[r]=o}),n}function hc(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function o(r){r.multi?(e.multi[r.kind].push(r),e.multi.fallback.push(r)):e[r.kind][r.tag]=e.fallback[r.tag]=r}for(t=0,n=arguments.length;t<n;t+=1)arguments[t].forEach(o);return e}function cn(e){return this.extend(e)}cn.prototype.extend=function(t){var n=[],o=[];if(t instanceof fe)o.push(t);else if(Array.isArray(t))o=o.concat(t);else if(t&&(Array.isArray(t.implicit)||Array.isArray(t.explicit)))t.implicit&&(n=n.concat(t.implicit)),t.explicit&&(o=o.concat(t.explicit));else throw new ye("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(i){if(!(i instanceof fe))throw new ye("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(i.loadKind&&i.loadKind!=="scalar")throw new ye("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(i.multi)throw new ye("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),o.forEach(function(i){if(!(i instanceof fe))throw new ye("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var r=Object.create(cn.prototype);return r.implicit=(this.implicit||[]).concat(n),r.explicit=(this.explicit||[]).concat(o),r.compiledImplicit=Or(r,"implicit"),r.compiledExplicit=Or(r,"explicit"),r.compiledTypeMap=hc(r.compiledImplicit,r.compiledExplicit),r};var Lr=cn,Pr=new fe("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Tr=new fe("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Fr=new fe("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Yr=new Lr({explicit:[Pr,Tr,Fr]});function fc(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function pc(){return null}function gc(e){return e===null}var Hr=new fe("tag:yaml.org,2002:null",{kind:"scalar",resolve:fc,construct:pc,predicate:gc,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function yc(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function mc(e){return e==="true"||e==="True"||e==="TRUE"}function xc(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Br=new fe("tag:yaml.org,2002:bool",{kind:"scalar",resolve:yc,construct:mc,predicate:xc,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function bc(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function kc(e){return 48<=e&&e<=55}function vc(e){return 48<=e&&e<=57}function wc(e){if(e===null)return!1;var t=e.length,n=0,o=!1,r;if(!t)return!1;if(r=e[n],(r==="-"||r==="+")&&(r=e[++n]),r==="0"){if(n+1===t)return!0;if(r=e[++n],r==="b"){for(n++;n<t;n++)if(r=e[n],r!=="_"){if(r!=="0"&&r!=="1")return!1;o=!0}return o&&r!=="_"}if(r==="x"){for(n++;n<t;n++)if(r=e[n],r!=="_"){if(!bc(e.charCodeAt(n)))return!1;o=!0}return o&&r!=="_"}if(r==="o"){for(n++;n<t;n++)if(r=e[n],r!=="_"){if(!kc(e.charCodeAt(n)))return!1;o=!0}return o&&r!=="_"}}if(r==="_")return!1;for(;n<t;n++)if(r=e[n],r!=="_"){if(!vc(e.charCodeAt(n)))return!1;o=!0}return!(!o||r==="_")}function Cc(e){var t=e,n=1,o;if(t.indexOf("_")!==-1&&(t=t.replace(/_/g,"")),o=t[0],(o==="-"||o==="+")&&(o==="-"&&(n=-1),t=t.slice(1),o=t[0]),t==="0")return 0;if(o==="0"){if(t[1]==="b")return n*parseInt(t.slice(2),2);if(t[1]==="x")return n*parseInt(t.slice(2),16);if(t[1]==="o")return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function Nc(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!ce.isNegativeZero(e)}var Wr=new fe("tag:yaml.org,2002:int",{kind:"scalar",resolve:wc,construct:Cc,predicate:Nc,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zc=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Mc(e){return!(e===null||!zc.test(e)||e[e.length-1]==="_")}function _c(e){var t,n;return t=e.replace(/_/g,"").toLowerCase(),n=t[0]==="-"?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:n*parseFloat(t,10)}var Sc=/^[-+]?[0-9]+e/;function $c(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(ce.isNegativeZero(e))return"-0.0";return n=e.toString(10),Sc.test(n)?n.replace("e",".e"):n}function Ic(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||ce.isNegativeZero(e))}var Xr=new fe("tag:yaml.org,2002:float",{kind:"scalar",resolve:Mc,construct:_c,predicate:Ic,represent:$c,defaultStyle:"lowercase"}),Ur=Yr.extend({implicit:[Hr,Br,Wr,Xr]}),jr=Ur,Gr=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vr=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Ac(e){return e===null?!1:Gr.exec(e)!==null||Vr.exec(e)!==null}function Ec(e){var t,n,o,r,i,s,l,c=0,d=null,p,u,h;if(t=Gr.exec(e),t===null&&(t=Vr.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],o=+t[2]-1,r=+t[3],!t[4])return new Date(Date.UTC(n,o,r));if(i=+t[4],s=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(p=+t[10],u=+(t[11]||0),d=(p*60+u)*6e4,t[9]==="-"&&(d=-d)),h=new Date(Date.UTC(n,o,r,i,s,l,c)),d&&h.setTime(h.getTime()-d),h}function Dc(e){return e.toISOString()}var Kr=new fe("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Ac,construct:Ec,instanceOf:Date,represent:Dc});function Oc(e){return e==="<<"||e===null}var Zr=new fe("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Oc}),dn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
147
|
+
\r`;function Lc(e){if(e===null)return!1;var t,n,o=0,r=e.length,i=dn;for(n=0;n<r;n++)if(t=i.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;o+=6}return o%8===0}function Pc(e){var t,n,o=e.replace(/[\r\n=]/g,""),r=o.length,i=dn,s=0,l=[];for(t=0;t<r;t++)t%4===0&&t&&(l.push(s>>16&255),l.push(s>>8&255),l.push(s&255)),s=s<<6|i.indexOf(o.charAt(t));return n=r%4*6,n===0?(l.push(s>>16&255),l.push(s>>8&255),l.push(s&255)):n===18?(l.push(s>>10&255),l.push(s>>2&255)):n===12&&l.push(s>>4&255),new Uint8Array(l)}function Tc(e){var t="",n=0,o,r,i=e.length,s=dn;for(o=0;o<i;o++)o%3===0&&o&&(t+=s[n>>18&63],t+=s[n>>12&63],t+=s[n>>6&63],t+=s[n&63]),n=(n<<8)+e[o];return r=i%3,r===0?(t+=s[n>>18&63],t+=s[n>>12&63],t+=s[n>>6&63],t+=s[n&63]):r===2?(t+=s[n>>10&63],t+=s[n>>4&63],t+=s[n<<2&63],t+=s[64]):r===1&&(t+=s[n>>2&63],t+=s[n<<4&63],t+=s[64],t+=s[64]),t}function Fc(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var qr=new fe("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Lc,construct:Pc,predicate:Fc,represent:Tc}),Yc=Object.prototype.hasOwnProperty,Hc=Object.prototype.toString;function Bc(e){if(e===null)return!0;var t=[],n,o,r,i,s,l=e;for(n=0,o=l.length;n<o;n+=1){if(r=l[n],s=!1,Hc.call(r)!=="[object Object]")return!1;for(i in r)if(Yc.call(r,i))if(!s)s=!0;else return!1;if(!s)return!1;if(t.indexOf(i)===-1)t.push(i);else return!1}return!0}function Wc(e){return e!==null?e:[]}var Jr=new fe("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Bc,construct:Wc}),Xc=Object.prototype.toString;function Uc(e){if(e===null)return!0;var t,n,o,r,i,s=e;for(i=new Array(s.length),t=0,n=s.length;t<n;t+=1){if(o=s[t],Xc.call(o)!=="[object Object]"||(r=Object.keys(o),r.length!==1))return!1;i[t]=[r[0],o[r[0]]]}return!0}function jc(e){if(e===null)return[];var t,n,o,r,i,s=e;for(i=new Array(s.length),t=0,n=s.length;t<n;t+=1)o=s[t],r=Object.keys(o),i[t]=[r[0],o[r[0]]];return i}var Qr=new fe("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Uc,construct:jc}),Gc=Object.prototype.hasOwnProperty;function Vc(e){if(e===null)return!0;var t,n=e;for(t in n)if(Gc.call(n,t)&&n[t]!==null)return!1;return!0}function Kc(e){return e!==null?e:{}}var Rr=new fe("tag:yaml.org,2002:set",{kind:"mapping",resolve:Vc,construct:Kc}),un=jr.extend({implicit:[Kr,Zr],explicit:[qr,Jr,Qr,Rr]}),Ee=Object.prototype.hasOwnProperty,$t=1,eo=2,to=3,It=4,hn=1,Zc=2,no=3,qc=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Jc=/[\x85\u2028\u2029]/,Qc=/[,\[\]\{\}]/,ro=/^(?:!|!!|![a-z\-]+!)$/i,oo=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function io(e){return Object.prototype.toString.call(e)}function _e(e){return e===10||e===13}function Oe(e){return e===9||e===32}function xe(e){return e===9||e===32||e===10||e===13}function We(e){return e===44||e===91||e===93||e===123||e===125}function Rc(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function ed(e){return e===120?2:e===117?4:e===85?8:0}function td(e){return 48<=e&&e<=57?e-48:-1}function so(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
|
|
148
|
+
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"
":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}function nd(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function ao(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}for(var lo=new Array(256),co=new Array(256),Xe=0;Xe<256;Xe++)lo[Xe]=so(Xe)?1:0,co[Xe]=so(Xe);function rd(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||un,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function uo(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=ac(n),new ye(t,n)}function P(e,t){throw uo(e,t)}function At(e,t){e.onWarning&&e.onWarning.call(null,uo(e,t))}var ho={YAML:function(t,n,o){var r,i,s;t.version!==null&&P(t,"duplication of %YAML directive"),o.length!==1&&P(t,"YAML directive accepts exactly one argument"),r=/^([0-9]+)\.([0-9]+)$/.exec(o[0]),r===null&&P(t,"ill-formed argument of the YAML directive"),i=parseInt(r[1],10),s=parseInt(r[2],10),i!==1&&P(t,"unacceptable YAML version of the document"),t.version=o[0],t.checkLineBreaks=s<2,s!==1&&s!==2&&At(t,"unsupported YAML version of the document")},TAG:function(t,n,o){var r,i;o.length!==2&&P(t,"TAG directive accepts exactly two arguments"),r=o[0],i=o[1],ro.test(r)||P(t,"ill-formed tag handle (first argument) of the TAG directive"),Ee.call(t.tagMap,r)&&P(t,'there is a previously declared suffix for "'+r+'" tag handle'),oo.test(i)||P(t,"ill-formed tag prefix (second argument) of the TAG directive");try{i=decodeURIComponent(i)}catch{P(t,"tag prefix is malformed: "+i)}t.tagMap[r]=i}};function De(e,t,n,o){var r,i,s,l;if(t<n){if(l=e.input.slice(t,n),o)for(r=0,i=l.length;r<i;r+=1)s=l.charCodeAt(r),s===9||32<=s&&s<=1114111||P(e,"expected valid JSON character");else qc.test(l)&&P(e,"the stream contains non-printable characters");e.result+=l}}function fo(e,t,n,o){var r,i,s,l;for(ce.isObject(n)||P(e,"cannot merge mappings; the provided source object is unacceptable"),r=Object.keys(n),s=0,l=r.length;s<l;s+=1)i=r[s],Ee.call(t,i)||(ao(t,i,n[i]),o[i]=!0)}function Ue(e,t,n,o,r,i,s,l,c){var d,p;if(Array.isArray(r))for(r=Array.prototype.slice.call(r),d=0,p=r.length;d<p;d+=1)Array.isArray(r[d])&&P(e,"nested arrays are not supported inside keys"),typeof r=="object"&&io(r[d])==="[object Object]"&&(r[d]="[object Object]");if(typeof r=="object"&&io(r)==="[object Object]"&&(r="[object Object]"),r=String(r),t===null&&(t={}),o==="tag:yaml.org,2002:merge")if(Array.isArray(i))for(d=0,p=i.length;d<p;d+=1)fo(e,t,i[d],n);else fo(e,t,i,n);else!e.json&&!Ee.call(n,r)&&Ee.call(t,r)&&(e.line=s||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,P(e,"duplicated mapping key")),ao(t,r,i),delete n[r];return t}function fn(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):P(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function ie(e,t,n){for(var o=0,r=e.input.charCodeAt(e.position);r!==0;){for(;Oe(r);)r===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),r=e.input.charCodeAt(++e.position);if(t&&r===35)do r=e.input.charCodeAt(++e.position);while(r!==10&&r!==13&&r!==0);if(_e(r))for(fn(e),r=e.input.charCodeAt(e.position),o++,e.lineIndent=0;r===32;)e.lineIndent++,r=e.input.charCodeAt(++e.position);else break}return n!==-1&&o!==0&&e.lineIndent<n&&At(e,"deficient indentation"),o}function Et(e){var t=e.position,n;return n=e.input.charCodeAt(t),!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||xe(n)))}function pn(e,t){t===1?e.result+=" ":t>1&&(e.result+=ce.repeat(`
|
|
149
|
+
`,t-1))}function od(e,t,n){var o,r,i,s,l,c,d,p,u=e.kind,h=e.result,f;if(f=e.input.charCodeAt(e.position),xe(f)||We(f)||f===35||f===38||f===42||f===33||f===124||f===62||f===39||f===34||f===37||f===64||f===96||(f===63||f===45)&&(r=e.input.charCodeAt(e.position+1),xe(r)||n&&We(r)))return!1;for(e.kind="scalar",e.result="",i=s=e.position,l=!1;f!==0;){if(f===58){if(r=e.input.charCodeAt(e.position+1),xe(r)||n&&We(r))break}else if(f===35){if(o=e.input.charCodeAt(e.position-1),xe(o))break}else{if(e.position===e.lineStart&&Et(e)||n&&We(f))break;if(_e(f))if(c=e.line,d=e.lineStart,p=e.lineIndent,ie(e,!1,-1),e.lineIndent>=t){l=!0,f=e.input.charCodeAt(e.position);continue}else{e.position=s,e.line=c,e.lineStart=d,e.lineIndent=p;break}}l&&(De(e,i,s,!1),pn(e,e.line-c),i=s=e.position,l=!1),Oe(f)||(s=e.position+1),f=e.input.charCodeAt(++e.position)}return De(e,i,s,!1),e.result?!0:(e.kind=u,e.result=h,!1)}function id(e,t){var n,o,r;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,o=r=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(De(e,o,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)o=e.position,e.position++,r=e.position;else return!0;else _e(n)?(De(e,o,r,!0),pn(e,ie(e,!1,t)),o=r=e.position):e.position===e.lineStart&&Et(e)?P(e,"unexpected end of the document within a single quoted scalar"):(e.position++,r=e.position);P(e,"unexpected end of the stream within a single quoted scalar")}function sd(e,t){var n,o,r,i,s,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=o=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return De(e,n,e.position,!0),e.position++,!0;if(l===92){if(De(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),_e(l))ie(e,!1,t);else if(l<256&&lo[l])e.result+=co[l],e.position++;else if((s=ed(l))>0){for(r=s,i=0;r>0;r--)l=e.input.charCodeAt(++e.position),(s=Rc(l))>=0?i=(i<<4)+s:P(e,"expected hexadecimal character");e.result+=nd(i),e.position++}else P(e,"unknown escape sequence");n=o=e.position}else _e(l)?(De(e,n,o,!0),pn(e,ie(e,!1,t)),n=o=e.position):e.position===e.lineStart&&Et(e)?P(e,"unexpected end of the document within a double quoted scalar"):(e.position++,o=e.position)}P(e,"unexpected end of the stream within a double quoted scalar")}function ad(e,t){var n=!0,o,r,i,s=e.tag,l,c=e.anchor,d,p,u,h,f,g=Object.create(null),x,k,m,y;if(y=e.input.charCodeAt(e.position),y===91)p=93,f=!1,l=[];else if(y===123)p=125,f=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),y=e.input.charCodeAt(++e.position);y!==0;){if(ie(e,!0,t),y=e.input.charCodeAt(e.position),y===p)return e.position++,e.tag=s,e.anchor=c,e.kind=f?"mapping":"sequence",e.result=l,!0;n?y===44&&P(e,"expected the node content, but found ','"):P(e,"missed comma between flow collection entries"),k=x=m=null,u=h=!1,y===63&&(d=e.input.charCodeAt(e.position+1),xe(d)&&(u=h=!0,e.position++,ie(e,!0,t))),o=e.line,r=e.lineStart,i=e.position,je(e,t,$t,!1,!0),k=e.tag,x=e.result,ie(e,!0,t),y=e.input.charCodeAt(e.position),(h||e.line===o)&&y===58&&(u=!0,y=e.input.charCodeAt(++e.position),ie(e,!0,t),je(e,t,$t,!1,!0),m=e.result),f?Ue(e,l,g,k,x,m,o,r,i):u?l.push(Ue(e,null,g,k,x,m,o,r,i)):l.push(x),ie(e,!0,t),y=e.input.charCodeAt(e.position),y===44?(n=!0,y=e.input.charCodeAt(++e.position)):n=!1}P(e,"unexpected end of the stream within a flow collection")}function ld(e,t){var n,o,r=hn,i=!1,s=!1,l=t,c=0,d=!1,p,u;if(u=e.input.charCodeAt(e.position),u===124)o=!1;else if(u===62)o=!0;else return!1;for(e.kind="scalar",e.result="";u!==0;)if(u=e.input.charCodeAt(++e.position),u===43||u===45)hn===r?r=u===43?no:Zc:P(e,"repeat of a chomping mode identifier");else if((p=td(u))>=0)p===0?P(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?P(e,"repeat of an indentation width identifier"):(l=t+p-1,s=!0);else break;if(Oe(u)){do u=e.input.charCodeAt(++e.position);while(Oe(u));if(u===35)do u=e.input.charCodeAt(++e.position);while(!_e(u)&&u!==0)}for(;u!==0;){for(fn(e),e.lineIndent=0,u=e.input.charCodeAt(e.position);(!s||e.lineIndent<l)&&u===32;)e.lineIndent++,u=e.input.charCodeAt(++e.position);if(!s&&e.lineIndent>l&&(l=e.lineIndent),_e(u)){c++;continue}if(e.lineIndent<l){r===no?e.result+=ce.repeat(`
|
|
150
|
+
`,i?1+c:c):r===hn&&i&&(e.result+=`
|
|
151
|
+
`);break}for(o?Oe(u)?(d=!0,e.result+=ce.repeat(`
|
|
152
|
+
`,i?1+c:c)):d?(d=!1,e.result+=ce.repeat(`
|
|
153
|
+
`,c+1)):c===0?i&&(e.result+=" "):e.result+=ce.repeat(`
|
|
154
|
+
`,c):e.result+=ce.repeat(`
|
|
155
|
+
`,i?1+c:c),i=!0,s=!0,c=0,n=e.position;!_e(u)&&u!==0;)u=e.input.charCodeAt(++e.position);De(e,n,e.position,!1)}return!0}function po(e,t){var n,o=e.tag,r=e.anchor,i=[],s,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=i),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,P(e,"tab characters must not be used in indentation")),!(c!==45||(s=e.input.charCodeAt(e.position+1),!xe(s))));){if(l=!0,e.position++,ie(e,!0,-1)&&e.lineIndent<=t){i.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,je(e,t,to,!1,!0),i.push(e.result),ie(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)P(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=o,e.anchor=r,e.kind="sequence",e.result=i,!0):!1}function cd(e,t,n){var o,r,i,s,l,c,d=e.tag,p=e.anchor,u={},h=Object.create(null),f=null,g=null,x=null,k=!1,m=!1,y;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),y=e.input.charCodeAt(e.position);y!==0;){if(!k&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,P(e,"tab characters must not be used in indentation")),o=e.input.charCodeAt(e.position+1),i=e.line,(y===63||y===58)&&xe(o))y===63?(k&&(Ue(e,u,h,f,g,null,s,l,c),f=g=x=null),m=!0,k=!0,r=!0):k?(k=!1,r=!0):P(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,y=o;else{if(s=e.line,l=e.lineStart,c=e.position,!je(e,n,eo,!1,!0))break;if(e.line===i){for(y=e.input.charCodeAt(e.position);Oe(y);)y=e.input.charCodeAt(++e.position);if(y===58)y=e.input.charCodeAt(++e.position),xe(y)||P(e,"a whitespace character is expected after the key-value separator within a block mapping"),k&&(Ue(e,u,h,f,g,null,s,l,c),f=g=x=null),m=!0,k=!1,r=!1,f=e.tag,g=e.result;else if(m)P(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=p,!0}else if(m)P(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,e.anchor=p,!0}if((e.line===i||e.lineIndent>t)&&(k&&(s=e.line,l=e.lineStart,c=e.position),je(e,t,It,!0,r)&&(k?g=e.result:x=e.result),k||(Ue(e,u,h,f,g,x,s,l,c),f=g=x=null),ie(e,!0,-1),y=e.input.charCodeAt(e.position)),(e.line===i||e.lineIndent>t)&&y!==0)P(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return k&&Ue(e,u,h,f,g,null,s,l,c),m&&(e.tag=d,e.anchor=p,e.kind="mapping",e.result=u),m}function dd(e){var t,n=!1,o=!1,r,i,s;if(s=e.input.charCodeAt(e.position),s!==33)return!1;if(e.tag!==null&&P(e,"duplication of a tag property"),s=e.input.charCodeAt(++e.position),s===60?(n=!0,s=e.input.charCodeAt(++e.position)):s===33?(o=!0,r="!!",s=e.input.charCodeAt(++e.position)):r="!",t=e.position,n){do s=e.input.charCodeAt(++e.position);while(s!==0&&s!==62);e.position<e.length?(i=e.input.slice(t,e.position),s=e.input.charCodeAt(++e.position)):P(e,"unexpected end of the stream within a verbatim tag")}else{for(;s!==0&&!xe(s);)s===33&&(o?P(e,"tag suffix cannot contain exclamation marks"):(r=e.input.slice(t-1,e.position+1),ro.test(r)||P(e,"named tag handle cannot contain such characters"),o=!0,t=e.position+1)),s=e.input.charCodeAt(++e.position);i=e.input.slice(t,e.position),Qc.test(i)&&P(e,"tag suffix cannot contain flow indicator characters")}i&&!oo.test(i)&&P(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch{P(e,"tag name is malformed: "+i)}return n?e.tag=i:Ee.call(e.tagMap,r)?e.tag=e.tagMap[r]+i:r==="!"?e.tag="!"+i:r==="!!"?e.tag="tag:yaml.org,2002:"+i:P(e,'undeclared tag handle "'+r+'"'),!0}function ud(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&P(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!xe(n)&&!We(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&P(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function hd(e){var t,n,o;if(o=e.input.charCodeAt(e.position),o!==42)return!1;for(o=e.input.charCodeAt(++e.position),t=e.position;o!==0&&!xe(o)&&!We(o);)o=e.input.charCodeAt(++e.position);return e.position===t&&P(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),Ee.call(e.anchorMap,n)||P(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],ie(e,!0,-1),!0}function je(e,t,n,o,r){var i,s,l,c=1,d=!1,p=!1,u,h,f,g,x,k;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,i=s=l=It===n||to===n,o&&ie(e,!0,-1)&&(d=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;dd(e)||ud(e);)ie(e,!0,-1)?(d=!0,l=i,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=d||r),(c===1||It===n)&&($t===n||eo===n?x=t:x=t+1,k=e.position-e.lineStart,c===1?l&&(po(e,k)||cd(e,k,x))||ad(e,x)?p=!0:(s&&ld(e,x)||id(e,x)||sd(e,x)?p=!0:hd(e)?(p=!0,(e.tag!==null||e.anchor!==null)&&P(e,"alias node should not have any properties")):od(e,x,$t===n)&&(p=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(p=l&&po(e,k))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&P(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),u=0,h=e.implicitTypes.length;u<h;u+=1)if(g=e.implicitTypes[u],g.resolve(e.result)){e.result=g.construct(e.result),e.tag=g.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(Ee.call(e.typeMap[e.kind||"fallback"],e.tag))g=e.typeMap[e.kind||"fallback"][e.tag];else for(g=null,f=e.typeMap.multi[e.kind||"fallback"],u=0,h=f.length;u<h;u+=1)if(e.tag.slice(0,f[u].tag.length)===f[u].tag){g=f[u];break}g||P(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&P(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+g.kind+'", not "'+e.kind+'"'),g.resolve(e.result,e.tag)?(e.result=g.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):P(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||p}function fd(e){var t=e.position,n,o,r,i=!1,s;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(s=e.input.charCodeAt(e.position))!==0&&(ie(e,!0,-1),s=e.input.charCodeAt(e.position),!(e.lineIndent>0||s!==37));){for(i=!0,s=e.input.charCodeAt(++e.position),n=e.position;s!==0&&!xe(s);)s=e.input.charCodeAt(++e.position);for(o=e.input.slice(n,e.position),r=[],o.length<1&&P(e,"directive name must not be less than one character in length");s!==0;){for(;Oe(s);)s=e.input.charCodeAt(++e.position);if(s===35){do s=e.input.charCodeAt(++e.position);while(s!==0&&!_e(s));break}if(_e(s))break;for(n=e.position;s!==0&&!xe(s);)s=e.input.charCodeAt(++e.position);r.push(e.input.slice(n,e.position))}s!==0&&fn(e),Ee.call(ho,o)?ho[o](e,o,r):At(e,'unknown document directive "'+o+'"')}if(ie(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,ie(e,!0,-1)):i&&P(e,"directives end mark is expected"),je(e,e.lineIndent-1,It,!1,!0),ie(e,!0,-1),e.checkLineBreaks&&Jc.test(e.input.slice(t,e.position))&&At(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Et(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,ie(e,!0,-1));return}if(e.position<e.length-1)P(e,"end of the stream or a document separator is expected");else return}function go(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
|
|
156
|
+
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new rd(e,t),o=e.indexOf("\0");for(o!==-1&&(n.position=o,P(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)fd(n);return n.documents}function pd(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var o=go(e,n);if(typeof t!="function")return o;for(var r=0,i=o.length;r<i;r+=1)t(o[r])}function gd(e,t){var n=go(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new ye("expected a single document in the stream, but found more")}}var yd=pd,md=gd,yo={loadAll:yd,load:md},mo=Object.prototype.toString,xo=Object.prototype.hasOwnProperty,gn=65279,xd=9,it=10,bd=13,kd=32,vd=33,wd=34,yn=35,Cd=37,Nd=38,zd=39,Md=42,bo=44,_d=45,Dt=58,Sd=61,$d=62,Id=63,Ad=64,ko=91,vo=93,Ed=96,wo=123,Dd=124,Co=125,pe={};pe[0]="\\0",pe[7]="\\a",pe[8]="\\b",pe[9]="\\t",pe[10]="\\n",pe[11]="\\v",pe[12]="\\f",pe[13]="\\r",pe[27]="\\e",pe[34]='\\"',pe[92]="\\\\",pe[133]="\\N",pe[160]="\\_",pe[8232]="\\L",pe[8233]="\\P";var Od=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],Ld=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Pd(e,t){var n,o,r,i,s,l,c;if(t===null)return{};for(n={},o=Object.keys(t),r=0,i=o.length;r<i;r+=1)s=o[r],l=String(t[s]),s.slice(0,2)==="!!"&&(s="tag:yaml.org,2002:"+s.slice(2)),c=e.compiledTypeMap.fallback[s],c&&xo.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[s]=l;return n}function Td(e){var t,n,o;if(t=e.toString(16).toUpperCase(),e<=255)n="x",o=2;else if(e<=65535)n="u",o=4;else if(e<=4294967295)n="U",o=8;else throw new ye("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+ce.repeat("0",o-t.length)+t}var Fd=1,st=2;function Yd(e){this.schema=e.schema||un,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=ce.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=Pd(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?st:Fd,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function No(e,t){for(var n=ce.repeat(" ",t),o=0,r=-1,i="",s,l=e.length;o<l;)r=e.indexOf(`
|
|
157
157
|
`,o),r===-1?(s=e.slice(o),o=l):(s=e.slice(o,r+1),o=r+1),s.length&&s!==`
|
|
158
|
-
`&&(i+=n),i+=s;return i}function
|
|
159
|
-
`+
|
|
158
|
+
`&&(i+=n),i+=s;return i}function mn(e,t){return`
|
|
159
|
+
`+ce.repeat(" ",e.indent*t)}function Hd(e,t){var n,o,r;for(n=0,o=e.implicitTypes.length;n<o;n+=1)if(r=e.implicitTypes[n],r.resolve(t))return!0;return!1}function Ot(e){return e===kd||e===xd}function at(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==gn||65536<=e&&e<=1114111}function zo(e){return at(e)&&e!==gn&&e!==bd&&e!==it}function Mo(e,t,n){var o=zo(e),r=o&&!Ot(e);return(n?o:o&&e!==bo&&e!==ko&&e!==vo&&e!==wo&&e!==Co)&&e!==yn&&!(t===Dt&&!r)||zo(t)&&!Ot(t)&&e===yn||t===Dt&&r}function Bd(e){return at(e)&&e!==gn&&!Ot(e)&&e!==_d&&e!==Id&&e!==Dt&&e!==bo&&e!==ko&&e!==vo&&e!==wo&&e!==Co&&e!==yn&&e!==Nd&&e!==Md&&e!==vd&&e!==Dd&&e!==Sd&&e!==$d&&e!==zd&&e!==wd&&e!==Cd&&e!==Ad&&e!==Ed}function Wd(e){return!Ot(e)&&e!==Dt}function lt(e,t){var n=e.charCodeAt(t),o;return n>=55296&&n<=56319&&t+1<e.length&&(o=e.charCodeAt(t+1),o>=56320&&o<=57343)?(n-55296)*1024+o-56320+65536:n}function _o(e){var t=/^\n* /;return t.test(e)}var So=1,xn=2,$o=3,Io=4,Ge=5;function Xd(e,t,n,o,r,i,s,l){var c,d=0,p=null,u=!1,h=!1,f=o!==-1,g=-1,x=Bd(lt(e,0))&&Wd(lt(e,e.length-1));if(t||s)for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=lt(e,c),!at(d))return Ge;x=x&&Mo(d,p,l),p=d}else{for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=lt(e,c),d===it)u=!0,f&&(h=h||c-g-1>o&&e[g+1]!==" ",g=c);else if(!at(d))return Ge;x=x&&Mo(d,p,l),p=d}h=h||f&&c-g-1>o&&e[g+1]!==" "}return!u&&!h?x&&!s&&!r(e)?So:i===st?Ge:xn:n>9&&_o(e)?Ge:s?i===st?Ge:xn:h?Io:$o}function Ud(e,t,n,o,r){e.dump=(function(){if(t.length===0)return e.quotingType===st?'""':"''";if(!e.noCompatMode&&(Od.indexOf(t)!==-1||Ld.test(t)))return e.quotingType===st?'"'+t+'"':"'"+t+"'";var i=e.indent*Math.max(1,n),s=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-i),l=o||e.flowLevel>-1&&n>=e.flowLevel;function c(d){return Hd(e,d)}switch(Xd(t,l,e.indent,s,c,e.quotingType,e.forceQuotes&&!o,r)){case So:return t;case xn:return"'"+t.replace(/'/g,"''")+"'";case $o:return"|"+Ao(t,e.indent)+Eo(No(t,i));case Io:return">"+Ao(t,e.indent)+Eo(No(jd(t,s),i));case Ge:return'"'+Gd(t)+'"';default:throw new ye("impossible error: invalid scalar style")}})()}function Ao(e,t){var n=_o(e)?String(t):"",o=e[e.length-1]===`
|
|
160
160
|
`,r=o&&(e[e.length-2]===`
|
|
161
161
|
`||e===`
|
|
162
162
|
`),i=r?"+":o?"":"-";return n+i+`
|
|
163
163
|
`}function Eo(e){return e[e.length-1]===`
|
|
164
|
-
`?e.slice(0,-1):e}function
|
|
164
|
+
`?e.slice(0,-1):e}function jd(e,t){for(var n=/(\n+)([^\n]*)/g,o=(function(){var d=e.indexOf(`
|
|
165
165
|
`);return d=d!==-1?d:e.length,n.lastIndex=d,Do(e.slice(0,d),t)})(),r=e[0]===`
|
|
166
166
|
`||e[0]===" ",i,s;s=n.exec(e);){var l=s[1],c=s[2];i=c[0]===" ",o+=l+(!r&&!i&&c!==""?`
|
|
167
167
|
`:"")+Do(c,t),r=i}return o}function Do(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,o,r=0,i,s=0,l=0,c="";o=n.exec(e);)l=o.index,l-r>t&&(i=s>r?s:l,c+=`
|
|
168
168
|
`+e.slice(r,i),r=i+1),s=l;return c+=`
|
|
169
169
|
`,e.length-r>t&&s>r?c+=e.slice(r,s)+`
|
|
170
|
-
`+e.slice(s+1):c+=e.slice(r),c.slice(1)}function
|
|
171
|
-
`:""}var
|
|
172
|
-
`)}
|
|
170
|
+
`+e.slice(s+1):c+=e.slice(r),c.slice(1)}function Gd(e){for(var t="",n=0,o,r=0;r<e.length;n>=65536?r+=2:r++)n=lt(e,r),o=pe[n],!o&&at(n)?(t+=e[r],n>=65536&&(t+=e[r+1])):t+=o||Td(n);return t}function Vd(e,t,n){var o="",r=e.tag,i,s,l;for(i=0,s=n.length;i<s;i+=1)l=n[i],e.replacer&&(l=e.replacer.call(n,String(i),l)),($e(e,t,l,!1,!1)||typeof l>"u"&&$e(e,t,null,!1,!1))&&(o!==""&&(o+=","+(e.condenseFlow?"":" ")),o+=e.dump);e.tag=r,e.dump="["+o+"]"}function Oo(e,t,n,o){var r="",i=e.tag,s,l,c;for(s=0,l=n.length;s<l;s+=1)c=n[s],e.replacer&&(c=e.replacer.call(n,String(s),c)),($e(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&$e(e,t+1,null,!0,!0,!1,!0))&&((!o||r!=="")&&(r+=mn(e,t)),e.dump&&it===e.dump.charCodeAt(0)?r+="-":r+="- ",r+=e.dump);e.tag=i,e.dump=r||"[]"}function Kd(e,t,n){var o="",r=e.tag,i=Object.keys(n),s,l,c,d,p;for(s=0,l=i.length;s<l;s+=1)p="",o!==""&&(p+=", "),e.condenseFlow&&(p+='"'),c=i[s],d=n[c],e.replacer&&(d=e.replacer.call(n,c,d)),$e(e,t,c,!1,!1)&&(e.dump.length>1024&&(p+="? "),p+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),$e(e,t,d,!1,!1)&&(p+=e.dump,o+=p));e.tag=r,e.dump="{"+o+"}"}function Zd(e,t,n,o){var r="",i=e.tag,s=Object.keys(n),l,c,d,p,u,h;if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys=="function")s.sort(e.sortKeys);else if(e.sortKeys)throw new ye("sortKeys must be a boolean or a function");for(l=0,c=s.length;l<c;l+=1)h="",(!o||r!=="")&&(h+=mn(e,t)),d=s[l],p=n[d],e.replacer&&(p=e.replacer.call(n,d,p)),$e(e,t+1,d,!0,!0,!0)&&(u=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,u&&(e.dump&&it===e.dump.charCodeAt(0)?h+="?":h+="? "),h+=e.dump,u&&(h+=mn(e,t)),$e(e,t+1,p,!0,u)&&(e.dump&&it===e.dump.charCodeAt(0)?h+=":":h+=": ",h+=e.dump,r+=h));e.tag=i,e.dump=r||"{}"}function Lo(e,t,n){var o,r,i,s,l,c;for(r=n?e.explicitTypes:e.implicitTypes,i=0,s=r.length;i<s;i+=1)if(l=r[i],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,mo.call(l.represent)==="[object Function]")o=l.represent(t,c);else if(xo.call(l.represent,c))o=l.represent[c](t,c);else throw new ye("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=o}return!0}return!1}function $e(e,t,n,o,r,i,s){e.tag=null,e.dump=n,Lo(e,n,!1)||Lo(e,n,!0);var l=mo.call(e.dump),c=o,d;o&&(o=e.flowLevel<0||e.flowLevel>t);var p=l==="[object Object]"||l==="[object Array]",u,h;if(p&&(u=e.duplicates.indexOf(n),h=u!==-1),(e.tag!==null&&e.tag!=="?"||h||e.indent!==2&&t>0)&&(r=!1),h&&e.usedDuplicates[u])e.dump="*ref_"+u;else{if(p&&h&&!e.usedDuplicates[u]&&(e.usedDuplicates[u]=!0),l==="[object Object]")o&&Object.keys(e.dump).length!==0?(Zd(e,t,e.dump,r),h&&(e.dump="&ref_"+u+e.dump)):(Kd(e,t,e.dump),h&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object Array]")o&&e.dump.length!==0?(e.noArrayIndent&&!s&&t>0?Oo(e,t-1,e.dump,r):Oo(e,t,e.dump,r),h&&(e.dump="&ref_"+u+e.dump)):(Vd(e,t,e.dump),h&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&Ud(e,e.dump,t,i,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new ye("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function qd(e,t){var n=[],o=[],r,i;for(bn(e,n,o),r=0,i=o.length;r<i;r+=1)t.duplicates.push(n[o[r]]);t.usedDuplicates=new Array(i)}function bn(e,t,n){var o,r,i;if(e!==null&&typeof e=="object")if(r=t.indexOf(e),r!==-1)n.indexOf(r)===-1&&n.push(r);else if(t.push(e),Array.isArray(e))for(r=0,i=e.length;r<i;r+=1)bn(e[r],t,n);else for(o=Object.keys(e),r=0,i=o.length;r<i;r+=1)bn(e[o[r]],t,n)}function Jd(e,t){t=t||{};var n=new Yd(t);n.noRefs||qd(e,n);var o=e;return n.replacer&&(o=n.replacer.call({"":o},"",o)),$e(n,0,o,!0,!0)?n.dump+`
|
|
171
|
+
`:""}var Qd=Jd,Rd={dump:Qd};function kn(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var eu=fe,tu=Lr,nu=Yr,ru=Ur,ou=jr,iu=un,su=yo.load,au=yo.loadAll,lu=Rd.dump,cu=ye,du={binary:qr,float:Xr,map:Fr,null:Hr,pairs:Qr,set:Rr,timestamp:Kr,bool:Br,int:Wr,merge:Zr,omap:Jr,seq:Tr,str:Pr},uu=kn("safeLoad","load"),hu=kn("safeLoadAll","loadAll"),fu=kn("safeDump","dump"),pu={Type:eu,Schema:tu,FAILSAFE_SCHEMA:nu,JSON_SCHEMA:ru,CORE_SCHEMA:ou,DEFAULT_SCHEMA:iu,load:su,loadAll:au,dump:lu,YAMLException:cu,types:du,safeLoad:uu,safeLoadAll:hu,safeDump:fu};function gu(e){const t=e.match(/^(\d+)x(\d+)x(\d+)$/);return t?{width:parseInt(t[1],10),depth:parseInt(t[2],10),height:parseInt(t[3],10)}:null}function Po(e){const t=e.match(/^(\d+)x(\d+)$/);return t?{width:parseInt(t[1],10),height:parseInt(t[2],10)}:null}function yu(e){const t=e.match(/^(-?\d+),(-?\d+)$/);return t?{x:parseInt(t[1],10),y:parseInt(t[2],10)}:null}function mu(e){const t=e.match(/^(.+?)\s*@\s*(\d+)$/);return t?{name:t[1].trim(),elevation:parseInt(t[2],10)}:null}function xu(e,t,n){let o={};const r=e.match(/\{([^}]+)\}\s*$/);if(r){const f=r[1].split(/\s+/);for(const g of f){const[x,k]=g.split("=");if(x&&k){const m=parseFloat(k);o[x]=isNaN(m)?k:m}}e=e.replace(/\{[^}]+\}\s*$/,"").trim()}const i=e.trim().split(/\s+/);if(i.length<4)return null;const s=i[0],l=i[1],c=i[2],d=i[3],p=yu(c),u=gu(d);if(!p||!u)return null;const h=n[l]||l;return{tier:t,label:s,color:h,x:p.x,y:p.y,width:u.width,depth:u.depth,height:u.height,...o}}function bu(e){const t=pu.load(e);let n={width:1100,height:700};if(typeof t.canvas=="string"){const h=Po(t.canvas);h&&(n=h)}else t.canvas&&typeof t.canvas=="object"&&(n=t.canvas);let o={width:400,depth:280};if(typeof t.floor=="string"){const h=Po(t.floor);h&&(o={width:h.width,depth:h.height})}else t.floor&&typeof t.floor=="object"&&(o=t.floor);let r={x:n.width/2,y:n.height-80};t.origin&&typeof t.origin=="object"&&(r=t.origin);const i={};if(t.colors&&typeof t.colors=="object")for(const[h,f]of Object.entries(t.colors))i[h]=f;const s=[],l={dark:["#0f172a","#1e293b","#334155","#475569"],light:["#f1f5f9","#e0f2fe","#dbeafe","#ede9fe"]},c={dark:["#334155","#475569","#64748b","#94a3b8"],light:["#94a3b8","#7dd3fc","#93c5fd","#c4b5fd"]},d=t.theme||"dark";Array.isArray(t.tiers)&&t.tiers.forEach((h,f)=>{if(typeof h=="string"){const g=mu(h);g&&s.push({name:g.name,elevation:g.elevation,floorColor:l[d][f]||l[d][0],floorOpacity:f===0?.95:.7-f*.1,borderColor:c[d][f]||c[d][0]})}else if(h&&typeof h=="object"){const g=h;s.push({name:g.name||`Tier ${f}`,elevation:g.elevation||f*150,floorColor:g.floorColor||l[d][f],floorOpacity:g.floorOpacity??(f===0?.95:.7-f*.1),borderColor:g.borderColor||c[d][f]})}});const p=[];if(t.nodes&&typeof t.nodes=="object"&&!Array.isArray(t.nodes)){const h=t.nodes;for(const[f,g]of Object.entries(h)){const x=parseInt(f,10);if(!(isNaN(x)||!Array.isArray(g))){for(const k of g)if(typeof k=="string"){const m=xu(k,x,i);m&&p.push(m)}else if(k&&typeof k=="object"){const m=k;p.push({tier:x,label:m.label||"",color:i[m.color]||m.color||"slate",x:m.x||0,y:m.y||0,width:m.width||100,depth:m.depth||80,height:m.height||40,opacity:m.opacity,blur:m.blur,translucent:m.translucent})}}}}const u=[];if(Array.isArray(t.pillars)){for(const h of t.pillars)if(typeof h=="string"){const f=h.match(/^(-?\d+),(-?\d+)\s+(\d+)->(\d+)$/);f&&u.push({x:parseInt(f[1],10),y:parseInt(f[2],10),fromTier:parseInt(f[3],10),toTier:parseInt(f[4],10)})}else if(h&&typeof h=="object"){const f=h;u.push({x:f.x||0,y:f.y||0,fromTier:f.fromTier||0,toTier:f.toTier||1})}}return{title:t.title||"Untitled",description:t.description||"",theme:d,canvas:n,origin:r,cornerRadius:t.corner??t.cornerRadius??14,tiers:s,floorSize:o,nodes:p,pillars:u.length>0?u:void 0}}function ku(e){const t=[];t.push(`title: ${e.title}`),e.description&&t.push(`description: ${e.description}`),t.push(`theme: ${e.theme}`),t.push(`canvas: ${e.canvas.width}x${e.canvas.height}`),t.push(`floor: ${e.floorSize.width}x${e.floorSize.depth}`),e.cornerRadius&&t.push(`corner: ${e.cornerRadius}`),t.push("");const n={};e.nodes.forEach(r=>{n[r.color]=(n[r.color]||0)+1});const o=Object.entries(n).filter(([,r])=>r>=2).map(([r])=>r);return o.length>0&&(t.push("colors:"),o.forEach(r=>{const i=r.slice(0,3);t.push(` ${i}: &${i} ${r}`)}),t.push("")),t.push("tiers:"),e.tiers.forEach(r=>{t.push(` - ${r.name} @ ${r.elevation}`)}),t.push(""),t.push("nodes:"),e.tiers.forEach((r,i)=>{const s=e.nodes.filter(l=>l.tier===i);s.length!==0&&(t.push(` ${i}: # ${r.name}`),s.forEach(l=>{let c=l.color;o.includes(l.color)&&(c=`*${l.color.slice(0,3)}`);const d=[];l.opacity!==void 0&&d.push(`opacity=${l.opacity}`),l.blur!==void 0&&d.push(`blur=${l.blur}`),l.translucent&&d.push("translucent=true");const p=d.length>0?` { ${d.join(" ")} }`:"",u=`${l.width}x${l.depth}x${l.height}`,h=`${l.x},${l.y}`,f=l.label.padEnd(12),g=c.padEnd(8);t.push(` - ${f} ${g} ${h.padEnd(8)} ${u}${p}`)}))}),e.pillars&&e.pillars.length>0&&(t.push(""),t.push("pillars:"),e.pillars.forEach(r=>{t.push(` - ${r.x},${r.y} ${r.fromTier}->${r.toTier}`)})),t.join(`
|
|
172
|
+
`)}q.ArcDiagram=jl,q.DiagramCanvas=Qn,q.DiagramEditor=Hl,q.EditorProvider=Hn,q.ISO_COLORS=Ze,q.configToYaml=ku,q.getColorShading=Kn,q.isoBoundingBox=vs,q.isoBox=Te,q.isoShading=Vn,q.isoToScreen=F,q.parseYamlConfig=bu,q.renderToElement=Kl,q.renderToString=Ar,q.screenToIsoFloor=Xt,q.useDiagram=Ne,q.useEditor=he,q.useEditorState=Ve,q.useViewMode=Wt,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})}));
|