likec4 1.52.0 → 1.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/__app__/src/likec4.js +34 -48
  2. package/__app__/src/routes/index.js +7 -0
  3. package/__app__/src/routes/single.js +30 -18
  4. package/__app__/src/style.css +1 -1
  5. package/__app__/src/vendors.js +2065 -2809
  6. package/config/schema.json +56 -0
  7. package/dist/THIRD-PARTY-LICENSES.md +10 -2
  8. package/dist/_chunks/filesystem.mjs +70 -68
  9. package/dist/_chunks/index.d.mts +10 -1
  10. package/dist/_chunks/index2.d.mts +76 -4
  11. package/dist/_chunks/libs/@hono/mcp.mjs +1 -1
  12. package/dist/_chunks/libs/@logtape/logtape.d.mts +1021 -0
  13. package/dist/_chunks/libs/@logtape/logtape.mjs +4 -6
  14. package/dist/_chunks/libs/@modelcontextprotocol/sdk.d.mts +1 -1
  15. package/dist/_chunks/libs/@nanostores/react.d.mts +5 -5
  16. package/dist/_chunks/libs/destr.mjs +1 -0
  17. package/dist/_chunks/libs/fast-equals.mjs +1 -1
  18. package/dist/_chunks/libs/langium.mjs +1 -1
  19. package/dist/_chunks/libs/remeda.mjs +2 -2
  20. package/dist/_chunks/libs/tinyrainbow.mjs +1 -1
  21. package/dist/_chunks/libs/unstorage.mjs +1 -0
  22. package/dist/_chunks/node.mjs +1 -0
  23. package/dist/_chunks/sequence.mjs +1 -1
  24. package/dist/_chunks/src.mjs +14 -12
  25. package/dist/_chunks/src2.mjs +46 -46
  26. package/dist/cli/index.mjs +164 -84
  27. package/dist/index.d.mts +16 -819
  28. package/dist/index.mjs +1 -1
  29. package/dist/vite-plugin/index.mjs +1 -1
  30. package/dist/vite-plugin/internal.mjs +1 -1
  31. package/package.json +34 -33
  32. package/react/index.d.mts +24 -20
  33. package/react/index.mjs +969 -1728
  34. package/vite-plugin-modules.d.ts +5 -0
  35. package/dist/_chunks/LikeC4.mjs +0 -1
  36. package/dist/_chunks/libs/boxen.d.mts +0 -1
@@ -1,40 +1,40 @@
1
- import{t as e}from"./libs/birpc.mjs";import{C as t,D as n,I as r,S as i,W as a,Z as o,b as s,f as c,k as l,o as u,q as d,r as f,t as p,y as m}from"./libs/remeda.mjs";import{_ as h,c as g,d as _,f as v,i as y,l as b,m as x,o as ee,r as S,s as te,t as ne,x as re}from"./filesystem.mjs";import{t as C}from"./libs/defu.mjs";import{r as w,t as T}from"./libs/pathe.mjs";import{n as E}from"./libs/tinyrainbow.mjs";import{t as D}from"./libs/json5.mjs";import{a as O,i as k,n as A,r as j,t as M}from"./libs/langium.mjs";import{o as N}from"./libs/ufo.mjs";import{t as ie}from"./libs/pako.mjs";import"@likec4/core/model";import{LikeC4Styles as P,invariant as ae,isNonEmptyArray as oe,memoizeProp as se,nonexhaustive as ce}from"@likec4/core";import{pathToFileURL as le}from"url";import{RichText as ue,flattenMarkdownOrString as de}from"@likec4/core/types";import{compareNatural as fe,invariant as pe,sortNaturalByFqn as me}from"@likec4/core/utils";function he(e){let t=h.getChild(`lang`),n=C(e,{useFileSystem:!0,manualLayouts:!0,watch:!1,graphviz:`wasm`}),r=n.graphviz===`binary`;return t.info(`${E.dim(`layout`)} ${r?`binary`:`wasm`}`),S({...n.useFileSystem?{...ee(n.watch),...n.manualLayouts?b:g}:{...te,...g},...y(r?new _:new v)})}async function ge(e,t){ne(t);let n=w(e),r=le(n).toString(),i=r.endsWith(`/`)?r:r+`/`;return se(globalThis,`likec4:`+n,async()=>{let e=h.getChild(`lang`),r=C(t,{useFileSystem:!0,manualLayouts:!0,watch:!1});if(r.mcp)throw Error(`MCP server is not supported in this build`);let a=he(r),o={name:T(n),uri:i},s=a.shared.workspace.WorkspaceManager;e.info(`${E.dim(`workspace:`)} ${n}`),s.initialize({capabilities:{},processId:null,rootUri:null,workspaceFolders:[o]}),await s.initializeWorkspace([o]);let c=a.shared.workspace.LangiumDocuments.userDocuments.toArray();if(c.length===0)throw e.error(`no LikeC4 sources found`),Error(`no LikeC4 sources found`);return e.info(`${E.dim(`workspace:`)} found ${c.length} source files`),x(a,h,t)})}const F=h.getChild(`vite`);async function _e({logger:e,likec4:t},n){e.info([E.green(`adhoc:view`),E.dim(`project:`),n.projectId].join(` `));let r=await t.views.adhocView(n.predicates,n.projectId);return e.info([E.green(`adhoc:view`),`✅`].join(` `)),r}function ve(e){let t=e.split(`
1
+ import{t as e}from"./libs/birpc.mjs";import{C as t,D as n,I as r,W as i,Z as a,k as o,o as s,q as c,r as l,t as u,v as d,x as f,y as p}from"./libs/remeda.mjs";import{_ as m,c as h,d as g,f as _,h as v,i as y,l as b,m as x,o as ee,r as S,s as te,t as C,x as ne}from"./filesystem.mjs";import{t as w}from"./libs/defu.mjs";import{r as T,t as re}from"./libs/pathe.mjs";import{t as E}from"./libs/tinyrainbow.mjs";import{t as D}from"./libs/json5.mjs";import{a as O,i as k,n as A,r as j,t as M}from"./libs/langium.mjs";import{o as N}from"./libs/ufo.mjs";import{t as ie}from"./libs/pako.mjs";import"@likec4/core/model";import{LikeC4Styles as ae,invariant as oe,isNonEmptyArray as se,memoizeProp as ce,nonexhaustive as le}from"@likec4/core";import{pathToFileURL as ue}from"url";import{RichText as de,flattenMarkdownOrString as fe}from"@likec4/core/types";import{compareNatural as pe,invariant as me,sortNaturalByFqn as he}from"@likec4/core/utils";function ge(e){let t=m.getChild(`lang`),n=w(e,{useFileSystem:!0,manualLayouts:!0,watch:!1,graphviz:`wasm`}),r=n.graphviz===`binary`;return t.info(`${E.dim(`layout`)} ${r?`binary`:`wasm`}`),S({...n.useFileSystem?{...ee(n.watch),...n.manualLayouts?b:h}:{...te,...h},...y(r?new g:new _)})}async function _e(e,t){let n=T(e),r=ue(n).toString(),i=r.endsWith(`/`)?r:r+`/`;return ce(globalThis,`likec4:`+n,async()=>{let e=m.getChild(`lang`),r=w(t,{...v,useFileSystem:!0,manualLayouts:!0,watch:!1});if(C(r),r.mcp)throw Error(`MCP server is not supported in this build`);let a=ge(r),o={name:re(n),uri:i},s=a.shared.workspace.WorkspaceManager;e.info(`${E.dim(`workspace:`)} ${n}`),s.initialize({capabilities:{},processId:null,rootUri:null,workspaceFolders:[o]}),await s.initializeWorkspace([o]);let c=a.shared.workspace.LangiumDocuments.userDocuments.toArray();if(c.length===0)throw e.error(`no LikeC4 sources found`),Error(`no LikeC4 sources found`);return e.info(`${E.dim(`workspace:`)} found ${c.length} source files`),x(a,m,t)})}const P=m.getChild(`vite`);async function ve({logger:e,likec4:t},n){e.info([E.green(`adhoc:view`),E.dim(`project:`),n.projectId].join(` `));let r=await t.views.adhocView(n.predicates,n.projectId);return e.info([E.green(`adhoc:view`),`✅`].join(` `)),r}function ye(e){let t=e.split(`
2
2
  `),n=/^\s+at\s+/,r=t.findIndex(e=>n.test(e));return r===-1&&(r=1),{message:t.slice(0,r).join(`
3
3
  `),stack:t.slice(r).join(`
4
- `)}}function ye(e,{name:t,error:n}){e.hot.send({type:`error`,err:{...ve(n),name:t??`LikeC4PluginError`,plugin:`vite-plugin-likec4`}})}async function be({logger:e,likec4:t},n){e.info([E.green(`view:onChange`),E.dim(`project`)+`:`,n.projectId,E.dim(`view`)+`:`,n.viewId,E.dim(`change`)+`:`,n.change.op].join(` `));let r=await t.editor.applyChange(n);if(!r.success){e.error(`Failed to apply view change:\n${r.error}`);let t=Error(r.error);throw t.stack=r.error,t}e.info([E.green(`view:onChange`),`✅`].join(` `))}function xe(t){let n=null,r=t.server;e({updateView:e=>be(t,e),calcAdhocView:e=>_e(t,e)},{on:e=>r.hot.on(`likec4:rpc`,e),post:e=>r.hot.send(`likec4:rpc`,e),onFunctionError:(e,i)=>{t.logger.error(`RPC error in ${i}`,{error:e});let a=e.stack??e.message;try{n!==a&&(n=a,ye(r,{name:e.name,error:a}))}catch(e){t.logger.error(`Failed to send error to client`,{error:e})}}})}const Se=e=>e.charAt(0).toLocaleUpperCase()+e.slice(1),Ce=e=>e.split(`.`).map(Se).join(``),we=e=>Ce(e.parent?e.id.slice(e.parent.length+1):e.id),Te=({autoLayout:e})=>{switch(e.direction){case`TB`:return`down`;case`BT`:return`up`;case`LR`:return`right`;case`RL`:return`left`}},Ee=({shape:e})=>{switch(e){case`queue`:case`cylinder`:case`rectangle`:case`document`:return e;case`person`:return`c4-person`;case`storage`:return`stored_data`;case`component`:case`bucket`:case`mobile`:case`browser`:return`rectangle`}};function De(e){let t=e.$view,{nodes:r,edges:i}=t,a=new Map,o=(e,t)=>{let n=we(e),i=(t?t+`.`:``)+n;a.set(e.id,i);let s=JSON.stringify(e.title),c=Ee(e);return new A().append(n,`: {`,j).indent({indentedChildren:t=>t.append(`label: `,s,j).appendIf(c!==`rectangle`,`shape: `,c,j).appendIf(e.children.length>0,j,M(r.filter(t=>t.parent===e.id),e=>o(e,i))),indentation:2}).append(`}`,j)},s=e=>new A().append(a.get(e.source),` -> `,a.get(e.target)).append(t=>e.label&&t.append(`: `,JSON.stringify(e.label)));return k(new A().append(`direction: `,Te(t),j,j).append(M(r.filter(e=>n(e.parent)),e=>o(e),{appendNewLineIfNotEmpty:!0})).appendIf(i.length>0,j,M(i,e=>s(e),{appendNewLineIfNotEmpty:!0})))}const I=`data:page/id,likec4-`,L=1e4,R=`#dae8fc`,Oe=`#2563eb`,z=`#1e40af`,ke=`diagrams.drawio`,Ae=`#74c0fc`;function B(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&apos;`)}function je(e){let t=e.split(/\r?\n/),n={},r={},i={},a={},o=!1,s=0;for(;s<t.length;){let e=t[s];if(e==null){s+=1;continue}if(e.trim()===`// <likec4.layout.drawio>`){o=!0,s+=1;let e=[];for(;s<t.length&&t[s]?.trim()!==`// </likec4.layout.drawio>`;){let n=t[s]?.trim();n?.startsWith(`// `)&&e.push(n.slice(3)),s+=1}if(e.length>0)try{let t=e.join(`
5
- `);n=JSON.parse(t)}catch{}s+=1;continue}if(e.trim()===`// <likec4.strokeColor.vertices>`){for(o=!0,s+=1;s<t.length&&t[s]?.trim()!==`// </likec4.strokeColor.vertices>`;){let e=t[s]?.trim();if(e?.startsWith(`// `)&&e.includes(`=`)){let t=e.slice(3).trim(),n=t.indexOf(`=`);if(n>0){let e=t.slice(0,n).trim(),i=t.slice(n+1).trim();e&&i&&(r[e]=i)}}s+=1}s+=1;continue}if(e.trim()===`// <likec4.strokeWidth.vertices>`){for(o=!0,s+=1;s<t.length&&t[s]?.trim()!==`// </likec4.strokeWidth.vertices>`;){let e=t[s]?.trim();if(e?.startsWith(`// `)&&e.includes(`=`)){let t=e.slice(3).trim(),n=t.indexOf(`=`);if(n>0){let e=t.slice(0,n).trim(),r=t.slice(n+1).trim();e&&r!==``&&(i[e]=r)}}s+=1}s+=1;continue}if(e.trim()===`// <likec4.edge.waypoints>`){for(o=!0,s+=1;s<t.length&&t[s]?.trim()!==`// </likec4.edge.waypoints>`;){let e=t[s]?.trim();if(e?.startsWith(`// `)){let t=e.slice(3).trim(),n=t.indexOf(` `);if(n>0){let e=t.slice(0,n).trim(),r=t.slice(n+1).trim();if(e&&r)try{let t=JSON.parse(r);Array.isArray(t)&&(a[e]=t)}catch{}}}s+=1}s+=1;continue}s+=1}return o?{layoutByView:n,strokeColorByFqn:r,strokeWidthByFqn:i,edgeWaypoints:a}:null}function Me(e){let t=encodeURIComponent(e),n=new TextEncoder().encode(t);return Ne(ie.deflateRaw(n))}function Ne(e){if(typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}const V={getNotes(e){return e.notes},getSummary(e){return e.summary},getTags(e){return e.tags},getNavigateTo(e){return e.navigateTo},getIcon(e){return e.icon},getLinks(e){return e.links},getNotation(e){return e.notation},getCustomData(e){return e.customData},getChildren(e){return e.children}},H={getKind(e){return e.kind},getNotation(e){return e.notation},getLinks(e){return e.links},getMetadata(e){return e.metadata},getCustomData(e){return e.customData}};function Pe(e){return e.$styles??P.DEFAULT}function U(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`)}function W(e){if(e==null)return``;let t=typeof e;if(t===`string`){let t=e;return t.trim()===``?``:t}return t===`number`||t===`boolean`?String(e):``}function Fe(e,t){return e&&t!==`none`||t===`dashed`?`dashed=1;`:``}function Ie(e,t){return e===`none`?`0`:t||e?`1`:``}function Le(e,t){return{fill:e?.fill??R,stroke:t,font:e?.font??t}}function Re(e,t,n){return t&&t in e.theme.colors?t:n}function ze(e,t,n){let r=Pe(e),i=Re(r,t??n,n);try{return r.colors(i)}catch{return P.DEFAULT.colors(n)}}function Be(e){let t=`shape=rectangle;rounded=1;arcSize=12;`;switch(e){case`person`:return`shape=actor;`;case`rectangle`:case`browser`:case`mobile`:case`bucket`:return t;case`cylinder`:case`queue`:case`storage`:return`shape=cylinder3;whiteSpace=wrap;boundedLbl=1;backgroundOutline=1;size=15;`;case`document`:return`shape=document;whiteSpace=wrap;html=1;boundedLbl=1;`;case`component`:return`shape=component;`;default:return t}}function Ve(e,t){let n=ze(e,t,`primary`).elements;return{fill:String(n.fill??R),stroke:String(n.stroke??Oe),font:String(n.hiContrast??n.stroke??z)}}function He(e,t){let n=ze(e,t??`gray`,`gray`);return String(n.relationships?.line??z)}function Ue(e,t){let n=ze(e,t??`gray`,`gray`).relationships;return{font:String(n?.label??n?.line??z),background:String(n?.labelBg??`#ffffff`)}}function We(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=t.x+t.width/2,a=t.y+t.height/2,o=i-n,s=a-r,c=Math.abs(o)>=Math.abs(s);return{exitX:c?o>=0?1:0:.5,exitY:c?.5:s>=0?1:0,entryX:c?o>=0?0:1:.5,entryY:c?.5:s>=0?0:1}}function Ge(e){if(Array.isArray(e)&&e.length>=2&&typeof e[0]==`number`&&typeof e[1]==`number`)return[[e[0],e[1]]];let t=e;return typeof t.x==`number`&&typeof t.y==`number`?[[t.x,t.y]]:[]}function Ke(e,t,n,r,i,a){return n?``:t===``?`<div style="box-sizing:border-box;width:100%;min-height:100%;display:flex;align-items:center;justify-content:center;text-align:center;color:${r};font-family:${i};"><b style="font-size:${a}px;">${U(e)}</b></div>`:`<div style="box-sizing:border-box;width:100%;min-height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:${r};font-family:${i};"><b style="font-size:${a}px;">${U(e)}</b><br/><span style="font-weight:normal;font-size:${a}px;">${U(t)}</span></div>`}function G(e,t,n){n!=null&&n!==``&&e.push(`${t}=${encodeURIComponent(n)}`)}function qe(e,t,n){n!=null&&e.push(`${t}=${n}`)}function Je(e){return e===``?``:`link=${encodeURIComponent(`${I}${e}`)};`}function K(e){let t=e==null?null:de(e);return t!=null&&!l(t)?t.trim():``}function Ye(e){return!Array.isArray(e)||e.length===0?``:encodeURIComponent(JSON.stringify(e.map(e=>({url:e.url,title:e.title}))))}function Xe(e){return typeof e!=`object`||!e||Array.isArray(e)||Object.keys(e).length===0?``:encodeURIComponent(JSON.stringify(e))}const Ze=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;function Qe(e){let t=[];return G(t,`likec4Description`,e.desc),G(t,`likec4Technology`,e.tech),G(t,`likec4Notes`,e.notes),G(t,`likec4Tags`,e.tagList),G(t,`likec4NavigateTo`,e.navTo),G(t,`likec4Icon`,e.iconName),G(t,`likec4Summary`,e.summaryStr),e.linksJson!==``&&t.push(`likec4Links=${e.linksJson}`),G(t,`likec4Border`,e.borderVal),qe(t,`likec4Opacity`,e.containerOpacityNum),G(t,`likec4StrokeWidth`,e.strokeWidth),e.colorNameForRoundtrip!==``&&t.push(`likec4ColorName=${e.colorNameForRoundtrip}`),G(t,`likec4Size`,e.nodeStyle?.size),G(t,`likec4Padding`,e.nodeStyle?.padding),G(t,`likec4TextSize`,e.nodeStyle?.textSize),G(t,`likec4IconPosition`,e.nodeStyle?.iconPosition),e.strokeHex&&Ze.test(e.strokeHex)&&G(t,`likec4StrokeColor`,e.strokeHex),G(t,`likec4Notation`,e.nodeNotation??void 0),t.length>0?t.join(`;`)+`;`:``}function $e(e){return!e||typeof e!=`object`||Array.isArray(e)||Object.keys(e).length===0?``:`
6
- <mxUserObject>`+Object.entries(e).map(([e,t])=>{let n=typeof t==`string`?t:t==null?``:String(t);return`<data key="${B(e)}">${B(n)}</data>`}).join(``)+`</mxUserObject>`}function et(e){let t=[];return G(t,`likec4Description`,e.edgeDesc),G(t,`likec4Technology`,e.edgeTech),G(t,`likec4Notes`,e.edgeNotes),G(t,`likec4NavigateTo`,e.edgeNavTo),G(t,`likec4RelationshipKind`,e.edgeKind??void 0),G(t,`likec4Notation`,e.edgeNotation??void 0),e.edgeLinksJson!==``&&t.push(`likec4Links=${e.edgeLinksJson}`),e.edgeMetadataJson!==``&&t.push(`likec4Metadata=${e.edgeMetadataJson}`),t.length>0?t.join(`;`)+`;`:``}function tt(e){return e.label?B(e.label):``}function nt(e,t){let n=t?.[`${e.source}|${e.target}|${e.id}`]??t?.[`${e.source}|${e.target}`],r=Array.isArray(n)?n.flatMap(Ge):[];return r.length>0?`<mxGeometry relative="1" as="geometry">${`<Array as="points">`+r.map(([e,t])=>`<mxPoint x="${Math.round(e)}" y="${Math.round(t)}"/>`).join(``)+`</Array>`}</mxGeometry>`:`<mxGeometry relative="1" as="geometry" />`}function rt(e,t,n,r){let{bboxes:i,fontFamily:a}=t,o=i.get(e.source),s=i.get(e.target),c=o&&s?We(o,s):{exitX:1,exitY:.5,entryX:0,entryY:.5},l=`exitX=${c.exitX};exitY=${c.exitY};entryX=${c.entryX};entryY=${c.entryY};`,u=He(n,e.color),d=e.line===`dashed`?`dashed=1;`:e.line===`dotted`?`dashed=1;dashPattern=1 1;`:``,f=pt(e.head),p=e.tail==null||e.tail===`none`?`none`:pt(e.tail),m=et({edgeDesc:K(e.description),edgeTech:K(e.technology),edgeNotes:K(e.notes),edgeNavTo:W(e.navigateTo),edgeKind:H.getKind(e),edgeNotation:H.getNotation(e),edgeLinksJson:Ye(H.getLinks(e)),edgeMetadataJson:Xe(H.getMetadata(e))}),h=Ue(n,e.color);return`endArrow=${f};startArrow=${p};html=1;rounded=0;${l}strokeColor=${u};strokeWidth=2;${d}${r===``?``:`fontColor=${h.font};fontSize=12;align=center;verticalAlign=middle;labelBackgroundColor=none;fontFamily=${encodeURIComponent(a)};`}${m}`}function it(e,t,n,r,i,a){let{defaultParentId:o}=t,s=i(e.source),c=i(e.target),l=tt(e),u=nt(e,n?.edgeWaypoints);return`<mxCell id="${a}" value="${l}" style="${rt(e,t,r,l)}" edge="1" parent="${o}" source="${s}" target="${c}">
7
- ${u}${$e(H.getCustomData(e))}
8
- </mxCell>`}function at(e,t,n){let{bboxes:r,defaultParentId:i,nodeIdsInView:a}=t,o=n(e.id),s=r.get(e.id),{width:c,height:l}=s,u=e.parent!=null&&a.has(e.parent)?n(e.parent):i,d=e.parent==null?void 0:r.get(e.parent);return{id:o,parentId:u,x:d==null?s.x+t.offsetX:s.x-d.x,y:d==null?s.y+t.offsetY:s.y-d.y,width:c,height:l}}function ot(e,t,n,r){let{containerNodeIds:i,effectiveStyles:a,fontFamily:o,containerTitleFontSizePx:s,containerTitleColor:c}=t,l=n?.strokeColorByNodeId,u=n?.strokeWidthByNodeId,d=i.has(e.id),f=e.title,p=K(e.description),m=K(e.technology),h=K(V.getNotes(e)),g=V.getTags(e),_=Array.isArray(g)&&g.length>0?g.join(`,`):``,v=W(V.getNavigateTo(e)),y=W(V.getIcon(e)),b=d?`shape=rectangle;rounded=0;container=1;collapsible=0;startSize=0;`:Be(e.shape),x=l?.[e.id],ee=u?.[e.id],S=x?Le(Ve(r,e.color),x):Ve(r,e.color),te=S?.fill??R,ne=S?.stroke??Oe,re=S?.font??S?.stroke??z,C=`fillColor=${te};strokeColor=${ne};fontColor=${re};`,w=e.style,T=a.fontSize(w?.textSize),E=B(Ke(f,p,d,re,o,T)),D=w?.border,O=ee??Ie(D,d),k=O===``?``:`strokeWidth=${O};`,A=Fe(d,D),j=d===!0?w?.opacity??15:void 0,M=j!=null&&d===!0?`fillOpacity=${Math.min(100,Math.max(0,j))};`:``,N=Qe({desc:p,tech:m,notes:h,tagList:_,navTo:v,iconName:y,summaryStr:K(V.getSummary(e)),linksJson:Ye(V.getLinks(e)),borderVal:D,containerOpacityNum:j,strokeWidth:O,colorNameForRoundtrip:e.color?encodeURIComponent(String(e.color)):``,nodeStyle:w,strokeHex:ne,nodeNotation:V.getNotation(e)}),ie=$e(V.getCustomData(e)),P=Je(v);return{value:E,styleStr:`${d?`align=left;verticalAlign=top;overflow=fill;whiteSpace=wrap;html=1;`:`align=center;verticalAlign=middle;verticalLabelPosition=middle;labelPosition=center;fontSize=${T};fontStyle=1;spacingTop=4;spacingLeft=2;spacingRight=2;spacingBottom=2;overflow=fill;whiteSpace=wrap;html=1;fontFamily=${encodeURIComponent(o)};`}${b}${C}${k}${A}${M}${P}${N}`,userObjectXml:ie,navTo:v,isContainer:d,title:f,fontFamily:o,containerTitleFontSizePx:s,containerTitleColor:c}}function st(e,t,n,r,i,a){let o=at(e,t,i),s=ot(e,t,n,r);return{...o,value:s.value,styleStr:s.styleStr,userObjectXml:s.userObjectXml,navTo:s.navTo,isContainer:s.isContainer,fontFamily:s.fontFamily,...s.isContainer&&{title:s.title??``,titleCellId:String(a),containerTitleFontSizePx:s.containerTitleFontSizePx,containerTitleColor:s.containerTitleColor}}}function ct(e){let t=`<mxGeometry height="${Math.round(e.height)}" width="${Math.round(e.width)}" x="${Math.round(e.x)}" y="${Math.round(e.y)}" as="geometry" />`,n=e.userObjectXml===``?`\n ${t}`:`${e.userObjectXml}\n ${t}`,r=e.isContainer&&e.title!=null?B(e.title):e.value,i=e.navTo===``?`<mxCell id="${e.id}" value="${e.value}" style="${e.styleStr}" vertex="1" parent="${e.parentId}">\n ${n}\n</mxCell>`:`<UserObject label="${r}" link="${I}${B(e.navTo)}" id="${e.id}">\n <mxCell parent="${e.parentId}" style="${e.styleStr}" value="${e.value}" vertex="1">\n ${n}\n</mxCell>\n</UserObject>`;return e.isContainer?{vertexXml:i,titleCellXml:lt(e.title??``,e.titleCellId??e.id,e.navTo,e.id,e.fontFamily,e.containerTitleFontSizePx??12,e.containerTitleColor??Ae),isContainer:!0}:{vertexXml:i,isContainer:!1}}function lt(e,t,n,r,i,a,o){let s=B(e),c=Math.max(60,Math.min(260,e.length*8)),l=Je(n),u=`shape=text;html=1;fillColor=none;strokeColor=none;align=left;verticalAlign=top;fontSize=${a};fontStyle=1;fontColor=${o};fontFamily=${encodeURIComponent(i)};${l}`;if(n===``)return`<mxCell id="${t}" value="${s}" style="${u}" vertex="1" parent="${r}">\n <mxGeometry x="8" y="8" width="${c}" height="18" as="geometry" />\n</mxCell>`;let d=`<mxCell parent="${r}" style="${u}" value="${s}" vertex="1">\n <mxGeometry x="8" y="8" width="${c}" height="18" as="geometry" />\n</mxCell>`;return`<UserObject label="${B(e)}" link="${I}${B(n)}" id="${t}">\n ${d}\n</UserObject>`}function ut(e){return typeof e.title==`string`?e.title:null}function dt(e){let t=e.description;return typeof t==`object`&&t&&`txt`in t?String(t.txt):typeof t==`object`&&t&&`md`in t?String(t.md):typeof t==`string`?t:``}function ft(e){let t=ut(e),n=dt(e),r=n.trim()===``?``:encodeURIComponent(n.trim()),i=e.notation,a=typeof i==`string`&&i!==``?i:void 0,o=a==null?``:encodeURIComponent(a);return[`rounded=1;whiteSpace=wrap;html=1;fillColor=none;strokeColor=none;`,`likec4ViewTitle=${encodeURIComponent(t??e.id)};`,r===``?``:`likec4ViewDescription=${r};`,o===``?``:`likec4ViewNotation=${o};`].join(``)}function pt(e){switch(e){case`none`:return`none`;case`open`:case`onormal`:case`vee`:return`open`;case`diamond`:case`odiamond`:return`diamond`;case`dot`:case`odot`:return`oval`;case`crow`:return`block`;default:return`block`}}const q={x:0,y:0,width:120,height:60};function mt(e){return e.x===q.x&&e.y===q.y&&e.width===q.width&&e.height===q.height}function ht(e,t,n){let r=e=>`${e.x},${e.y},${e.width},${e.height}`,i=t.filter(e=>!n.has(e.id)),a=new Map;for(let t of i){let n=e.get(t.id);if(!n)continue;let i=r(n),o=a.get(i)??[];o.push(t),a.set(i,o)}for(let t of a.values()){if(t.length<=1)continue;let n=t[0],r=n?e.get(n.id):void 0;r&&mt(r)&&t.forEach((t,n)=>{e.set(t.id,{...r,x:r.x,y:r.y+n*(r.height+24)})})}}function gt(e,t,n,r,i,a){let o=[...n].filter(e=>t.has(e.id)).sort((e,t)=>(t.level??0)-(e.level??0));for(let t of o){let n=(V.getChildren(t)??[]).filter(e=>r.has(e));if(n.length===0||!mt(e.get(t.id)))continue;let o=1/0,s=1/0,c=-1/0,l=-1/0;for(let t of n){let n=e.get(t);n&&(o=Math.min(o,n.x),s=Math.min(s,n.y),c=Math.max(c,n.x+n.width),l=Math.max(l,n.y+n.height))}o!==1/0&&e.set(t.id,{x:o-i,y:s-a,width:c-o+2*i,height:l-s+2*a})}}function _t(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e.values())t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height);t===1/0&&(t=0),n===1/0&&(n=0),r===-1/0&&(r=t+800),i===-1/0&&(i=n+600);let a=t+(r-t)/2,o=n+(i-n)/2;return{offsetX:800/2-a,offsetY:600/2-o,canvasWidth:800,canvasHeight:600}}function vt(e,t){let r=e.$view,{nodes:i}=r,a=t?.layoutOverride,o=[...i].sort((e,t)=>n(e.parent)&&n(t.parent)?0:n(e.parent)?-1:n(t.parent)?1:e.parent===t.parent?0:e.id.startsWith(t.id+`.`)?1:t.id.startsWith(e.id+`.`)?-1:0),s=e=>{let t=a?.[e.id];if(t)return t;let n=e;return{x:typeof n.x==`number`?n.x:Array.isArray(n.position)?n.position[0]:0,y:typeof n.y==`number`?n.y:Array.isArray(n.position)?n.position[1]:0,width:typeof n.width==`number`?n.width:n.size?.width??120,height:typeof n.height==`number`?n.height:n.size?.height??60}},c=new Map;for(let e of o)c.set(e.id,s(e));let l=new Set(i.map(e=>e.id)),u=new Set(i.filter(e=>{let t=V.getChildren(e);return Array.isArray(t)&&t.some(e=>l.has(e))}).map(e=>e.id));ht(c,o,u);let d=Pe(e),f=d.theme.spacing.xl;gt(c,u,o,l,f,d.theme.spacing.xl+d.theme.spacing.md);let{offsetX:p,offsetY:m,canvasWidth:h,canvasHeight:g}=_t(c);return{view:r,bboxes:c,containerNodeIds:u,sortedNodes:o,offsetX:p,offsetY:m,canvasWidth:h,canvasHeight:g,defaultParentId:`1`,rootId:`0`,effectiveStyles:d,fontFamily:`'IBM Plex Sans Variable',ui-sans-serif,system-ui,sans-serif`,containerTitleFontSizePx:Math.round(d.theme.textSizes.xs),containerTitleColor:Ae,nodeIdsInView:l}}function yt(e,t){let n=e.$view,{edges:r}=n,i=t?.compressed!==!1,a=vt(e,t),{sortedNodes:o,defaultParentId:s,rootId:c,canvasWidth:l,canvasHeight:u}=a,d=new Map,f=2,p=e=>{let t=d.get(e);if(!t){if(f>=L)throw Error(`DrawIO cell ID range exhausted`);t=String(f++),d.set(e,t)}return t},m=[],h=[],g=[],_=L;for(let n of o){let r=ct(st(n,a,t,e,p,_));r.isContainer?(m.push(r.vertexXml),r.titleCellXml&&m.push(r.titleCellXml),_++):h.push(r.vertexXml)}for(let n of r){if(f>=L)throw Error(`DrawIO cell ID range exhausted`);let r=String(f++);g.push(it(n,a,t,e,p,r))}let v=[`<mxCell id="${s}" value="" style="${ft(n)}" vertex="1" parent="${c}">
4
+ `)}}function be(e,{name:t,error:n}){e.hot.send({type:`error`,err:{...ye(n),name:t??`LikeC4PluginError`,plugin:`vite-plugin-likec4`}})}async function xe({logger:e,likec4:t},n){e.info([E.green(`view:onChange`),E.dim(`project`),n.projectId,E.dim(`view`),n.viewId,E.dim(`change`),n.change.op].join(` `));let r=await t.editor.applyChange(n);if(!r.success){e.error(`Failed to apply view change:\n${r.error}`);let t=Error(r.error);throw t.stack=r.error,t}e.info([E.green(`view:onChange`),`✅`].join(` `))}function Se(t){let n=null,r=t.server;e({updateView:e=>xe(t,e),calcAdhocView:e=>ve(t,e)},{on:e=>r.hot.on(`likec4:rpc`,e),post:e=>r.hot.send(`likec4:rpc`,e),onFunctionError:(e,i)=>{t.logger.error(`RPC error in ${i}`,{error:e});let a=e.stack??e.message;try{n!==a&&(n=a,be(r,{name:e.name,error:a}))}catch(e){t.logger.error(`Failed to send error to client`,{error:e})}}})}const Ce=e=>e.charAt(0).toLocaleUpperCase()+e.slice(1),we=e=>e.split(`.`).map(Ce).join(``),Te=e=>we(e.parent?e.id.slice(e.parent.length+1):e.id),Ee=({autoLayout:e})=>{switch(e.direction){case`TB`:return`down`;case`BT`:return`up`;case`LR`:return`right`;case`RL`:return`left`}},De=({shape:e})=>{switch(e){case`queue`:case`cylinder`:case`rectangle`:case`document`:return e;case`person`:return`c4-person`;case`storage`:return`stored_data`;case`component`:case`bucket`:case`mobile`:case`browser`:return`rectangle`}};function Oe(e){let t=e.$view,{nodes:r,edges:i}=t,a=new Map,o=(e,t)=>{let n=Te(e),i=(t?t+`.`:``)+n;a.set(e.id,i);let s=JSON.stringify(e.title),c=De(e);return new A().append(n,`: {`,j).indent({indentedChildren:t=>t.append(`label: `,s,j).appendIf(c!==`rectangle`,`shape: `,c,j).appendIf(e.children.length>0,j,M(r.filter(t=>t.parent===e.id),e=>o(e,i))),indentation:2}).append(`}`,j)},s=e=>new A().append(a.get(e.source),` -> `,a.get(e.target)).append(t=>e.label&&t.append(`: `,JSON.stringify(e.label)));return k(new A().append(`direction: `,Ee(t),j,j).append(M(r.filter(e=>n(e.parent)),e=>o(e),{appendNewLineIfNotEmpty:!0})).appendIf(i.length>0,j,M(i,e=>s(e),{appendNewLineIfNotEmpty:!0})))}const ke=`data:page/id,likec4-`,F=1e4,I=`#dae8fc`,Ae=`#2563eb`,L=`#1e40af`,je=`diagrams.drawio`,Me=`#74c0fc`;function R(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&apos;`)}function Ne(e){let t=e.split(/\r?\n/),n={},r={},i={},a={},o=!1,s=0;for(;s<t.length;){let e=t[s];if(e==null){s+=1;continue}if(e.trim()===`// <likec4.layout.drawio>`){o=!0,s+=1;let e=[];for(;s<t.length&&t[s]?.trim()!==`// </likec4.layout.drawio>`;){let n=t[s]?.trim();n?.startsWith(`// `)&&e.push(n.slice(3)),s+=1}if(e.length>0)try{let t=e.join(`
5
+ `);n=JSON.parse(t)}catch{}s+=1;continue}if(e.trim()===`// <likec4.strokeColor.vertices>`){for(o=!0,s+=1;s<t.length&&t[s]?.trim()!==`// </likec4.strokeColor.vertices>`;){let e=t[s]?.trim();if(e?.startsWith(`// `)&&e.includes(`=`)){let t=e.slice(3).trim(),n=t.indexOf(`=`);if(n>0){let e=t.slice(0,n).trim(),i=t.slice(n+1).trim();e&&i&&(r[e]=i)}}s+=1}s+=1;continue}if(e.trim()===`// <likec4.strokeWidth.vertices>`){for(o=!0,s+=1;s<t.length&&t[s]?.trim()!==`// </likec4.strokeWidth.vertices>`;){let e=t[s]?.trim();if(e?.startsWith(`// `)&&e.includes(`=`)){let t=e.slice(3).trim(),n=t.indexOf(`=`);if(n>0){let e=t.slice(0,n).trim(),r=t.slice(n+1).trim();e&&r!==``&&(i[e]=r)}}s+=1}s+=1;continue}if(e.trim()===`// <likec4.edge.waypoints>`){for(o=!0,s+=1;s<t.length&&t[s]?.trim()!==`// </likec4.edge.waypoints>`;){let e=t[s]?.trim();if(e?.startsWith(`// `)){let t=e.slice(3).trim(),n=t.indexOf(` `);if(n>0){let e=t.slice(0,n).trim(),r=t.slice(n+1).trim();if(e&&r)try{let t=JSON.parse(r);Array.isArray(t)&&(a[e]=t)}catch{}}}s+=1}s+=1;continue}s+=1}return o?{layoutByView:n,strokeColorByFqn:r,strokeWidthByFqn:i,edgeWaypoints:a}:null}function Pe(e){let t=encodeURIComponent(e),n=new TextEncoder().encode(t);return Fe(ie.deflateRaw(n))}function Fe(e){if(typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}const z={getNotes(e){return e.notes},getSummary(e){return e.summary},getTags(e){return e.tags},getNavigateTo(e){return e.navigateTo},getIcon(e){return e.icon},getLinks(e){return e.links},getNotation(e){return e.notation},getCustomData(e){return e.customData},getChildren(e){return e.children}},B={getKind(e){return e.kind},getNotation(e){return e.notation},getLinks(e){return e.links},getMetadata(e){return e.metadata},getCustomData(e){return e.customData}};function Ie(e){return e.$styles??ae.DEFAULT}function V(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`)}function H(e){if(e==null)return``;let t=typeof e;if(t===`string`){let t=e;return t.trim()===``?``:t}return t===`number`||t===`boolean`?String(e):``}function Le(e,t){return e&&t!==`none`||t===`dashed`?`dashed=1;`:``}function Re(e,t){return e===`none`?`0`:t||e?`1`:``}function ze(e,t){return{fill:e?.fill??I,stroke:t,font:e?.font??t}}function Be(e,t,n){return t&&t in e.theme.colors?t:n}function U(e,t,n){let r=Ie(e),i=Be(r,t??n,n);try{return r.colors(i)}catch{return ae.DEFAULT.colors(n)}}function Ve(e){let t=`shape=rectangle;rounded=1;arcSize=12;`;switch(e){case`person`:return`shape=actor;`;case`rectangle`:case`browser`:case`mobile`:case`bucket`:return t;case`cylinder`:case`queue`:case`storage`:return`shape=cylinder3;whiteSpace=wrap;boundedLbl=1;backgroundOutline=1;size=15;`;case`document`:return`shape=document;whiteSpace=wrap;html=1;boundedLbl=1;`;case`component`:return`shape=component;`;default:return t}}function He(e,t){let n=U(e,t,`primary`).elements;return{fill:String(n.fill??I),stroke:String(n.stroke??Ae),font:String(n.hiContrast??n.stroke??L)}}function Ue(e,t){let n=U(e,t??`gray`,`gray`);return String(n.relationships?.line??L)}function We(e,t){let n=U(e,t??`gray`,`gray`).relationships;return{font:String(n?.label??n?.line??L),background:String(n?.labelBg??`#ffffff`)}}function Ge(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=t.x+t.width/2,a=t.y+t.height/2,o=i-n,s=a-r,c=Math.abs(o)>=Math.abs(s);return{exitX:c?o>=0?1:0:.5,exitY:c?.5:s>=0?1:0,entryX:c?o>=0?0:1:.5,entryY:c?.5:s>=0?0:1}}function Ke(e){if(Array.isArray(e)&&e.length>=2&&typeof e[0]==`number`&&typeof e[1]==`number`)return[[e[0],e[1]]];let t=e;return typeof t.x==`number`&&typeof t.y==`number`?[[t.x,t.y]]:[]}function qe(e,t,n,r,i,a){return n?``:t===``?`<div style="box-sizing:border-box;width:100%;min-height:100%;display:flex;align-items:center;justify-content:center;text-align:center;color:${r};font-family:${i};"><b style="font-size:${a}px;">${V(e)}</b></div>`:`<div style="box-sizing:border-box;width:100%;min-height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:${r};font-family:${i};"><b style="font-size:${a}px;">${V(e)}</b><br/><span style="font-weight:normal;font-size:${a}px;">${V(t)}</span></div>`}function W(e,t,n){n!=null&&n!==``&&e.push(`${t}=${encodeURIComponent(n)}`)}function Je(e,t,n){n!=null&&e.push(`${t}=${n}`)}function Ye(e){return e===``?``:`link=${encodeURIComponent(`${ke}${e}`)};`}function G(e){let t=e==null?null:fe(e);return t!=null&&!o(t)?t.trim():``}function Xe(e){return!Array.isArray(e)||e.length===0?``:encodeURIComponent(JSON.stringify(e.map(e=>({url:e.url,title:e.title}))))}function Ze(e){return typeof e!=`object`||!e||Array.isArray(e)||Object.keys(e).length===0?``:encodeURIComponent(JSON.stringify(e))}const Qe=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;function $e(e){let t=[];return W(t,`likec4Description`,e.desc),W(t,`likec4Technology`,e.tech),W(t,`likec4Notes`,e.notes),W(t,`likec4Tags`,e.tagList),W(t,`likec4NavigateTo`,e.navTo),W(t,`likec4Icon`,e.iconName),W(t,`likec4Summary`,e.summaryStr),e.linksJson!==``&&t.push(`likec4Links=${e.linksJson}`),W(t,`likec4Border`,e.borderVal),Je(t,`likec4Opacity`,e.containerOpacityNum),W(t,`likec4StrokeWidth`,e.strokeWidth),e.colorNameForRoundtrip!==``&&t.push(`likec4ColorName=${e.colorNameForRoundtrip}`),W(t,`likec4Size`,e.nodeStyle?.size),W(t,`likec4Padding`,e.nodeStyle?.padding),W(t,`likec4TextSize`,e.nodeStyle?.textSize),W(t,`likec4IconPosition`,e.nodeStyle?.iconPosition),e.strokeHex&&Qe.test(e.strokeHex)&&W(t,`likec4StrokeColor`,e.strokeHex),W(t,`likec4Notation`,e.nodeNotation??void 0),t.length>0?t.join(`;`)+`;`:``}function et(e,t,n,r){if(r?.profile!==`leanix`)return``;let i=[`bridgeManaged=true`,`likec4Id=${encodeURIComponent(e)}`,`likec4Kind=${encodeURIComponent(t)}`,`likec4ViewId=${encodeURIComponent(n)}`];r.projectId!=null&&r.projectId!==``&&i.push(`likec4ProjectId=${encodeURIComponent(r.projectId)}`);let a=r.leanixFactSheetTypeByKind?.[t];return a!=null&&a!==``&&i.push(`leanixFactSheetType=${encodeURIComponent(a)}`),i.join(`;`)+`;`}function tt(e,t){return t?.profile===`leanix`?`bridgeManaged=true;likec4RelationId=${encodeURIComponent(e)};`:``}function nt(e){return!e||typeof e!=`object`||Array.isArray(e)||Object.keys(e).length===0?``:`
6
+ <mxUserObject>`+Object.entries(e).map(([e,t])=>{let n=typeof t==`string`?t:t==null?``:String(t);return`<data key="${R(e)}">${R(n)}</data>`}).join(``)+`</mxUserObject>`}function rt(e){let t=[];return W(t,`likec4Description`,e.edgeDesc),W(t,`likec4Technology`,e.edgeTech),W(t,`likec4Notes`,e.edgeNotes),W(t,`likec4NavigateTo`,e.edgeNavTo),W(t,`likec4RelationshipKind`,e.edgeKind??void 0),W(t,`likec4Notation`,e.edgeNotation??void 0),e.edgeLinksJson!==``&&t.push(`likec4Links=${e.edgeLinksJson}`),e.edgeMetadataJson!==``&&t.push(`likec4Metadata=${e.edgeMetadataJson}`),t.length>0?t.join(`;`)+`;`:``}function it(e){return e.label?R(e.label):``}function at(e,t){let n=t?.[`${e.source}|${e.target}|${e.id}`]??t?.[`${e.source}|${e.target}`],r=Array.isArray(n)?n.flatMap(Ke):[];return r.length>0?`<mxGeometry relative="1" as="geometry">${`<Array as="points">`+r.map(([e,t])=>`<mxPoint x="${Math.round(e)}" y="${Math.round(t)}"/>`).join(``)+`</Array>`}</mxGeometry>`:`<mxGeometry relative="1" as="geometry" />`}function ot(e,t,n,r,i){let{bboxes:a,fontFamily:o}=t,s=a.get(e.source),c=a.get(e.target),l=s&&c?Ge(s,c):{exitX:1,exitY:.5,entryX:0,entryY:.5},u=`exitX=${l.exitX};exitY=${l.exitY};entryX=${l.entryX};entryY=${l.entryY};`,d=Ue(n,e.color),f=e.line===`dashed`?`dashed=1;`:e.line===`dotted`?`dashed=1;dashPattern=1 1;`:``,p=_t(e.head),m=e.tail==null||e.tail===`none`?`none`:_t(e.tail),h=rt({edgeDesc:G(e.description),edgeTech:G(e.technology),edgeNotes:G(e.notes),edgeNavTo:H(e.navigateTo),edgeKind:B.getKind(e),edgeNotation:B.getNotation(e),edgeLinksJson:Xe(B.getLinks(e)),edgeMetadataJson:Ze(B.getMetadata(e))}),g=tt(e.id,i),_=We(n,e.color);return`endArrow=${p};startArrow=${m};html=1;rounded=0;${u}strokeColor=${d};strokeWidth=2;${f}${r===``?``:`fontColor=${_.font};fontSize=12;align=center;verticalAlign=middle;labelBackgroundColor=none;fontFamily=${encodeURIComponent(o)};`}${h}${g}`}function st(e,t,n,r,i,a){let{defaultParentId:o}=t,s=i(e.source),c=i(e.target),l=it(e),u=at(e,n?.edgeWaypoints);return`<mxCell id="${a}" value="${l}" style="${ot(e,t,r,l,n)}" edge="1" parent="${o}" source="${s}" target="${c}">
7
+ ${u}${nt(B.getCustomData(e))}
8
+ </mxCell>`}function ct(e,t,n){let{bboxes:r,defaultParentId:i,nodeIdsInView:a}=t,o=n(e.id),s=r.get(e.id),{width:c,height:l}=s,u=e.parent!=null&&a.has(e.parent)?n(e.parent):i,d=e.parent==null?void 0:r.get(e.parent);return{id:o,parentId:u,x:d==null?s.x+t.offsetX:s.x-d.x,y:d==null?s.y+t.offsetY:s.y-d.y,width:c,height:l}}function lt(e,t,n,r){let{containerNodeIds:i,effectiveStyles:a,fontFamily:o,containerTitleFontSizePx:s,containerTitleColor:c}=t,l=n?.strokeColorByNodeId,u=n?.strokeWidthByNodeId,d=i.has(e.id),f=e.kind??``,p=e.title,m=G(e.description),h=G(e.technology),g=G(z.getNotes(e)),_=z.getTags(e),v=Array.isArray(_)&&_.length>0?_.join(`,`):``,y=H(z.getNavigateTo(e)),b=H(z.getIcon(e)),x=f===`actor`||e.shape===`person`,ee=d?`shape=rectangle;rounded=0;container=1;collapsible=0;startSize=0;`:x?`shape=actor;`:Ve(e.shape),S=l?.[e.id],te=u?.[e.id],C=S?ze(He(r,e.color),S):He(r,e.color),ne=C?.fill??I,w=C?.stroke??Ae,T=C?.font??C?.stroke??L,re=`fillColor=${ne};strokeColor=${w};fontColor=${T};`,E=e.style,D=a.fontSize(E?.textSize),O=R(qe(p,m,d,T,o,D)),k=E?.border,A=te??Re(k,d),j=A===``?``:`strokeWidth=${A};`,M=Le(d,k),N=d===!0?E?.opacity??15:void 0,ie=N!=null&&d===!0?`fillOpacity=${Math.min(100,Math.max(0,N))};`:``,ae=$e({desc:m,tech:h,notes:g,tagList:v,navTo:y,iconName:b,summaryStr:G(z.getSummary(e)),linksJson:Xe(z.getLinks(e)),borderVal:k,containerOpacityNum:N,strokeWidth:A,colorNameForRoundtrip:e.color?encodeURIComponent(String(e.color)):``,nodeStyle:E,strokeHex:w,nodeNotation:z.getNotation(e)})+et(e.id,f,t.view.id,n),oe=nt(z.getCustomData(e)),se=Ye(y);return{value:O,styleStr:`${d?`align=left;verticalAlign=top;overflow=fill;whiteSpace=wrap;html=1;`:`align=center;verticalAlign=middle;verticalLabelPosition=middle;labelPosition=center;fontSize=${D};fontStyle=1;spacingTop=4;spacingLeft=2;spacingRight=2;spacingBottom=2;overflow=fill;whiteSpace=wrap;html=1;fontFamily=${encodeURIComponent(o)};`}${ee}${re}${j}${M}${ie}${se}${ae}`,userObjectXml:oe,navTo:y,isContainer:d,title:p,fontFamily:o,containerTitleFontSizePx:s,containerTitleColor:c}}function ut(e,t,n,r,i,a){let o=ct(e,t,i),s=lt(e,t,n,r);return{...o,value:s.value,styleStr:s.styleStr,userObjectXml:s.userObjectXml,navTo:s.navTo,isContainer:s.isContainer,fontFamily:s.fontFamily,...s.isContainer&&{title:s.title??``,titleCellId:String(a),containerTitleFontSizePx:s.containerTitleFontSizePx,containerTitleColor:s.containerTitleColor}}}function dt(e){let t=`<mxGeometry height="${Math.round(e.height)}" width="${Math.round(e.width)}" x="${Math.round(e.x)}" y="${Math.round(e.y)}" as="geometry" />`,n=e.userObjectXml===``?`\n ${t}`:`${e.userObjectXml}\n ${t}`,r=e.isContainer&&e.title!=null?R(e.title):e.value,i=e.navTo===``?`<mxCell id="${e.id}" value="${e.value}" style="${e.styleStr}" vertex="1" parent="${e.parentId}">\n ${n}\n</mxCell>`:`<UserObject label="${r}" link="${ke}${R(e.navTo)}" id="${e.id}">\n <mxCell parent="${e.parentId}" style="${e.styleStr}" value="${e.value}" vertex="1">\n ${n}\n</mxCell>\n</UserObject>`;return e.isContainer?{vertexXml:i,titleCellXml:ft(e.title??``,e.titleCellId??e.id,e.navTo,e.id,e.fontFamily,e.containerTitleFontSizePx??12,e.containerTitleColor??Me),isContainer:!0}:{vertexXml:i,isContainer:!1}}function ft(e,t,n,r,i,a,o){let s=R(e),c=Math.max(60,Math.min(260,e.length*8)),l=Ye(n),u=`shape=text;html=1;fillColor=none;strokeColor=none;align=left;verticalAlign=top;fontSize=${a};fontStyle=1;fontColor=${o};fontFamily=${encodeURIComponent(i)};${l}`;if(n===``)return`<mxCell id="${t}" value="${s}" style="${u}" vertex="1" parent="${r}">\n <mxGeometry x="8" y="8" width="${c}" height="18" as="geometry" />\n</mxCell>`;let d=`<mxCell parent="${r}" style="${u}" value="${s}" vertex="1">\n <mxGeometry x="8" y="8" width="${c}" height="18" as="geometry" />\n</mxCell>`;return`<UserObject label="${R(e)}" link="${ke}${R(n)}" id="${t}">\n ${d}\n</UserObject>`}function pt(e){return typeof e.title==`string`?e.title:null}function mt(e){let t=e.description;return typeof t==`object`&&t&&`txt`in t?String(t.txt):typeof t==`object`&&t&&`md`in t?String(t.md):typeof t==`string`?t:``}function ht(e,t){let n=[`bridgeManaged=true;`,`likec4ViewId=${encodeURIComponent(e.id)};`];return t.projectId!=null&&t.projectId!==``&&n.push(`likec4ProjectId=${encodeURIComponent(t.projectId)};`),n}function gt(e,t){let n=pt(e),r=mt(e),i=r.trim()===``?``:encodeURIComponent(r.trim()),a=e.notation,o=typeof a==`string`&&a!==``?a:void 0,s=o==null?``:encodeURIComponent(o),c=[`rounded=1;whiteSpace=wrap;html=1;fillColor=none;strokeColor=none;`,`likec4ViewTitle=${encodeURIComponent(n??e.id)};`,i===``?``:`likec4ViewDescription=${i};`,s===``?``:`likec4ViewNotation=${s};`];return t?.profile===`leanix`&&c.push(...ht(e,t)),c.join(``)}function _t(e){switch(e){case`none`:return`none`;case`open`:case`onormal`:case`vee`:return`open`;case`diamond`:case`odiamond`:return`diamond`;case`dot`:case`odot`:return`oval`;case`crow`:return`block`;default:return`block`}}const K={x:0,y:0,width:120,height:60};function vt(e){return e.x===K.x&&e.y===K.y&&e.width===K.width&&e.height===K.height}function yt(e,t,n){let r=e=>`${e.x},${e.y},${e.width},${e.height}`,i=t.filter(e=>!n.has(e.id)),a=new Map;for(let t of i){let n=e.get(t.id);if(!n)continue;let i=r(n),o=a.get(i)??[];o.push(t),a.set(i,o)}for(let t of a.values()){if(t.length<=1)continue;let n=t[0],r=n?e.get(n.id):void 0;r&&vt(r)&&t.forEach((t,n)=>{e.set(t.id,{...r,x:r.x,y:r.y+n*(r.height+24)})})}}function bt(e,t,n,r,i,a){let o=[...n].filter(e=>t.has(e.id)).sort((e,t)=>(t.level??0)-(e.level??0));for(let t of o){let n=(z.getChildren(t)??[]).filter(e=>r.has(e));if(n.length===0||!vt(e.get(t.id)))continue;let o=1/0,s=1/0,c=-1/0,l=-1/0;for(let t of n){let n=e.get(t);n&&(o=Math.min(o,n.x),s=Math.min(s,n.y),c=Math.max(c,n.x+n.width),l=Math.max(l,n.y+n.height))}o!==1/0&&e.set(t.id,{x:o-i,y:s-a,width:c-o+2*i,height:l-s+2*a})}}function xt(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e.values())t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height);t===1/0&&(t=0),n===1/0&&(n=0),r===-1/0&&(r=t+800),i===-1/0&&(i=n+600);let a=t+(r-t)/2,o=n+(i-n)/2;return{offsetX:800/2-a,offsetY:600/2-o,canvasWidth:800,canvasHeight:600}}function St(e,t){let r=e.$view,{nodes:i}=r,a=t?.layoutOverride,o=[...i].sort((e,t)=>n(e.parent)&&n(t.parent)?0:n(e.parent)?-1:n(t.parent)?1:e.parent===t.parent?0:e.id.startsWith(t.id+`.`)?1:t.id.startsWith(e.id+`.`)?-1:0),s=e=>{let t=a?.[e.id];if(t)return t;let n=e;return{x:typeof n.x==`number`?n.x:Array.isArray(n.position)?n.position[0]:0,y:typeof n.y==`number`?n.y:Array.isArray(n.position)?n.position[1]:0,width:typeof n.width==`number`?n.width:n.size?.width??120,height:typeof n.height==`number`?n.height:n.size?.height??60}},c=new Map;for(let e of o)c.set(e.id,s(e));let l=new Set(i.map(e=>e.id)),u=new Set(i.filter(e=>{let t=z.getChildren(e);return Array.isArray(t)&&t.some(e=>l.has(e))}).map(e=>e.id));yt(c,o,u);let d=Ie(e),f=d.theme.spacing.xl;bt(c,u,o,l,f,d.theme.spacing.xl+d.theme.spacing.md);let{offsetX:p,offsetY:m,canvasWidth:h,canvasHeight:g}=xt(c);return{view:r,bboxes:c,containerNodeIds:u,sortedNodes:o,offsetX:p,offsetY:m,canvasWidth:h,canvasHeight:g,defaultParentId:`1`,rootId:`0`,effectiveStyles:d,fontFamily:`'IBM Plex Sans Variable',ui-sans-serif,system-ui,sans-serif`,containerTitleFontSizePx:Math.round(d.theme.textSizes.xs),containerTitleColor:Me,nodeIdsInView:l}}function Ct(e,t){let n=e.$view,{edges:r}=n,i=t?.compressed!==!1,a=St(e,t),{sortedNodes:o,defaultParentId:s,rootId:c,canvasWidth:l,canvasHeight:u}=a,d=new Map,f=2,p=e=>{let t=d.get(e);if(!t){if(f>=F)throw Error(`DrawIO cell ID range exhausted`);t=String(f++),d.set(e,t)}return t},m=[],h=[],g=[],_=F;for(let n of o){let r=dt(ut(n,a,t,e,p,_));r.isContainer?(m.push(r.vertexXml),r.titleCellXml&&m.push(r.titleCellXml),_++):h.push(r.vertexXml)}for(let n of r){if(f>=F)throw Error(`DrawIO cell ID range exhausted`);let r=String(f++);g.push(st(n,a,t,e,p,r))}let v=[`<mxCell id="${s}" value="" style="${gt(n,t)}" vertex="1" parent="${c}">
9
9
  <mxGeometry x="0" y="0" width="${l}" height="${u}" as="geometry" />
10
10
  </mxCell>`,...m,...h,...g].join(`
11
- `),y=(ut(n)??n.id).trim()||n.id,b=`<mxGraphModel dx="800" dy="800" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
11
+ `),y=(pt(n)??n.id).trim()||n.id,b=`<mxGraphModel dx="800" dy="800" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
12
12
  <root>
13
13
  <mxCell id="${c}" />
14
14
  ${v}
15
15
  </root>
16
- </mxGraphModel>`,x=i?Me(b):b;return{name:y,id:n.id,content:x}}function bt(e,t){let n=B(t??new Date().toISOString());return e.length===0?`<?xml version="1.0" encoding="UTF-8"?>
16
+ </mxGraphModel>`,x=i?Pe(b):b;return{name:y,id:n.id,content:x}}function wt(e,t){let n=R(t??new Date().toISOString());return e.length===0?`<?xml version="1.0" encoding="UTF-8"?>
17
17
  <mxfile host="LikeC4" modified="${n}" agent="LikeC4" version="1.0" etag="" type="device">
18
18
  </mxfile>
19
19
  `:`<?xml version="1.0" encoding="UTF-8"?>
20
20
  <mxfile host="LikeC4" modified="${n}" agent="LikeC4" version="1.0" etag="" type="device"${e.length>1?` pages="${e.length}"`:``}>
21
- ${e.map(e=>` <diagram name="${B(e.name)}" id="likec4-${B(e.id)}">${e.content}</diagram>`).join(`
21
+ ${e.map(e=>` <diagram name="${R(e.name)}" id="likec4-${R(e.id)}">${e.content}</diagram>`).join(`
22
22
  `)}
23
23
  </mxfile>
24
- `}function xt(e,t){return bt([yt(e,t)],t?.modified)}function St(e,t,n){return bt(e.map(e=>yt(e,t?.[e.$view.id])),n)}function Ct(e,t,n){let r={compressed:!1,...n};if(!t)return r;let i=t.layoutByView[e]?.nodes;return i!=null&&(r.layoutOverride=i),Object.keys(t.strokeColorByFqn).length>0&&(r.strokeColorByNodeId=t.strokeColorByFqn),Object.keys(t.strokeWidthByFqn).length>0&&(r.strokeWidthByNodeId=t.strokeWidthByFqn),Object.keys(t.edgeWaypoints).length>0&&(r.edgeWaypoints=t.edgeWaypoints),r}function wt(e,t,n){let r=t?je(t):null;return Object.fromEntries(e.map(e=>[e,Ct(e,r,n)]))}function Tt(e){let t=Me(e),n=JSON.stringify({type:`xml`,compressed:!0,data:t});return`https://app.diagrams.net/#create=`+encodeURIComponent(n)}const Et=e=>e.charAt(0).toLocaleUpperCase()+e.slice(1),Dt=e=>e.split(`.`).map(Et).join(``),Ot=e=>Dt(e.parent?e.id.slice(e.parent.length+1):e.id),kt=e=>e.replace(/\\?"/g,`'`),At=({shape:e,title:t})=>{let n=`label: ${JSON.stringify(t)}`;switch(e){case`queue`:return`@{ shape: horizontal-cylinder, ${n} }`;case`person`:return`@{ icon: "fa:user", shape: rounded, ${n} }`;case`storage`:return`@{ shape: disk, ${n} }`;case`cylinder`:return`@{ shape: cylinder, ${n} }`;case`mobile`:case`browser`:return`@{ shape: rounded, ${n} }`;case`bucket`:return`@{ shape: trap-t, ${n} }`;case`rectangle`:return`@{ shape: rectangle, ${n} }`;case`document`:return`@{ shape: doc, ${n} }`;case`component`:return`@{ shape: rectangle, ${n} }`;default:ce(e)}};function jt(e){let t=e.$view,{nodes:r,edges:i}=t,a=new Map,o=(e,t)=>{let n=Ot(e),i=(t?t+`.`:``)+n;a.set(e.id,i);let s=new A;if(e.children.length>0){let t=kt(e.title);s.append(`subgraph `,i,'["`',t,'`"]',j).indent({indentedChildren:[M(r.filter(t=>t.parent===e.id),e=>o(e,i),{appendNewLineIfNotEmpty:!0})],indentation:2}).append(`end`,j)}else s.append(i,At(e));return s},s=e=>new A().append(a.get(e.source),` -.`,e.label?' "`'+kt(e.label)+'`" .-':`-`,`> `,a.get(e.target));return k(new A().append(`---`,j,`title: ${JSON.stringify(kt(e.titleOrId))}`,j,`---`,j).append(`graph `,t.autoLayout.direction,j).indent({indentedChildren:e=>{e.append(M(r.filter(e=>n(e.parent)),e=>o(e),{appendNewLineIfNotEmpty:!0})).appendIf(i.length>0,M(i,e=>s(e),{appendNewLineIfNotEmpty:!0}))},indentation:2}))}function J(e){return e.length===0?`never`:e.sort(fe).map(e=>` | ${JSON.stringify(e)}`).join(`
25
- `).trimStart()}function Mt(e){let t=p(e);return t.length===0?`never`:o(t,me,s(e=>` | ${JSON.stringify(e.id)}`)).join(`
26
- `).trimStart()}function Nt(e,t={}){let{useCorePackage:n=!1}=t;return`
24
+ `}function Tt(e,t){return wt([Ct(e,t)],t?.modified)}function Et(e,t,n){return wt(e.map(e=>Ct(e,t?.[e.$view.id])),n)}function Dt(e,t,n){let r={compressed:!1,...n};if(!t)return r;let i=t.layoutByView[e]?.nodes;return i!=null&&(r.layoutOverride=i),Object.keys(t.strokeColorByFqn).length>0&&(r.strokeColorByNodeId=t.strokeColorByFqn),Object.keys(t.strokeWidthByFqn).length>0&&(r.strokeWidthByNodeId=t.strokeWidthByFqn),Object.keys(t.edgeWaypoints).length>0&&(r.edgeWaypoints=t.edgeWaypoints),r}function Ot(e,t,n){let r=t?Ne(t):null;return Object.fromEntries(e.map(e=>[e,Dt(e,r,n)]))}function kt(e){let t=Pe(e),n=JSON.stringify({type:`xml`,compressed:!0,data:t});return`https://app.diagrams.net/#create=`+encodeURIComponent(n)}const At=e=>e.charAt(0).toLocaleUpperCase()+e.slice(1),jt=e=>e.split(`.`).map(At).join(``),Mt=e=>jt(e.parent?e.id.slice(e.parent.length+1):e.id),q=e=>e.replace(/\\?"/g,`'`),Nt=({shape:e,title:t})=>{let n=`label: ${JSON.stringify(t)}`;switch(e){case`queue`:return`@{ shape: horizontal-cylinder, ${n} }`;case`person`:return`@{ icon: "fa:user", shape: rounded, ${n} }`;case`storage`:return`@{ shape: disk, ${n} }`;case`cylinder`:return`@{ shape: cylinder, ${n} }`;case`mobile`:case`browser`:return`@{ shape: rounded, ${n} }`;case`bucket`:return`@{ shape: trap-t, ${n} }`;case`rectangle`:return`@{ shape: rectangle, ${n} }`;case`document`:return`@{ shape: doc, ${n} }`;case`component`:return`@{ shape: rectangle, ${n} }`;default:le(e)}};function Pt(e){let t=e.$view,{nodes:r,edges:i}=t,a=new Map,o=(e,t)=>{let n=Mt(e),i=(t?t+`.`:``)+n;a.set(e.id,i);let s=new A;if(e.children.length>0){let t=q(e.title);s.append(`subgraph `,i,'["`',t,'`"]',j).indent({indentedChildren:[M(r.filter(t=>t.parent===e.id),e=>o(e,i),{appendNewLineIfNotEmpty:!0})],indentation:2}).append(`end`,j)}else s.append(i,Nt(e));return s},s=e=>new A().append(a.get(e.source),` -.`,e.label?' "`'+q(e.label)+'`" .-':`-`,`> `,a.get(e.target));return k(new A().append(`---`,j,`title: ${JSON.stringify(q(e.titleOrId))}`,j,`---`,j).append(`graph `,t.autoLayout.direction,j).indent({indentedChildren:e=>{e.append(M(r.filter(e=>n(e.parent)),e=>o(e),{appendNewLineIfNotEmpty:!0})).appendIf(i.length>0,M(i,e=>s(e),{appendNewLineIfNotEmpty:!0}))},indentation:2}))}function J(e){return e.length===0?`never`:e.sort(pe).map(e=>` | ${JSON.stringify(e)}`).join(`
25
+ `).trimStart()}function Ft(e){let t=u(e);return t.length===0?`never`:a(t,he,p(e=>` | ${JSON.stringify(e.id)}`)).join(`
26
+ `).trimStart()}function It(e,t={}){let{useCorePackage:n=!1}=t;return`
27
27
  import type { Aux, SpecAux } from '${n?`@likec4/core/types`:`likec4/model`}';
28
28
 
29
29
  export type $Specs = SpecAux<
30
30
  // Element kinds
31
- ${J(i(e.specification.elements))},
31
+ ${J(f(e.specification.elements))},
32
32
  // Deployment kinds
33
- ${J(i(e.specification.deployments??{}))},
33
+ ${J(f(e.specification.deployments??{}))},
34
34
  // Relationship kinds
35
- ${J(i(e.specification.relationships??{}))},
35
+ ${J(f(e.specification.relationships??{}))},
36
36
  // Tags
37
- ${J(i(e.specification.tags??{}))},
37
+ ${J(f(e.specification.tags??{}))},
38
38
  // Metadata keys
39
39
  ${J(e.specification.metadataKeys??[])}
40
40
  >
@@ -42,11 +42,11 @@ export type $Specs = SpecAux<
42
42
  export type $Aux = Aux<
43
43
  ${JSON.stringify(e.stage)},
44
44
  // Elements
45
- ${Mt(e.$data.elements)},
45
+ ${Ft(e.$data.elements)},
46
46
  // Deployments
47
- ${Mt(e.$data.deployments.elements)},
47
+ ${Ft(e.$data.deployments.elements)},
48
48
  // Views
49
- ${J(i(e.$data.views))},
49
+ ${J(f(e.$data.views))},
50
50
  // Project ID
51
51
  ${JSON.stringify(e.projectId)},
52
52
  $Specs
@@ -62,7 +62,7 @@ export type $DeploymentKind = $Aux['DeploymentKind']
62
62
  export type $Tag = $Aux['Tag']
63
63
  export type $Tags = readonly $Aux['Tag'][]
64
64
  export type $MetadataKey = $Aux['MetadataKey']
65
- `.trimStart()}function Pt(e,t={}){let n=Nt(e,t),{useCorePackage:r=!1}=t;return`
65
+ `.trimStart()}function Lt(e,t={}){let n=It(e,t),{useCorePackage:r=!1}=t;return`
66
66
  /* prettier-ignore-start */
67
67
  /* eslint-disable */
68
68
 
@@ -77,8 +77,8 @@ ${n}
77
77
  export const likec4model: LikeC4Model<$Aux> = new LikeC4Model(${D.stringify(e.$data,{space:2,quote:`'`})} as any) as any
78
78
 
79
79
  /* prettier-ignore-end */
80
- `.trimStart()}const Ft=e=>e.charAt(0).toLocaleUpperCase()+e.slice(1),Y=e=>e.split(/[.-]/).map(Ft).join(``),It=e=>Y(e.parent?e.id.slice(e.parent.length+1):e.id),X=(e,t,n=`#3b82f6`)=>e?t(e)??n:n,Lt=({autoLayout:e})=>{switch(e.direction){case`TB`:return`top to bottom`;case`BT`:return console.warn(`Bottom to top direction is not supported. Defaulting to top to bottom.`),`top to bottom`;case`LR`:return`left to right`;case`RL`:return console.warn(`Right to left direction is not supported. Defaulting to left to right.`),`left to right`}},Rt=({shape:e})=>{switch(e){case`queue`:case`rectangle`:case`person`:return e;case`storage`:case`cylinder`:return`database`;case`component`:return`component`;case`document`:case`mobile`:case`bucket`:case`browser`:return`rectangle`;default:ce(e)}},Z=e=>l(e)?null:JSON.stringify(e).slice(1,-1).replace(/\\"/g,`"`);function zt(e){let t=e.$view,r=e.$model.$styles.theme.colors,{nodes:i,edges:a}=t,o=e=>t=>t in r?r[t].elements[e]:void 0,s=e=>t=>t in r?r[t].relationships[e]:void 0,c=new Map,u=()=>new A().append(`title "`,e.titleOrId,`"`,j).append(Lt(t),` direction`,j),d=()=>new A().append(`hide stereotype`,j).append(`skinparam ranksep `,`60`,j).append(`skinparam nodesep `,`30`,j).append(`skinparam {`,j).indent({indentedChildren:e=>e.append(`arrowFontSize `,`10`,j).append(`defaultTextAlignment `,`center`,j).append(`wrapWidth `,`200`,j).append(`maxMessageSize `,`100`,j).append(`shadowing `,`false`,j),indentation:2}).append(`}`,j),f=e=>{let t=Rt(e),n=Y(e.id);return new A().append(`skinparam `,t,`<<`,n,`>>`,`{`,j).indent({indentedChildren:t=>t.append(`BackgroundColor `,X(e.color,o(`fill`)),j).append(`FontColor `,X(e.color,o(`hiContrast`),`#FFFFFF`),j).append(`BorderColor `,X(e.color,o(`stroke`)),j),indentation:2}).append(`}`,j)},p=e=>{let t=Rt(e),n=Y(e.id),r=Z(e.title)||It(e),i=Z(e.technology);c.set(e.id,n);let a=ue.from(e.description);return new A().append(t,` `).append(`"`).append(`==`,r).appendIf(!!i,`\\n<size:10>[`,i,`]</size>`).appendIf(a.nonEmpty,`\\n\\n`,Z(a.text)).append(`"`,` <<`,n,`>> `,`as `,n,j)},m=e=>{let t=Z(e.title)||It(e),n=Y(e.id);return c.set(e.id,n),new A().append(`rectangle "`,t,`" <<`,n,`>> as `,n,` {`,j).indent({indentedChildren:t=>t.append(`skinparam `,`RectangleBorderColor<<`,n,`>> `,X(e.color,o(`fill`)),j).append(`skinparam `,`RectangleFontColor<<`,n,`>> `,X(e.color,o(`fill`)),j).append(`skinparam `,`RectangleBorderStyle<<`,n,`>> `,`dashed`,j,j).append(M(i.filter(t=>t.parent===e.id),e=>e.children.length>0?m(e):p(e))),indentation:2}).append(`}`,j)},h=e=>{let t=e.technology||``,n=e.label||t,r=X(e.color,s(`line`),`#777777`),i=e=>`<color:${r}>${e.replaceAll(`"`,`'`)}`,a=new A().append(c.get(e.source),` .[`,r,`,thickness=2].> `,c.get(e.target));return(n||t)&&(a.append(` : `,n.split(`
81
- `).map(e=>l(e)?e:i(e)).join(`\\n`)),t&&t!==n&&a.append(`\\n<size:8>[`,i(t),`]</size>`)),a.append(j)};return k(new A().append(`@startuml`,j).append(u(),j).append(d(),j).append(M(i.filter(e=>e.children.length==0),e=>f(e),{appendNewLineIfNotEmpty:!0})).append(M(i.filter(e=>n(e.parent)),e=>e.children.length>0?m(e):p(e),{appendNewLineIfNotEmpty:!0})).appendIf(a.length>0,j,M(a,e=>h(e),{appendNewLineIfNotEmpty:!0})).append(`@enduml`,j))}function Bt(e){return M(e,e=>O`${D.stringify(e.id)}`,{separator:` | `})}function Vt(e){let t=Array.from(e),n=new A;return n.appendTemplate`
80
+ `.trimStart()}const Rt=e=>e.charAt(0).toLocaleUpperCase()+e.slice(1),Y=e=>e.split(/[.-]/).map(Rt).join(``),zt=e=>Y(e.parent?e.id.slice(e.parent.length+1):e.id),X=(e,t,n=`#3b82f6`)=>e?t(e)??n:n,Bt=({autoLayout:e})=>{switch(e.direction){case`TB`:return`top to bottom`;case`BT`:return console.warn(`Bottom to top direction is not supported. Defaulting to top to bottom.`),`top to bottom`;case`LR`:return`left to right`;case`RL`:return console.warn(`Right to left direction is not supported. Defaulting to left to right.`),`left to right`}},Vt=({shape:e})=>{switch(e){case`queue`:case`rectangle`:case`person`:return e;case`storage`:case`cylinder`:return`database`;case`component`:return`component`;case`document`:case`mobile`:case`bucket`:case`browser`:return`rectangle`;default:le(e)}},Z=e=>o(e)?null:JSON.stringify(e).slice(1,-1).replace(/\\"/g,`"`);function Ht(e){let t=e.$view,r=e.$model.$styles.theme.colors,{nodes:i,edges:a}=t,s=e=>t=>t in r?r[t].elements[e]:void 0,c=e=>t=>t in r?r[t].relationships[e]:void 0,l=new Map,u=()=>new A().append(`title "`,e.titleOrId,`"`,j).append(Bt(t),` direction`,j),d=()=>new A().append(`hide stereotype`,j).append(`skinparam ranksep `,`60`,j).append(`skinparam nodesep `,`30`,j).append(`skinparam {`,j).indent({indentedChildren:e=>e.append(`arrowFontSize `,`10`,j).append(`defaultTextAlignment `,`center`,j).append(`wrapWidth `,`200`,j).append(`maxMessageSize `,`100`,j).append(`shadowing `,`false`,j),indentation:2}).append(`}`,j),f=e=>{let t=Vt(e),n=Y(e.id);return new A().append(`skinparam `,t,`<<`,n,`>>`,`{`,j).indent({indentedChildren:t=>t.append(`BackgroundColor `,X(e.color,s(`fill`)),j).append(`FontColor `,X(e.color,s(`hiContrast`),`#FFFFFF`),j).append(`BorderColor `,X(e.color,s(`stroke`)),j),indentation:2}).append(`}`,j)},p=e=>{let t=Vt(e),n=Y(e.id),r=Z(e.title)||zt(e),i=Z(e.technology);l.set(e.id,n);let a=de.from(e.description);return new A().append(t,` `).append(`"`).append(`==`,r).appendIf(!!i,`\\n<size:10>[`,i,`]</size>`).appendIf(a.nonEmpty,`\\n\\n`,Z(a.text)).append(`"`,` <<`,n,`>> `,`as `,n,j)},m=e=>{let t=Z(e.title)||zt(e),n=Y(e.id);return l.set(e.id,n),new A().append(`rectangle "`,t,`" <<`,n,`>> as `,n,` {`,j).indent({indentedChildren:t=>t.append(`skinparam `,`RectangleBorderColor<<`,n,`>> `,X(e.color,s(`fill`)),j).append(`skinparam `,`RectangleFontColor<<`,n,`>> `,X(e.color,s(`fill`)),j).append(`skinparam `,`RectangleBorderStyle<<`,n,`>> `,`dashed`,j,j).append(M(i.filter(t=>t.parent===e.id),e=>e.children.length>0?m(e):p(e))),indentation:2}).append(`}`,j)},h=e=>{let t=e.technology||``,n=e.label||t,r=X(e.color,c(`line`),`#777777`),i=e=>`<color:${r}>${e.replaceAll(`"`,`'`)}`,a=new A().append(l.get(e.source),` .[`,r,`,thickness=2].> `,l.get(e.target));return(n||t)&&(a.append(` : `,n.split(`
81
+ `).map(e=>o(e)?e:i(e)).join(`\\n`)),t&&t!==n&&a.append(`\\n<size:8>[`,i(t),`]</size>`)),a.append(j)};return k(new A().append(`@startuml`,j).append(u(),j).append(d(),j).append(M(i.filter(e=>e.children.length==0),e=>f(e),{appendNewLineIfNotEmpty:!0})).append(M(i.filter(e=>n(e.parent)),e=>e.children.length>0?m(e):p(e),{appendNewLineIfNotEmpty:!0})).appendIf(a.length>0,j,M(a,e=>h(e),{appendNewLineIfNotEmpty:!0})).append(`@enduml`,j))}function Ut(e){return M(e,e=>O`${D.stringify(e.id)}`,{separator:` | `})}function Wt(e){let t=Array.from(e),n=new A;return n.appendTemplate`
82
82
  /******************************************************************************
83
83
  * This file was generated
84
84
  * DO NOT EDIT MANUALLY!
@@ -90,7 +90,7 @@ export const likec4model: LikeC4Model<$Aux> = new LikeC4Model(${D.stringify(e.$d
90
90
 
91
91
  import type { DiagramView } from 'likec4'
92
92
  `.append(j,j),t.length===0?(n.append(`export {}`,j),k(n)):(n.appendTemplate`
93
- export type LikeC4ViewId = ${Bt(t)};
93
+ export type LikeC4ViewId = ${Ut(t)};
94
94
  export const LikeC4Views = {
95
95
  `.indent({indentation:2,indentedChildren(e){e.appendNewLineIf(t.length>1).append(M(t,e=>O`${D.stringify(e.id)}: (${D.stringify(e)} as unknown) as DiagramView`,{separator:`,`,appendNewLineIfNotEmpty:!0}))}}).append(`} as const satisfies Record<LikeC4ViewId, DiagramView>`,j,j).appendTemplate`
96
96
  export type LikeC4Views = typeof LikeC4Views
@@ -104,7 +104,7 @@ export const likec4model: LikeC4Model<$Aux> = new LikeC4Model(${D.stringify(e.$d
104
104
  }
105
105
 
106
106
  /* prettier-ignore-end */
107
- `.append(j),k(n))}function Ht(e,t={}){let{useCorePackage:n=!1}=t;pe(!e.isParsed(),`can not generate react types for parsed model`);let r=Nt(e,t);return`
107
+ `.append(j),k(n))}function Gt(e,t={}){let{useCorePackage:n=!1}=t;me(!e.isParsed(),`can not generate react types for parsed model`);let r=It(e,t);return`
108
108
  /* prettier-ignore-start */
109
109
  /* eslint-disable */
110
110
 
@@ -160,9 +160,9 @@ export {
160
160
  ReactLikeC4
161
161
  }
162
162
  /* prettier-ignore-end */
163
- `.trimStart()}function Q(e,t=`.js`){return{matches:n=>{let{module:r,projectId:i}=n.match(/^likec4:plugin\/(?<projectId>.+)\/(?<module>.+)$/)?.groups??n.match(/^likec4:(?<module>.+)\/(?<projectId>.+)$/)?.groups??{};return!r||!i?null:(r.endsWith(t)&&(r=r.slice(0,-t.length)),r===e?i:null)},virtualId:n=>N(`likec4:plugin`,n,e)+t}}const Ut={"<":`\\u003C`,">":`\\u003E`,"/":`\\u002F`,"\\":`\\\\`,"\b":`\\b`,"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`,"\0":`\\0`,"\u2028":`\\u2028`,"\u2029":`\\u2029`};function Wt(e){return e.replace(/[<>\b\f\n\r\t\0\u2028\u2029\\]/g,e=>Ut[e])}function $(e,t){return{id:`likec4:${e}`,virtualId:`likec4:plugin/${e}.js`,async load({logger:n,projects:r}){return n.info(E.dim(`generating likec4:${e}`)),`
163
+ `.trimStart()}function Q(e,t=`.js`){return{matches:n=>{let{module:r,projectId:i}=n.match(/^likec4:plugin\/(?<projectId>.+)\/(?<module>.+)$/)?.groups??n.match(/^likec4:(?<module>.+)\/(?<projectId>.+)$/)?.groups??{};return!r||!i?null:(r.endsWith(t)&&(r=r.slice(0,-t.length)),r===e?i:null)},virtualId:n=>N(`likec4:plugin`,n,e)+t}}const Kt={"<":`\\u003C`,">":`\\u003E`,"/":`\\u002F`,"\\":`\\\\`,"\b":`\\b`,"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`,"\0":`\\0`,"\u2028":`\\u2028`,"\u2029":`\\u2029`};function qt(e){return e.replace(/[<>\b\f\n\r\t\0\u2028\u2029\\]/g,e=>Kt[e])}function $(e,t){return{id:`likec4:${e}`,virtualId:`likec4:plugin/${e}.js`,async load({logger:n,projects:r}){return n.info(E.dim(`generating likec4:${e}`)),`
164
164
  export let ${t}Fn = {
165
- ${r.map(({id:t})=>{let n=Wt(JSON.stringify(N(`likec4:${e}`,t)));return`${JSON.stringify(t)}: () => import(${n})`}).join(`,
165
+ ${r.map(({id:t})=>{let n=qt(JSON.stringify(N(`likec4:${e}`,t)));return`${JSON.stringify(t)}: () => import(${n})`}).join(`,
166
166
  `)}
167
167
  }
168
168
 
@@ -194,7 +194,7 @@ if (import.meta.hot) {
194
194
  }
195
195
  })
196
196
  }
197
- `}}}function Gt(e){let t=new A;return t.appendTemplate`
197
+ `}}}function Jt(e){let t=new A;return t.appendTemplate`
198
198
  /******************************************************************************
199
199
  * This file was generated
200
200
  * DO NOT EDIT MANUALLY!
@@ -205,7 +205,7 @@ if (import.meta.hot) {
205
205
  switch (viewId) {
206
206
  `.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(M([...e.views()],e=>O`
207
207
  case ${JSON.stringify(e.id)}: {
208
- return ${JSON.stringify(De(e))}
208
+ return ${JSON.stringify(Oe(e))}
209
209
  }
210
210
  `,{appendNewLineIfNotEmpty:!0})).appendTemplate`
211
211
  default: {
@@ -213,7 +213,7 @@ if (import.meta.hot) {
213
213
  }
214
214
  `}}).append(j,` }`,j).appendTemplate`
215
215
  }
216
- `.append(j,j),k(t)}const Kt={...Q(`d2`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating likec4:d2/${t.id}`)),Gt(await e.computedModel(t.id))}},qt=$(`d2`,`loadD2Sources`);function Jt(e){let t=new A;return t.appendTemplate`
216
+ `.append(j,j),k(t)}const Yt={...Q(`d2`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating likec4:d2/${t.id}`)),Jt(await e.computedModel(t.id))}},Xt=$(`d2`,`loadD2Sources`);function Zt(e){let t=new A;return t.appendTemplate`
217
217
  /******************************************************************************
218
218
  * This file was generated
219
219
  * DO NOT EDIT MANUALLY!
@@ -243,7 +243,7 @@ if (import.meta.hot) {
243
243
  default: {
244
244
  throw new Error('Unknown viewId: ' + viewId)
245
245
  }
246
- `}}).append(j,` }`,j,`}`,j,j),k(t)}const Yt={...Q(`dot`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating likec4:dot/${t.id}`)),Jt(m(await e.views.viewsAsGraphvizOut(t.id),({id:e,svg:t,dot:n})=>[e,{dot:n,svg:t}]))}},Xt=$(`dot`,`loadDotSources`);function Zt(e){let t=new A;return t.appendTemplate`
246
+ `}}).append(j,` }`,j,`}`,j,j),k(t)}const Qt={...Q(`dot`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating likec4:dot/${t.id}`)),Zt(d(await e.views.viewsAsGraphvizOut(t.id),({id:e,svg:t,dot:n})=>[e,{dot:n,svg:t}]))}},$t=$(`dot`,`loadDotSources`);function en(e){let t=new A;return t.appendTemplate`
247
247
  /******************************************************************************
248
248
  * This file was generated
249
249
  * DO NOT EDIT MANUALLY!
@@ -254,7 +254,7 @@ if (import.meta.hot) {
254
254
  switch (viewId) {
255
255
  `.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(M([...e.views()],e=>O`
256
256
  case ${JSON.stringify(e.id)}: {
257
- return ${JSON.stringify(Tt(xt(e)))}
257
+ return ${JSON.stringify(kt(Tt(e)))}
258
258
  }
259
259
  `,{appendNewLineIfNotEmpty:!0})).appendTemplate`
260
260
  default: {
@@ -262,7 +262,7 @@ if (import.meta.hot) {
262
262
  }
263
263
  `}}).append(j,` }`,j).appendTemplate`
264
264
  }
265
- `.append(j,j),k(t)}const Qt={...Q(`drawio`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating likec4:drawio/${t.id}`)),Zt(await e.layoutedModel(t.id))}},$t=$(`drawio`,`loadDrawioSources`);function en(e){let{imports:n,cases:r}=o(e.flatMap(e=>e.nodes.map(e=>e.icon)),d(e=>t(e)&&!(e.toLowerCase().startsWith(`http:`)||e.toLowerCase().startsWith(`https:`))),f(),u(fe)).reduce((e,t,n)=>{let r=t.startsWith(`file:`),i=`Icon`+n.toString().padStart(2,`0`);if(r)return e.imports.push(`import ${i} from '${t}?inline'`),e.cases.push(` '${t}': () => jsx('img', { src: ${i} })`),e;let[a,o]=t.split(`:`);return e.imports.push(`import ${i} from '@likec4/icons/${a}/${o}'`),e.cases.push(` '${a}:${o}': ${i}`),e},{imports:[],cases:[]});return`
265
+ `.append(j,j),k(t)}const tn={...Q(`drawio`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating likec4:drawio/${t.id}`)),en(await e.layoutedModel(t.id))}},nn=$(`drawio`,`loadDrawioSources`);function rn(e){let{imports:n,cases:r}=a(e.flatMap(e=>e.nodes.map(e=>e.icon)),c(e=>t(e)&&!(e.toLowerCase().startsWith(`http:`)||e.toLowerCase().startsWith(`https:`))),l(),s(pe)).reduce((e,t,n)=>{let r=t.startsWith(`file:`),i=`Icon`+n.toString().padStart(2,`0`);if(r)return e.imports.push(`import ${i} from '${t}?inline'`),e.cases.push(` '${t}': () => jsx('img', { src: ${i} })`),e;let[a,o]=t.split(`:`);return e.imports.push(`import ${i} from '@likec4/icons/${a}/${o}'`),e.cases.push(` '${a}:${o}': ${i}`),e},{imports:[],cases:[]});return`
266
266
  import { jsx } from 'react/jsx-runtime'
267
267
  ${n.join(`
268
268
  `)}
@@ -278,11 +278,11 @@ export function IconRenderer({ node, ...props }) {
278
278
  }
279
279
  return jsx(IconComponent, props)
280
280
  }
281
- `}const tn={...Q(`icons`,`.jsx`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating likec4:icons/${t.id}`)),en(await e.views.computedViews(t.id))}},nn=/^[a-zA-Z0-9_.-]+$/;function rn(e){if(!nn.test(e))throw Error(`Unsafe value for code generation: ${e}`);return JSON.stringify(e)}function an(e){return JSON.stringify(e)}const on={id:`likec4:icons`,virtualId:`likec4:plugin/icons.jsx`,async load({projects:e,logger:t}){return t.info(E.dim(`generating likec4:icons`)),`
281
+ `}const an={...Q(`icons`,`.jsx`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating likec4:icons/${t.id}`)),rn(await e.views.computedViews(t.id))}},on=/^[a-zA-Z0-9_.-]+$/;function sn(e){if(!on.test(e))throw Error(`Unsafe value for code generation: ${e}`);return JSON.stringify(e)}function cn(e){return JSON.stringify(e)}const ln={id:`likec4:icons`,virtualId:`likec4:plugin/icons.jsx`,async load({projects:e,logger:t}){return t.info(E.dim(`generating likec4:icons`)),`
282
282
  import { jsx } from 'react/jsx-runtime'
283
283
  import { lazy, Suspense } from 'react'
284
284
  export let ProjectIconsRegistry = {
285
- ${e.filter(e=>nn.test(e.id)?!0:(t.warn(E.yellow(`Skipping project with unsafe id for icons registry: ${e.id}`)),!1)).map(e=>({idLiteral:rn(e.id),pkgLiteral:an(N(`likec4:icons`,e.id))})).map(({idLiteral:e,pkgLiteral:t})=>`${e}: lazy(() => import(${t}).then(m => ({default: m.IconRenderer})))`).join(`,
285
+ ${e.filter(e=>on.test(e.id)?!0:(t.warn(E.yellow(`Skipping project with unsafe id for icons registry: ${e.id}`)),!1)).map(e=>({idLiteral:sn(e.id),pkgLiteral:cn(N(`likec4:icons`,e.id))})).map(({idLiteral:e,pkgLiteral:t})=>`${e}: lazy(() => import(${t}).then(m => ({default: m.IconRenderer})))`).join(`,
286
286
  `)}
287
287
  }
288
288
 
@@ -315,7 +315,7 @@ if (import.meta.hot) {
315
315
  }
316
316
  })
317
317
  }
318
- `}};function sn(e){let t=new A;return t.appendTemplate`
318
+ `}};function un(e){let t=new A;return t.appendTemplate`
319
319
  /******************************************************************************
320
320
  * This file was generated
321
321
  * DO NOT EDIT MANUALLY!
@@ -326,7 +326,7 @@ if (import.meta.hot) {
326
326
  switch (viewId) {
327
327
  `.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(M([...e.views()],e=>O`
328
328
  case ${JSON.stringify(e.id)}: {
329
- return ${JSON.stringify(jt(e))}
329
+ return ${JSON.stringify(Pt(e))}
330
330
  }
331
331
  `,{appendNewLineIfNotEmpty:!0})).appendTemplate`
332
332
  default: {
@@ -335,7 +335,7 @@ if (import.meta.hot) {
335
335
  `}}).append(j,` }`,j).appendTemplate`
336
336
  }
337
337
 
338
- `.append(j,j),k(t)}const cn={...Q(`mmd`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating virtual:likec4/mmd/${t.id}`)),sn(await e.computedModel(t.id))}},ln=$(`mmd`,`loadMmdSources`),un=e=>`
338
+ `.append(j,j),k(t)}const dn={...Q(`mmd`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating virtual:likec4/mmd/${t.id}`)),un(await e.computedModel(t.id))}},fn=$(`mmd`,`loadMmdSources`),pn=e=>`
339
339
  import { createHooksForModel, atom } from 'likec4/vite-plugin/internal'
340
340
 
341
341
  export const $likec4data = atom(${D.stringify(e.$data)})
@@ -361,7 +361,7 @@ if (import.meta.hot) {
361
361
  }
362
362
  })
363
363
  }
364
- `,dn={...Q(`model`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating likec4:model/${t.id}`)),un(await e.layoutedModel(t.id))}},fn=$(`model`,`loadModel`),pn=e=>`
364
+ `,mn={...Q(`model`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating likec4:model/${t.id}`)),pn(await e.layoutedModel(t.id))}},hn=$(`model`,`loadModel`),gn=e=>`
365
365
  import { atom, useStore } from 'likec4/vite-plugin/internal'
366
366
 
367
367
  export const isSingleProject = ${e.length===1};
@@ -391,7 +391,7 @@ if (import.meta.hot) {
391
391
  }
392
392
  })
393
393
  }
394
- `,mn={id:`likec4:projects`,virtualId:`likec4:plugin/projects.js`,async load({logger:e,projects:t}){return e.info(E.dim(`generating likec4:projects`)),pn(s(t,c([`id`,`title`])))}},hn=e=>`
394
+ `,_n={id:`likec4:projects`,virtualId:`likec4:plugin/projects.js`,async load({logger:e,projects:t}){return e.info(E.dim(`generating likec4:projects`)),gn(p(t,e=>({id:e.id,title:e.title,landingPage:e.config.landingPage})))}},vn=e=>`
395
395
  import { atom, useStore } from 'likec4/vite-plugin/internal'
396
396
 
397
397
  export const $viewdata = atom(${D.stringify(e)})
@@ -413,11 +413,11 @@ if (import.meta.hot) {
413
413
  }
414
414
  })
415
415
  }
416
- `,gn=()=>`
416
+ `,yn=()=>`
417
417
  export function useLikeC4ProjectsOverview() {
418
418
  throw new Error('No projects overview available for this workspace: single project mode is enabled')
419
419
  }
420
- `,_n={id:`likec4:projects-overview`,virtualId:`likec4:plugin/projects-overview.js`,async load({logger:e,projects:t,likec4:n}){return t.length<2?gn():(e.info(E.dim(`generating likec4:projects-overview`)),hn(await n.projectsOverview()))}};function vn(e){let t=new A;return t.appendTemplate`
420
+ `,bn={id:`likec4:projects-overview`,virtualId:`likec4:plugin/projects-overview.js`,async load({logger:e,projects:t,likec4:n}){return t.length<2?yn():(e.info(E.dim(`generating likec4:projects-overview`)),vn(await n.projectsOverview()))}};function xn(e){let t=new A;return t.appendTemplate`
421
421
  /******************************************************************************
422
422
  * This file was generated
423
423
  * DO NOT EDIT MANUALLY!
@@ -428,7 +428,7 @@ export function useLikeC4ProjectsOverview() {
428
428
  switch (viewId) {
429
429
  `.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(M([...e.views()],e=>O`
430
430
  case ${JSON.stringify(e.id)}: {
431
- return ${JSON.stringify(zt(e))}
431
+ return ${JSON.stringify(Ht(e))}
432
432
  }
433
433
  `,{appendNewLineIfNotEmpty:!0})).appendTemplate`
434
434
  default: {
@@ -436,7 +436,7 @@ export function useLikeC4ProjectsOverview() {
436
436
  }
437
437
  `}}).append(j,` }`,j).appendTemplate`
438
438
  }
439
- `.append(j,j),k(t)}const yn={...Q(`puml`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating likec4:puml/${t.id}`)),vn(await e.computedModel(t.id))}},bn=$(`puml`,`loadPumlSources`),xn=e=>`
439
+ `.append(j,j),k(t)}const Sn={...Q(`puml`),async load({likec4:e,project:t,logger:n}){return n.info(E.dim(`generating likec4:puml/${t.id}`)),xn(await e.computedModel(t.id))}},Cn=$(`puml`,`loadPumlSources`),wn=e=>`
440
440
  import { jsx as _jsx } from "react/jsx-runtime";
441
441
  import { LikeC4ModelProvider as Provider, LikeC4View as GenericView, ReactLikeC4 as GenericReactLikeC4 } from 'likec4/react';
442
442
  import { IconRenderer } from 'likec4:icons/${e}'
@@ -459,7 +459,7 @@ export {
459
459
  useLikeC4View,
460
460
  useLikeC4Views
461
461
  }
462
- `,Sn={...Q(`react`),async load({project:e,logger:t}){return t.info(E.dim(`generating likec4:react/${e.id}`)),xn(e.id)}},Cn={id:`likec4:react`,virtualId:`likec4:plugin/react.js`,async load({logger:e,projects:t}){let n=a(t);return e.info(E.dim(`generating likec4:react for`)+` `+n.id),xn(n.id)}},wn={id:`likec4:rpc`,virtualId:`likec4:plugin/rpc.js`,async load({logger:e}){return e.info(E.dim(`generating likec4:rpc`)),`
462
+ `,Tn={...Q(`react`),async load({project:e,logger:t}){return t.info(E.dim(`generating likec4:react/${e.id}`)),wn(e.id)}},En={id:`likec4:react`,virtualId:`likec4:plugin/react.js`,async load({logger:e,projects:t}){let n=i(t);return e.info(E.dim(`generating likec4:react for`)+` `+n.id),wn(n.id)}},Dn={id:`likec4:rpc`,virtualId:`likec4:plugin/rpc.js`,async load({logger:e}){return e.info(E.dim(`generating likec4:rpc`)),`
463
463
  import { createRpc } from 'likec4/vite-plugin/internal'
464
464
 
465
465
  export const isRpcAvailable = !!import.meta.hot
@@ -486,7 +486,7 @@ export const likec4rpc = rpc ?? {
486
486
  throw new Error('likec4rpc.calcAdhocView is not available in production')
487
487
  },
488
488
  }
489
- `}},Tn=e=>`
489
+ `}},On=e=>`
490
490
  export { IconRenderer } from 'likec4:icons/${e}'
491
491
  export {
492
492
  $likec4data,
@@ -496,4 +496,4 @@ export {
496
496
  useLikeC4View
497
497
  } from 'likec4:model/${e}'
498
498
  export const projectId = ${JSON.stringify(e)}
499
- `,En={id:`likec4:single-project`,virtualId:`likec4:plugin/single-project.js`,async load({logger:e,projects:t}){let n=a(t);return e.info(E.dim(`generating likec4:single-project for`)+` `+n.id),Tn(n.id)}},Dn=[dn,tn,Kt,Yt,cn,yn,Qt],On=[...Dn,Sn],kn=[mn,fn,_n,En,Cn,qt,Xt,ln,bn,$t,on,wn];function An({environments:e,...t}){let n,i,a=t.watch??!1;return{name:`vite-plugin-likec4`,applyToEnvironment(t){return e?e.includes(t.name):!0},async configResolved(e){if(t.languageServices)n=t.languageServices;else{let r=a=t.watch??e.mode===`development`;n=(await ge(t.workspace??e.root,{graphviz:t.graphviz??`wasm`,configureLogger:`console`,watch:r})).languageServices}i=n.workspaceUri.fsPath},resolveId(e){for(let t of On){let n=t.matches(e);if(n)return t.virtualId(n)}for(let t of kn)if(t.id===e)return t.virtualId;return null},async load(e){for(let t of On){let r=t.matches(e);if(r){let e=n.project(r);return await t.load({logger:F,likec4:n,project:e,assetsDir:i})}}for(let t of kn)if(t.virtualId===e){let e=n.projects();return ae(oe(e)),await t.load({logger:F,likec4:n,projects:e,assetsDir:i})}return null},configureServer(e){let t=e.hot;xe.call(this,{logger:F,likec4:n,server:e});let i=()=>s(n.projects(),e=>({id:e.id,title:e.title,folder:e.folder.toString()})),a=i(),o=async t=>{let n=e.moduleGraph.getModuleById(t);if(n&&n.importers.size>0)try{await e.reloadModule(n)}catch(e){F.error(re(e))}};n.builder.onModelParsed(async()=>{let[e]=n.getErrors();if(e){t.send({type:`error`,err:{name:`LikeC4ValidationError`,...ve(e.message),plugin:`vite-plugin-likec4`,loc:{file:e.sourceFsPath,line:e.line,column:e.range.start.character+1}}});return}let s=i();if(!r(s,a)){a=s,await o(mn.virtualId),await o(on.virtualId),await o(fn.virtualId),a.length>1&&await o(_n.virtualId);return}for(let e of s)for(let t of Dn)await o(t.virtualId(e.id))})},async buildEnd(){a&&await n.dispose()}}}export{Pt as a,xt as c,De as d,ge as f,zt as i,St as l,Ht as n,jt as o,Vt as r,wt as s,An as t,ke as u};
499
+ `,kn={id:`likec4:single-project`,virtualId:`likec4:plugin/single-project.js`,async load({logger:e,projects:t}){let n=i(t);return e.info(E.dim(`generating likec4:single-project for`)+` `+n.id),On(n.id)}},An=[mn,an,Yt,Qt,dn,Sn,tn],jn=[...An,Tn],Mn=[_n,hn,bn,kn,En,Xt,$t,fn,Cn,nn,ln,Dn];function Nn({environments:e,...t}){let n,i,a=t.watch??!1;return{name:`vite-plugin-likec4`,applyToEnvironment(t){return e?e.includes(t.name):!0},async configResolved(e){if(t.languageServices)n=t.languageServices;else{let r=a=t.watch??e.mode===`development`;n=(await _e(t.workspace??e.root,{graphviz:t.graphviz??`wasm`,configureLogger:`console`,printErrors:t.printErrors??!0,throwIfInvalid:t.throwIfInvalid??!1,watch:r})).languageServices}i=n.workspaceUri.fsPath},resolveId(e){for(let t of jn){let n=t.matches(e);if(n)return t.virtualId(n)}for(let t of Mn)if(t.id===e)return t.virtualId;return null},async load(e){for(let t of jn){let r=t.matches(e);if(r){let e=n.project(r);return await t.load({logger:P,likec4:n,project:e,assetsDir:i})}}for(let t of Mn)if(t.virtualId===e){let e=n.projects();return oe(se(e)),await t.load({logger:P,likec4:n,projects:e,assetsDir:i})}return null},configureServer(e){let t=e.hot;Se.call(this,{logger:P,likec4:n,server:e});let i=()=>p(n.projects(),e=>({id:e.id,title:e.title,folder:e.folder.toString(),landingPage:e.config.landingPage})),a=i(),o=async t=>{let n=e.moduleGraph.getModuleById(t);if(n&&n.importers.size>0)try{await e.reloadModule(n)}catch(e){P.error(ne(e))}};n.builder.onModelParsed(async()=>{let[e]=n.getErrors();if(e){t.send({type:`error`,err:{name:`LikeC4ValidationError`,...ye(e.message),plugin:`vite-plugin-likec4`,loc:{file:e.sourceFsPath,line:e.line,column:e.range.start.character+1}}});return}let s=i();if(!r(s,a)){a=s,await o(_n.virtualId),await o(ln.virtualId),await o(hn.virtualId),a.length>1&&await o(bn.virtualId);return}for(let e of s)for(let t of An)await o(t.virtualId(e.id))})},async buildEnd(){a&&await n.dispose()}}}export{Lt as a,Tt as c,Oe as d,_e as f,Ht as i,Et as l,Gt as n,Pt as o,Wt as r,Ot as s,Nn as t,je as u};