@likec4/core 1.55.1 → 1.56.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 (37) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md +30 -30
  2. package/dist/_chunks/Builder.view-element.mjs +2 -2
  3. package/dist/_chunks/LikeC4Model.d.mts +1 -0
  4. package/dist/_chunks/assignTagColors.mjs +1 -1
  5. package/dist/_chunks/index5.d.mts +4 -0
  6. package/dist/_chunks/libs/{@mantine/colors-generator.mjs → chroma-js.mjs} +2 -2
  7. package/dist/_chunks/libs/graphology-dag.d.mts +607 -0
  8. package/dist/_chunks/libs/hast-util-to-html.mjs +1 -1
  9. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -1
  10. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +1 -1
  11. package/dist/_chunks/libs/mdast-util-gfm.mjs +11 -11
  12. package/dist/_chunks/libs/mnemonist.mjs +1 -1
  13. package/dist/_chunks/libs/unified.mjs +1 -1
  14. package/dist/_chunks/manual-layout.mjs +1 -1
  15. package/dist/_chunks/mnemonist.d.mts +1 -1
  16. package/dist/_chunks/model.mjs +4 -4
  17. package/dist/_chunks/rolldown-runtime.mjs +1 -1
  18. package/dist/_chunks/types.mjs +1 -1
  19. package/dist/builder/index.d.mts +0 -6
  20. package/dist/builder/index.mjs +1 -1
  21. package/dist/compute-view/index.d.mts +0 -4
  22. package/dist/compute-view/index.mjs +2 -2
  23. package/dist/geometry/index.mjs +1 -1
  24. package/dist/index.d.mts +0 -1
  25. package/dist/index.mjs +1 -1
  26. package/dist/model/index.d.mts +0 -5
  27. package/dist/model/index.mjs +1 -1
  28. package/dist/styles/index.d.mts +0 -1
  29. package/dist/styles/index.mjs +1 -1
  30. package/dist/types/index.mjs +1 -1
  31. package/dist/utils/graphology/index.d.mts +2 -1
  32. package/dist/utils/graphology/index.mjs +1 -1
  33. package/dist/utils/index.d.mts +0 -2
  34. package/dist/utils/index.mjs +1 -1
  35. package/package.json +9 -9
  36. package/dist/_chunks/geometry.mjs +0 -1
  37. package/dist/_chunks/utils.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime.mjs";import{A as t,E as n,I as r,L as i,N as a,O as o,Q as s,T as c,X as l,c as ee,et as u,i as d,l as te,m as ne,r as f,s as re}from"./libs/remeda.mjs";import{$ as ie,H as ae,O as oe,St as p,Y as m,_t as h,bt as g,ct as se,dt as ce,ft as le,j as ue,mt as de,t as _,ut as fe,vt as v,xt as y,yt as pe}from"./types.mjs";import{$ as b,A as x,B as S,D as me,E as he,F as C,H as ge,I as w,J as _e,L as T,Q as E,R as ve,S as D,U as ye,Y as be,a as O,c as k,h as A,j,k as xe,o as M,q as Se,r as Ce,u as N,y as we,z as Te}from"./utils.mjs";import{t as P}from"./libs/mnemonist.mjs";import{n as Ee,t as De}from"./manual-layout.mjs";var F=class{Aux;id;_literalId;hierarchyLevel;imported;constructor(e,t){this.$model=e,this.$element=t,this.id=this.$element.id,this._literalId=this.$element.id;let[n,r]=de(this.id);n?(this.imported={from:n,fqn:r},this.hierarchyLevel=C(r)):(this.imported=null,this.hierarchyLevel=C(this.id))}get name(){return Te(this.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$element.kind}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get tags(){return A(this,Symbol.for(`tags`),()=>d([...this.$element.tags??[],...this.$model.specification.elements[this.$element.kind]?.tags??[]]))}get metadata(){return this.$element.metadata??{}}get title(){return this.$element.title}get hasSummary(){return!!this.$element.summary&&!!this.$element.description&&!t(this.$element.summary,this.$element.description)}get summary(){return _.memoize(this,`summary`,y(this.$element))}get description(){return _.memoize(this,`description`,g(this.$element))}get technology(){return this.$element.technology??null}get links(){return this.$element.links??[]}get defaultView(){return A(this,Symbol.for(`defaultView`),()=>D(this.scopedViews())??null)}get isRoot(){return this.parent===null}get style(){return A(this,`style`,()=>p({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$element.style}))}get projectId(){return this.imported?.from??this.$model.projectId}isAncestorOf(e){return w(this,e)}isDescendantOf(e){return w(e,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=j(this.id,e.id);return t?this.$model.element(t):null}children(){return this.$model.children(this)}descendants(e){return e?ge([...this.$model.descendants(this)],e)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}get allOutgoing(){return A(this,Symbol.for(`allOutgoing`),()=>new Set(this.outgoing()))}get allIncoming(){return A(this,Symbol.for(`allIncoming`),()=>new Set(this.incoming()))}views(){return A(this,Symbol.for(`views`),()=>{let e=new Set;for(let t of this.$model.views())t.includesElement(this.id)&&e.add(t);return e})}scopedViews(){return A(this,Symbol.for(`scopedViews`),()=>{let e=new Set;for(let t of this.$model.views())t.isScopedElementView()&&t.viewOf.id===this.id&&e.add(t);return e})}isDeployed(){return o(D(this.deployments()))}deployments(){return this.$model.deployment.instancesOf(this)}hasMetadata(){return!!this.$element.metadata&&!i(this.$element.metadata)}getMetadata(e){return e?this.$element.metadata?.[e]:this.$element.metadata??{}}isTagged(e){return this.tags.includes(e)}},Oe=class{Aux;get style(){return A(this,`style`,()=>p({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$node.style}))}get name(){return Te(this.id)}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get summary(){return _.memoize(this,`summary`,y(this.$node))}get description(){return _.memoize(this,`description`,g(this.$node))}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=j(this.id,e.id);return t?this.$model.node(t):null}siblings(){return this.$model.siblings(this)}isSibling(e){return this.parent===e.parent}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}*views(){for(let e of this.$model.views())e._type===`deployment`&&e.includesDeployment(this.id)&&(yield e)}isDeploymentNode(){return!1}isInstance(){return!1}get allOutgoing(){return A(this,Symbol.for(`allOutgoing`),()=>z.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())))}get allIncoming(){return A(this,Symbol.for(`allIncoming`),()=>z.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())))}hasMetadata(){return!!this.$node.metadata&&!i(this.$node.metadata)}getMetadata(e){return e?this.$node.metadata?.[e]:this.$node.metadata??{}}isTagged(e){return this.tags.includes(e)}},I=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t){super(),this.$model=e,this.$node=t,this.id=t.id,this._literalId=t.id,this.title=t.title,this.hierarchyLevel=C(t.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}get metadata(){return this.$node.metadata??{}}get tags(){return A(this,Symbol.for(`tags`),()=>d([...this.$node.tags??[],...this.$model.$model.specification.deployments[this.kind]?.tags??[]]))}children(){return this.$model.children(this)}descendants(e=`desc`){return this.$model.descendants(this,e)}isDeploymentNode(){return!0}*instances(){for(let e of this.descendants(`desc`))e.isInstance()&&(yield e)}onlyOneInstance(){let e=this.children();if(e.size!==1)return null;let t=D(e);return t?t.isInstance()?t:t.onlyOneInstance():null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;let{outgoing:e,incoming:t}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(let n of this.instances()){for(let t of n.element.outgoing())e.add(t);for(let e of n.element.incoming())t.add(e)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){let{outgoing:e,incoming:t}=this.relationshipsFromInstances();return k(t,e)}},L=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t,n){super(),this.$model=e,this.$instance=t,this.element=n,this.id=t.id,this._literalId=t.id,this.title=t.title??n.title,this.hierarchyLevel=C(t.id)}get $node(){return this.$instance}get parent(){return b(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){return A(this,`style`,()=>p({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.element.$element.style,...this.$instance.style}))}get tags(){return A(this,Symbol.for(`tags`),()=>d([...this.$instance.tags??[],...this.element.tags]))}get kind(){return this.element.kind}get metadata(){return this.$instance.metadata??this.element.metadata??{}}get summary(){return _.memoize(this,`summary`,y(this.$instance)??y(this.element.$element))}get description(){return _.memoize(this,`description`,g(this.$instance)??g(this.element.$element))}get technology(){return this.$instance.technology??this.element.technology??null}get links(){return this.$instance.links??this.element.links}isInstance(){return!0}outgoingModelRelationships(){return this.element.outgoing()}incomingModelRelationships(){return this.element.incoming()}*views(){for(let e of this.$model.views())if(e._type===`deployment`){if(e.includesDeployment(this.id)){yield e;continue}e.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield e)}}},ke=class{constructor(e,t){this.instance=e,this.element=t}get id(){return this.instance.id}get _literalId(){return this.instance.id}get style(){return A(this,`style `,()=>({shape:this.element.shape,color:this.element.color,...this.element.$element.style}))}get shape(){return this.element.shape}get color(){return this.element.color}get title(){return this.element.title}get summary(){return this.element.summary}get description(){return this.element.description}get technology(){return this.element.technology}isDeploymentNode(){return!1}isInstance(){return!1}},R=class{boundary;source;target;constructor(e,t){this.$model=e,this.$relationship=t,this.source=e.deploymentRef(t.source),this.target=e.deploymentRef(t.target);let n=j(this.source.id,this.target.id);this.boundary=n?this.$model.node(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return o(this.$relationship.title)?this.$relationship.title:null}get technology(){return r(this.$relationship.technology)?(this.kind&&this.$model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return _.memoize(this,`summary`,y(this.$relationship))}get description(){return _.memoize(this,`description`,g(this.$relationship))}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.$model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.$model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.$model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.$model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!0}isModelRelation(){return!1}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},z=class e{static empty(){return new e}static from(t,n){return new e(new Set(t),new Set(n))}constructor(e=new Set,t=new Set){this.model=e,this.deployment=t}get isEmpty(){return this.model.size===0&&this.deployment.size===0}get nonEmpty(){return this.model.size>0||this.deployment.size>0}get size(){return this.model.size+this.deployment.size}intersect(t){return e.from(k(this.model,t.model),k(this.deployment,t.deployment))}difference(t){return e.from(O(this.model,t.model),O(this.deployment,t.deployment))}union(t){return e.from(N(this.model,t.model),N(this.deployment,t.deployment))}};const B=e=>typeof e==`string`?e:e.id,Ae=`/`,V=e=>{if(E(!e.includes(`
2
- `),`View title cannot contain newlines`),e.includes(`/`)){let t=e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0);return s(t,1)?t:[``]}return[e.trim()]},H=e=>V(e).join(`/`),je=e=>{let t=V(e);return s(t,2)?t.slice(0,-1).join(`/`):null},Me=e=>e.includes(`/`)?V(e).pop()??e:e.trim();var Ne=class{#e=new Map;#t=new Map;#n=new P.default(()=>new Set);#r=new P.default(()=>new Set);#i=new Set;#a=new Map;#o=new P.default(()=>new Set);#s=new P.default(()=>new Set);#c=new P.default(()=>new Set);#l=new P.default(()=>new Set);#u=new Map;$deployments;constructor(e){this.$model=e;let t=this.$deployments=e.$data.deployments,n=f(t.elements);for(let e of ye(n)){let t=this.addElement(e);for(let e of t.tags)this.#l.get(e).add(t);t.isInstance()&&this.#r.get(t.element.id).add(t)}for(let e of f(t.relations)){let t=this.addRelation(e);for(let e of t.tags)this.#l.get(e).add(t)}}get $styles(){return this.$model.$styles}get projectId(){return this.$model.projectId}get project(){return this.$model.project}get specification(){return this.$model.specification}element(e){if(e instanceof I||e instanceof L)return e;let t=B(e);return b(this.#e.get(t),`Element ${t} not found`)}findElement(e){return this.#e.get(e)??null}node(e){let t=this.element(e);return E(t.isDeploymentNode(),`Element ${t.id} is not a deployment node`),t}findNode(e){let t=this.findElement(e);return t?(E(t.isDeploymentNode(),`Element ${t?.id} is not a deployment node`),t):null}instance(e){let t=this.element(e);return E(t.isInstance(),`Element ${t.id} is not a deployed instance`),t}findInstance(e){let t=this.findElement(e);return t?(E(t.isInstance(),`Element ${t?.id} is not a deployed instance`),t):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(let e of this.#e.values())e.isDeploymentNode()&&(yield e)}*nodesOfKind(e){for(let t of this.#e.values())t.isDeploymentNode()&&t.kind===e&&(yield t)}*instances(){for(let e of this.#e.values())e.isInstance()&&(yield e)}*instancesOf(e){let t=B(e),n=this.#r.get(t);n&&(yield*n)}deploymentRef(e){if(m.isInsideInstanceRef(e)){let{deployment:t,element:n}=e;return xe(this.#u,`${t}@${n}`,()=>new ke(this.instance(t),this.$model.element(n)))}return this.element(e.deployment)}relationships(){return this.#a.values()}relationship(e){let t=B(e);return b(this.#a.get(t),`DeploymentRelationModel ${t} not found`)}findRelationship(e){return this.#a.get(e)??null}*views(){for(let e of this.$model.views())e.isDeploymentView()&&(yield e)}parent(e){let t=B(e);return this.#t.get(t)||null}children(e){let t=B(e);return this.#n.get(t)}*siblings(e){let t=B(e),n=this.parent(e)?.children()??this.roots();for(let e of n)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this.#t.get(t);)yield n,t=n.id}*descendants(e,t=`desc`){for(let n of this.children(e))t===`asc`?(yield n,yield*this.descendants(n.id)):(yield*this.descendants(n.id),yield n)}*incoming(e,t=`all`){let n=B(e);for(let e of this.#o.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this.#s.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}addElement(e){if(this.#e.has(e.id))throw Error(`Element ${e.id} already exists`);let t=ae(e)?new I(this,Object.freeze(e)):new L(this,Object.freeze(e),this.$model.element(e.element));this.#e.set(t.id,t);let n=S(t.id);return n?(E(this.#e.has(n),`Parent ${n} of ${t.id} not found`),this.#t.set(t.id,this.node(n)),this.#n.get(n).add(t)):(E(t.isDeploymentNode(),`Root element ${t.id} is not a deployment node`),this.#i.add(t)),t}addRelation(e){if(this.#a.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new R(this,Object.freeze(e));this.#a.set(t.id,t),this.#o.get(t.target.id).add(t),this.#s.get(t.source.id).add(t);let n=t.boundary?.id??null;if(n)for(let e of[n,...x(n)])this.#c.get(e).add(t);for(let e of x(t.source.id)){if(e===n)break;this.#s.get(e).add(t)}for(let e of x(t.target.id)){if(e===n)break;this.#o.get(e).add(t)}return t}},U=class{source;target;boundary;constructor(e,t){this.model=e,this.$relationship=t,this.source=e.element(m.flatten(t.source)),this.target=e.element(m.flatten(t.target));let n=j(this.source.id,this.target.id);this.boundary=n?this.model.element(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return r(this.$relationship.title)?null:this.$relationship.title}get technology(){return r(this.$relationship.technology)?(this.kind&&this.model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return _.memoize(this,`summary`,y(this.$relationship))}get description(){return _.memoize(this,`description`,g(this.$relationship))}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!1}isModelRelation(){return!0}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},W=class{Aux;$viewModel;$view;$edge;constructor(e,t,n,r){this.source=n,this.target=r,this.$viewModel=e,this.$view=e.$view,this.$edge=t}get id(){return this.$edge.id}get parent(){return this.$edge.parent?this.$viewModel.node(this.$edge.parent):null}get label(){return this.$edge.label??null}get description(){return _.memoize(this,`description`,this.$edge.description)}get technology(){return this.$edge.technology??null}hasParent(){return this.$edge.parent!==null}get tags(){return this.$edge.tags??[]}get stepNumber(){return this.isStep()?se(this.id):null}get navigateTo(){return this.$edge.navigateTo?this.$viewModel.$model.view(this.$edge.navigateTo):null}get color(){return this.$edge.color}get line(){return this.$edge.line??this.$viewModel.$styles.defaults.relationship.line}get head(){return this.$edge.head??this.$viewModel.$styles.defaults.relationship.arrow}get tail(){return this.$edge.tail}isStep(){return le(this.id)}*relationships(e){for(let t of this.$edge.relations)if(e){let n=this.$viewModel.$model.findRelationship(t,e);n&&(yield n)}else yield this.$viewModel.$model.relationship(t)}includesRelation(e){let t=typeof e==`string`?e:e.id;return this.$edge.relations.includes(t)}isTagged(e){return this.tags.includes(e)}},G=class{Aux;$viewModel;$view;$node;constructor(e,t){this.$viewModel=e,this.$view=e.$view,this.$node=t}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return _.memoize(this,`description`,this.$node.description)}get technology(){return this.$node.technology??null}get notes(){return _.memoize(this,`notes`,this.$node.notes)}get parent(){return this.$node.parent?this.$viewModel.node(this.$node.parent):null}get element(){let e=this.$node.modelRef;return e?this.$viewModel.$model.element(e):null}get deployment(){let e=this.$node.deploymentRef;return e?this.$viewModel.$model.deployment.element(e):null}get shape(){return this.$node.shape}get color(){return this.$node.color}get icon(){return this.$node.icon??null}get tags(){return this.$node.tags}get links(){return this.$node.links??[]}get navigateTo(){return this.$node.navigateTo?this.$viewModel.$model.view(this.$node.navigateTo):null}get style(){return this.$node.style}get x(){return`x`in this.$node?this.$node.x:void 0}get y(){return`y`in this.$node?this.$node.y:void 0}get width(){return`width`in this.$node?this.$node.width:void 0}get height(){return`height`in this.$node?this.$node.height:void 0}children(){return A(this,`children`,()=>new Set(this.$node.children.map(e=>this.$viewModel.node(e))))}*ancestors(){let e=this.parent;for(;e;)yield e,e=e.parent}*siblings(){let e=this.parent?.children()??this.$viewModel.roots();for(let t of e)t.id!==this.id&&(yield t)}*incoming(e=`all`){for(let t of this.$node.inEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.target.id===this.id:case e===`to-descendants`&&n.target.id!==this.id:yield n;break}}}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoing(e=`all`){for(let t of this.$node.outEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.source.id===this.id:case e===`from-descendants`&&n.source.id!==this.id:yield n;break}}}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}isLayouted(){return`width`in this.$node&&`height`in this.$node}hasChildren(){return this.$node.children.length>0}hasParent(){return this.$node.parent!==null}hasElement(){return o(this.$node.modelRef)}hasDeployment(){return o(this.$node.deploymentRef)}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return ce(this.$node)}isTagged(e){return this.tags.includes(e)}},K=class{Aux;#e;#t=new Set;#n=new Map;#r=new Map;#i=new Set;#a=new Set;#o=new Set;#s=new P.default(e=>new Set);#c;id;$model;title;folder;viewPath;constructor(e,t,n,r){this.$model=e,this.#e=n,this.id=n.id,this.folder=t,this.#c=r;for(let e of this.#e.nodes){let t=new G(this,Object.freeze(e));this.#n.set(e.id,t),e.parent||this.#t.add(t),e.deploymentRef&&this.#a.add(e.deploymentRef),e.modelRef&&this.#i.add(e.modelRef);for(let e of t.tags)this.#s.get(e).add(t)}for(let e of this.#e.edges){let t=new W(this,Object.freeze(e),this.node(e.source),this.node(e.target));for(let e of t.tags)this.#s.get(e).add(t);for(let t of e.relations)this.#o.add(t);this.#r.set(e.id,t)}this.title=n.title?Me(n.title):null,this.viewPath=n.title?H(n.title):n.id}get $styles(){return this.$model.$styles}get _type(){return this.#e[v]}get stage(){return this.#e[h]}get bounds(){if(`bounds`in this.#e)return this.#e.bounds;if(this.#c)return this.#c.bounds;throw Error(`View is not layouted`)}get titleOrId(){return this.title??this.viewOf?.title??this.id}get titleOrUntitled(){return this.title??`Untitled`}get breadcrumbs(){return A(this,`breadcrumbs`,()=>this.folder.isRoot?[this]:[...this.folder.breadcrumbs,this])}get description(){return _.memoize(this,`description`,this.#e.description)}get tags(){return this.#e.tags??[]}get links(){return this.#e.links??[]}get viewOf(){if(this.isElementView()){let e=this.#e.viewOf;return e?this.$model.element(e):null}return null}get mode(){return this.isDynamicView()?this.#e.variant??`diagram`:null}get includedTags(){return[...this.#s.keys()]}get $view(){if(!this.isLayouted()||`drifts`in this.#e)return this.#e;let e=this.#c;return e?A(this,`withDriftReasons`,()=>De(this.#e,e)):this.#e}get $layouted(){if(!this.isLayouted())throw Error(`View is not layouted`);return this.$manual??this.#e}get hasManualLayout(){return this.#c!==void 0}get hasLayoutDrifts(){if(!this.isLayouted())return!1;let e=this.$manual;return!!e?.drifts&&e.drifts.length>0}get $manual(){if(!this.isLayouted())return null;let e=this.#c;return e?this.#e._layout===`manual`?this.#e:A(this,`snapshotWithManualLayout`,()=>Ee(this.#e,e)):null}get projectId(){return this.$model.projectId}roots(){return this.#t.values()}*compounds(){for(let e of this.#n.values())e.hasChildren()&&(yield e)}node(e){let t=B(e);return b(this.#n.get(t),`Node ${t} not found in view ${this.#e.id}`)}findNode(e){return this.#n.get(B(e))??null}findNodeWithElement(e){let t=B(e);return this.#i.has(t)?he(this.#n.values(),e=>e.hasElement()&&e.element.id===t)??null:null}nodes(){return this.#n.values()}edge(e){let t=B(e);return b(this.#r.get(t),`Edge ${t} not found in view ${this.#e.id}`)}findEdge(e){return this.#r.get(B(e))??null}edges(){return this.#r.values()}*edgesWithRelation(e){for(let t of this.#r.values())t.includesRelation(e)&&(yield t)}*elements(){for(let e of this.#n.values())e.hasElement()&&(yield e)}isTagged(e){return this.tags.includes(e)}includesElement(e){return this.#i.has(B(e))}includesDeployment(e){return this.#a.has(B(e))}includesRelation(e){return this.#o.has(B(e))}isComputed(){return this.#e[h]===`computed`}isLayouted(){return this.#e[h]===`layouted`}isDiagram(){return this.#e[h]===`layouted`}isElementView(){return this.#e[v]===`element`}isScopedElementView(){return this.#e[v]===`element`&&o(this.#e.viewOf)}isDeploymentView(){return this.#e[v]===`deployment`}isDynamicView(){return this.#e[v]===`dynamic`}},q=class e{$model;path;title;isRoot;parentPath;defaultViewId;constructor(e,t,r){this.$model=e,this.path=t.join(`/`),this.isRoot=this.path===``,this.title=n(t),this.isRoot?this.parentPath=void 0:this.parentPath=t.slice(0,-1).join(`/`),this.defaultViewId=r}get defaultView(){return this.defaultViewId?this.$model.view(this.defaultViewId):null}get breadcrumbs(){return E(!this.isRoot,`Root view folder has no breadcrumbs`),A(this,`breadcrumbs`,()=>{let e=this.parent;return e?e.isRoot?[e,this]:[...e.breadcrumbs,this]:[this]})}get parent(){return E(!this.isRoot,`Root view folder has no parent`),r(this.parentPath)?null:this.$model.viewFolder(this.parentPath)}get children(){return this.$model.viewFolderItems(this.path)}get folders(){return A(this,`folders`,()=>{let t=[];for(let n of this.children)n instanceof e&&t.push(n);return t})}get views(){return A(this,`views`,()=>{let e=[];for(let t of this.children)t instanceof K&&e.push(t);return e})}},J=class e{Aux;_elements=new Map;_parents=new Map;_children=new P.default(()=>new Set);_rootElements=new Set;_relations=new Map;_incoming=new P.default(()=>new Set);_outgoing=new P.default(()=>new Set);_internal=new P.default(()=>new Set);_views=new Map;_rootViewFolder;_viewFolders=new Map;_viewFolderItems=new P.default(()=>new Set);_allTags=new P.default(()=>new Set);static fromParsed(t){return new e(t)}static create(t){return new e(t)}static fromDump(t){let{_stage:n=`layouted`,projectId:r=`unknown`,project:i,globals:a,imports:o,deployments:s,views:c,relations:l,elements:ee,specification:u}=t;return new e({[h]:n,projectId:r,project:i,globals:{predicates:a?.predicates??{},dynamicPredicates:a?.dynamicPredicates??{},styles:a?.styles??{}},imports:o??{},deployments:{elements:s?.elements??{},relations:s?.relations??{}},views:c??{},relations:l??{},elements:ee??{},specification:u})}deployment;$data;constructor(e){this.$data=e;for(let[,t]of l(e.elements)){let e=this.addElement(t);for(let t of e.tags)this._allTags.get(t).add(e)}for(let[t,n]of l(e.imports??{}))for(let e of ye(n)){let n=this.addImportedElement(t,e);for(let e of n.tags)this._allTags.get(e).add(n)}for(let t of f(e.relations)){let e=this.addRelation(t);for(let t of e.tags)this._allTags.get(t).add(e)}if(this.deployment=new Ne(this),pe(e,`computed`)||pe(e,`layouted`)){let t=be(`/`),n=u(f(e.views),c(e=>({view:e,path:H(e.title??e.id),folderPath:e.title&&je(e.title)||``})),te((e,n)=>t(e.folderPath,n.folderPath))),r=e=>{let t=this._viewFolders.get(e);if(!t){let r=re(e,`/`);E(s(r,1),`View group path "${e}" must have at least one element`);let i;i=e===``?n.find(e=>e.view.id===`index`):n.find(t=>t.path===e),t=new q(this,r,i?.view.id),this._viewFolders.set(e,t)}return t};this._rootViewFolder=r(``);for(let{folderPath:e}of n)this._viewFolders.has(e)||re(e,`/`).reduce((e,t)=>{let n=e.join(`/`),a=r(i(n)?t:n+`/`+t);return this._viewFolderItems.get(n).add(a),e.push(t),e},[]);for(let{view:t,folderPath:i}of n){let n=new K(this,r(i),t,e.manualLayouts?.[t.id]);this._viewFolderItems.get(i).add(n),this._views.set(t.id,n);for(let e of n.tags)this._allTags.get(e).add(n)}}else this._rootViewFolder=new q(this,[``],void 0),this._viewFolders.set(this._rootViewFolder.path,this._rootViewFolder)}get asParsed(){return this}get asComputed(){return this}get asLayouted(){return this}get $styles(){return A(this,`styles`,()=>ue.from(this.project.styles,this.specification.customColors))}isParsed(){return this.stage===`parsed`}isLayouted(){return this.stage===`layouted`}isComputed(){return this.stage===`computed`}get $model(){return this.$data}get stage(){return this.$data[h]}get projectId(){return this.$data.projectId??`default`}get project(){return this.$data.project??A(this,Symbol.for(`project`),()=>({id:this.projectId,styles:{},manualLayouts:{}}))}get specification(){return this.$data.specification}get globals(){return A(this,Symbol.for(`globals`),()=>({predicates:{...this.$data.globals?.predicates},dynamicPredicates:{...this.$data.globals?.dynamicPredicates},styles:{...this.$data.globals?.styles}}))}element(e){if(e instanceof F)return e;let t=B(e);return b(this._elements.get(t),`Element ${t} not found`)}findElement(e){return this._elements.get(B(e))??null}roots(){return this._rootElements.values()}elements(){return this._elements.values()}relationships(){return this._relations.values()}relationship(e,t){if(t===`deployment`)return this.deployment.relationship(e);let n=B(e),r=this._relations.get(n)??null;return r||t===`model`?b(r,`Model relation ${n} not found`):b(this.deployment.findRelationship(n),`No model/deployment relation ${n} not found`)}findRelationship(e,t){if(t===`deployment`)return this.deployment.findRelationship(e);let n=this._relations.get(B(e))??null;return n||t===`model`?n:this.deployment.findRelationship(e)}views(){return this._views.values()}view(e){let t=B(e);return b(this._views.get(t),`View ${t} not found`)}findView(e){return this._views.get(e)??null}findManualLayout(e){return`manualLayouts`in this.$data?this.$data.manualLayouts?.[e]??null:null}viewFolder(e){return b(this._viewFolders.get(e),`View folder ${e} not found`)}get rootViewFolder(){return this._rootViewFolder}get hasViewFolders(){return this._viewFolders.size>1}viewFolderItems(e){return E(this._viewFolders.has(e),`View folder ${e} not found`),this._viewFolderItems.get(e)}parent(e){let t=B(e);return this._parents.get(t)||null}children(e){let t=B(e);return this._children.get(t)}*siblings(e){let t=B(e),n=this._parents.get(t),r=n?this._children.get(n.id).values():this.roots();for(let e of r)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this._parents.get(t);)yield n,t=n.id}*descendants(e){for(let t of this.children(e))yield t,yield*this.descendants(t.id)}*incoming(e,t=`all`){let n=B(e);for(let e of this._incoming.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this._outgoing.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}get tags(){return A(this,`tags`,()=>te([...this._allTags.keys()],_e))}get tagsSortedByUsage(){return A(this,`tagsSortedByUsage`,()=>u([...this._allTags.entries()],c(([e,t])=>({tag:e,count:t.size,tagged:t})),te((e,t)=>_e(e.tag,t.tag)),ee([ne(`count`),`desc`])))}findByTag(e,t){return me(this._allTags.get(e),e=>t===`elements`?e instanceof F:t===`views`?e instanceof K:t===`relationships`?e instanceof U:!0)}*elementsOfKind(e){for(let t of this._elements.values())t.kind===e&&(yield t)}*elementsWhere(e){let t=oe(e);for(let e of this._elements.values())t(e)&&(yield e)}*relationshipsWhere(e){let t=oe(e);for(let e of this._relations.values())t(e)&&(yield e)}addElement(e){if(this._elements.has(e.id))throw Error(`Element ${e.id} already exists`);let t=new F(this,Object.freeze(e));this._elements.set(t.id,t);let n=S(t.id);return n?(E(this._elements.has(n),`Parent ${n} of ${t.id} not found`),this._parents.set(t.id,this.element(n)),this._children.get(n).add(t)):this._rootElements.add(t),t}addImportedElement(e,t){E(!fe(t.id),`Imported element already has global FQN`);let n=ie(e,t.id);if(this._elements.has(n))throw Error(`Element ${n} already exists`);let r=new F(this,Object.freeze({...t,id:n}));this._elements.set(r.id,r);let i=S(r.id);for(;i;){if(i.includes(`.`)&&this._elements.has(i))return this._parents.set(r.id,this.element(i)),this._children.get(i).add(r),r;i=S(i)}return this._rootElements.add(r),r}addRelation(e){if(this._relations.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new U(this,Object.freeze(e)),{source:n,target:r}=t;this._relations.set(t.id,t),this._incoming.get(r.id).add(t),this._outgoing.get(n.id).add(t);let i=j(n.id,r.id);if(i)for(let e of[i,...x(i)])this._internal.get(e).add(t);for(let e of x(n.id)){if(e===i)break;this._outgoing.get(e).add(t)}for(let e of x(r.id)){if(e===i)break;this._incoming.get(e).add(t)}return t}};(function(e){e.EMPTY=J.create({_stage:`computed`,projectId:`default`,project:{id:`default`},specification:{elements:{},relationships:{},deployments:{},tags:{}},globals:{predicates:{},dynamicPredicates:{},styles:{}},deployments:{elements:{},relations:{}},elements:{},relations:{},views:{},imports:{}})})(J||={});let Pe;(function(e){e.isInside=e=>t=>w(e,t.source.id)&&w(e,t.target.id);let t=e.isDirectedBetween=(e,t)=>n=>(n.source.id===e||w(e,n.source.id))&&(n.target.id===t||w(t,n.target.id));e.isAnyBetween=(e,n)=>{let r=t(e,n),i=t(n,e);return e=>r(e)||i(e)};let n=e.isIncoming=e=>t=>(t.target.id===e||w(e,t.target.id))&&!w(e,t.source.id),r=e.isOutgoing=e=>t=>(t.source.id===e||w(e,t.source.id))&&!w(e,t.target.id);e.isAnyInOut=e=>{let t=n(e),i=r(e);return e=>t(e)||i(e)}})(Pe||={});const Y=Symbol.for(`nodejs.util.inspect.custom`);var Fe=class e{id;constructor(e,t,n){this.source=e,this.target=t,this.relations=n,this.id=Ce(`deployment:${e.id}:${t.id}`)}get expression(){return`${this.source.id} -> ${this.target.id}`}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target),this._boundary}nonEmpty(){return this.relations.nonEmpty}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){let e=[...this.relations.model].map(e=>` `+e.expression);e.length?e.unshift(` model:`):e.unshift(` model: []`);let t=[...this.relations.deployment].map(e=>` `+e.expression);return t.length?t.unshift(` deployment:`):t.unshift(` deployment: []`),[this.expression,...e,...t].join(`
3
- `)}hasDirectDeploymentRelation(){for(let e of this.relations.deployment)if(e.source.id===this.source.id||e.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(t){return Array.isArray(t)?t.reduce((e,t)=>e.mergeWith(t),this):(E(this.source.id===t.source.id,`Cannot merge connections with different sources`),E(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,this.relations.union(t.relations)))}difference(t){return new e(this.source,this.target,this.relations.difference(t.relations))}intersect(t){return new e(this.source,this.target,this.relations.intersect(t.relations))}equals(t){return E(t instanceof e,`Other should ne DeploymentConnectionModel`),this.id===t.id&&this.source.id===t.source.id&&this.target.id===t.target.id&&M(this.relations.model,t.relations.model)&&M(this.relations.deployment,t.relations.deployment)}update(t){return t&&={model:this.relations.model,deployment:this.relations.deployment,...t},new e(this.source,this.target,t?new z(t.model??new Set,t.deployment??new Set):this.relations)}};function X(e,t){if(!t){let t=e;return e=>X(e,t)}let n=e.source===t.source,r=e.target===t.target;if(n&&r)return!1;let i=w(t.source.id,e.source.id),a=w(t.target.id,e.target.id);return i&&a||n&&a||r&&i}function Ie(e,t){let n=t;for(let t of e)X(t,n)&&(n=t);return n===t?null:n}function Le(e){let t=[],n=e.slice(),r;for(;r=n.shift();){let e;for(;e=Ie(n,r);){let r=n.indexOf(e);t.push(n.splice(r,1)[0])}t.push(r)}return t}function Re(e){return e.boundary?.id?`.${e.boundary.id}`:``}function ze(e,t){if(!e||Se(e)){let t=e??`asc`;return e=>Be(e,t)}return Be(e,t??`asc`)}function Be(e,t){return u(e,c(e=>({id:Re(e),conn:e})),ge(t),c(e=>e.conn))}function Ve(e,t){return e.filter(e=>X(t,e))}function He(e,t){return e.filter(X(t))}function Ue(e){let t=new Map;for(let n of e){let e=t.get(n.id);e?t.set(n.id,n.mergeWith(e)):t.set(n.id,n)}return[...t.values()]}function We(e,t){let n=new Map([...t].map(e=>[e.id,e]));return[...e].reduce((e,t)=>{let r=n.get(t.id);if(!r)return e.push(t),e;let i=t.difference(r);return i.nonEmpty()&&e.push(i),e},[])}function Z(e,t){return t?e.source===t.source&&e.target===t.target:t=>e.source===t.source&&e.target===t.target}function Ge(e,t){return t?e.source===t.source:t=>e.source===t.source}function Ke(e,t){return t?e.target===t.target:t=>e.target===t.target}function qe(e,t){if(!t){let t=e;return e=>qe(e,t)}let n=e;return T(n.source,t)&&!T(n.target,t)}function Je(e,t){if(!t){let t=e;return e=>Je(e,t)}let n=e;return T(n.target,t)&&!T(n.source,t)}function Ye(e,t){if(!t){let t=e;return e=>Ye(e,t)}let n=e;return T(n.source,t)!==T(n.target,t)}var Q=class e{id;constructor(e,t,n=new Set){this.source=e,this.target=t,this.relations=n,this.id=Ce(`model:${e.id}:${t.id}`)}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target)}get expression(){return`${this.source.id} -> ${this.target.id}`}get isDirect(){return this.nonEmpty()&&!this.isImplicit}get isImplicit(){return this.nonEmpty()&&we(this.relations,a(Z(this)))}get directRelations(){return new Set(me(this.relations,Z(this)))}nonEmpty(){return this.relations.size>0}mergeWith(t){return E(this.source.id===t.source.id,`Cannot merge connections with different sources`),E(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,N(this.relations,t.relations))}difference(t){return new e(this.source,this.target,O(this.relations,t.relations))}intersect(t){return E(t instanceof e,`Cannot intersect connection with different type`),new e(this.source,this.target,k(this.relations,t.relations))}equals(t){E(t instanceof e,`Cannot merge connection with different type`);let n=t;return this.id===n.id&&this.source.id===n.source.id&&this.target.id===n.target.id&&M(this.relations,n.relations)}update(t){return new e(this.source,this.target,t)}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){return[this.expression,this.relations.size?` relations:`:` relations: [ ]`,...[...this.relations].map(e=>` `+e.expression)].join(`
4
- `)}reversed(){return new e(this.target,this.source)}},Xe=e({findConnection:()=>$,findConnectionsBetween:()=>Ze,findConnectionsWithin:()=>Qe});function $(e,t,n=`directed`){if(e===t||ve(e,t))return[];let r=e.allOutgoing.intersect(t.allIncoming),i=r.nonEmpty?[new Fe(e,t,r)]:[];return n===`directed`?i:[...i,...$(t,e,`directed`)]}function Ze(e,t,n=`both`){if(e.allIncoming.isEmpty&&e.allOutgoing.isEmpty)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of $(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function Qe(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...Ze(t,r.slice(n+1),`both`)),e),[])}var $e=e({findConnection:()=>et,findConnectionsBetween:()=>tt,findConnectionsWithin:()=>nt});function et(e,t,n=`directed`){if(e===t||ve(e,t))return[];let r=k(e.allOutgoing,t.allIncoming),i=r.size>0?new Q(e,t,r):null;if(n===`directed`)return i?[i]:[];let a=k(e.allIncoming,t.allOutgoing),o=a.size>0?new Q(t,e,a):null;return i&&o?[i,o]:i?[i]:o?[o]:[]}function tt(e,t,n=`both`){if(e.allIncoming.size===0&&e.allOutgoing.size===0)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of et(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function nt(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...tt(t,r.slice(n+1),`both`)),e),[])}function rt(e){return e instanceof I}function it(e){return e instanceof L}function at(e){return rt(e)||it(e)}function ot(e){return e instanceof ke}function st(e){return e instanceof R}function ct(e){return e instanceof U}function lt(e){return e instanceof F}function ut(e){return e instanceof K}function dt(e){return e instanceof G}function ft(e){return e instanceof W}export{Fe as A,Ae as B,Ye as C,Ue as D,qe as E,K as F,I as G,je as H,G as I,F as J,R as K,W as L,Pe as M,J as N,ze as O,q as P,U as R,Ke as S,X as T,H as U,Me as V,L as W,Ve as _,ft as a,Ge as b,ot as c,et as d,tt as f,We as g,Q as h,st as i,Y as j,Le as k,dt as l,Xe as m,at as n,lt as o,$e as p,z as q,rt as r,ut as s,it as t,ct as u,Ie as v,Je as w,Z as x,He as y,Ne as z};
1
+ import{n as e}from"./rolldown-runtime.mjs";import{A as t,E as n,I as r,L as i,N as a,O as o,Q as s,T as c,X as l,c as ee,et as u,i as d,l as f,m as te,r as p,s as ne}from"./libs/remeda.mjs";import{$ as re,$t as ie,Bt as ae,Dn as m,Dt as oe,En as h,Et as g,H as se,It as _,Jt as ce,O as le,On as v,Sn as y,Ut as b,Y as x,_t as S,cn as C,ct as ue,dn as w,dt as de,en as fe,ft as pe,gn as me,hn as he,j as ge,jt as T,kt as E,ln as _e,mn as ve,mt as ye,nn as D,on as O,pn as be,qt as xe,sn as k,t as A,tn as j,un as Se,ut as Ce,vt as M,wt as we,xn as N,yt as Te}from"./types.mjs";import{t as P}from"./libs/mnemonist.mjs";import{n as Ee,t as De}from"./manual-layout.mjs";var F=class{Aux;id;_literalId;hierarchyLevel;imported;constructor(e,t){this.$model=e,this.$element=t,this.id=this.$element.id,this._literalId=this.$element.id;let[n,r]=ye(this.id);n?(this.imported={from:n,fqn:r},this.hierarchyLevel=O(r)):(this.imported=null,this.hierarchyLevel=O(this.id))}get name(){return Se(this.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$element.kind}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get tags(){return _(this,Symbol.for(`tags`),()=>d([...this.$element.tags??[],...this.$model.specification.elements[this.$element.kind]?.tags??[]]))}get metadata(){return this.$element.metadata??{}}get title(){return this.$element.title}get hasSummary(){return!!this.$element.summary&&!!this.$element.description&&!t(this.$element.summary,this.$element.description)}get summary(){return A.memoize(this,`summary`,m(this.$element))}get description(){return A.memoize(this,`description`,h(this.$element))}get technology(){return this.$element.technology??null}get links(){return this.$element.links??[]}get defaultView(){return _(this,Symbol.for(`defaultView`),()=>b(this.scopedViews())??null)}get isRoot(){return this.parent===null}get style(){return _(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$element.style}))}get projectId(){return this.imported?.from??this.$model.projectId}isAncestorOf(e){return k(this,e)}isDescendantOf(e){return k(e,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=D(this.id,e.id);return t?this.$model.element(t):null}children(){return this.$model.children(this)}descendants(e){return e?be([...this.$model.descendants(this)],e)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}get allOutgoing(){return _(this,Symbol.for(`allOutgoing`),()=>new Set(this.outgoing()))}get allIncoming(){return _(this,Symbol.for(`allIncoming`),()=>new Set(this.incoming()))}views(){return _(this,Symbol.for(`views`),()=>{let e=new Set;for(let t of this.$model.views())t.includesElement(this.id)&&e.add(t);return e})}scopedViews(){return _(this,Symbol.for(`scopedViews`),()=>{let e=new Set;for(let t of this.$model.views())t.isScopedElementView()&&t.viewOf.id===this.id&&e.add(t);return e})}isDeployed(){return o(b(this.deployments()))}deployments(){return this.$model.deployment.instancesOf(this)}hasMetadata(){return!!this.$element.metadata&&!i(this.$element.metadata)}getMetadata(e){return e?this.$element.metadata?.[e]:this.$element.metadata??{}}isTagged(e){return this.tags.includes(e)}},Oe=class{Aux;get style(){return _(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$node.style}))}get name(){return Se(this.id)}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get summary(){return A.memoize(this,`summary`,m(this.$node))}get description(){return A.memoize(this,`description`,h(this.$node))}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=D(this.id,e.id);return t?this.$model.node(t):null}siblings(){return this.$model.siblings(this)}isSibling(e){return this.parent===e.parent}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}*views(){for(let e of this.$model.views())e._type===`deployment`&&e.includesDeployment(this.id)&&(yield e)}isDeploymentNode(){return!1}isInstance(){return!1}get allOutgoing(){return _(this,Symbol.for(`allOutgoing`),()=>z.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())))}get allIncoming(){return _(this,Symbol.for(`allIncoming`),()=>z.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())))}hasMetadata(){return!!this.$node.metadata&&!i(this.$node.metadata)}getMetadata(e){return e?this.$node.metadata?.[e]:this.$node.metadata??{}}isTagged(e){return this.tags.includes(e)}},I=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t){super(),this.$model=e,this.$node=t,this.id=t.id,this._literalId=t.id,this.title=t.title,this.hierarchyLevel=O(t.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}get metadata(){return this.$node.metadata??{}}get tags(){return _(this,Symbol.for(`tags`),()=>d([...this.$node.tags??[],...this.$model.$model.specification.deployments[this.kind]?.tags??[]]))}children(){return this.$model.children(this)}descendants(e=`desc`){return this.$model.descendants(this,e)}isDeploymentNode(){return!0}*instances(){for(let e of this.descendants(`desc`))e.isInstance()&&(yield e)}onlyOneInstance(){let e=this.children();if(e.size!==1)return null;let t=b(e);return t?t.isInstance()?t:t.onlyOneInstance():null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;let{outgoing:e,incoming:t}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(let n of this.instances()){for(let t of n.element.outgoing())e.add(t);for(let e of n.element.incoming())t.add(e)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){let{outgoing:e,incoming:t}=this.relationshipsFromInstances();return E(t,e)}},L=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t,n){super(),this.$model=e,this.$instance=t,this.element=n,this.id=t.id,this._literalId=t.id,this.title=t.title??n.title,this.hierarchyLevel=O(t.id)}get $node(){return this.$instance}get parent(){return y(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){return _(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.element.$element.style,...this.$instance.style}))}get tags(){return _(this,Symbol.for(`tags`),()=>d([...this.$instance.tags??[],...this.element.tags]))}get kind(){return this.element.kind}get metadata(){return this.$instance.metadata??this.element.metadata??{}}get summary(){return A.memoize(this,`summary`,m(this.$instance)??m(this.element.$element))}get description(){return A.memoize(this,`description`,h(this.$instance)??h(this.element.$element))}get technology(){return this.$instance.technology??this.element.technology??null}get links(){return this.$instance.links??this.element.links}isInstance(){return!0}outgoingModelRelationships(){return this.element.outgoing()}incomingModelRelationships(){return this.element.incoming()}*views(){for(let e of this.$model.views())if(e._type===`deployment`){if(e.includesDeployment(this.id)){yield e;continue}e.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield e)}}},ke=class{constructor(e,t){this.instance=e,this.element=t}get id(){return this.instance.id}get _literalId(){return this.instance.id}get style(){return _(this,`style `,()=>({shape:this.element.shape,color:this.element.color,...this.element.$element.style}))}get shape(){return this.element.shape}get color(){return this.element.color}get title(){return this.element.title}get summary(){return this.element.summary}get description(){return this.element.description}get technology(){return this.element.technology}isDeploymentNode(){return!1}isInstance(){return!1}},R=class{boundary;source;target;constructor(e,t){this.$model=e,this.$relationship=t,this.source=e.deploymentRef(t.source),this.target=e.deploymentRef(t.target);let n=D(this.source.id,this.target.id);this.boundary=n?this.$model.node(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return o(this.$relationship.title)?this.$relationship.title:null}get technology(){return r(this.$relationship.technology)?(this.kind&&this.$model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return A.memoize(this,`summary`,m(this.$relationship))}get description(){return A.memoize(this,`description`,h(this.$relationship))}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.$model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.$model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.$model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.$model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!0}isModelRelation(){return!1}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},z=class e{static empty(){return new e}static from(t,n){return new e(new Set(t),new Set(n))}constructor(e=new Set,t=new Set){this.model=e,this.deployment=t}get isEmpty(){return this.model.size===0&&this.deployment.size===0}get nonEmpty(){return this.model.size>0||this.deployment.size>0}get size(){return this.model.size+this.deployment.size}intersect(t){return e.from(E(this.model,t.model),E(this.deployment,t.deployment))}difference(t){return e.from(g(this.model,t.model),g(this.deployment,t.deployment))}union(t){return e.from(T(this.model,t.model),T(this.deployment,t.deployment))}};const B=e=>typeof e==`string`?e:e.id,Ae=`/`,V=e=>{if(N(!e.includes(`
2
+ `),`View title cannot contain newlines`),e.includes(`/`)){let t=e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0);return s(t,1)?t:[``]}return[e.trim()]},H=e=>V(e).join(`/`),je=e=>{let t=V(e);return s(t,2)?t.slice(0,-1).join(`/`):null},Me=e=>e.includes(`/`)?V(e).pop()??e:e.trim();var Ne=class{#e=new Map;#t=new Map;#n=new P.default(()=>new Set);#r=new P.default(()=>new Set);#i=new Set;#a=new Map;#o=new P.default(()=>new Set);#s=new P.default(()=>new Set);#c=new P.default(()=>new Set);#l=new P.default(()=>new Set);#u=new Map;$deployments;constructor(e){this.$model=e;let t=this.$deployments=e.$data.deployments,n=p(t.elements);for(let e of ve(n)){let t=this.addElement(e);for(let e of t.tags)this.#l.get(e).add(t);t.isInstance()&&this.#r.get(t.element.id).add(t)}for(let e of p(t.relations)){let t=this.addRelation(e);for(let e of t.tags)this.#l.get(e).add(t)}}get $styles(){return this.$model.$styles}get projectId(){return this.$model.projectId}get project(){return this.$model.project}get specification(){return this.$model.specification}element(e){if(e instanceof I||e instanceof L)return e;let t=B(e);return y(this.#e.get(t),`Element ${t} not found`)}findElement(e){return this.#e.get(e)??null}node(e){let t=this.element(e);return N(t.isDeploymentNode(),`Element ${t.id} is not a deployment node`),t}findNode(e){let t=this.findElement(e);return t?(N(t.isDeploymentNode(),`Element ${t?.id} is not a deployment node`),t):null}instance(e){let t=this.element(e);return N(t.isInstance(),`Element ${t.id} is not a deployed instance`),t}findInstance(e){let t=this.findElement(e);return t?(N(t.isInstance(),`Element ${t?.id} is not a deployed instance`),t):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(let e of this.#e.values())e.isDeploymentNode()&&(yield e)}*nodesOfKind(e){for(let t of this.#e.values())t.isDeploymentNode()&&t.kind===e&&(yield t)}*instances(){for(let e of this.#e.values())e.isInstance()&&(yield e)}*instancesOf(e){let t=B(e),n=this.#r.get(t);n&&(yield*n)}deploymentRef(e){if(x.isInsideInstanceRef(e)){let{deployment:t,element:n}=e;return fe(this.#u,`${t}@${n}`,()=>new ke(this.instance(t),this.$model.element(n)))}return this.element(e.deployment)}relationships(){return this.#a.values()}relationship(e){let t=B(e);return y(this.#a.get(t),`DeploymentRelationModel ${t} not found`)}findRelationship(e){return this.#a.get(e)??null}*views(){for(let e of this.$model.views())e.isDeploymentView()&&(yield e)}parent(e){let t=B(e);return this.#t.get(t)||null}children(e){let t=B(e);return this.#n.get(t)}*siblings(e){let t=B(e),n=this.parent(e)?.children()??this.roots();for(let e of n)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this.#t.get(t);)yield n,t=n.id}*descendants(e,t=`desc`){for(let n of this.children(e))t===`asc`?(yield n,yield*this.descendants(n.id)):(yield*this.descendants(n.id),yield n)}*incoming(e,t=`all`){let n=B(e);for(let e of this.#o.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this.#s.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}addElement(e){if(this.#e.has(e.id))throw Error(`Element ${e.id} already exists`);let t=se(e)?new I(this,Object.freeze(e)):new L(this,Object.freeze(e),this.$model.element(e.element));this.#e.set(t.id,t);let n=w(t.id);return n?(N(this.#e.has(n),`Parent ${n} of ${t.id} not found`),this.#t.set(t.id,this.node(n)),this.#n.get(n).add(t)):(N(t.isDeploymentNode(),`Root element ${t.id} is not a deployment node`),this.#i.add(t)),t}addRelation(e){if(this.#a.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new R(this,Object.freeze(e));this.#a.set(t.id,t),this.#o.get(t.target.id).add(t),this.#s.get(t.source.id).add(t);let n=t.boundary?.id??null;if(n)for(let e of[n,...j(n)])this.#c.get(e).add(t);for(let e of j(t.source.id)){if(e===n)break;this.#s.get(e).add(t)}for(let e of j(t.target.id)){if(e===n)break;this.#o.get(e).add(t)}return t}},U=class{source;target;boundary;constructor(e,t){this.model=e,this.$relationship=t,this.source=e.element(x.flatten(t.source)),this.target=e.element(x.flatten(t.target));let n=D(this.source.id,this.target.id);this.boundary=n?this.model.element(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return r(this.$relationship.title)?null:this.$relationship.title}get technology(){return r(this.$relationship.technology)?(this.kind&&this.model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return A.memoize(this,`summary`,m(this.$relationship))}get description(){return A.memoize(this,`description`,h(this.$relationship))}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!1}isModelRelation(){return!0}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},W=class{Aux;$viewModel;$view;$edge;constructor(e,t,n,r){this.source=n,this.target=r,this.$viewModel=e,this.$view=e.$view,this.$edge=t}get id(){return this.$edge.id}get parent(){return this.$edge.parent?this.$viewModel.node(this.$edge.parent):null}get label(){return this.$edge.label??null}get description(){return A.memoize(this,`description`,this.$edge.description)}get technology(){return this.$edge.technology??null}hasParent(){return this.$edge.parent!==null}get tags(){return this.$edge.tags??[]}get stepNumber(){return this.isStep()?ue(this.id):null}get navigateTo(){return this.$edge.navigateTo?this.$viewModel.$model.view(this.$edge.navigateTo):null}get color(){return this.$edge.color}get line(){return this.$edge.line??this.$viewModel.$styles.defaults.relationship.line}get head(){return this.$edge.head??this.$viewModel.$styles.defaults.relationship.arrow}get tail(){return this.$edge.tail}isStep(){return pe(this.id)}*relationships(e){for(let t of this.$edge.relations)if(e){let n=this.$viewModel.$model.findRelationship(t,e);n&&(yield n)}else yield this.$viewModel.$model.relationship(t)}includesRelation(e){let t=typeof e==`string`?e:e.id;return this.$edge.relations.includes(t)}isTagged(e){return this.tags.includes(e)}},G=class{Aux;$viewModel;$view;$node;constructor(e,t){this.$viewModel=e,this.$view=e.$view,this.$node=t}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return A.memoize(this,`description`,this.$node.description)}get technology(){return this.$node.technology??null}get notes(){return A.memoize(this,`notes`,this.$node.notes)}get parent(){return this.$node.parent?this.$viewModel.node(this.$node.parent):null}get element(){let e=this.$node.modelRef;return e?this.$viewModel.$model.element(e):null}get deployment(){let e=this.$node.deploymentRef;return e?this.$viewModel.$model.deployment.element(e):null}get shape(){return this.$node.shape}get color(){return this.$node.color}get icon(){return this.$node.icon??null}get tags(){return this.$node.tags}get links(){return this.$node.links??[]}get navigateTo(){return this.$node.navigateTo?this.$viewModel.$model.view(this.$node.navigateTo):null}get style(){return this.$node.style}get x(){return`x`in this.$node?this.$node.x:void 0}get y(){return`y`in this.$node?this.$node.y:void 0}get width(){return`width`in this.$node?this.$node.width:void 0}get height(){return`height`in this.$node?this.$node.height:void 0}children(){return _(this,`children`,()=>new Set(this.$node.children.map(e=>this.$viewModel.node(e))))}*ancestors(){let e=this.parent;for(;e;)yield e,e=e.parent}*siblings(){let e=this.parent?.children()??this.$viewModel.roots();for(let t of e)t.id!==this.id&&(yield t)}*incoming(e=`all`){for(let t of this.$node.inEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.target.id===this.id:case e===`to-descendants`&&n.target.id!==this.id:yield n;break}}}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoing(e=`all`){for(let t of this.$node.outEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.source.id===this.id:case e===`from-descendants`&&n.source.id!==this.id:yield n;break}}}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}isLayouted(){return`width`in this.$node&&`height`in this.$node}hasChildren(){return this.$node.children.length>0}hasParent(){return this.$node.parent!==null}hasElement(){return o(this.$node.modelRef)}hasDeployment(){return o(this.$node.deploymentRef)}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return de(this.$node)}isTagged(e){return this.tags.includes(e)}},K=class{Aux;#e;#t=new Set;#n=new Map;#r=new Map;#i=new Set;#a=new Set;#o=new Set;#s=new P.default(e=>new Set);#c;id;$model;title;folder;viewPath;constructor(e,t,n,r){this.$model=e,this.#e=n,this.id=n.id,this.folder=t,this.#c=r;for(let e of this.#e.nodes){let t=new G(this,Object.freeze(e));this.#n.set(e.id,t),e.parent||this.#t.add(t),e.deploymentRef&&this.#a.add(e.deploymentRef),e.modelRef&&this.#i.add(e.modelRef);for(let e of t.tags)this.#s.get(e).add(t)}for(let e of this.#e.edges){let t=new W(this,Object.freeze(e),this.node(e.source),this.node(e.target));for(let e of t.tags)this.#s.get(e).add(t);for(let t of e.relations)this.#o.add(t);this.#r.set(e.id,t)}this.title=n.title?Me(n.title):null,this.viewPath=n.title?H(n.title):n.id}get $styles(){return this.$model.$styles}get _type(){return this.#e[M]}get stage(){return this.#e[S]}get bounds(){if(`bounds`in this.#e)return this.#e.bounds;if(this.#c)return this.#c.bounds;throw Error(`View is not layouted`)}get titleOrId(){return this.title??this.viewOf?.title??this.id}get titleOrUntitled(){return this.title??`Untitled`}get breadcrumbs(){return _(this,`breadcrumbs`,()=>this.folder.isRoot?[this]:[...this.folder.breadcrumbs,this])}get description(){return A.memoize(this,`description`,this.#e.description)}get tags(){return this.#e.tags??[]}get links(){return this.#e.links??[]}get viewOf(){if(this.isElementView()){let e=this.#e.viewOf;return e?this.$model.element(e):null}return null}get mode(){return this.isDynamicView()?this.#e.variant??`diagram`:null}get includedTags(){return[...this.#s.keys()]}get $view(){if(!this.isLayouted()||`drifts`in this.#e)return this.#e;let e=this.#c;return e?_(this,`withDriftReasons`,()=>De(this.#e,e)):this.#e}get $layouted(){if(!this.isLayouted())throw Error(`View is not layouted`);return this.$manual??this.#e}get hasManualLayout(){return this.#c!==void 0}get hasLayoutDrifts(){if(!this.isLayouted())return!1;let e=this.$manual;return!!e?.drifts&&e.drifts.length>0}get $manual(){if(!this.isLayouted())return null;let e=this.#c;return e?this.#e._layout===`manual`?this.#e:_(this,`snapshotWithManualLayout`,()=>Ee(this.#e,e)):null}get projectId(){return this.$model.projectId}roots(){return this.#t.values()}*compounds(){for(let e of this.#n.values())e.hasChildren()&&(yield e)}node(e){let t=B(e);return y(this.#n.get(t),`Node ${t} not found in view ${this.#e.id}`)}findNode(e){return this.#n.get(B(e))??null}findNodeWithElement(e){let t=B(e);return this.#i.has(t)?xe(this.#n.values(),e=>e.hasElement()&&e.element.id===t)??null:null}nodes(){return this.#n.values()}edge(e){let t=B(e);return y(this.#r.get(t),`Edge ${t} not found in view ${this.#e.id}`)}findEdge(e){return this.#r.get(B(e))??null}edges(){return this.#r.values()}*edgesWithRelation(e){for(let t of this.#r.values())t.includesRelation(e)&&(yield t)}*elements(){for(let e of this.#n.values())e.hasElement()&&(yield e)}isTagged(e){return this.tags.includes(e)}includesElement(e){return this.#i.has(B(e))}includesDeployment(e){return this.#a.has(B(e))}includesRelation(e){return this.#o.has(B(e))}isComputed(){return this.#e[S]===`computed`}isLayouted(){return this.#e[S]===`layouted`}isDiagram(){return this.#e[S]===`layouted`}isElementView(){return this.#e[M]===`element`}isScopedElementView(){return this.#e._type===`element`&&o(this.#e.viewOf)}isDeploymentView(){return this.#e[M]===`deployment`}isDynamicView(){return this.#e[M]===`dynamic`}},q=class e{$model;path;title;isRoot;parentPath;defaultViewId;constructor(e,t,r){this.$model=e,this.path=t.join(`/`),this.isRoot=this.path===``,this.title=n(t),this.isRoot?this.parentPath=void 0:this.parentPath=t.slice(0,-1).join(`/`),this.defaultViewId=r}get defaultView(){return this.defaultViewId?this.$model.view(this.defaultViewId):null}get breadcrumbs(){return N(!this.isRoot,`Root view folder has no breadcrumbs`),_(this,`breadcrumbs`,()=>{let e=this.parent;return e?e.isRoot?[e,this]:[...e.breadcrumbs,this]:[this]})}get parent(){return N(!this.isRoot,`Root view folder has no parent`),r(this.parentPath)?null:this.$model.viewFolder(this.parentPath)}get children(){return this.$model.viewFolderItems(this.path)}get folders(){return _(this,`folders`,()=>{let t=[];for(let n of this.children)n instanceof e&&t.push(n);return t})}get views(){return _(this,`views`,()=>{let e=[];for(let t of this.children)t instanceof K&&e.push(t);return e})}},J=class e{Aux;_elements=new Map;_parents=new Map;_children=new P.default(()=>new Set);_rootElements=new Set;_relations=new Map;_incoming=new P.default(()=>new Set);_outgoing=new P.default(()=>new Set);_internal=new P.default(()=>new Set);_views=new Map;_rootViewFolder;_viewFolders=new Map;_viewFolderItems=new P.default(()=>new Set);_allTags=new P.default(()=>new Set);static fromParsed(t){return new e(t)}static create(t){return new e(t)}static fromDump(t){let{_stage:n=`layouted`,projectId:r=`unknown`,project:i,globals:a,imports:o,deployments:s,views:c,relations:l,elements:ee,specification:u}=t;return new e({[S]:n,projectId:r,project:i,globals:{predicates:a?.predicates??{},dynamicPredicates:a?.dynamicPredicates??{},styles:a?.styles??{}},imports:o??{},deployments:{elements:s?.elements??{},relations:s?.relations??{}},views:c??{},relations:l??{},elements:ee??{},specification:u})}deployment;$data;constructor(e){this.$data=e;for(let[,t]of l(e.elements)){let e=this.addElement(t);for(let t of e.tags)this._allTags.get(t).add(e)}for(let[t,n]of l(e.imports??{}))for(let e of ve(n)){let n=this.addImportedElement(t,e);for(let e of n.tags)this._allTags.get(e).add(n)}for(let t of p(e.relations)){let e=this.addRelation(t);for(let t of e.tags)this._allTags.get(t).add(e)}if(this.deployment=new Ne(this),Te(e,`computed`)||Te(e,`layouted`)){let t=me(`/`),n=u(p(e.views),c(e=>({view:e,path:H(e.title??e.id),folderPath:e.title&&je(e.title)||``})),f((e,n)=>t(e.folderPath,n.folderPath))),r=e=>{let t=this._viewFolders.get(e);if(!t){let r=ne(e,`/`);N(s(r,1),`View group path "${e}" must have at least one element`);let i;i=e===``?n.find(e=>e.view.id===`index`):n.find(t=>t.path===e),t=new q(this,r,i?.view.id),this._viewFolders.set(e,t)}return t};this._rootViewFolder=r(``);for(let{folderPath:e}of n)this._viewFolders.has(e)||ne(e,`/`).reduce((e,t)=>{let n=e.join(`/`),a=r(i(n)?t:n+`/`+t);return this._viewFolderItems.get(n).add(a),e.push(t),e},[]);for(let{view:t,folderPath:i}of n){let n=new K(this,r(i),t,e.manualLayouts?.[t.id]);this._viewFolderItems.get(i).add(n),this._views.set(t.id,n);for(let e of n.tags)this._allTags.get(e).add(n)}}else this._rootViewFolder=new q(this,[``],void 0),this._viewFolders.set(this._rootViewFolder.path,this._rootViewFolder)}get asParsed(){return this}get asComputed(){return this}get asLayouted(){return this}get $styles(){return _(this,`styles`,()=>ge.from(this.project.styles,this.specification.customColors))}isParsed(){return this.stage===`parsed`}isLayouted(){return this.stage===`layouted`}isComputed(){return this.stage===`computed`}get $model(){return this.$data}get stage(){return this.$data[S]}get projectId(){return this.$data.projectId??`default`}get project(){return this.$data.project??_(this,Symbol.for(`project`),()=>({id:this.projectId,styles:{},manualLayouts:{}}))}get specification(){return this.$data.specification}get globals(){return _(this,Symbol.for(`globals`),()=>({predicates:{...this.$data.globals?.predicates},dynamicPredicates:{...this.$data.globals?.dynamicPredicates},styles:{...this.$data.globals?.styles}}))}element(e){if(e instanceof F)return e;let t=B(e);return y(this._elements.get(t),`Element ${t} not found`)}findElement(e){return this._elements.get(B(e))??null}roots(){return this._rootElements.values()}elements(){return this._elements.values()}relationships(){return this._relations.values()}relationship(e,t){if(t===`deployment`)return this.deployment.relationship(e);let n=B(e),r=this._relations.get(n)??null;return r||t===`model`?y(r,`Model relation ${n} not found`):y(this.deployment.findRelationship(n),`No model/deployment relation ${n} not found`)}findRelationship(e,t){if(t===`deployment`)return this.deployment.findRelationship(e);let n=this._relations.get(B(e))??null;return n||t===`model`?n:this.deployment.findRelationship(e)}views(){return this._views.values()}view(e){let t=B(e);return y(this._views.get(t),`View ${t} not found`)}findView(e){return this._views.get(e)??null}findManualLayout(e){return`manualLayouts`in this.$data?this.$data.manualLayouts?.[e]??null:null}viewFolder(e){return y(this._viewFolders.get(e),`View folder ${e} not found`)}get rootViewFolder(){return this._rootViewFolder}get hasViewFolders(){return this._viewFolders.size>1}viewFolderItems(e){return N(this._viewFolders.has(e),`View folder ${e} not found`),this._viewFolderItems.get(e)}parent(e){let t=B(e);return this._parents.get(t)||null}children(e){let t=B(e);return this._children.get(t)}*siblings(e){let t=B(e),n=this._parents.get(t),r=n?this._children.get(n.id).values():this.roots();for(let e of r)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this._parents.get(t);)yield n,t=n.id}*descendants(e){for(let t of this.children(e))yield t,yield*this.descendants(t.id)}*incoming(e,t=`all`){let n=B(e);for(let e of this._incoming.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this._outgoing.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}get tags(){return _(this,`tags`,()=>f([...this._allTags.keys()],he))}get tagsSortedByUsage(){return _(this,`tagsSortedByUsage`,()=>u([...this._allTags.entries()],c(([e,t])=>({tag:e,count:t.size,tagged:t})),f((e,t)=>he(e.tag,t.tag)),ee([te(`count`),`desc`])))}findByTag(e,t){return ce(this._allTags.get(e),e=>t===`elements`?e instanceof F:t===`views`?e instanceof K:t===`relationships`?e instanceof U:!0)}*elementsOfKind(e){for(let t of this._elements.values())t.kind===e&&(yield t)}*elementsWhere(e){let t=le(e);for(let e of this._elements.values())t(e)&&(yield e)}*relationshipsWhere(e){let t=le(e);for(let e of this._relations.values())t(e)&&(yield e)}addElement(e){if(this._elements.has(e.id))throw Error(`Element ${e.id} already exists`);let t=new F(this,Object.freeze(e));this._elements.set(t.id,t);let n=w(t.id);return n?(N(this._elements.has(n),`Parent ${n} of ${t.id} not found`),this._parents.set(t.id,this.element(n)),this._children.get(n).add(t)):this._rootElements.add(t),t}addImportedElement(e,t){N(!Ce(t.id),`Imported element already has global FQN`);let n=re(e,t.id);if(this._elements.has(n))throw Error(`Element ${n} already exists`);let r=new F(this,Object.freeze({...t,id:n}));this._elements.set(r.id,r);let i=w(r.id);for(;i;){if(i.includes(`.`)&&this._elements.has(i))return this._parents.set(r.id,this.element(i)),this._children.get(i).add(r),r;i=w(i)}return this._rootElements.add(r),r}addRelation(e){if(this._relations.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new U(this,Object.freeze(e)),{source:n,target:r}=t;this._relations.set(t.id,t),this._incoming.get(r.id).add(t),this._outgoing.get(n.id).add(t);let i=D(n.id,r.id);if(i)for(let e of[i,...j(i)])this._internal.get(e).add(t);for(let e of j(n.id)){if(e===i)break;this._outgoing.get(e).add(t)}for(let e of j(r.id)){if(e===i)break;this._incoming.get(e).add(t)}return t}};(function(e){e.EMPTY=J.create({_stage:`computed`,projectId:`default`,project:{id:`default`},specification:{elements:{},relationships:{},deployments:{},tags:{}},globals:{predicates:{},dynamicPredicates:{},styles:{}},deployments:{elements:{},relations:{}},elements:{},relations:{},views:{},imports:{}})})(J||={});let Pe;(function(e){e.isInside=e=>t=>k(e,t.source.id)&&k(e,t.target.id);let t=e.isDirectedBetween=(e,t)=>n=>(n.source.id===e||k(e,n.source.id))&&(n.target.id===t||k(t,n.target.id));e.isAnyBetween=(e,n)=>{let r=t(e,n),i=t(n,e);return e=>r(e)||i(e)};let n=e.isIncoming=e=>t=>(t.target.id===e||k(e,t.target.id))&&!k(e,t.source.id),r=e.isOutgoing=e=>t=>(t.source.id===e||k(e,t.source.id))&&!k(e,t.target.id);e.isAnyInOut=e=>{let t=n(e),i=r(e);return e=>t(e)||i(e)}})(Pe||={});const Y=Symbol.for(`nodejs.util.inspect.custom`);var Fe=class e{id;constructor(e,t,n){this.source=e,this.target=t,this.relations=n,this.id=we(`deployment:${e.id}:${t.id}`)}get expression(){return`${this.source.id} -> ${this.target.id}`}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target),this._boundary}nonEmpty(){return this.relations.nonEmpty}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){let e=[...this.relations.model].map(e=>` `+e.expression);e.length?e.unshift(` model:`):e.unshift(` model: []`);let t=[...this.relations.deployment].map(e=>` `+e.expression);return t.length?t.unshift(` deployment:`):t.unshift(` deployment: []`),[this.expression,...e,...t].join(`
3
+ `)}hasDirectDeploymentRelation(){for(let e of this.relations.deployment)if(e.source.id===this.source.id||e.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(t){return Array.isArray(t)?t.reduce((e,t)=>e.mergeWith(t),this):(N(this.source.id===t.source.id,`Cannot merge connections with different sources`),N(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,this.relations.union(t.relations)))}difference(t){return new e(this.source,this.target,this.relations.difference(t.relations))}intersect(t){return new e(this.source,this.target,this.relations.intersect(t.relations))}equals(t){return N(t instanceof e,`Other should ne DeploymentConnectionModel`),this.id===t.id&&this.source.id===t.source.id&&this.target.id===t.target.id&&oe(this.relations.model,t.relations.model)&&oe(this.relations.deployment,t.relations.deployment)}update(t){return t&&={model:this.relations.model,deployment:this.relations.deployment,...t},new e(this.source,this.target,t?new z(t.model??new Set,t.deployment??new Set):this.relations)}};function X(e,t){if(!t){let t=e;return e=>X(e,t)}let n=e.source===t.source,r=e.target===t.target;if(n&&r)return!1;let i=k(t.source.id,e.source.id),a=k(t.target.id,e.target.id);return i&&a||n&&a||r&&i}function Ie(e,t){let n=t;for(let t of e)X(t,n)&&(n=t);return n===t?null:n}function Le(e){let t=[],n=e.slice(),r;for(;r=n.shift();){let e;for(;e=Ie(n,r);){let r=n.indexOf(e);t.push(n.splice(r,1)[0])}t.push(r)}return t}function Re(e){return e.boundary?.id?`.${e.boundary.id}`:``}function ze(e,t){if(!e||ie(e)){let t=e??`asc`;return e=>Be(e,t)}return Be(e,t??`asc`)}function Be(e,t){return u(e,c(e=>({id:Re(e),conn:e})),be(t),c(e=>e.conn))}function Ve(e,t){return e.filter(e=>X(t,e))}function He(e,t){return e.filter(X(t))}function Ue(e){let t=new Map;for(let n of e){let e=t.get(n.id);e?t.set(n.id,n.mergeWith(e)):t.set(n.id,n)}return[...t.values()]}function We(e,t){let n=new Map([...t].map(e=>[e.id,e]));return[...e].reduce((e,t)=>{let r=n.get(t.id);if(!r)return e.push(t),e;let i=t.difference(r);return i.nonEmpty()&&e.push(i),e},[])}function Z(e,t){return t?e.source===t.source&&e.target===t.target:t=>e.source===t.source&&e.target===t.target}function Ge(e,t){return t?e.source===t.source:t=>e.source===t.source}function Ke(e,t){return t?e.target===t.target:t=>e.target===t.target}function qe(e,t){if(!t){let t=e;return e=>qe(e,t)}let n=e;return C(n.source,t)&&!C(n.target,t)}function Je(e,t){if(!t){let t=e;return e=>Je(e,t)}let n=e;return C(n.target,t)&&!C(n.source,t)}function Ye(e,t){if(!t){let t=e;return e=>Ye(e,t)}let n=e;return C(n.source,t)!==C(n.target,t)}var Q=class e{id;constructor(e,t,n=new Set){this.source=e,this.target=t,this.relations=n,this.id=we(`model:${e.id}:${t.id}`)}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target)}get expression(){return`${this.source.id} -> ${this.target.id}`}get isDirect(){return this.nonEmpty()&&!this.isImplicit}get isImplicit(){return this.nonEmpty()&&ae(this.relations,a(Z(this)))}get directRelations(){return new Set(ce(this.relations,Z(this)))}nonEmpty(){return this.relations.size>0}mergeWith(t){return N(this.source.id===t.source.id,`Cannot merge connections with different sources`),N(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,T(this.relations,t.relations))}difference(t){return new e(this.source,this.target,g(this.relations,t.relations))}intersect(t){return N(t instanceof e,`Cannot intersect connection with different type`),new e(this.source,this.target,E(this.relations,t.relations))}equals(t){N(t instanceof e,`Cannot merge connection with different type`);let n=t;return this.id===n.id&&this.source.id===n.source.id&&this.target.id===n.target.id&&oe(this.relations,n.relations)}update(t){return new e(this.source,this.target,t)}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){return[this.expression,this.relations.size?` relations:`:` relations: [ ]`,...[...this.relations].map(e=>` `+e.expression)].join(`
4
+ `)}reversed(){return new e(this.target,this.source)}},Xe=e({findConnection:()=>$,findConnectionsBetween:()=>Ze,findConnectionsWithin:()=>Qe});function $(e,t,n=`directed`){if(e===t||_e(e,t))return[];let r=e.allOutgoing.intersect(t.allIncoming),i=r.nonEmpty?[new Fe(e,t,r)]:[];return n===`directed`?i:[...i,...$(t,e,`directed`)]}function Ze(e,t,n=`both`){if(e.allIncoming.isEmpty&&e.allOutgoing.isEmpty)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of $(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function Qe(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...Ze(t,r.slice(n+1),`both`)),e),[])}var $e=e({findConnection:()=>et,findConnectionsBetween:()=>tt,findConnectionsWithin:()=>nt});function et(e,t,n=`directed`){if(e===t||_e(e,t))return[];let r=E(e.allOutgoing,t.allIncoming),i=r.size>0?new Q(e,t,r):null;if(n===`directed`)return i?[i]:[];let a=E(e.allIncoming,t.allOutgoing),o=a.size>0?new Q(t,e,a):null;return i&&o?[i,o]:i?[i]:o?[o]:[]}function tt(e,t,n=`both`){if(e.allIncoming.size===0&&e.allOutgoing.size===0)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of et(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function nt(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...tt(t,r.slice(n+1),`both`)),e),[])}function rt(e){return e instanceof I}function it(e){return e instanceof L}function at(e){return rt(e)||it(e)}function ot(e){return e instanceof ke}function st(e){return e instanceof R}function ct(e){return e instanceof U}function lt(e){return e instanceof F}function ut(e){return e instanceof K}function dt(e){return e instanceof G}function ft(e){return e instanceof W}export{Fe as A,Ae as B,Ye as C,Ue as D,qe as E,K as F,I as G,je as H,G as I,F as J,R as K,W as L,Pe as M,J as N,ze as O,q as P,U as R,Ke as S,X as T,H as U,Me as V,L as W,Ve as _,ft as a,Ge as b,ot as c,et as d,tt as f,We as g,Q as h,st as i,Y as j,Le as k,dt as l,Xe as m,at as n,lt as o,$e as p,z as q,rt as r,ut as s,it as t,ct as u,Ie as v,Je as w,Z as x,He as y,Ne as z};
@@ -1 +1 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));export{s as n,l as r,o as t};
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));export{s as n,l as r,o as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime.mjs";import{t}from"./libs/defu.mjs";import{B as n,I as r,M as i,N as a,O as o,T as s,V as c,et as l,it as ee,k as u,rt as te,t as ne,x as re}from"./libs/remeda.mjs";import{Q as d,et as f,h as p,i as ie,n as ae,t as oe}from"./utils.mjs";import{i as m,n as se,t as ce}from"./libs/mnemonist.mjs";import{a as le,c as ue,d as de,f as fe,h as pe,i as me,l as he,m as ge,n as _e,o as ve,p as ye,r as be,s as xe,t as Se,u as Ce}from"./libs/@radix-ui/colors.mjs";import{n as h,t as we}from"./libs/@mantine/colors-generator.mjs";function Te(e){return re(e,e=>e===void 0)}function Ee(e){return e.summary??e.description}function De(e){return e.description??e.summary}function Oe(e,t){return e[g]===t}const g=`_stage`,ke=`_type`,Ae=`_layout`;var je=e({DeploymentFqn:()=>w,EdgeId:()=>j,Fqn:()=>x,GlobalFqn:()=>D,GroupElementKind:()=>S,MarkdownOrString:()=>v,NodeId:()=>A,NoneIcon:()=>b,ProjectId:()=>_,RelationId:()=>E,StepEdgeKind:()=>Me,ViewId:()=>T,extractStep:()=>P,flattenMarkdownOrString:()=>y,isGlobalFqn:()=>O,isGroupElementKind:()=>C,isStepEdgeId:()=>N,splitGlobalFqn:()=>k,stepEdgeId:()=>M});function _(e){return e}function v(e){return typeof e==`string`?{txt:e}:e}function y(e){if(r(e))return null;let t=u(e)?e:e.txt??e.md;return o(t?.trim())?t:null}const b=`none`;function x(e,t){return t?t+`.`+e:e}const S=`@group`;function C(e){return e.kind===S}function w(e,t){return t?t+`.`+e:e}function T(e){return e}function E(e){return e}function D(e,t){return d(typeof e==`string`&&e!=``),`@`+e+`.`+t}function O(e){return e.startsWith(`@`)}function k(e){if(!e.startsWith(`@`))return[null,e];let t=e.indexOf(`.`);if(t<2)throw Error(`Invalid global FQN`);return[e.slice(1,t),e.slice(t+1)]}function A(e){return e}function j(e){return e}function M(e,t){let n=`step-${String(e).padStart(2,`0`)}`;return t?`${n}.${t}`:n}const Me=`@step`;function N(e){return e.startsWith(`step-`)}function P(e){if(!N(e))throw Error(`Invalid step edge id: ${e}`);return parseFloat(e.slice(5))}let F;(function(e){function t(e){return`model`in e&&!(`project`in e)}e.isElementRef=t;function n(e){return`project`in e&&`model`in e}e.isImportRef=n;function r(e){if(u(e))throw Error(`Expected FqnRef, got: "${e}"`);if(n(e))return D(e.project,e.model);if(t(e))return e.model;throw Error(`Expected FqnRef.ModelRef or FqnRef.ImportRef`)}e.flatten=r;function i(e){return t(e)||n(e)}e.isModelRef=i;function a(e){return`deployment`in e&&`element`in e}e.isInsideInstanceRef=a;function o(e){return`deployment`in e&&!(`element`in e)}e.isDeploymentElementRef=o;function s(e){return o(e)||a(e)}e.isDeploymentRef=s})(F||={});let I;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&F.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`ref`in e&&F.isDeploymentRef(e.ref)}e.isDeploymentRef=r;function i(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=i;function a(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=a;function o(e){return`where`in e&&c(e.where.expr)}e.isWhere=o;function s(e){return`custom`in e&&(c(e.custom.expr)||o(e.custom.expr))}e.isCustom=s;function c(e){return t(e)||n(e)||r(e)||i(e)||a(e)}e.is=c;function l(e){return s(e)&&(e=e.custom.expr),o(e)&&(e=e.where.expr),e}e.unwrap=l})(I||={});let L;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(L||={});let R;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return L.isWhere(e)}e.isRelationWhere=n;function r(e){return I.isWhere(e)}e.isFqnExprWhere=r;function i(e){return I.is(e)||I.isWhere(e)||I.isCustom(e)}e.isFqnExpr=i;function a(e){return L.is(e)||L.isWhere(e)||L.isCustom(e)}e.isRelation=a})(R||={});let z;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&F.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=r;function i(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=i;function a(e){return`where`in e&&s(e.where.expr)}e.isWhere=a;function o(e){return`custom`in e&&(s(e.custom.expr)||a(e.custom.expr))}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.custom.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(z||={});let B;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(B||={});let V;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return B.isWhere(e)}e.isRelationWhere=n;function r(e){return z.isWhere(e)}e.isFqnExprWhere=r;function i(e){return z.is(e)||z.isWhere(e)||z.isCustom(e)}e.isFqnExpr=i;function a(e){return B.is(e)||B.isWhere(e)||B.isCustom(e)}e.isRelationExpr=a})(V||={});function Ne(e){return o(e.kind)&&!o(e.element)}function Pe(e){return o(e.element)&&!o(e.kind)}const H={fill:`#3b82f6`,stroke:`#2563eb`,hiContrast:`#eff6ff`,loContrast:`#bfdbfe`},U={fill:`#0284c7`,stroke:`#0369a1`,hiContrast:`#f0f9ff`,loContrast:`#B6ECF7`},W={fill:`#64748b`,stroke:`#475569`,hiContrast:`#f8fafc`,loContrast:`#cbd5e1`},Fe={primary:H,blue:H,secondary:U,sky:U,muted:W,slate:W,gray:{fill:`#737373`,stroke:`#525252`,hiContrast:`#fafafa`,loContrast:`#d4d4d4`},red:{fill:`#AC4D39`,stroke:`#853A2D`,hiContrast:`#FBD3CB`,loContrast:`#f5b2a3`},green:{fill:`#428a4f`,stroke:`#2d5d39`,hiContrast:`#f8fafc`,loContrast:`#c2f0c2`},amber:{fill:`#A35829`,stroke:`#7E451D`,hiContrast:`#FFE0C2`,loContrast:`#f9b27c`},indigo:{fill:`#6366f1`,stroke:`#4f46e5`,hiContrast:`#eef2ff`,loContrast:`#c7d2fe`}},Ie={line:`#8D8D8D`,labelBg:`#18191B`,label:`#C9C9C9`},G={line:`#64748b`,labelBg:`#0f172a`,label:`#cbd5e1`},K={line:`#3b82f6`,labelBg:`#172554`,label:`#60a5fa`},q={line:`#0ea5e9`,labelBg:`#082f49`,label:`#38bdf8`},Le={amber:{line:`#b45309`,labelBg:`#78350f`,label:`#FFE0C2`},blue:K,gray:Ie,green:{line:`#15803d`,labelBg:`#052e16`,label:`#22c55e`},indigo:{line:`#6366f1`,labelBg:`#1e1b4b`,label:`#818cf8`},muted:G,primary:K,red:{line:`#AC4D39`,labelBg:`#b91c1c`,label:`#f5b2a3`},secondary:q,sky:q,slate:G},Re={sizes:{xs:{width:180,height:100},sm:{width:240,height:135},md:{width:320,height:180},lg:{width:420,height:234},xl:{width:520,height:290}},spacing:{xs:8,sm:10,md:16,lg:24,xl:32},textSizes:{xs:13.33,sm:16,md:19.2,lg:23.04,xl:27.65},iconSizes:{xs:24,sm:36,md:60,lg:82,xl:90}},ze=[`xs`,`sm`,`md`,`lg`,`xl`],Be=[`left`,`right`,`top`,`bottom`],Ve=[`solid`,`dashed`,`dotted`,`none`],He=[`rectangle`,`person`,`browser`,`mobile`,`cylinder`,`storage`,`queue`,`bucket`,`document`,`component`],J=[`amber`,`blue`,`gray`,`slate`,`green`,`indigo`,`muted`,`primary`,`red`,`secondary`,`sky`],Ue=[`tomato`,`grass`,`blue`,`ruby`,`orange`,`indigo`,`pink`,`teal`,`purple`,`amber`,`crimson`,`red`,`lime`,`yellow`,`violet`],Y={tomato:ye.tomato9,grass:me.grass9,blue:_e.blue9,ruby:de.ruby9,orange:xe.orange9,indigo:le.indigo9,pink:ue.pink9,teal:fe.teal9,purple:he.purple9,amber:Se.amber9,crimson:be.crimson9,red:Ce.red9,lime:ve.lime9,yellow:pe.yellow9,violet:ge.violet9};function We(e){return e in Y}const Ge={colors:J.reduce((e,t)=>(e[t]={elements:Fe[t],relationships:Le[t]},e),{}),...Re};function Ke(e){d(h.valid(e),`Invalid color: ${e}`);let t=we(e),n=t[6],r=qe(n);return{elements:{fill:n,stroke:t[7],...r},relationships:{line:t[4],label:t[3],labelBg:t[9]}}}function qe(e){let t=h(e),n=t.brighten(2),r=t.darken(2),i,a,o,s;do i=n,a=r,n=n.brighten(1),r=r.darken(1),o=h.contrastAPCA(t,n),s=h.contrastAPCA(t,r);while(Math.abs(o)<60&&Math.abs(s)<60&&(!c(n,i)||!c(r,a)));return Math.abs(o)>Math.abs(s)?{hiContrast:n.brighten(.4).hex(),loContrast:n.hex()}:{hiContrast:r.darken(.4).hex(),loContrast:r.hex()}}function Je(e,t){let n=t??6,r=h(e.fill),i=h(e.stroke),a=r.luminance()>.8,o=l(ne(h.scale(a?[r.darken(.02).desaturate(.05),r.darken(.1).desaturate(.1)]:[r.shade(.12,`lch`).desaturate(.05),r.shade(.35,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null),h.scale(a?[i.darken(.04).desaturate(.05),i.darken(.12).desaturate(.1)]:[i.shade(.15,`lch`).desaturate(.08),i.shade(.4,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null)),s(([t,n])=>({...e,fill:t.hex(),stroke:n.hex()})));return d(o.length===n,`Expected ${n} colors, got ${o.length}`),o}const Ye={color:`primary`,size:`md`,opacity:15,shape:`rectangle`,group:{opacity:15,border:`dashed`},relationship:{color:`gray`,line:`dashed`,arrow:`normal`}},Xe=Ge,X={theme:Xe,defaults:Ye};var Ze=class e{theme;defaults;static DEFAULT=new e(X);static from(n,i){if(!n&&!i)return this.DEFAULT;let{customCss:a,theme:o,defaults:s}={...n},l=t({theme:o},{defaults:{...s}},{theme:{colors:{...i}}},X);return r(a?.content)&&c(l,X)?this.DEFAULT:new e(l,a)}constructor(e,t){this.config=e,this.customCss=t,this.theme=e.theme,this.defaults=e.defaults}get fingerprint(){return p(this,`fingerprint`,()=>ie({config:this.config,customCss:this.customCss}))}get elementColors(){return this.theme.colors[this.defaults.color].elements}get relationshipColors(){return this.theme.colors[this.defaults.relationship.color].relationships}get groupColors(){let e=this.defaults.group?.color;if(!e)return this.elementColors;if(!this.isThemeColor(e))throw Error(`Default group color not found in theme: ${e}`);return p(this,`defaultGroup`,()=>({...this.elementColors,...this.theme.colors[e].elements}))}isDefaultColor(e){return e===this.defaults.color}colors(e){return this.computeFrom(e??this.defaults.color)}compoundColorsCache=new se.default(e=>new ce.default(t=>Je(e,t)));colorsForCompounds(e,t){return this.compoundColorsCache.get(e).get(t??6)}fontSize(e){return e??=this.defaults.text??this.defaults.size,this.theme.textSizes[e]}padding(e){return e??=this.defaults.padding??this.defaults.size,this.theme.spacing[e]}iconSize(e){return e??=this.defaults.size,this.theme.iconSizes[e]}isThemeColor(e){return e in this.theme.colors}nodeSizes(e){let t=Qe(e,this.defaults.size);return{sizes:t,values:{sizes:this.theme.sizes[t.size],padding:this.padding(t.padding),textSize:this.fontSize(t.textSize),iconSize:this.iconSize(t.iconSize)}}}computeFrom(e){if(this.isThemeColor(e))return this.theme.colors[e];if(!h.valid(e))throw Error(`Invalid color value: "${e}" (not a theme color and not a valid CSS color)`);return Ke(e)}equals(e){return e===this?!0:this.constructor===e.constructor?this.fingerprint===e.fingerprint:!1}tagColor(e){return this.isThemeColor(e)?this.theme.colors[e].elements:We(e)?this.computeFrom(Y[e]).elements:this.computeFrom(e).elements}};function Qe({size:e,padding:t,textSize:n,iconSize:r,...i},a=X.defaults.size){return e??=a,n??=e,t??=e,r??=e,{...i,size:e,padding:t,textSize:n,iconSize:r}}function $e(e){let t=typeof e==`string`?e:e.color;return t.startsWith(`#`)||t.startsWith(`rgb`)}function et(e){return`tag`in e}function tt(e){return`kind`in e}function nt(e){return`metadata`in e}function rt(e){return`participant`in e}function it(e){return`not`in e}function at(e){return`and`in e}function Z(e){return`or`in e}function Q(e){switch(!0){case rt(e):{let t=e.participant;return ot(t,Q(e.operator))}case et(e):{if(u(e.tag)||`eq`in e.tag){let t=u(e.tag)?e.tag:e.tag.eq;return e=>Array.isArray(e.tags)&&e.tags.includes(t)}let t=e.tag.neq;return e=>!Array.isArray(e.tags)||!e.tags.includes(t)}case tt(e):{if(u(e.kind)||`eq`in e.kind){let t=u(e.kind)?e.kind:e.kind.eq;return e=>e.kind===t}let t=e.kind.neq;return e=>i(e.kind)||e.kind!==t}case nt(e):{let{key:t,value:n}=e.metadata;if(n===void 0)return e=>e.metadata!=null&&t in e.metadata&&e.metadata[t]!=null;if(u(n)||`eq`in n){let e=u(n)?n:n.eq;return n=>{if(!n.metadata)return!1;let r=n.metadata[t];return Array.isArray(r)?r.includes(e):r===e}}let r=n.neq;return e=>{if(!e.metadata)return!0;let n=e.metadata[t];return n==null?!0:Array.isArray(n)?!n.includes(r):n!==r}}case it(e):return a(Q(e.not));case at(e):return ee(e.and.map(Q));case Z(e):return te(e.or.map(Q));default:f(e)}}function ot(e,t){return n=>{if(!n.source||!n.target)return!1;switch(e){case`source`:return t(n.source);case`target`:return t(n.target)}}}function st(e){return`include`in e||`exclude`in e}function ct(e){return`targets`in e&&`style`in e}function lt(e){return e._stage===`computed`}function ut(e){return e._stage===`layouted`}function $(e){return e._type===`element`}function dt(e){return $(e)&&o(e.viewOf)}function ft(e){return $(e)&&o(e.extends)}function pt(e){return e._type===`deployment`}function mt(e){return e._type===`dynamic`}function ht(e){return`styleId`in e}function gt(e){return`predicateId`in e}function _t(e){return e===`TB`||e===`BT`||e===`LR`||e===`RL`}function vt(e){return`direction`in e}function yt(e){return N(e)&&e.includes(`.`)?e.slice(0,e.indexOf(`.`)+1):null}function bt(e){return!!e&&!(`__series`in e||`__parallel`in e)}function xt(e){return!!e&&`__parallel`in e&&n(e.__parallel)}function St(e){return!!e&&`__series`in e&&n(e.__series)}function Ct(e){return`title`in e&&`groupRules`in e&&Array.isArray(e.groupRules)}function wt(e){return`rank`in e&&Array.isArray(e.targets)}const Tt=Symbol.for(`text`),Et=Symbol.for(`html`);var Dt=class e{static mdcache=new m.default(500);static txtcache=new m.default(500);static getOrCreateFromText(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.txtcache.get(t);return n||(n=new e({txt:t}),e.txtcache.set(t,n),n)}static getOrCreateFromMarkdown(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.mdcache.get(t);return n||(n=new e({md:t}),e.mdcache.set(t,n),n)}static memoize(t,n,r){return p(t,n,()=>e.from(r))}static from(t){return t==null||t===e.EMPTY?e.EMPTY:t instanceof e?t:typeof t==`string`?this.getOrCreateFromText(t):`isEmpty`in t&&t.isEmpty?e.EMPTY:`md`in t?this.getOrCreateFromMarkdown(t.md):this.getOrCreateFromText(t.txt)}static EMPTY=new class extends e{isEmpty=!0;nonEmpty=!1;isMarkdown=!1;$source=null;constructor(){super({txt:``})}get text(){return null}get md(){return null}get html(){return null}};$source;isEmpty;nonEmpty;isMarkdown;constructor(e){this.isMarkdown=!1,typeof e==`string`?(this.$source={txt:e},this.isEmpty=e.trim()===``):(this.$source=e,this.isEmpty=!0,`md`in e?(this.isEmpty=e.md===``,this.isMarkdown=!0):this.isEmpty=e.txt===``),this.nonEmpty=!this.isEmpty}get text(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:p(this,Tt,()=>oe(e.md))}get md(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;if(`md`in e)return e.md;if(`txt`in e)return e.txt;f(e)}get html(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:p(this,Et,()=>ae(e.md))}equals(t){return this===t?!0:t instanceof e?this.isEmpty&&t.isEmpty?!0:this.isEmpty!==t.isEmpty||this.isMarkdown!==t.isMarkdown?!1:this.isMarkdown?this.$source?.md===t.$source?.md:this.$source?.txt===t.$source?.txt:!1}};export{D as $,Qe as A,J as B,nt as C,et as D,rt as E,Ve as F,B as G,Ne as H,Ue as I,L as J,R as K,He as L,Xe as M,Ye as N,Q as O,Ke as P,x as Q,Be as R,tt as S,Te as St,Z as T,V as U,Pe as V,z as W,w as X,F as Y,j as Z,ft as _,g as _t,bt as a,E as at,ct as b,De as bt,_t as c,P as ct,ht as d,C as dt,S as et,lt as f,N as ft,$ as g,Ae as gt,mt as h,M as ht,yt as i,_ as it,Ze as j,$e as k,vt as l,y as lt,ut as m,k as mt,Ct as n,A as nt,xt as o,Me as ot,pt as p,je as pt,I as q,wt as r,b as rt,St as s,T as st,Dt as t,v as tt,gt as u,O as ut,dt as v,ke as vt,it as w,at as x,Ee as xt,st as y,Oe as yt,ze as z};
1
+ import{n as e,r as t}from"./rolldown-runtime.mjs";import{t as n}from"./libs/defu.mjs";import{B as r,F as i,I as a,M as o,N as s,O as c,P as ee,Q as l,R as u,T as te,V as d,a as ne,et as re,f as ie,it as ae,k as f,l as oe,rt as se,t as ce,x as le}from"./libs/remeda.mjs";import{i as ue,n as de,s as fe,t as pe}from"./libs/mnemonist.mjs";import{t as me}from"./libs/natural-compare-lite.mjs";import{t as he}from"./libs/ohash.mjs";import{n as ge}from"./libs/hast-util-sanitize.mjs";import{t as _e}from"./libs/rehype-sanitize.mjs";import{t as ve}from"./libs/rehype-stringify.mjs";import{l as ye,t as be}from"./libs/mdast-util-from-markdown.mjs";import{t as xe}from"./libs/remark-gfm.mjs";import{t as Se}from"./libs/remark-github-blockquote-alert.mjs";import{t as Ce}from"./libs/remark-parse.mjs";import{t as we}from"./libs/remark-rehype.mjs";import{t as Te}from"./libs/unified.mjs";import{a as Ee,c as De,d as Oe,f as ke,h as Ae,i as je,l as Me,m as Ne,n as Pe,o as Fe,p as Ie,r as Le,s as Re,t as ze,u as Be}from"./libs/@radix-ui/colors.mjs";import{t as p}from"./libs/chroma-js.mjs";function Ve(e){return le(e,e=>e===void 0)}function He(e){return e.summary??e.description}function Ue(e){return e.description??e.summary}function We(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&typeof e[1]==`number`}function Ge(e){return We(e)?{x:e[0],y:e[1]}:[e.x,e.y]}function Ke(e,t){if(e===void 0||e==null){let n=typeof t==`function`?t():t;throw Error(n??`Expected defined value, but received ${e}`)}return e}function m(e,t){if(!e)throw Error(t??`Invariant failed`)}function h(e){throw Error(`NonExhaustive value: ${e}`)}const qe={center({x:e,y:t,width:n,height:r}){return{x:e+n/2,y:t+r/2}},toPoints({x:e,y:t,width:n,height:r}){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r}]},fromPoints(e){let{x1:t,y1:n,x2:r,y2:i}=g.fromPoints(e);return{x:t,y:n,width:r-t,height:i-n}},merge(...e){if(m(l(e,1),`No boxes provided`),e.length===1)return e[0];let t=e[0].x,n=e[0].y,r=e[0].x+e[0].width,i=e[0].y+e[0].height;for(let a=1;a<e.length;a++){let o=e[a];t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x+o.width),i=Math.max(i,o.y+o.height)}return{x:Math.floor(t),y:Math.floor(n),width:Math.round(r-t),height:Math.round(i-n)}},fromRectBox(e){return{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),width:Math.abs(e.x2-e.x1),height:Math.abs(e.y2-e.y1)}},toRectBox(e){return{x1:e.x,y1:e.y,x2:e.x+e.width,y2:e.y+e.height}},expand(e,t){return t===0?e:{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}},shrink(e,t){return t===0?e:{x:e.x+t,y:e.y+t,width:e.width-t*2,height:e.height-t*2}},includes(e,t){return e===t?!0:e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height}},g={center({x1:e,y1:t,x2:n,y2:r}){return{x:(e+n)/2,y:(t+r)/2}},fromPoints(e){m(e.length>0,`At least one point is required`);let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let[a,o]of e)t=Math.min(t,a),n=Math.min(n,o),r=Math.max(r,a),i=Math.max(i,o);return{x1:t,y1:n,x2:r,y2:i}},merge(...e){m(e.length>0,`No boxes provided`);let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x1),n=Math.min(n,a.y1),r=Math.max(r,a.x2),i=Math.max(i,a.y2);return{x1:t,y1:n,x2:r,y2:i}},toBBox(e){return{x:e.x1,y:e.y1,width:e.x2-e.x1,height:e.y2-e.y1}},includes(e,t){return e===t?!0:e.x1<=t.x1&&e.y1<=t.y1&&e.x2>=t.x2&&e.y2>=t.y2}};function Je(e,t,n){return e.length===0||t.length===0?[]:(n??=Object.is,re(ce(e,t),ne(([e,t])=>n(e,t)),te(([e,t])=>e)))}var _=t(me(),1);function v(e,t){return e===t?0:f(e)?f(t)?(0,_.default)(e,t):1:f(t)?-1:0}function y(e){return oe(e,v)}function Ye(...e){return e.length===0?y:y(e[0])}function Xe(e=`.`,t=!1){return(n,r)=>{if(n===r)return 0;if(!n)return-1;if(!r)return 1;let i=n.split(e),a=r.split(e),o=Math.min(i.length,a.length);for(let e=0;e<o;e++){let t=i[e],n=a[e],r=(0,_.default)(t,n);if(r!==0)return r}let s=i.length-a.length;return t?-1*s:s}}function Ze(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(0,t):null}function Qe(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t+1):e}const b=e=>E(e)?e:e.id;function x(e,t){let n=b(e);return t?b(t).startsWith(n+`.`):e=>{let t=b(e);return n.startsWith(t+`.`)}}function S(e,t){if(!t)return t=>S(e,t);let n=b(e),r=b(t);return n===r||r.startsWith(n+`.`)||n.startsWith(r+`.`)}function $e(e,t){return t?x(t,e):t=>x(e,t)}function C(e){return(E(e)?e:e.id).split(`.`).length}function et(e,t){let n=E(e)?e:e.id,r=E(t)?t:t.id;if(n===r)return 0;let i=C(n),a=C(r);if(S(n,r))return Math.abs(i-a);let o=w(n,r),s=o?C(o):0;return i+a-(2*s+1)}function w(e,t){let n=e.split(`.`);if(n.length<2)return null;let r=t.split(`.`);if(r.length<2)return null;let i=[];for(let e=0;e<Math.min(n.length,r.length)-1&&n[e]===r[e];e++)i.push(n[e]);return i.length===0?null:i.join(`.`)}function tt(e){let t=e.split(`.`);if(t.pop(),!l(t,2))return t;for(let e=1;e<t.length;e++)t[e]=t[e-1]+`.`+t[e];return t.reverse()}function T(e,t){let n=e.split(`.`).length,r=t.split(`.`).length;switch(!0){case n>r:return 1;case n<r:return-1;default:return 0}}function nt(e,t){return T(e.id,t.id)}function rt(e){return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>e.fqn.length-t.fqn.length).map(({item:e})=>e)}function it(e,t){let n=t;for(let t of e)t!==n&&x(t,n)&&(n=t);return n===t?null:n}function at(e){let t=[],n=[...e],r;for(;r=n.shift();){let e;for(;e=it(n,r);)t.push(...n.splice(n.indexOf(e),1));t.push(r)}return t}function ot(e,t){if(!e||E(e)){let t=e??`asc`;return e=>ot(e,t)}let n=t===`desc`?-1:1;return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>{if(e.fqn.length!==t.fqn.length)return(e.fqn.length-t.fqn.length)*n;for(let n=0;n<e.fqn.length;n++){let r=v(e.fqn[n],t.fqn[n]);if(r!==0)return r}return 0}).map(({item:e})=>e)}function st(e,t,n){let r=e.get(t);return r||(r=n(t),e.set(t,r)),r}function E(e){return e!=null&&typeof e==`string`}function ct(e){return!!e&&Array.isArray(e)&&e.length>0}function lt(e,t){return m(typeof t==`string`,`Path must be string`),typeof e==`object`&&!!e&&e[t]!=null}function ut(e){return t=>lt(t,e)}function dt(...e){if(e.length===1&&typeof e[0]==`string`)return ut(e[0]);let[t,n]=e;return lt(t,n)}function ft(...e){return(t=>e.some(e=>e(t)))}function pt(e){return typeof e==`object`&&!!e&&Symbol.iterator in e}function mt(e,t){let n=t??e;m(i(n));function*r(e){for(let t of e)n(t)&&(yield t)}return t?r(e):r}function ht(e,t){let n=t??e;m(i(n));function r(e){for(let t of e)if(n(t))return t}return t?r(e):r}function gt(e,t){let n=t??e;m(typeof n==`number`&&n>=0,`Count must be a non-negative number`);function*r(e){let t=0;for(let r of e){if(t>=n)break;yield r,t++}}return t===void 0?e=>r(e):r(e)}function _t(e){return e?vt(e):vt}function*vt(e){for(let t of e)yield*t}function yt(e,t){let n=t??e;m(i(n));function*r(e){for(let t of e)yield*n(t)}return t?r(e):r}function bt(e){return e?xt(e):xt}function xt(e){let{value:t}=e[Symbol.iterator]().next();return t}function St(e,t){let n=t??e;m(i(n));function*r(e){for(let t of e)yield n(t)}return t?r(e):r}function Ct(e,t,n){let r=u(n)?t:e,a=n??t;m(i(r));function o(e){let t=a;for(let n of e)t=r(t,n);return t}return u(n)?o(e):o}function wt(e,t){let n=t??e;m(i(n));function r(e){for(let t of e)if(n(t))return!0;return!1}return t?r(e):r}function Tt(e){return e?Array.from(e):e=>Array.from(e)}function Et(e){return e?new Set(e):e=>new Set(e)}function Dt(e){return e?Ot(e):Ot}function*Ot(e){let t=new Set;for(let n of e)t.has(n)||(t.add(n),yield n)}function D(e,t,n){let r=typeof t==`symbol`?t:Symbol.for(t);return e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!1,writable:!1,value:n()}),e[r]}function kt(...e){let t=100;return e.length===2?t=ie(e[0],e[1]):e.length===1&&(t=e[0]),new Promise(e=>{setTimeout(()=>{e(`LIKEC4_DELAY`)},t??100)})}function At(){return Promise.resolve().then(()=>void 0)}function jt(e){Promise.resolve().then(e)}const Mt=(e,t)=>{let n=w(e.source.id,e.target.id),r=w(t.source.id,t.target.id);if(n&&!r)return 1;if(!n&&r)return-1;let i=n&&r?T(n,r):0;if(i!==0)return i;let a=T(e.source.id,t.source.id);return a===0?T(e.target.id,t.target.id):a};function Nt(...e){let t=new Set;for(let n of e)for(let e of n)t.add(e);return t}function Pt(e,...t){let n=new Set;if(e.size===0)return n;let r=l(t,2)?(0,fe.intersection)(...t):t[0];if(r.size===0)return n;for(let t of e)r.has(t)&&n.add(t);return n}function Ft(e,t){if(e.size===0)return new Set;if(t.size===0)return new Set(e);let n=new Set;for(let r of e)t.has(r)||n.add(r);return n}function It(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function Lt(e,t){return(0,fe.symmetricDifference)(e,t)}function Rt(e,t){if(e.size===0||t.size===0)return!1;t.size<e.size&&([e,t]=[t,e]);for(let n of e)if(t.has(n))return!0;return!1}function O(e){return m(typeof e==`object`&&ee(e),`objectHash: value must be an object`),he(e)}function zt(e){let t=5381,n=e.length;m(n>0,`stringHash: empty string`);for(let r=0;r<n;r++)t=t*33^e.charCodeAt(r);return(t>>>0).toString(36)}function Bt(){return Te().use(Ce).use(xe).use(Se).use(we,{allowDangerousHtml:!0}).use(_e,n({attributes:{"*":[`className`],svg:[`width`,`height`,`viewBox`,`fill`,`ariaHidden`],path:[`d`,`fill`,`stroke`,`strokeWidth`,`strokeLinecap`,`strokeLinejoin`]},tagNames:[`svg`,`g`,`path`,`div`],protocols:{src:[`data`]}},ge)).use(ve,{allowDangerousHtml:!0})}function k(e){return(``+Bt().processSync(e)).trim()}function A(e){return ye(be(e),{includeHtml:!1,includeImageAlt:!1})}var j=class e{constructor(e,t){this.x=e,this.y=t,m(typeof e==`number`&&!isNaN(e)&&isFinite(e)&&typeof t==`number`&&!isNaN(t)&&isFinite(t),`Invalid arguments for Vector: (${e}, ${t})`)}static create(...t){return t.length===2?new e(t[0],t[1]):new e(t[0].x,t[0].y)}static add(e,t){return{x:e.x+t.x,y:e.y+t.y}}static subtract(e,t){return{x:e.x-t.x,y:e.y-t.y}}static multiply(e,t){return{x:e.x*t,y:e.y*t}}static divide(e,t){return{x:e.x/t,y:e.y/t}}static dot(e,t){return e.x*t.x+e.y*t.y}add(t){return new e(this.x+t.x,this.y+t.y)}subtract(t){return new e(this.x-t.x,this.y-t.y)}multiply(t){return new e(this.x*t,this.y*t)}divide(t){return new e(this.x/t,this.y/t)}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}length(){return this.x===0&&this.y===0?0:Math.sqrt(this.x**2+this.y**2)}normalize(){let t=this.length();return t===0?new e(0,0):new e(this.x/t,this.y/t)}round(){return new e(Math.round(this.x),Math.round(this.y))}trunc(){return new e(Math.trunc(this.x),Math.trunc(this.y))}toObject(){return{x:this.x,y:this.y}}};function Vt(...e){return e.length===1&&e[0]instanceof j?e[0]:e.length===2?new j(e[0],e[1]):new j(e[0].x,e[0].y)}function Ht(e,t){return e[M]===t}const M=`_stage`,Ut=`_type`,Wt=`_layout`;var Gt=e({DeploymentFqn:()=>B,EdgeId:()=>Yt,Fqn:()=>L,GlobalFqn:()=>U,GroupElementKind:()=>R,MarkdownOrString:()=>P,NodeId:()=>Jt,NoneIcon:()=>I,ProjectId:()=>N,RelationId:()=>H,StepEdgeKind:()=>Zt,ViewId:()=>V,extractStep:()=>Qt,flattenMarkdownOrString:()=>F,isGlobalFqn:()=>Kt,isGroupElementKind:()=>z,isStepEdgeId:()=>W,splitGlobalFqn:()=>qt,stepEdgeId:()=>Xt});function N(e){return e}function P(e){return typeof e==`string`?{txt:e}:e}function F(e){if(a(e))return null;let t=f(e)?e:e.txt??e.md;return c(t?.trim())?t:null}const I=`none`;function L(e,t){return t?t+`.`+e:e}const R=`@group`;function z(e){return e.kind===R}function B(e,t){return t?t+`.`+e:e}function V(e){return e}function H(e){return e}function U(e,t){return m(typeof e==`string`&&e!=``),`@`+e+`.`+t}function Kt(e){return e.startsWith(`@`)}function qt(e){if(!e.startsWith(`@`))return[null,e];let t=e.indexOf(`.`);if(t<2)throw Error(`Invalid global FQN`);return[e.slice(1,t),e.slice(t+1)]}function Jt(e){return e}function Yt(e){return e}function Xt(e,t){let n=`step-${String(e).padStart(2,`0`)}`;return t?`${n}.${t}`:n}const Zt=`@step`;function W(e){return e.startsWith(`step-`)}function Qt(e){if(!W(e))throw Error(`Invalid step edge id: ${e}`);return parseFloat(e.slice(5))}let G;(function(e){function t(e){return`model`in e&&!(`project`in e)}e.isElementRef=t;function n(e){return`project`in e&&`model`in e}e.isImportRef=n;function r(e){if(f(e))throw Error(`Expected FqnRef, got: "${e}"`);if(n(e))return U(e.project,e.model);if(t(e))return e.model;throw Error(`Expected FqnRef.ModelRef or FqnRef.ImportRef`)}e.flatten=r;function i(e){return t(e)||n(e)}e.isModelRef=i;function a(e){return`deployment`in e&&`element`in e}e.isInsideInstanceRef=a;function o(e){return`deployment`in e&&!(`element`in e)}e.isDeploymentElementRef=o;function s(e){return o(e)||a(e)}e.isDeploymentRef=s})(G||={});let K;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&G.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`ref`in e&&G.isDeploymentRef(e.ref)}e.isDeploymentRef=r;function i(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=i;function a(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=a;function o(e){return`where`in e&&c(e.where.expr)}e.isWhere=o;function s(e){return`custom`in e&&(c(e.custom.expr)||o(e.custom.expr))}e.isCustom=s;function c(e){return t(e)||n(e)||r(e)||i(e)||a(e)}e.is=c;function ee(e){return s(e)&&(e=e.custom.expr),o(e)&&(e=e.where.expr),e}e.unwrap=ee})(K||={});let q;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(q||={});let $t;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return q.isWhere(e)}e.isRelationWhere=n;function r(e){return K.isWhere(e)}e.isFqnExprWhere=r;function i(e){return K.is(e)||K.isWhere(e)||K.isCustom(e)}e.isFqnExpr=i;function a(e){return q.is(e)||q.isWhere(e)||q.isCustom(e)}e.isRelation=a})($t||={});let J;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&G.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=r;function i(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=i;function a(e){return`where`in e&&s(e.where.expr)}e.isWhere=a;function o(e){return`custom`in e&&(s(e.custom.expr)||a(e.custom.expr))}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.custom.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(J||={});let Y;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(Y||={});let en;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return Y.isWhere(e)}e.isRelationWhere=n;function r(e){return J.isWhere(e)}e.isFqnExprWhere=r;function i(e){return J.is(e)||J.isWhere(e)||J.isCustom(e)}e.isFqnExpr=i;function a(e){return Y.is(e)||Y.isWhere(e)||Y.isCustom(e)}e.isRelationExpr=a})(en||={});function tn(e){return c(e.kind)&&!c(e.element)}function nn(e){return c(e.element)&&!c(e.kind)}const rn={fill:`#3b82f6`,stroke:`#2563eb`,hiContrast:`#eff6ff`,loContrast:`#bfdbfe`},an={fill:`#0284c7`,stroke:`#0369a1`,hiContrast:`#f0f9ff`,loContrast:`#B6ECF7`},on={fill:`#64748b`,stroke:`#475569`,hiContrast:`#f8fafc`,loContrast:`#cbd5e1`},sn={primary:rn,blue:rn,secondary:an,sky:an,muted:on,slate:on,gray:{fill:`#737373`,stroke:`#525252`,hiContrast:`#fafafa`,loContrast:`#d4d4d4`},red:{fill:`#AC4D39`,stroke:`#853A2D`,hiContrast:`#FBD3CB`,loContrast:`#f5b2a3`},green:{fill:`#428a4f`,stroke:`#2d5d39`,hiContrast:`#f8fafc`,loContrast:`#c2f0c2`},amber:{fill:`#A35829`,stroke:`#7E451D`,hiContrast:`#FFE0C2`,loContrast:`#f9b27c`},indigo:{fill:`#6366f1`,stroke:`#4f46e5`,hiContrast:`#eef2ff`,loContrast:`#c7d2fe`}},cn={line:`#8D8D8D`,labelBg:`#18191B`,label:`#C9C9C9`},ln={line:`#64748b`,labelBg:`#0f172a`,label:`#cbd5e1`},un={line:`#3b82f6`,labelBg:`#172554`,label:`#eff5fd`},dn={line:`#0ea5e9`,labelBg:`#082f49`,label:`#d4f2ff`},fn={amber:{line:`#b45309`,labelBg:`#78350f`,label:`#FFE0C2`},blue:un,gray:cn,green:{line:`#15803d`,labelBg:`#052e16`,label:`#bbfcd3`},indigo:{line:`#6366f1`,labelBg:`#1e1b4b`,label:`#cbd0fd`},muted:ln,primary:un,red:{line:`#AC4D39`,labelBg:`#b91c1c`,label:`#fcd9d2`},secondary:dn,sky:dn,slate:ln},pn={sizes:{xs:{width:180,height:100},sm:{width:240,height:135},md:{width:320,height:180},lg:{width:420,height:234},xl:{width:520,height:290}},spacing:{xs:8,sm:10,md:16,lg:24,xl:32},textSizes:{xs:13.33,sm:16,md:19.2,lg:23.04,xl:27.65},iconSizes:{xs:24,sm:36,md:60,lg:82,xl:90}},mn=[`xs`,`sm`,`md`,`lg`,`xl`],hn=[`left`,`right`,`top`,`bottom`],gn=[`solid`,`dashed`,`dotted`,`none`],_n=[`rectangle`,`person`,`browser`,`mobile`,`cylinder`,`storage`,`queue`,`bucket`,`document`,`component`],vn=[`amber`,`blue`,`gray`,`slate`,`green`,`indigo`,`muted`,`primary`,`red`,`secondary`,`sky`],yn=[`tomato`,`grass`,`blue`,`ruby`,`orange`,`indigo`,`pink`,`teal`,`purple`,`amber`,`crimson`,`red`,`lime`,`yellow`,`violet`],bn={tomato:Ie.tomato9,grass:je.grass9,blue:Pe.blue9,ruby:Oe.ruby9,orange:Re.orange9,indigo:Ee.indigo9,pink:De.pink9,teal:ke.teal9,purple:Me.purple9,amber:ze.amber9,crimson:Le.crimson9,red:Be.red9,lime:Fe.lime9,yellow:Ae.yellow9,violet:Ne.violet9};function xn(e){return e in bn}const Sn={colors:vn.reduce((e,t)=>(e[t]={elements:sn[t],relationships:fn[t]},e),{}),...pn};function Cn(e,t){return t=Math.max(-1,Math.min(1,t)),e.map(e=>{let n=t>0?e+(255-e)*t:e*(1+t);return Math.round(Math.max(0,Math.min(255,n)))})}function wn(e,t){return p(Cn(p(e).rgb(),t)).hex()}function Tn(e){m(p.valid(e),`Invalid color: ${e}`);let t=e.trim(),n=En(t.startsWith(`#`)?t:p(t).hex());return{elements:{fill:n.el_main,stroke:n.el_secondary,hiContrast:n.el_hiContrast,loContrast:n.el_loContrast},relationships:{line:n.rel_secondary,label:n.rel_hiContrast,labelBg:n.rel_main}}}function En(e){let t=e,n=p(t).darken(.8).hex(),r=Dn(t),i=r.hiContrast,a=r.loContrast,o=t;return{el_main:t,el_secondary:n,el_hiContrast:i,el_loContrast:a,rel_main:o,rel_secondary:wn(t,-.25),rel_hiContrast:Dn(o).hiContrast}}function Dn(e){let t=p(e),n=t.brighten(2),r=t.darken(2),i,a,o,s;do i=n,a=r,n=n.brighten(1),r=r.darken(1),o=p.contrastAPCA(t,n),s=p.contrastAPCA(t,r);while(Math.abs(o)<60&&Math.abs(s)<60&&(!d(n,i)||!d(r,a)));return Math.abs(o)>Math.abs(s)?{hiContrast:p(n.brighten(.4)).hex(),loContrast:n.hex()}:{hiContrast:p(r.darken(.4)).hex(),loContrast:r.hex()}}function On(e,t){let n=t??6,r=p(e.fill),i=p(e.stroke),a=r.luminance()>.8,o=re(ce(p.scale(a?[r.darken(.02).desaturate(.05),r.darken(.1).desaturate(.1)]:[r.shade(.12,`lch`).desaturate(.05),r.shade(.35,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null),p.scale(a?[i.darken(.04).desaturate(.05),i.darken(.12).desaturate(.1)]:[i.shade(.15,`lch`).desaturate(.08),i.shade(.4,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null)),te(([t,n])=>({...e,fill:t.hex(),stroke:n.hex()})));return m(o.length===n,`Expected ${n} colors, got ${o.length}`),o}const kn={color:`primary`,size:`md`,opacity:15,shape:`rectangle`,group:{opacity:15,border:`dashed`},relationship:{color:`gray`,line:`dashed`,arrow:`normal`}},X=Sn,Z={theme:X,defaults:kn};var An=class e{theme;defaults;static DEFAULT=new e(Z);static from(t,r){if(!t&&!r)return this.DEFAULT;let{customCss:i,theme:o,defaults:s}={...t},c=n({theme:o},{defaults:{...s}},{theme:{colors:{...r}}},Z);return a(i?.content)&&d(c,Z)?this.DEFAULT:new e(c,i)}constructor(e,t){this.config=e,this.customCss=t,this.theme=e.theme,this.defaults=e.defaults}get fingerprint(){return D(this,`fingerprint`,()=>O({config:this.config,customCss:this.customCss}))}get elementColors(){return this.theme.colors[this.defaults.color].elements}get relationshipColors(){return this.theme.colors[this.defaults.relationship.color].relationships}get groupColors(){let e=this.defaults.group?.color;if(!e)return this.elementColors;if(!this.isThemeColor(e))throw Error(`Default group color not found in theme: ${e}`);return D(this,`defaultGroup`,()=>({...this.elementColors,...this.theme.colors[e].elements}))}isDefaultColor(e){return e===this.defaults.color}colors(e){return this.computeFrom(e??this.defaults.color)}compoundColorsCache=new de.default(e=>new pe.default(t=>On(e,t)));colorsForCompounds(e,t){return this.compoundColorsCache.get(e).get(t??6)}fontSize(e){return e??=this.defaults.text??this.defaults.size,this.theme.textSizes[e]}padding(e){return e??=this.defaults.padding??this.defaults.size,this.theme.spacing[e]}iconSize(e){return e??=this.defaults.size,this.theme.iconSizes[e]}isThemeColor(e){return e in this.theme.colors}nodeSizes(e){let t=jn(e,this.defaults.size);return{sizes:t,values:{sizes:this.theme.sizes[t.size],padding:this.padding(t.padding),textSize:this.fontSize(t.textSize),iconSize:this.iconSize(t.iconSize)}}}computeFrom(e){if(this.isThemeColor(e))return this.theme.colors[e];if(!p.valid(e))throw Error(`Invalid color value: "${e}" (not a theme color and not a valid CSS color)`);return Tn(e)}equals(e){return e===this?!0:this.constructor===e.constructor?this.fingerprint===e.fingerprint:!1}tagColor(e){return this.isThemeColor(e)?this.theme.colors[e].elements:xn(e)?this.computeFrom(bn[e]).elements:this.computeFrom(e).elements}};function jn({size:e,padding:t,textSize:n,iconSize:r,...i},a=Z.defaults.size){return e??=a,n??=e,t??=e,r??=e,{...i,size:e,padding:t,textSize:n,iconSize:r}}function Mn(e){let t=typeof e==`string`?e:e.color;return t.startsWith(`#`)||t.startsWith(`rgb`)}function Nn(e){return`tag`in e}function Pn(e){return`kind`in e}function Fn(e){return`metadata`in e}function In(e){return`participant`in e}function Ln(e){return`not`in e}function Rn(e){return`and`in e}function zn(e){return`or`in e}function Q(e){switch(!0){case In(e):{let t=e.participant;return Bn(t,Q(e.operator))}case Nn(e):{if(f(e.tag)||`eq`in e.tag){let t=f(e.tag)?e.tag:e.tag.eq;return e=>Array.isArray(e.tags)&&e.tags.includes(t)}let t=e.tag.neq;return e=>!Array.isArray(e.tags)||!e.tags.includes(t)}case Pn(e):{if(f(e.kind)||`eq`in e.kind){let t=f(e.kind)?e.kind:e.kind.eq;return e=>e.kind===t}let t=e.kind.neq;return e=>o(e.kind)||e.kind!==t}case Fn(e):{let{key:t,value:n}=e.metadata;if(n===void 0)return e=>e.metadata!=null&&t in e.metadata&&e.metadata[t]!=null;if(f(n)||`eq`in n){let e=f(n)?n:n.eq;return n=>{if(!n.metadata)return!1;let r=n.metadata[t];return Array.isArray(r)?r.includes(e):r===e}}let r=n.neq;return e=>{if(!e.metadata)return!0;let n=e.metadata[t];return n==null?!0:Array.isArray(n)?!n.includes(r):n!==r}}case Ln(e):return s(Q(e.not));case Rn(e):return ae(e.and.map(Q));case zn(e):return se(e.or.map(Q));default:h(e)}}function Bn(e,t){return n=>{if(!n.source||!n.target)return!1;switch(e){case`source`:return t(n.source);case`target`:return t(n.target)}}}function Vn(e){return`include`in e||`exclude`in e}function Hn(e){return`targets`in e&&`style`in e}function Un(e){return e._stage===`computed`}function Wn(e){return e._stage===`layouted`}function $(e){return e._type===`element`}function Gn(e){return $(e)&&c(e.viewOf)}function Kn(e){return $(e)&&c(e.extends)}function qn(e){return e._type===`deployment`}function Jn(e){return e._type===`dynamic`}function Yn(e){return`styleId`in e}function Xn(e){return`predicateId`in e}function Zn(e){return e===`TB`||e===`BT`||e===`LR`||e===`RL`}function Qn(e){return`direction`in e}function $n(e){return W(e)&&e.includes(`.`)?e.slice(0,e.indexOf(`.`)+1):null}function er(e){return!!e&&!(`__series`in e||`__parallel`in e)}function tr(e){return!!e&&`__parallel`in e&&r(e.__parallel)}function nr(e){return!!e&&`__series`in e&&r(e.__series)}function rr(e){return`title`in e&&`groupRules`in e&&Array.isArray(e.groupRules)}function ir(e){return`rank`in e&&Array.isArray(e.targets)}const ar=Symbol.for(`text`),or=Symbol.for(`html`);var sr=class e{static mdcache=new ue.default(500);static txtcache=new ue.default(500);static getOrCreateFromText(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.txtcache.get(t);return n||(n=new e({txt:t}),e.txtcache.set(t,n),n)}static getOrCreateFromMarkdown(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.mdcache.get(t);return n||(n=new e({md:t}),e.mdcache.set(t,n),n)}static memoize(t,n,r){return D(t,n,()=>e.from(r))}static from(t){return t==null||t===e.EMPTY?e.EMPTY:t instanceof e?t:typeof t==`string`?this.getOrCreateFromText(t):`isEmpty`in t&&t.isEmpty?e.EMPTY:`md`in t?this.getOrCreateFromMarkdown(t.md):this.getOrCreateFromText(t.txt)}static EMPTY=new class extends e{isEmpty=!0;nonEmpty=!1;isMarkdown=!1;$source=null;constructor(){super({txt:``})}get text(){return null}get md(){return null}get html(){return null}};$source;isEmpty;nonEmpty;isMarkdown;constructor(e){this.isMarkdown=!1,typeof e==`string`?(this.$source={txt:e},this.isEmpty=e.trim()===``):(this.$source=e,this.isEmpty=!0,`md`in e?(this.isEmpty=e.md===``,this.isMarkdown=!0):this.isEmpty=e.txt===``),this.nonEmpty=!this.isEmpty}get text(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:D(this,ar,()=>A(e.md))}get md(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;if(`md`in e)return e.md;if(`txt`in e)return e.txt;h(e)}get html(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:D(this,or,()=>k(e.md))}equals(t){return this===t?!0:t instanceof e?this.isEmpty&&t.isEmpty?!0:this.isEmpty!==t.isEmpty||this.isMarkdown!==t.isMarkdown?!1:this.isMarkdown?this.$source?.md===t.$source?.md:this.$source?.txt===t.$source?.txt:!1}};export{U as $,E as $t,jn as A,Lt as At,vn as B,wt as Bt,Fn as C,h as Cn,k as Ct,Nn as D,He as Dn,It as Dt,In as E,Ue as En,Ft as Et,gn as F,At as Ft,Y as G,_t as Gt,tn as H,St as Ht,yn as I,D as It,q as J,mt as Jt,$t as K,gt as Kt,_n as L,Dt as Lt,X as M,Mt,kn as N,kt as Nt,Q as O,Ve as On,Rt as Ot,Tn as P,jt as Pt,L as Q,ct as Qt,hn as R,Tt as Rt,Pn as S,Ke as Sn,A as St,zn as T,We as Tn,O as Tt,en as U,bt as Ut,nn as V,Ct as Vt,J as W,yt as Wt,B as X,dt as Xt,G as Y,pt as Yt,Yt as Z,ft as Zt,Kn as _,Ye as _n,M as _t,er as a,et as an,H as at,Hn as b,g as bn,j as bt,Zn as c,$e as cn,Qt as ct,Yn as d,Ze as dn,z as dt,st as en,R as et,Un as f,rt as fn,W as ft,$ as g,Xe as gn,Wt as gt,Jn as h,v as hn,Xt as ht,$n as i,T as in,N as it,An as j,Nt as jt,Mn as k,Pt as kt,Qn as l,S as ln,F as lt,Wn as m,at as mn,qt as mt,rr as n,w as nn,Jt as nt,tr as o,C as on,Zt as ot,qn as p,ot as pn,Gt as pt,K as q,ht as qt,ir as r,nt as rn,I as rt,nr as s,x as sn,V as st,sr as t,tt as tn,P as tt,Xn as u,Qe as un,Kt as ut,Gn as v,Je as vn,Ut as vt,Ln as w,Ge as wn,zt as wt,Rn as x,m as xn,Vt as xt,Vn as y,qe as yn,Ht as yt,mn as z,Et as zt};
@@ -1,8 +1,2 @@
1
- import "../_chunks/index.mjs";
2
- import "../_chunks/index2.mjs";
3
- import "../_chunks/index3.mjs";
4
- import "../_chunks/libs/mnemonist.mjs";
5
- import "../_chunks/mnemonist.mjs";
6
- import "../_chunks/LikeC4Model.mjs";
7
1
  import { $ as DeloymentModelHelpers, A as AddDeploymentViewHelper, B as ViewPredicate, C as AddViewHelper, D as ElementViewRulesBuilder, E as ElementViewBuilder, F as $exclude, G as NestedRelationshipHelper, H as ModelBuilder, I as $include, J as AddElement, K as RelationshipHelper, L as $rules, M as DeploymentRulesBuilderOp, N as DeploymentViewBuilder, O as TypedAddViewOfHelper, P as $autoLayout, Q as DeloymentModelBuildFunction, R as $style, S as $expr, T as AddViewRules, U as ModelBuilderFunction, V as AddElementHelpers, W as ModelHelpers, X as AddDeploymentNodeHelpers, Y as AddDeployedInstance, Z as AddDeploymentRelation, _ as ViewsBuilder, a as Invalid, b as mkViewBuilder, c as NewElementProps, d as Types, et as DeploymentModelBuilder, f as TypesNested, g as BuilderMethods, h as Builder, i as BuilderSpecification, j as AddDeploymentViewRules, k as $deploymentExpr, l as NewRelationProps, m as Warn, n as AnyTypesNested, nt as AddDeploymentNode, o as Metadata, p as ValidId, q as model, r as BuilderProjectSpecification, s as NewDeploymentNodeProps, t as AnyTypes, tt as deployment, u as NewViewProps, v as ViewsBuilderFunction, w as AddViewOfHelper, x as views, y as ViewsHelpers, z as LikeC4ViewBuilder } from "../_chunks/_types.mjs";
8
2
  export { $autoLayout, $deploymentExpr, $exclude, $expr, $include, $rules, $style, AddDeployedInstance, AddDeploymentNode, AddDeploymentNodeHelpers, AddDeploymentRelation, AddDeploymentViewHelper, AddDeploymentViewRules, AddElement, AddElementHelpers, AddViewHelper, AddViewOfHelper, AddViewRules, AnyTypes, AnyTypesNested, Builder, BuilderMethods, BuilderProjectSpecification, BuilderSpecification, DeloymentModelBuildFunction, DeloymentModelHelpers, DeploymentModelBuilder, DeploymentRulesBuilderOp, DeploymentViewBuilder, ElementViewBuilder, ElementViewRulesBuilder, Invalid, LikeC4ViewBuilder, Metadata, ModelBuilder, ModelBuilderFunction, ModelHelpers, NestedRelationshipHelper, NewDeploymentNodeProps, NewElementProps, NewRelationProps, NewViewProps, RelationshipHelper, TypedAddViewOfHelper, Types, TypesNested, ValidId, ViewPredicate, ViewsBuilder, ViewsBuilderFunction, ViewsHelpers, Warn, deployment, mkViewBuilder, model, views };
@@ -1 +1 @@
1
- import{t as e}from"../_chunks/libs/defu.mjs";import{B as t,C as n,F as r,M as i,Q as a,T as o,U as s,W as c,X as l,Y as u,et as d,k as f,w as p}from"../_chunks/libs/remeda.mjs";import{St as m,V as h,W as g,Y as _,_t as v,g as y,mt as b,ut as x,vt as S}from"../_chunks/types.mjs";import"../_chunks/geometry.mjs";import{B as C,Q as w,R as T,z as E}from"../_chunks/utils.mjs";import"../_chunks/libs/graphology-dag.mjs";import{t as D}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/ohash.mjs";import"../_chunks/libs/@ungap/structured-clone.mjs";import"../_chunks/libs/hast-util-sanitize.mjs";import"../_chunks/libs/rehype-sanitize.mjs";import"../_chunks/libs/hast-util-to-html.mjs";import"../_chunks/libs/character-entities-legacy.mjs";import"../_chunks/libs/character-entities-html4.mjs";import"../_chunks/libs/ccount.mjs";import"../_chunks/libs/comma-separated-tokens.mjs";import"../_chunks/libs/rehype-stringify.mjs";import"../_chunks/libs/devlop.mjs";import"../_chunks/libs/mdast-util-from-markdown.mjs";import"../_chunks/libs/escape-string-regexp.mjs";import"../_chunks/libs/mdast-util-find-and-replace.mjs";import"../_chunks/libs/mdast-util-gfm.mjs";import"../_chunks/libs/markdown-table.mjs";import"../_chunks/libs/longest-streak.mjs";import"../_chunks/libs/character-entities.mjs";import"../_chunks/libs/decode-named-character-reference.mjs";import"../_chunks/libs/micromark-extension-gfm.mjs";import"../_chunks/libs/remark-gfm.mjs";import"../_chunks/libs/remark-github-blockquote-alert.mjs";import"../_chunks/libs/remark-parse.mjs";import"../_chunks/libs/mdast-util-to-hast.mjs";import"../_chunks/libs/remark-rehype.mjs";import"../_chunks/libs/bail.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/is-plain-obj.mjs";import"../_chunks/libs/trough.mjs";import"../_chunks/libs/unified.mjs";import"../_chunks/libs/@radix-ui/colors.mjs";import"../_chunks/libs/@mantine/colors-generator.mjs";import"../_chunks/model.mjs";import"../_chunks/manual-layout.mjs";import{n as O,t as k}from"../_chunks/Builder.view-element.mjs";import"../_chunks/libs/graphology.mjs";import{t as A}from"../_chunks/assignTagColors.mjs";function j(e){if(f(e)){let t=e;switch(!0){case t.startsWith(`tag is not #`):return{tag:{neq:t.replace(`tag is not #`,``)}};case t.startsWith(`tag is #`):return{tag:{eq:t.replace(`tag is #`,``)}};case t.startsWith(`kind is not `):return{kind:{neq:t.replace(`kind is not `,``)}};case t.startsWith(`kind is `):return{kind:{eq:t.replace(`kind is `,``)}};case t.startsWith(`source.`):return{operator:j(t.replace(`source.`,``)),participant:`source`};case t.startsWith(`target.`):return{operator:j(t.replace(`target.`,``)),participant:`target`};default:throw Error(`Unknown where operator: ${e}`)}}if(e.and)return{and:o(e.and,j)};if(e.or)return{or:o(e.or,j)};if(e.not)return{not:j(e.not)};throw Error(`Unknown where operator: ${e}`)}function M(...e){return t=>{if(e.length===2&&typeof e[1]!=`string`&&(`where`in e[1]||`with`in e[1])){let n=t.$expr(e[0]),r=e[1].where?j(e[1].where):void 0;r&&(n={where:{expr:n,condition:r}});let i=e[1].with;return i&&(n=g.is(e[0])?{custom:{...i,expr:n}}:{customRelation:{...i,expr:n}}),t.include(n),t}return t.include(...e.map(e=>t.$expr(e))),t}}function N(...e){return t=>{let n=t.$expr(e[0]);if(e.length===2&&e[1].where){let t=j(e[1].where);n={where:{expr:n,condition:t}}}return t.exclude(n),t}}function P(e,{notation:n,...r}){return i=>i.style({targets:(t(e)?e:[e]).map(e=>i.$expr(e)),...n?{notation:n}:{},style:{...r}})}function F(e,t){return n=>n.autoLayout(e,t)}function I(...e){return t=>e.reduce((e,t)=>t(e),t)}function L(e){if(!f(e))return e;let t=e=>e;if(e===`*`)return t({wildcard:!0});if(e.startsWith(`->`))return e.endsWith(`->`)?t({inout:L(e.replace(/->/g,``).trim())}):t({incoming:L(e.replace(`-> `,``))});if(e.endsWith(` ->`))return t({outgoing:L(e.replace(` ->`,``))});if(e.includes(` <-> `)){let[n,r]=e.split(` <-> `);return t({source:L(n),target:L(r),isBidirectional:!0})}if(e.includes(` -> `)){let[n,r]=e.split(` -> `);return t({source:L(n),target:L(r)})}return e.endsWith(`._`)?t({ref:{deployment:e.replace(`._`,``)},selector:`expanded`}):e.endsWith(`.**`)?t({ref:{deployment:e.replace(`.**`,``)},selector:`descendants`}):e.endsWith(`.*`)?t({ref:{deployment:e.replace(`.*`,``)},selector:`children`}):t({ref:{deployment:e}})}function R(e){let t={$expr:e[S]===`deployment`?L:k,autoLayout(n,r){return e.rules.push(m({direction:n,rankSep:r?.rank,nodeSep:r?.node})),t},exclude(...n){return e.rules.push({exclude:n}),t},include(...n){return e.rules.push({include:n}),t},style(n){return e.rules.push(n),t},get Expr(){throw Error(`Expr is not available in runtime`)},get Types(){throw Error(`Types are not available in runtime`)},get ElementExpr(){throw Error(`ElementExpr is not available in runtime`)},get TypedExpr(){throw Error(`TypedExpr is not available in runtime`)}};return t}function z(e){return t(e)?s(e,e=>({})):e}function B({tags:e,elements:t,deployments:n,relationships:r,...i}){let a={};e&&Object.assign(a,z(e));let o=z(t);for(let[e,t]of l(o))if(t.tags)for(let n of t.tags)w(n in a,`Invalid specification for element kind "${e}": tag "${n}" not found`);let s=z(n??{});for(let[e,t]of l(s))if(t.tags)for(let n of t.tags)w(n in a,`Invalid specification for deployment kind "${e}": tag "${n}" not found`);return{...i,tags:a,elements:o,deployments:s,relationships:z(r??{})}}function V(e){return i(e)?null:typeof e==`string`?{txt:e}:e}function H(t,s=new Map,l=[],f=new Map,g={predicates:{},dynamicPredicates:{},styles:{}},k=new Map,j=[],L=new D.default(()=>new Map)){let z=B(t),U=()=>({elements:structuredClone(z.elements),deployments:structuredClone(z.deployments),relationships:structuredClone(z.relationships),tags:A(structuredClone(z.tags)),...z.metadataKeys?{metadataKeys:z.metadataKeys}:{},customColors:{}}),W=e=>{if(!(!e||!a(e,1)))return o(e,e=>typeof e==`string`?{url:e}:e)},G=(e,t,n)=>{r(t)&&(n=t,t={}),t??={};let{links:i=[],title:a=null,description:o=null,tags:s=[],...c}=typeof t==`string`?{title:t}:{...t},l=W(i);return[m({id:e,title:a,description:V(o),tags:s,links:l,_stage:`parsed`,...c}),n]},K=e=>{let[t,n]=b(e),r=(t?L.get(t):s).get(n);return w(r,`Element with id "${e}" not found`),r},q=e=>{if(typeof e==`string`){let[t,n]=b(e);return t?{project:t,model:n}:{model:n}}return`project`in e||`deployment`in e?e:q(e.model)},J={get Types(){throw Error(`Types are not available in runtime`)},clone:()=>{let e=new D.default(()=>new Map);for(let[t,n]of L)e.set(t,structuredClone(n));return H(structuredClone(z),structuredClone(s),structuredClone(l),structuredClone(f),structuredClone(g),structuredClone(k),structuredClone(j),e)},__addElement:e=>{let[t,n]=b(e.id),r=C(n),i=t?L.get(t):s;if(r&&w(i.get(r),`Parent element with id "${r}" not found for element with id "${e.id}"`),i.has(n))throw Error(`Element with id "${e.id}" already exists`);return i.set(n,t?{...e,id:n}:e),J},__addRelation(e){let t=q(e.source),n=_.flatten(t),r=q(e.target),i=_.flatten(r),a=K(n),o=K(i);if(x(n)&&x(i))throw Error(`Cannot create relationship between global elements`);return!x(n)&&!x(i)&&w(!T(a,o),`Cannot create relationship between elements in the same hierarchy`),l.push({id:`rel${l.length+1}`,...e,source:t,target:r}),J},__fqn(e){return w(e.trim()!==``,`Id must be non-empty`),e},__deploymentFqn(e){return w(e.trim()!==``,`Id must be non-empty`),e},__addSourcelessRelation(){throw Error(`Can be called only in nested model`)},__addView:e=>{if(f.has(e.id))throw Error(`View with id "${e.id}" already exists`);return y(e)&&`viewOf`in e&&w(s.get(e.viewOf),`Invalid scoped view ${e.id}, wlement with id "${e.viewOf}" not found`),f.set(e.id,e),J},__addDeployment:e=>{if(k.has(e.id))throw Error(`Deployment with id "${e.id}" already exists`);let t=C(e.id);return t&&w(k.get(t),`Parent element with id "${t}" not found for node with id "${e.id}"`),h(e)&&(w(t,`Instance ${e.id} of ${e.element} must be deployed under a parent node`),w(s.get(e.element),`Instance "${e.id}" references non-existing element "${e.element}"`)),k.set(e.id,e),J},__addDeploymentRelation:e=>(w(!T(e.source.deployment,e.target.deployment),`Cannot create relationship between elements in the same hierarchy`),w(k.has(e.source.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing source`),w(k.has(e.target.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing target`),j.push({id:`deploy_rel${j.length+1}`,...e}),J),build:e=>({[v]:`parsed`,projectId:typeof e==`string`?e:e?.id??`from-builder`,project:{id:typeof e==`string`?e:`from-builder`,...typeof e==`object`&&e?e:{}},specification:U(),elements:c(structuredClone(Array.from(s.entries()))),relations:p(l,e=>[e.id,structuredClone(e)]),globals:structuredClone(g),deployments:{elements:c(structuredClone(Array.from(k.entries()))),relations:p(j,e=>[e.id,structuredClone(e)])},views:c(structuredClone(Array.from(f.entries()))),imports:d(Array.from(L.entries()),o(([e,t])=>[e,structuredClone([...t.values()])]),u(([e,t])=>t.length>0),c())}),toLikeC4Model:e=>O(J.build(e)),helpers:()=>({model:{model:(...e)=>t=>e.reduce((e,t)=>t(e),t),rel:(t,n,r)=>i=>{let{title:a=``,links:o=[],description:s=null,notes:c=null,...l}=e(typeof r==`string`?{title:r}:{...r},{title:null,links:null}),u=W(o);return i.__addRelation(m({source:{model:t},target:{model:n},title:a,...s&&{description:V(s)},...c&&{notes:V(c)},links:u,...l})),i},relTo:(t,n)=>r=>{let{title:i=``,links:a,description:o=null,notes:s=null,...c}=e(typeof n==`string`?{title:n}:{...n},{title:null,links:null});return r.__addSourcelessRelation(m({target:{model:t},title:i,...o&&{description:V(o)},...s&&{notes:V(s)},links:W(a),...c})),r},...n(z.elements,({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,color:c,shape:l,style:u,title:d,description:f,summary:p,...h}=typeof i==`string`?{title:i}:{...i},g=s??e?.icon,_=W(o),v=a.__fqn(r);return a.__addElement(m({id:v,kind:n,...t,title:d??t.title??E(v),...f&&{description:V(f)},...p&&{summary:V(p)},style:m({icon:g,color:c??e?.color,shape:l??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...u}),..._&&{links:_},...h})),a});return a.with=(...e)=>t=>{a(t);let{__fqn:n,__addSourcelessRelation:i}=t;try{t.__fqn=e=>`${n(r)}.${e}`,t.__addSourcelessRelation=e=>t.__addRelation({...e,source:{model:n(r)}}),e.reduce((e,t)=>t(e),t)}finally{t.__fqn=n,t.__addSourcelessRelation=i}return t},a})},views:{views:(...e)=>t=>e.reduce((e,t)=>t(e),t),view:(e,t,n)=>{let[r,i]=G(e,t,n),a={...r,[S]:`element`,rules:[]},o=e=>(e.__addView(a),i&&i(R(a)),e);return o.with=(...e)=>t=>{o(t);let n=R(a);for(let t of e)t(n);return t},o},viewOf:(e,t,n,r)=>{let[i,a]=G(e,n,r),o={...i,viewOf:t,[S]:`element`,rules:[]},s=e=>(e.__addView(o),a&&a(R(o)),e);return s.with=(...e)=>t=>{s(t);let n=R(o);for(let t of e)t(n);return t},s},deploymentView:(e,t,n)=>{let[r,i]=G(e,t,n),a={...r,[S]:`deployment`,rules:[]},o=e=>(e.__addView(a),i&&i(R(a)),e);return o.with=(...e)=>t=>{o(t);let n=R(a);for(let t of e)t(n);return t},o},$autoLayout:F,$exclude:N,$include:M,$rules:I,$style:P},deployment:{deployment:(...e)=>t=>e.reduce((e,t)=>t(e),t),instanceOf:(e,t,n)=>r=>{i(t)?(t=e,e=E(e)):typeof t==`string`?n??={}:(n=t,t=e,e=E(e));let{links:a,title:o,description:s,summary:c,icon:l,color:u,shape:d,style:f,...p}=typeof n==`string`?{title:n}:{...n},h=r.__deploymentFqn(e);return r.__addDeployment(m({id:h,element:t,...o&&{title:o},...c&&{summary:V(c)},...s&&{description:V(s)},style:m({icon:l,color:u,shape:d,...f}),links:W(a),...p})),r},rel:(e,t,n)=>r=>{let{title:i=null,links:a,description:o=null,notes:s=null,...c}=typeof n==`string`?{title:n}:{...n};return r.__addDeploymentRelation(m({source:{deployment:e},target:{deployment:t},title:i,...o&&{description:V(o)},...s&&{notes:V(s)},links:W(a),...c})),r},...n(z.deployments??{},({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,style:c,title:l,description:u,summary:d,color:f,shape:p,...h}=typeof i==`string`?{title:i}:{...i},g=s??e?.icon,_=W(o),v=a.__deploymentFqn(r);return a.__addDeployment(m({id:v,kind:n,...t,title:l??t.title??E(v),...u&&{description:V(u)},...d&&{summary:V(d)},style:m({icon:g,color:f??e?.color,shape:p??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...c}),..._&&{links:_},...h})),a});return a.with=(...e)=>t=>{a(t);let{__deploymentFqn:n}=t;try{t.__deploymentFqn=e=>`${n(r)}.${e}`,e.reduce((e,t)=>t(e),t)}finally{t.__deploymentFqn=n}return t},a})}}),with:(...e)=>{let t=J.clone();return e.reduce((e,t)=>t(e),t)},model:e=>{let t=J.clone(),n=t.helpers().model,r=n.model;return e({...n,_:r},r)(t)},deployment:e=>{let t=J.clone(),n=t.helpers().deployment,r=n.deployment;return e({...n,_:r},r)(t)},views:e=>{let t=J.clone(),n=t.helpers().views;return e({...n,_:n.views},n.views)(t)}};return J}const U={forSpecification(e){let t=H(e);return{...t.helpers(),builder:t}},specification(e){return H(e)}};export{U as Builder};
1
+ import{t as e}from"../_chunks/libs/defu.mjs";import{B as t,C as n,F as r,M as i,Q as a,T as o,U as s,W as c,X as l,Y as u,et as d,k as f,w as p}from"../_chunks/libs/remeda.mjs";import{On as m,V as h,W as g,Y as _,_t as v,dn as y,g as b,ln as x,mt as S,un as C,ut as w,vt as T,xn as E}from"../_chunks/types.mjs";import{t as D}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/model.mjs";import{n as O,t as k}from"../_chunks/Builder.view-element.mjs";import{t as A}from"../_chunks/assignTagColors.mjs";function j(e){if(f(e)){let t=e;switch(!0){case t.startsWith(`tag is not #`):return{tag:{neq:t.replace(`tag is not #`,``)}};case t.startsWith(`tag is #`):return{tag:{eq:t.replace(`tag is #`,``)}};case t.startsWith(`kind is not `):return{kind:{neq:t.replace(`kind is not `,``)}};case t.startsWith(`kind is `):return{kind:{eq:t.replace(`kind is `,``)}};case t.startsWith(`source.`):return{operator:j(t.replace(`source.`,``)),participant:`source`};case t.startsWith(`target.`):return{operator:j(t.replace(`target.`,``)),participant:`target`};default:throw Error(`Unknown where operator: ${e}`)}}if(e.and)return{and:o(e.and,j)};if(e.or)return{or:o(e.or,j)};if(e.not)return{not:j(e.not)};throw Error(`Unknown where operator: ${e}`)}function M(...e){return t=>{if(e.length===2&&typeof e[1]!=`string`&&(`where`in e[1]||`with`in e[1])){let n=t.$expr(e[0]),r=e[1].where?j(e[1].where):void 0;r&&(n={where:{expr:n,condition:r}});let i=e[1].with;return i&&(n=g.is(e[0])?{custom:{...i,expr:n}}:{customRelation:{...i,expr:n}}),t.include(n),t}return t.include(...e.map(e=>t.$expr(e))),t}}function N(...e){return t=>{let n=t.$expr(e[0]);if(e.length===2&&e[1].where){let t=j(e[1].where);n={where:{expr:n,condition:t}}}return t.exclude(n),t}}function P(e,{notation:n,...r}){return i=>i.style({targets:(t(e)?e:[e]).map(e=>i.$expr(e)),...n?{notation:n}:{},style:{...r}})}function F(e,t){return n=>n.autoLayout(e,t)}function I(...e){return t=>e.reduce((e,t)=>t(e),t)}function L(e){if(!f(e))return e;let t=e=>e;if(e===`*`)return t({wildcard:!0});if(e.startsWith(`->`))return e.endsWith(`->`)?t({inout:L(e.replace(/->/g,``).trim())}):t({incoming:L(e.replace(`-> `,``))});if(e.endsWith(` ->`))return t({outgoing:L(e.replace(` ->`,``))});if(e.includes(` <-> `)){let[n,r]=e.split(` <-> `);return t({source:L(n),target:L(r),isBidirectional:!0})}if(e.includes(` -> `)){let[n,r]=e.split(` -> `);return t({source:L(n),target:L(r)})}return e.endsWith(`._`)?t({ref:{deployment:e.replace(`._`,``)},selector:`expanded`}):e.endsWith(`.**`)?t({ref:{deployment:e.replace(`.**`,``)},selector:`descendants`}):e.endsWith(`.*`)?t({ref:{deployment:e.replace(`.*`,``)},selector:`children`}):t({ref:{deployment:e}})}function R(e){let t={$expr:e._type===`deployment`?L:k,autoLayout(n,r){return e.rules.push(m({direction:n,rankSep:r?.rank,nodeSep:r?.node})),t},exclude(...n){return e.rules.push({exclude:n}),t},include(...n){return e.rules.push({include:n}),t},style(n){return e.rules.push(n),t},get Expr(){throw Error(`Expr is not available in runtime`)},get Types(){throw Error(`Types are not available in runtime`)},get ElementExpr(){throw Error(`ElementExpr is not available in runtime`)},get TypedExpr(){throw Error(`TypedExpr is not available in runtime`)}};return t}function z(e){return t(e)?s(e,e=>({})):e}function B({tags:e,elements:t,deployments:n,relationships:r,...i}){let a={};e&&Object.assign(a,z(e));let o=z(t);for(let[e,t]of l(o))if(t.tags)for(let n of t.tags)E(n in a,`Invalid specification for element kind "${e}": tag "${n}" not found`);let s=z(n??{});for(let[e,t]of l(s))if(t.tags)for(let n of t.tags)E(n in a,`Invalid specification for deployment kind "${e}": tag "${n}" not found`);return{...i,tags:a,elements:o,deployments:s,relationships:z(r??{})}}function V(e){return i(e)?null:typeof e==`string`?{txt:e}:e}function H(t,s=new Map,l=[],f=new Map,g={predicates:{},dynamicPredicates:{},styles:{}},k=new Map,j=[],L=new D.default(()=>new Map)){let z=B(t),U=()=>({elements:structuredClone(z.elements),deployments:structuredClone(z.deployments),relationships:structuredClone(z.relationships),tags:A(structuredClone(z.tags)),...z.metadataKeys?{metadataKeys:z.metadataKeys}:{},customColors:{}}),W=e=>{if(!(!e||!a(e,1)))return o(e,e=>typeof e==`string`?{url:e}:e)},G=(e,t,n)=>{r(t)&&(n=t,t={}),t??={};let{links:i=[],title:a=null,description:o=null,tags:s=[],...c}=typeof t==`string`?{title:t}:{...t},l=W(i);return[m({id:e,title:a,description:V(o),tags:s,links:l,_stage:`parsed`,...c}),n]},K=e=>{let[t,n]=S(e),r=(t?L.get(t):s).get(n);return E(r,`Element with id "${e}" not found`),r},q=e=>{if(typeof e==`string`){let[t,n]=S(e);return t?{project:t,model:n}:{model:n}}return`project`in e||`deployment`in e?e:q(e.model)},J={get Types(){throw Error(`Types are not available in runtime`)},clone:()=>{let e=new D.default(()=>new Map);for(let[t,n]of L)e.set(t,structuredClone(n));return H(structuredClone(z),structuredClone(s),structuredClone(l),structuredClone(f),structuredClone(g),structuredClone(k),structuredClone(j),e)},__addElement:e=>{let[t,n]=S(e.id),r=y(n),i=t?L.get(t):s;if(r&&E(i.get(r),`Parent element with id "${r}" not found for element with id "${e.id}"`),i.has(n))throw Error(`Element with id "${e.id}" already exists`);return i.set(n,t?{...e,id:n}:e),J},__addRelation(e){let t=q(e.source),n=_.flatten(t),r=q(e.target),i=_.flatten(r),a=K(n),o=K(i);if(w(n)&&w(i))throw Error(`Cannot create relationship between global elements`);return!w(n)&&!w(i)&&E(!x(a,o),`Cannot create relationship between elements in the same hierarchy`),l.push({id:`rel${l.length+1}`,...e,source:t,target:r}),J},__fqn(e){return E(e.trim()!==``,`Id must be non-empty`),e},__deploymentFqn(e){return E(e.trim()!==``,`Id must be non-empty`),e},__addSourcelessRelation(){throw Error(`Can be called only in nested model`)},__addView:e=>{if(f.has(e.id))throw Error(`View with id "${e.id}" already exists`);return b(e)&&`viewOf`in e&&E(s.get(e.viewOf),`Invalid scoped view ${e.id}, wlement with id "${e.viewOf}" not found`),f.set(e.id,e),J},__addDeployment:e=>{if(k.has(e.id))throw Error(`Deployment with id "${e.id}" already exists`);let t=y(e.id);return t&&E(k.get(t),`Parent element with id "${t}" not found for node with id "${e.id}"`),h(e)&&(E(t,`Instance ${e.id} of ${e.element} must be deployed under a parent node`),E(s.get(e.element),`Instance "${e.id}" references non-existing element "${e.element}"`)),k.set(e.id,e),J},__addDeploymentRelation:e=>(E(!x(e.source.deployment,e.target.deployment),`Cannot create relationship between elements in the same hierarchy`),E(k.has(e.source.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing source`),E(k.has(e.target.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing target`),j.push({id:`deploy_rel${j.length+1}`,...e}),J),build:e=>({[v]:`parsed`,projectId:typeof e==`string`?e:e?.id??`from-builder`,project:{id:typeof e==`string`?e:`from-builder`,...typeof e==`object`&&e?e:{}},specification:U(),elements:c(structuredClone(Array.from(s.entries()))),relations:p(l,e=>[e.id,structuredClone(e)]),globals:structuredClone(g),deployments:{elements:c(structuredClone(Array.from(k.entries()))),relations:p(j,e=>[e.id,structuredClone(e)])},views:c(structuredClone(Array.from(f.entries()))),imports:d(Array.from(L.entries()),o(([e,t])=>[e,structuredClone([...t.values()])]),u(([e,t])=>t.length>0),c())}),toLikeC4Model:e=>O(J.build(e)),helpers:()=>({model:{model:(...e)=>t=>e.reduce((e,t)=>t(e),t),rel:(t,n,r)=>i=>{let{title:a=``,links:o=[],description:s=null,notes:c=null,...l}=e(typeof r==`string`?{title:r}:{...r},{title:null,links:null}),u=W(o);return i.__addRelation(m({source:{model:t},target:{model:n},title:a,...s&&{description:V(s)},...c&&{notes:V(c)},links:u,...l})),i},relTo:(t,n)=>r=>{let{title:i=``,links:a,description:o=null,notes:s=null,...c}=e(typeof n==`string`?{title:n}:{...n},{title:null,links:null});return r.__addSourcelessRelation(m({target:{model:t},title:i,...o&&{description:V(o)},...s&&{notes:V(s)},links:W(a),...c})),r},...n(z.elements,({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,color:c,shape:l,style:u,title:d,description:f,summary:p,...h}=typeof i==`string`?{title:i}:{...i},g=s??e?.icon,_=W(o),v=a.__fqn(r);return a.__addElement(m({id:v,kind:n,...t,title:d??t.title??C(v),...f&&{description:V(f)},...p&&{summary:V(p)},style:m({icon:g,color:c??e?.color,shape:l??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...u}),..._&&{links:_},...h})),a});return a.with=(...e)=>t=>{a(t);let{__fqn:n,__addSourcelessRelation:i}=t;try{t.__fqn=e=>`${n(r)}.${e}`,t.__addSourcelessRelation=e=>t.__addRelation({...e,source:{model:n(r)}}),e.reduce((e,t)=>t(e),t)}finally{t.__fqn=n,t.__addSourcelessRelation=i}return t},a})},views:{views:(...e)=>t=>e.reduce((e,t)=>t(e),t),view:(e,t,n)=>{let[r,i]=G(e,t,n),a={...r,[T]:`element`,rules:[]},o=e=>(e.__addView(a),i&&i(R(a)),e);return o.with=(...e)=>t=>{o(t);let n=R(a);for(let t of e)t(n);return t},o},viewOf:(e,t,n,r)=>{let[i,a]=G(e,n,r),o={...i,viewOf:t,[T]:`element`,rules:[]},s=e=>(e.__addView(o),a&&a(R(o)),e);return s.with=(...e)=>t=>{s(t);let n=R(o);for(let t of e)t(n);return t},s},deploymentView:(e,t,n)=>{let[r,i]=G(e,t,n),a={...r,[T]:`deployment`,rules:[]},o=e=>(e.__addView(a),i&&i(R(a)),e);return o.with=(...e)=>t=>{o(t);let n=R(a);for(let t of e)t(n);return t},o},$autoLayout:F,$exclude:N,$include:M,$rules:I,$style:P},deployment:{deployment:(...e)=>t=>e.reduce((e,t)=>t(e),t),instanceOf:(e,t,n)=>r=>{i(t)?(t=e,e=C(e)):typeof t==`string`?n??={}:(n=t,t=e,e=C(e));let{links:a,title:o,description:s,summary:c,icon:l,color:u,shape:d,style:f,...p}=typeof n==`string`?{title:n}:{...n},h=r.__deploymentFqn(e);return r.__addDeployment(m({id:h,element:t,...o&&{title:o},...c&&{summary:V(c)},...s&&{description:V(s)},style:m({icon:l,color:u,shape:d,...f}),links:W(a),...p})),r},rel:(e,t,n)=>r=>{let{title:i=null,links:a,description:o=null,notes:s=null,...c}=typeof n==`string`?{title:n}:{...n};return r.__addDeploymentRelation(m({source:{deployment:e},target:{deployment:t},title:i,...o&&{description:V(o)},...s&&{notes:V(s)},links:W(a),...c})),r},...n(z.deployments??{},({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,style:c,title:l,description:u,summary:d,color:f,shape:p,...h}=typeof i==`string`?{title:i}:{...i},g=s??e?.icon,_=W(o),v=a.__deploymentFqn(r);return a.__addDeployment(m({id:v,kind:n,...t,title:l??t.title??C(v),...u&&{description:V(u)},...d&&{summary:V(d)},style:m({icon:g,color:f??e?.color,shape:p??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...c}),..._&&{links:_},...h})),a});return a.with=(...e)=>t=>{a(t);let{__deploymentFqn:n}=t;try{t.__deploymentFqn=e=>`${n(r)}.${e}`,e.reduce((e,t)=>t(e),t)}finally{t.__deploymentFqn=n}return t},a})}}),with:(...e)=>{let t=J.clone();return e.reduce((e,t)=>t(e),t)},model:e=>{let t=J.clone(),n=t.helpers().model,r=n.model;return e({...n,_:r},r)(t)},deployment:e=>{let t=J.clone(),n=t.helpers().deployment,r=n.deployment;return e({...n,_:r},r)(t)},views:e=>{let t=J.clone(),n=t.helpers().views;return e({...n,_:n.views},n.views)(t)}};return J}const U={forSpecification(e){let t=H(e);return{...t.helpers(),builder:t}},specification(e){return H(e)}};export{U as Builder};
@@ -1,8 +1,4 @@
1
1
  import { Dn as ModelExpression, Fr as AnyParsed, Mr as Any, S as ComputedView, Vr as ElementId, Xi as _type, Yi as _stage, _ as ComputedLikeC4ModelData, aa as NonEmptyArray, ai as Unknown, at as ComputedNode, b as ParsedLikeC4ModelData, cn as AnyIncludePredicate, fn as BaseViewProperties, hn as ViewAutoLayout, li as ViewId, mi as toComputed, rt as ComputedEdge, sn as AnyExcludePredicate, w as ParsedView } from "../_chunks/index.mjs";
2
- import "../_chunks/index2.mjs";
3
- import "../_chunks/index3.mjs";
4
- import "../_chunks/libs/mnemonist.mjs";
5
- import "../_chunks/mnemonist.mjs";
6
2
  import { C as ElementModel, T as RelationshipModel, n as LikeC4Model } from "../_chunks/LikeC4Model.mjs";
7
3
  import { B as ViewPredicate } from "../_chunks/_types.mjs";
8
4
  import "../_chunks/index4.mjs";
@@ -1,2 +1,2 @@
1
- import{r as e}from"../_chunks/rolldown-runtime.mjs";import"../_chunks/libs/defu.mjs";import{$ as t,C as n,D as r,K as i,L as a,Q as o,S as s,T as c,X as l,Y as u,b as d,d as f,et as p,i as m,m as h,r as ee,w as te,y as ne}from"../_chunks/libs/remeda.mjs";import{$ as g,_,_t as v,g as y,it as re,st as ie,vt as ae,xt as b}from"../_chunks/types.mjs";import"../_chunks/geometry.mjs";import{$ as x,D as S,I as C,K as w,L as T,Q as E,U as D,_ as O,r as k,v as A,x as j}from"../_chunks/utils.mjs";import{n as M,t as N}from"../_chunks/libs/graphology-dag.mjs";import{t as P}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/ohash.mjs";import"../_chunks/libs/@ungap/structured-clone.mjs";import"../_chunks/libs/hast-util-sanitize.mjs";import"../_chunks/libs/rehype-sanitize.mjs";import"../_chunks/libs/hast-util-to-html.mjs";import"../_chunks/libs/character-entities-legacy.mjs";import"../_chunks/libs/character-entities-html4.mjs";import"../_chunks/libs/ccount.mjs";import"../_chunks/libs/comma-separated-tokens.mjs";import"../_chunks/libs/rehype-stringify.mjs";import"../_chunks/libs/devlop.mjs";import"../_chunks/libs/mdast-util-from-markdown.mjs";import"../_chunks/libs/escape-string-regexp.mjs";import"../_chunks/libs/mdast-util-find-and-replace.mjs";import"../_chunks/libs/mdast-util-gfm.mjs";import"../_chunks/libs/markdown-table.mjs";import"../_chunks/libs/longest-streak.mjs";import"../_chunks/libs/character-entities.mjs";import"../_chunks/libs/decode-named-character-reference.mjs";import"../_chunks/libs/micromark-extension-gfm.mjs";import"../_chunks/libs/remark-gfm.mjs";import"../_chunks/libs/remark-github-blockquote-alert.mjs";import"../_chunks/libs/remark-parse.mjs";import"../_chunks/libs/mdast-util-to-hast.mjs";import"../_chunks/libs/remark-rehype.mjs";import"../_chunks/libs/bail.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/is-plain-obj.mjs";import"../_chunks/libs/trough.mjs";import"../_chunks/libs/unified.mjs";import"../_chunks/libs/@radix-ui/colors.mjs";import"../_chunks/libs/@mantine/colors-generator.mjs";import"../_chunks/model.mjs";import"../_chunks/manual-layout.mjs";import{a as F,c as I,i as L,n as R,o as z,r as B,s as V,t as H}from"../_chunks/Builder.view-element.mjs";import{t as U}from"../_chunks/libs/graphology.mjs";var W=M(),G=e(N(),1);function K(e){let t=new U({type:`directed`}),n=[];for(let r of ee(e))t.addNode(r.id,{view:r}),_(r)&&n.push(r);if(n.length===0)return e;for(let e of n){if(!t.hasNode(e.extends)){console.warn(`View "${e.id}" extends from "${e.extends}" which does not exist`);continue}if((0,G.default)(t,e.id,e.extends)){console.warn(`View "${e.id}" extends from "${e.extends}" which creates a cycle`);continue}t.addDirectedEdge(e.id,e.extends)}return(0,W.topologicalSort)(t).reverse().reduce((e,n)=>{let r=t.getNodeAttribute(n,`view`);if(!_(r))return e[r.id]=r,e;let i=e[r.extends];if(!i||!y(i))return e;let a=m([...i.tags??[],...r.tags??[]]),o=[...i.links??[],...r.links??[]];return e[r.id]={...i,...r,title:r.title??i.title??null,description:r.description??i.description??null,tags:a,links:w(o)?o:null,rules:[...i.rules,...r.rules]},e},{})}function q({edges:e,nodes:t,...n},r=`:`){let i=te(e,e=>[e.id,`${e.source}${r}${e.target}`]);return{...n,edges:e.map(e=>({...e,id:i[e.id]})),nodes:t.map(e=>({...e,inEdges:c(e.inEdges,e=>i[e]),outEdges:c(e.outEdges,e=>i[e])})),nodeIds:t.map(e=>e.id),edgeIds:e.map(e=>i[e.id])}}function oe({views:e,...t}){return{...t,views:n(e,e=>s(q(e),[`nodeIds`,`edgeIds`]))}}const J=e=>r(e).length,Y=e=>k(e);function se(e){let t=ce(e),n=(e,t)=>`${e}->${t}`,r=new P.default(e=>{let[t,n]=e.split(`->`);return{from:t,to:n,relationships:new Set}}),s=(e,t)=>r.get(n(e,t)).relationships,u=(e,t)=>{let n=t.projectId;E(n!==e.projectId,`Imported element must have a different project id`);let r=s(e.projectId,n);for(let n of t.incoming(`direct`))n.source.projectId===e.projectId&&r.add(n);let i=s(n,e.projectId);for(let n of t.outgoing(`direct`))n.target.projectId===e.projectId&&i.add(n)};for(let t of e)if(!a(t.$data.imports))for(let[e,n]of l(t.$data.imports))for(let r of n){let n=g(e,r.id);u(t,x(t.findElement(n),`Element ${r.id} from project ${e} not found in model ${t.projectId}`))}let d=Array.from(r.entries()).filter(([e,{relationships:t}])=>t.size>0).map(([e,{from:t,to:n,relationships:r}])=>{let a=[...r];E(o(a,1),`Relationships set must have at least one relationship`);let s={id:k(e),source:Y(t),target:Y(n),projectId:t,relations:c(a,h(`id`)),label:null,color:`gray`,parent:null,line:`solid`,tags:m(i(a,h(`tags`)))},l=ne(a);return l&&(s.label=l.title,s.description=b(l.$relationship)??null,s.technology=l.technology,s.color=l.color,s.line=l.line,l.kind&&(s.kind=l.kind),l.$relationship.navigateTo&&(s.navigateTo=l.$relationship.navigateTo)),s});I(t,d);let f=V({nodes:t,edges:d});return{id:`projects-view`,[ae]:`projects`,[v]:`computed`,title:`Projects`,description:{txt:`Overview of all projects and their relationships`},autoLayout:{direction:`TB`},...f}}function ce(e){let t=new Map;for(let n of e){let e=re(n.projectId),r={id:Y(e),kind:`@project`,parent:null,projectId:e,title:n.project.title??n.project.id,description:{txt:[`Elements: ${J(n.$data.elements)}`,`Relationships: ${J(n.$data.relations)}`,`Views: ${J(n.$data.views)}`].join(`
2
- `)},shape:`rectangle`,children:[],inEdges:[],outEdges:[],color:`primary`,level:0,style:{},tags:[]};t.set(r.id,r)}return t}function X(e){let n=D([...e]),r=new Set(n),i=new Map,a=new P.default(()=>null),o=n.reduce((e,n,o,s)=>(i.set(n.id,n),e.set(n.id,p(s,t(o+1),u(T(n)),f((e,t)=>(r.delete(t),e.some(C(t))||(e.push(t),a.set(t.id,n)),e),[]))),e),new P.default(()=>[]));return{sorted:n,byId:e=>x(i.get(e),`Element not found by id: ${e}`),root:r,parent:e=>a.get(typeof e==`string`?e:e.id),children:e=>o.get(typeof e==`string`?e:e.id),flatten:d(()=>new Set([...r,...n.reduce((e,t)=>{let n=o.get(t.id);return n.length===0?(e.push(t),e):(n.length>1&&e.push(...n),e)},[])]))}}const Z=(e,t)=>e.size>2&&t.size!==e.size?new Set(D([...X(e).flatten(),...t])):e.size>1?new Set(D([...e])):e;function Q(e,t,n){let r=e=>t.has(e),i=new Set([e]),a={incomers:new Set,subjects:new Set([e]),outgoers:new Set},o=new Set(n.incoming.flatMap(t=>{if(a.subjects.add(t.target),a.incomers.add(t.source),i.add(t.target),t.target!==e){let n=t.target.parent;for(;n&&n!==e;)i.add(n),n=n.parent}let n=t.source,o=[];for(;o.push(n),!(r(n)||!n.parent);)n=n.parent;return o})),s=new Set(n.outgoing.flatMap(t=>{if(a.subjects.add(t.source),a.outgoers.add(t.target),i.add(t.source),t.source!==e){let n=t.source.parent;for(;n&&n!==e;)i.add(n),n=n.parent}let n=t.target,o=[];for(;o.push(n),!(r(n)||!n.parent);)n=n.parent;return o}));return{incomers:Z(o,a.incomers),incoming:new Set(n.incoming),subjects:Z(i,a.subjects),outgoing:new Set(n.outgoing),outgoers:Z(s,a.outgoers)}}function le(e,t,n,r=`global`){let i=n?t.findView(n):null;if(r===`view`)return E(i,`Scope view id is required when scope is "view"`),ue(e,i,t);let a=t.element(e);return Q(a,A(a.ascendingSiblings()),{incoming:[...a.incoming()],outgoing:[...a.outgoing()]})}function ue(e,t,n){let r=n.element(e),i={incoming:O(S(r.incoming(),e=>t.includesRelation(e.id))),outgoing:O(S(r.outgoing(),e=>t.includesRelation(e.id)))},a=T(r);return Q(r,new Set([...r.ascendingSiblings(),...p(t.elements(),j(e=>e.element),S(e=>e!==r&&a(e)))]),i)}function $(e,t){return{...z(e,{id:ie(`adhoc`),_stage:`parsed`,_type:`element`,rules:t,title:null,description:null}),_type:`adhoc`,_stage:`computed`}}var de=class e{static use(t){return new e(t)}#e=[];constructor(e){this.model=e}Expr;include(...e){return this.#e.push({include:e.map(e=>H(e))}),this}exclude(...e){return this.#e.push({exclude:e.map(e=>H(e))}),this}compute(){return $(this.model,this.#e)}};export{de as AdhocView,$ as computeAdhocView,R as computeLikeC4Model,B as computeParsedModelData,se as computeProjectsView,le as computeRelationshipsView,L as computeView,K as resolveRulesExtendedViews,X as treeFromElements,F as unsafeComputeView,oe as viewsWithReadableEdges,q as withReadableEdges};
1
+ import{$ as e,C as t,D as n,K as r,L as i,Q as a,S as o,T as s,X as c,Y as l,b as u,d,et as f,i as p,m,r as h,w as g,y as _}from"../_chunks/libs/remeda.mjs";import{$ as v,Dn as y,Ht as ee,Jt as b,Qt as x,Rt as S,Sn as C,_ as w,_t as T,cn as E,g as D,it as te,mn as O,sn as ne,st as re,vt as k,wt as A,xn as j,zt as M}from"../_chunks/types.mjs";import{t as N}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/model.mjs";import{a as P,c as F,i as I,n as L,o as R,r as z,s as B,t as V}from"../_chunks/Builder.view-element.mjs";import{t as H}from"../_chunks/libs/graphology.mjs";import{n as U,t as W}from"../utils/graphology/index.mjs";function G(e){let t=new H({type:`directed`}),n=[];for(let r of h(e))t.addNode(r.id,{view:r}),w(r)&&n.push(r);if(n.length===0)return e;for(let e of n){if(!t.hasNode(e.extends)){console.warn(`View "${e.id}" extends from "${e.extends}" which does not exist`);continue}if((0,U.default)(t,e.id,e.extends)){console.warn(`View "${e.id}" extends from "${e.extends}" which creates a cycle`);continue}t.addDirectedEdge(e.id,e.extends)}return(0,W.topologicalSort)(t).reverse().reduce((e,n)=>{let r=t.getNodeAttribute(n,`view`);if(!w(r))return e[r.id]=r,e;let i=e[r.extends];if(!i||!D(i))return e;let a=p([...i.tags??[],...r.tags??[]]),o=[...i.links??[],...r.links??[]];return e[r.id]={...i,...r,title:r.title??i.title??null,description:r.description??i.description??null,tags:a,links:x(o)?o:null,rules:[...i.rules,...r.rules]},e},{})}function K({edges:e,nodes:t,...n},r=`:`){let i=g(e,e=>[e.id,`${e.source}${r}${e.target}`]);return{...n,edges:e.map(e=>({...e,id:i[e.id]})),nodes:t.map(e=>({...e,inEdges:s(e.inEdges,e=>i[e]),outEdges:s(e.outEdges,e=>i[e])})),nodeIds:t.map(e=>e.id),edgeIds:e.map(e=>i[e.id])}}function q({views:e,...n}){return{...n,views:t(e,e=>o(K(e),[`nodeIds`,`edgeIds`]))}}const J=e=>n(e).length,Y=e=>A(e);function ie(e){let t=ae(e),n=(e,t)=>`${e}->${t}`,o=new N.default(e=>{let[t,n]=e.split(`->`);return{from:t,to:n,relationships:new Set}}),l=(e,t)=>o.get(n(e,t)).relationships,u=(e,t)=>{let n=t.projectId;j(n!==e.projectId,`Imported element must have a different project id`);let r=l(e.projectId,n);for(let n of t.incoming(`direct`))n.source.projectId===e.projectId&&r.add(n);let i=l(n,e.projectId);for(let n of t.outgoing(`direct`))n.target.projectId===e.projectId&&i.add(n)};for(let t of e)if(!i(t.$data.imports))for(let[e,n]of c(t.$data.imports))for(let r of n){let n=v(e,r.id);u(t,C(t.findElement(n),`Element ${r.id} from project ${e} not found in model ${t.projectId}`))}let d=Array.from(o.entries()).filter(([e,{relationships:t}])=>t.size>0).map(([e,{from:t,to:n,relationships:i}])=>{let o=[...i];j(a(o,1),`Relationships set must have at least one relationship`);let c={id:A(e),source:Y(t),target:Y(n),projectId:t,relations:s(o,m(`id`)),label:null,color:`gray`,parent:null,line:`solid`,tags:p(r(o,m(`tags`)))},l=_(o);return l&&(c.label=l.title,c.description=y(l.$relationship)??null,c.technology=l.technology,c.color=l.color,c.line=l.line,l.kind&&(c.kind=l.kind),l.$relationship.navigateTo&&(c.navigateTo=l.$relationship.navigateTo)),c});F(t,d);let f=B({nodes:t,edges:d});return{id:`projects-view`,[k]:`projects`,[T]:`computed`,title:`Projects`,description:{txt:`Overview of all projects and their relationships`},autoLayout:{direction:`TB`},...f}}function ae(e){let t=new Map;for(let n of e){let e=te(n.projectId),r={id:Y(e),kind:`@project`,parent:null,projectId:e,title:n.project.title??n.project.id,description:{txt:[`Elements: ${J(n.$data.elements)}`,`Relationships: ${J(n.$data.relations)}`,`Views: ${J(n.$data.views)}`].join(`
2
+ `)},shape:`rectangle`,children:[],inEdges:[],outEdges:[],color:`primary`,level:0,style:{},tags:[]};t.set(r.id,r)}return t}function X(t){let n=O([...t]),r=new Set(n),i=new Map,a=new N.default(()=>null),o=n.reduce((t,n,o,s)=>(i.set(n.id,n),t.set(n.id,f(s,e(o+1),l(E(n)),d((e,t)=>(r.delete(t),e.some(ne(t))||(e.push(t),a.set(t.id,n)),e),[]))),t),new N.default(()=>[]));return{sorted:n,byId:e=>C(i.get(e),`Element not found by id: ${e}`),root:r,parent:e=>a.get(typeof e==`string`?e:e.id),children:e=>o.get(typeof e==`string`?e:e.id),flatten:u(()=>new Set([...r,...n.reduce((e,t)=>{let n=o.get(t.id);return n.length===0?(e.push(t),e):(n.length>1&&e.push(...n),e)},[])]))}}const Z=(e,t)=>e.size>2&&t.size!==e.size?new Set(O([...X(e).flatten(),...t])):e.size>1?new Set(O([...e])):e;function Q(e,t,n){let r=e=>t.has(e),i=new Set([e]),a={incomers:new Set,subjects:new Set([e]),outgoers:new Set},o=new Set(n.incoming.flatMap(t=>{if(a.subjects.add(t.target),a.incomers.add(t.source),i.add(t.target),t.target!==e){let n=t.target.parent;for(;n&&n!==e;)i.add(n),n=n.parent}let n=t.source,o=[];for(;o.push(n),!(r(n)||!n.parent);)n=n.parent;return o})),s=new Set(n.outgoing.flatMap(t=>{if(a.subjects.add(t.source),a.outgoers.add(t.target),i.add(t.source),t.source!==e){let n=t.source.parent;for(;n&&n!==e;)i.add(n),n=n.parent}let n=t.target,o=[];for(;o.push(n),!(r(n)||!n.parent);)n=n.parent;return o}));return{incomers:Z(o,a.incomers),incoming:new Set(n.incoming),subjects:Z(i,a.subjects),outgoing:new Set(n.outgoing),outgoers:Z(s,a.outgoers)}}function oe(e,t,n,r=`global`){let i=n?t.findView(n):null;if(r===`view`)return j(i,`Scope view id is required when scope is "view"`),se(e,i,t);let a=t.element(e);return Q(a,M(a.ascendingSiblings()),{incoming:[...a.incoming()],outgoing:[...a.outgoing()]})}function se(e,t,n){let r=n.element(e),i={incoming:S(b(r.incoming(),e=>t.includesRelation(e.id))),outgoing:S(b(r.outgoing(),e=>t.includesRelation(e.id)))},a=E(r);return Q(r,new Set([...r.ascendingSiblings(),...f(t.elements(),ee(e=>e.element),b(e=>e!==r&&a(e)))]),i)}function $(e,t){return{...R(e,{id:re(`adhoc`),_stage:`parsed`,_type:`element`,rules:t,title:null,description:null}),_type:`adhoc`,_stage:`computed`}}var ce=class e{static use(t){return new e(t)}#e=[];constructor(e){this.model=e}Expr;include(...e){return this.#e.push({include:e.map(e=>V(e))}),this}exclude(...e){return this.#e.push({exclude:e.map(e=>V(e))}),this}compute(){return $(this.model,this.#e)}};export{ce as AdhocView,$ as computeAdhocView,L as computeLikeC4Model,z as computeParsedModelData,ie as computeProjectsView,oe as computeRelationshipsView,I as computeView,G as resolveRulesExtendedViews,X as treeFromElements,P as unsafeComputeView,q as viewsWithReadableEdges,K as withReadableEdges};
@@ -1 +1 @@
1
- import"../_chunks/libs/defu.mjs";import"../_chunks/libs/remeda.mjs";import{a as e,i as t,n,o as r,r as i,t as a}from"../_chunks/geometry.mjs";import"../_chunks/utils.mjs";import"../_chunks/libs/graphology-dag.mjs";import"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/ohash.mjs";import"../_chunks/libs/@ungap/structured-clone.mjs";import"../_chunks/libs/hast-util-sanitize.mjs";import"../_chunks/libs/rehype-sanitize.mjs";import"../_chunks/libs/hast-util-to-html.mjs";import"../_chunks/libs/character-entities-legacy.mjs";import"../_chunks/libs/character-entities-html4.mjs";import"../_chunks/libs/ccount.mjs";import"../_chunks/libs/comma-separated-tokens.mjs";import"../_chunks/libs/rehype-stringify.mjs";import"../_chunks/libs/devlop.mjs";import"../_chunks/libs/mdast-util-from-markdown.mjs";import"../_chunks/libs/escape-string-regexp.mjs";import"../_chunks/libs/mdast-util-find-and-replace.mjs";import"../_chunks/libs/mdast-util-gfm.mjs";import"../_chunks/libs/markdown-table.mjs";import"../_chunks/libs/longest-streak.mjs";import"../_chunks/libs/character-entities.mjs";import"../_chunks/libs/decode-named-character-reference.mjs";import"../_chunks/libs/micromark-extension-gfm.mjs";import"../_chunks/libs/remark-gfm.mjs";import"../_chunks/libs/remark-github-blockquote-alert.mjs";import"../_chunks/libs/remark-parse.mjs";import"../_chunks/libs/mdast-util-to-hast.mjs";import"../_chunks/libs/remark-rehype.mjs";import"../_chunks/libs/bail.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/is-plain-obj.mjs";import"../_chunks/libs/trough.mjs";import"../_chunks/libs/unified.mjs";export{i as BBox,t as RectBox,a as Vector,e as convertPoint,r as isPoint,n as vector};
1
+ import{Tn as e,bn as t,bt as n,wn as r,xt as i,yn as a}from"../_chunks/types.mjs";export{a as BBox,t as RectBox,n as Vector,r as convertPoint,e as isPoint,i as vector};
package/dist/index.d.mts CHANGED
@@ -2,7 +2,6 @@ import { $ as LayoutedViewDriftReason, $i as ExclusiveUnion, $n as whereOperator
2
2
  import { a as RectBox, c as XYPoint, i as BBox, l as convertPoint, n as VectorValue, o as Dimensions, r as vector, s as Point, t as Vector, u as isPoint } from "./_chunks/index2.mjs";
3
3
  import { i as LikeC4Styles } from "./_chunks/index3.mjs";
4
4
  import { a as DefaultWeakMap, i as LinkedList, n as MultiMap, o as DefaultMap, r as Queue } from "./_chunks/libs/mnemonist.mjs";
5
- import "./_chunks/mnemonist.mjs";
6
5
  import { o as LayoutedProjectsView, r as ComputedProjectsView } from "./_chunks/_types2.mjs";
7
6
  import { D as isIterable, F as isAncestor, H as sortParentsFirst, I as isDescendantOf, J as nonNullable, L as isSameHierarchy, R as nameFromFqn, V as sortNaturalByFqn, Y as nonexhaustive, k as ancestorsFqn, m as memoizeProp, q as invariant, z as parentFqn } from "./_chunks/index5.mjs";
8
7
 
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import"./_chunks/libs/defu.mjs";import"./_chunks/libs/remeda.mjs";import{$ as e,A as t,C as n,D as r,E as i,G as a,H as o,J as s,K as c,O as l,Q as u,S as d,St as f,T as p,U as m,V as h,W as g,X as _,Y as v,Z as y,_ as b,_t as x,a as S,at as C,b as w,bt as T,c as E,ct as D,d as O,dt as k,et as A,f as j,ft as M,g as N,gt as P,h as F,ht as I,i as L,it as R,j as z,k as B,l as V,lt as H,m as U,mt as W,n as G,nt as K,o as q,ot as J,p as Y,pt as X,q as Z,r as Q,rt as $,s as ee,st as te,t as ne,tt as re,u as ie,ut as ae,v as oe,vt as se,w as ce,x as le,xt as ue,y as de,yt as fe}from"./_chunks/types.mjs";import{i as pe,r as me}from"./_chunks/geometry.mjs";import{$ as he,A as ge,B as _e,G as ve,H as ye,I as be,K as xe,L as Se,O as Ce,Q as we,R as Te,U as Ee,W as De,et as Oe,h as ke,q as Ae,z as je}from"./_chunks/utils.mjs";import"./_chunks/libs/graphology-dag.mjs";import{a as Me,n as Ne,o as Pe,r as Fe,t as Ie}from"./_chunks/libs/mnemonist.mjs";import"./_chunks/libs/natural-compare-lite.mjs";import"./_chunks/libs/ohash.mjs";import"./_chunks/libs/@ungap/structured-clone.mjs";import"./_chunks/libs/hast-util-sanitize.mjs";import"./_chunks/libs/rehype-sanitize.mjs";import"./_chunks/libs/hast-util-to-html.mjs";import"./_chunks/libs/character-entities-legacy.mjs";import"./_chunks/libs/character-entities-html4.mjs";import"./_chunks/libs/ccount.mjs";import"./_chunks/libs/comma-separated-tokens.mjs";import"./_chunks/libs/rehype-stringify.mjs";import"./_chunks/libs/devlop.mjs";import"./_chunks/libs/mdast-util-from-markdown.mjs";import"./_chunks/libs/escape-string-regexp.mjs";import"./_chunks/libs/mdast-util-find-and-replace.mjs";import"./_chunks/libs/mdast-util-gfm.mjs";import"./_chunks/libs/markdown-table.mjs";import"./_chunks/libs/longest-streak.mjs";import"./_chunks/libs/character-entities.mjs";import"./_chunks/libs/decode-named-character-reference.mjs";import"./_chunks/libs/micromark-extension-gfm.mjs";import"./_chunks/libs/remark-gfm.mjs";import"./_chunks/libs/remark-github-blockquote-alert.mjs";import"./_chunks/libs/remark-parse.mjs";import"./_chunks/libs/mdast-util-to-hast.mjs";import"./_chunks/libs/remark-rehype.mjs";import"./_chunks/libs/bail.mjs";import"./_chunks/libs/extend.mjs";import"./_chunks/libs/is-plain-obj.mjs";import"./_chunks/libs/trough.mjs";import"./_chunks/libs/unified.mjs";import"./_chunks/libs/@radix-ui/colors.mjs";import"./_chunks/libs/@mantine/colors-generator.mjs";import{i as Le,n as Re,t as ze}from"./_chunks/manual-layout.mjs";import"./_chunks/assignTagColors.mjs";import"./styles/index.mjs";var Be=Ie.default,Ve=Ne.default,He=Fe.default,Ue=Me.default,We=Pe.default;export{me as BBox,Be as DefaultMap,Ve as DefaultWeakMap,_ as DeploymentFqn,y as EdgeId,c as Expression,u as Fqn,Z as FqnExpr,v as FqnRef,e as GlobalFqn,A as GroupElementKind,z as LikeC4Styles,He as LinkedList,re as MarkdownOrString,m as ModelExpression,g as ModelFqnExpr,a as ModelRelationExpr,Ue as MultiMap,K as NodeId,$ as NoneIcon,R as ProjectId,We as Queue,pe as RectBox,s as RelationExpr,C as RelationId,ne as RichText,J as StepEdgeKind,te as ViewId,P as _layout,x as _stage,se as _type,ge as ancestorsFqn,Le as applyCachedLayout,Re as applyManualLayout,ze as calcDriftsFromSnapshot,t as ensureSizes,f as exact,D as extractStep,H as flattenMarkdownOrString,L as getParallelStepsPrefix,De as hasProp,we as invariant,be as isAncestor,le as isAndOperator,ve as isAnyOf,E as isAutoLayoutDirection,j as isComputedView,h as isDeployedInstance,o as isDeploymentNode,Y as isDeploymentView,Se as isDescendantOf,U as isDiagramView,U as isLayoutedView,S as isDynamicStep,q as isDynamicStepsParallel,ee as isDynamicStepsSeries,F as isDynamicView,N as isElementView,b as isExtendsElementView,ae as isGlobalFqn,k as isGroupElementKind,Ce as isIterable,d as isKindEqual,n as isMetadataEqual,xe as isNonEmptyArray,ce as isNotOperator,fe as isOnStage,p as isOrOperator,i as isParticipantOperator,Te as isSameHierarchy,oe as isScopedElementView,M as isStepEdgeId,Ae as isString,B as isTagColorSpecified,r as isTagEqual,V as isViewRuleAutoLayout,ie as isViewRuleGlobalPredicateRef,O as isViewRuleGlobalStyle,G as isViewRuleGroup,de as isViewRulePredicate,Q as isViewRuleRank,w as isViewRuleStyle,ke as memoizeProp,je as nameFromFqn,he as nonNullable,Oe as nonexhaustive,_e as parentFqn,T as preferDescription,ue as preferSummary,X as scalar,ye as sortNaturalByFqn,Ee as sortParentsFirst,W as splitGlobalFqn,I as stepEdgeId,l as whereOperatorAsPredicate};
1
+ import{$ as e,$t as t,A as ee,C as n,Cn as r,D as i,Dn as a,E as o,En as s,G as c,H as l,It as u,J as d,K as f,O as p,On as m,Q as h,Qt as g,S as _,Sn as v,T as y,U as b,V as x,W as S,X as C,Xt as w,Y as T,Yt as E,Z as D,Zt as O,_ as k,_t as A,a as j,at as M,b as N,bn as P,c as F,cn as I,ct as L,d as R,dn as z,dt as B,et as V,f as H,ft as U,g as W,gt as G,h as K,ht as q,i as J,it as Y,j as X,k as Z,l as Q,ln as te,lt as ne,m as $,mn as re,mt as ie,n as ae,nt as oe,o as se,ot as ce,p as le,pn as ue,pt as de,q as fe,r as pe,rt as me,s as he,sn as ge,st as _e,t as ve,tn as ye,tt as be,u as xe,un as Se,ut as Ce,v as we,vt as Te,w as Ee,x as De,xn as Oe,y as ke,yn as Ae,yt as je}from"./_chunks/types.mjs";import{a as Me,n as Ne,o as Pe,r as Fe,t as Ie}from"./_chunks/libs/mnemonist.mjs";import{i as Le,n as Re,t as ze}from"./_chunks/manual-layout.mjs";import"./styles/index.mjs";var Be=Ie.default,Ve=Ne.default,He=Fe.default,Ue=Me.default,We=Pe.default;export{Ae as BBox,Be as DefaultMap,Ve as DefaultWeakMap,C as DeploymentFqn,D as EdgeId,f as Expression,h as Fqn,fe as FqnExpr,T as FqnRef,e as GlobalFqn,V as GroupElementKind,X as LikeC4Styles,He as LinkedList,be as MarkdownOrString,b as ModelExpression,S as ModelFqnExpr,c as ModelRelationExpr,Ue as MultiMap,oe as NodeId,me as NoneIcon,Y as ProjectId,We as Queue,P as RectBox,d as RelationExpr,M as RelationId,ve as RichText,ce as StepEdgeKind,_e as ViewId,G as _layout,A as _stage,Te as _type,ye as ancestorsFqn,Le as applyCachedLayout,Re as applyManualLayout,ze as calcDriftsFromSnapshot,ee as ensureSizes,m as exact,L as extractStep,ne as flattenMarkdownOrString,J as getParallelStepsPrefix,w as hasProp,Oe as invariant,ge as isAncestor,De as isAndOperator,O as isAnyOf,F as isAutoLayoutDirection,H as isComputedView,x as isDeployedInstance,l as isDeploymentNode,le as isDeploymentView,I as isDescendantOf,$ as isDiagramView,$ as isLayoutedView,j as isDynamicStep,se as isDynamicStepsParallel,he as isDynamicStepsSeries,K as isDynamicView,W as isElementView,k as isExtendsElementView,Ce as isGlobalFqn,B as isGroupElementKind,E as isIterable,_ as isKindEqual,n as isMetadataEqual,g as isNonEmptyArray,Ee as isNotOperator,je as isOnStage,y as isOrOperator,o as isParticipantOperator,te as isSameHierarchy,we as isScopedElementView,U as isStepEdgeId,t as isString,Z as isTagColorSpecified,i as isTagEqual,Q as isViewRuleAutoLayout,xe as isViewRuleGlobalPredicateRef,R as isViewRuleGlobalStyle,ae as isViewRuleGroup,ke as isViewRulePredicate,pe as isViewRuleRank,N as isViewRuleStyle,u as memoizeProp,Se as nameFromFqn,v as nonNullable,r as nonexhaustive,z as parentFqn,s as preferDescription,a as preferSummary,de as scalar,ue as sortNaturalByFqn,re as sortParentsFirst,ie as splitGlobalFqn,q as stepEdgeId,p as whereOperatorAsPredicate};
@@ -1,8 +1,3 @@
1
- import "../_chunks/index.mjs";
2
- import "../_chunks/index2.mjs";
3
- import "../_chunks/index3.mjs";
4
- import "../_chunks/libs/mnemonist.mjs";
5
- import "../_chunks/mnemonist.mjs";
6
1
  import { C as ElementModel, S as NodeModel, T as RelationshipModel, _ as WithMetadata, a as DeploymentNodeModel, b as LikeC4ViewsFolder, d as DeploymentOrFqn, f as EdgeOrId, g as OutgoingFilter, h as NodeOrId, i as DeploymentElementModel, l as RelationshipsAccum, m as IncomingFilter, n as LikeC4Model, o as DeploymentRelationEndpoint, p as ElementOrFqn, r as DeployedInstanceModel, s as DeploymentRelationModel, t as AnyLikeC4Model, u as LikeC4DeploymentModel, v as WithTags, w as AnyRelationshipModel, x as EdgeModel, y as LikeC4ViewModel } from "../_chunks/LikeC4Model.mjs";
7
2
  import { A as sortDeepestFirst, C as hasSameTarget, D as isOutgoing, E as isNestedConnection, M as DeploymentConnectionModel, N as Connection, O as mergeConnections, S as hasSameSourceTarget, T as isIncoming, _ as differenceConnections, a as isDeployedInstanceModel, b as findDescendantConnections, c as isDeploymentRelationModel, d as isLikeC4ViewModel, f as isNestedElementOfDeployedInstanceModel, g as find_d_exports, h as find_d_exports$1, i as normalizeViewPath, j as ConnectionModel, k as sortConnectionsByBoundaryHierarchy, l as isEdgeModel, m as isRelationModel, n as extractViewTitleFromPath, o as isDeploymentElementModel, p as isNodeModel, r as getViewFolderPath, s as isDeploymentNodeModel, t as VIEW_FOLDERS_SEPARATOR, u as isElementModel, v as findAscendingConnections, w as isAnyInOut, x as hasSameSource, y as findDeepestNestedConnection } from "../_chunks/index4.mjs";
8
3
  export { AnyLikeC4Model, AnyRelationshipModel, Connection, ConnectionModel, DeployedInstanceModel, DeploymentConnectionModel, DeploymentElementModel, DeploymentNodeModel, DeploymentOrFqn, DeploymentRelationEndpoint, DeploymentRelationModel, EdgeModel, EdgeOrId, ElementModel, ElementOrFqn, IncomingFilter, LikeC4DeploymentModel, LikeC4Model, LikeC4ViewModel, LikeC4ViewsFolder, NodeModel, NodeOrId, OutgoingFilter, RelationshipModel, RelationshipsAccum, VIEW_FOLDERS_SEPARATOR, WithMetadata, WithTags, find_d_exports as deploymentConnection, differenceConnections, extractViewTitleFromPath, findAscendingConnections, findDeepestNestedConnection, findDescendantConnections, getViewFolderPath, hasSameSource, hasSameSourceTarget, hasSameTarget, isAnyInOut, isDeployedInstanceModel, isDeploymentElementModel, isDeploymentNodeModel, isDeploymentRelationModel, isEdgeModel, isElementModel, isIncoming, isLikeC4ViewModel, isRelationModel as isModelRelation, isRelationModel, isRelationModel as isRelationshipModel, isNestedConnection, isNestedElementOfDeployedInstanceModel, isNodeModel, isOutgoing, mergeConnections, find_d_exports$1 as modelConnection, normalizeViewPath, sortConnectionsByBoundaryHierarchy, sortDeepestFirst };
@@ -1 +1 @@
1
- import"../_chunks/libs/defu.mjs";import"../_chunks/libs/remeda.mjs";import"../_chunks/types.mjs";import"../_chunks/geometry.mjs";import"../_chunks/utils.mjs";import"../_chunks/libs/graphology-dag.mjs";import"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/ohash.mjs";import"../_chunks/libs/@ungap/structured-clone.mjs";import"../_chunks/libs/hast-util-sanitize.mjs";import"../_chunks/libs/rehype-sanitize.mjs";import"../_chunks/libs/hast-util-to-html.mjs";import"../_chunks/libs/character-entities-legacy.mjs";import"../_chunks/libs/character-entities-html4.mjs";import"../_chunks/libs/ccount.mjs";import"../_chunks/libs/comma-separated-tokens.mjs";import"../_chunks/libs/rehype-stringify.mjs";import"../_chunks/libs/devlop.mjs";import"../_chunks/libs/mdast-util-from-markdown.mjs";import"../_chunks/libs/escape-string-regexp.mjs";import"../_chunks/libs/mdast-util-find-and-replace.mjs";import"../_chunks/libs/mdast-util-gfm.mjs";import"../_chunks/libs/markdown-table.mjs";import"../_chunks/libs/longest-streak.mjs";import"../_chunks/libs/character-entities.mjs";import"../_chunks/libs/decode-named-character-reference.mjs";import"../_chunks/libs/micromark-extension-gfm.mjs";import"../_chunks/libs/remark-gfm.mjs";import"../_chunks/libs/remark-github-blockquote-alert.mjs";import"../_chunks/libs/remark-parse.mjs";import"../_chunks/libs/mdast-util-to-hast.mjs";import"../_chunks/libs/remark-rehype.mjs";import"../_chunks/libs/bail.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/is-plain-obj.mjs";import"../_chunks/libs/trough.mjs";import"../_chunks/libs/unified.mjs";import"../_chunks/libs/@radix-ui/colors.mjs";import"../_chunks/libs/@mantine/colors-generator.mjs";import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,M as f,N as p,O as m,P as h,R as g,S as _,T as v,U as y,V as b,W as x,_ as S,a as C,b as w,c as T,g as E,h as D,i as O,k,l as A,m as j,n as M,o as N,p as P,q as F,r as I,s as L,t as R,u as z,v as B,w as V,x as H,y as U,z as W}from"../_chunks/model.mjs";import"../_chunks/manual-layout.mjs";export{f as Connection,D as ConnectionModel,x as DeployedInstanceModel,e as DeploymentConnectionModel,o as DeploymentNodeModel,u as DeploymentRelationModel,d as EdgeModel,l as ElementModel,W as LikeC4DeploymentModel,p as LikeC4Model,a as LikeC4ViewModel,h as LikeC4ViewsFolder,c as NodeModel,g as RelationshipModel,F as RelationshipsAccum,t as VIEW_FOLDERS_SEPARATOR,j as deploymentConnection,E as differenceConnections,b as extractViewTitleFromPath,S as findAscendingConnections,B as findDeepestNestedConnection,U as findDescendantConnections,s as getViewFolderPath,w as hasSameSource,H as hasSameSourceTarget,_ as hasSameTarget,n as isAnyInOut,R as isDeployedInstanceModel,M as isDeploymentElementModel,I as isDeploymentNodeModel,O as isDeploymentRelationModel,C as isEdgeModel,N as isElementModel,V as isIncoming,L as isLikeC4ViewModel,z as isModelRelation,z as isRelationModel,z as isRelationshipModel,v as isNestedConnection,T as isNestedElementOfDeployedInstanceModel,A as isNodeModel,i as isOutgoing,r as mergeConnections,P as modelConnection,y as normalizeViewPath,m as sortConnectionsByBoundaryHierarchy,k as sortDeepestFirst};
1
+ import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,H as s,I as c,J as l,K as u,L as d,M as f,N as p,O as m,P as h,R as g,S as _,T as v,U as y,V as b,W as x,_ as S,a as C,b as w,c as T,g as E,h as D,i as O,k,l as A,m as j,n as M,o as N,p as P,q as F,r as I,s as L,t as R,u as z,v as B,w as V,x as H,y as U,z as W}from"../_chunks/model.mjs";export{f as Connection,D as ConnectionModel,x as DeployedInstanceModel,e as DeploymentConnectionModel,o as DeploymentNodeModel,u as DeploymentRelationModel,d as EdgeModel,l as ElementModel,W as LikeC4DeploymentModel,p as LikeC4Model,a as LikeC4ViewModel,h as LikeC4ViewsFolder,c as NodeModel,g as RelationshipModel,F as RelationshipsAccum,t as VIEW_FOLDERS_SEPARATOR,j as deploymentConnection,E as differenceConnections,b as extractViewTitleFromPath,S as findAscendingConnections,B as findDeepestNestedConnection,U as findDescendantConnections,s as getViewFolderPath,w as hasSameSource,H as hasSameSourceTarget,_ as hasSameTarget,n as isAnyInOut,R as isDeployedInstanceModel,M as isDeploymentElementModel,I as isDeploymentNodeModel,O as isDeploymentRelationModel,C as isEdgeModel,N as isElementModel,V as isIncoming,L as isLikeC4ViewModel,z as isModelRelation,z as isRelationModel,z as isRelationshipModel,v as isNestedConnection,T as isNestedElementOfDeployedInstanceModel,A as isNodeModel,i as isOutgoing,r as mergeConnections,P as modelConnection,y as normalizeViewPath,m as sortConnectionsByBoundaryHierarchy,k as sortDeepestFirst};
@@ -1,4 +1,3 @@
1
1
  import { Ar as Sizes, Cr as ThemeColorValues, Dr as DefaultTagColors, Er as BorderStyles, Or as ElementShapes, Sr as ThemeColor, Tr as isThemeColor, _r as RelationshipLineType, ar as CustomColorDefinitions, br as SpacingSize, cr as HexColor, dr as LikeC4StyleDefaults, fr as LikeC4StylesConfig, gr as RelationshipColorValues, hr as RelationshipArrowTypes, ir as CustomColor, jr as ThemeColors, kr as IconPositions, lr as IconPosition, mr as RelationshipArrowType, nr as Color, or as ElementColorValues, pr as LikeC4Theme, rr as ColorLiteral, sr as ElementShape, tr as BorderStyle, ur as IconSize, vr as ShapeSize, wr as isCustomColor, xr as TextSize, yr as Size } from "../_chunks/index.mjs";
2
- import "../_chunks/index2.mjs";
3
2
  import { a as assignTagColors, i as LikeC4Styles, n as styleDefaults, r as computeColorValues, t as defaultTheme } from "../_chunks/index3.mjs";
4
3
  export { BorderStyle, BorderStyles, Color, ColorLiteral, CustomColor, CustomColorDefinitions, DefaultTagColors, ElementColorValues, ElementShape, ElementShapes, HexColor, IconPosition, IconPositions, IconSize, LikeC4StyleDefaults, LikeC4Styles, LikeC4StylesConfig, LikeC4Theme, RelationshipArrowType, RelationshipArrowTypes, RelationshipColorValues, RelationshipLineType, ShapeSize, Size, Sizes, SpacingSize, TextSize, ThemeColor, ThemeColorValues, ThemeColors, assignTagColors, computeColorValues, defaultTheme, isCustomColor, isThemeColor, styleDefaults };
@@ -1 +1 @@
1
- import"../_chunks/libs/defu.mjs";import"../_chunks/libs/remeda.mjs";import{B as e,F as t,I as n,L as r,M as i,N as a,P as o,R as s,j as c,z as l}from"../_chunks/types.mjs";import"../_chunks/geometry.mjs";import"../_chunks/utils.mjs";import"../_chunks/libs/graphology-dag.mjs";import"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/ohash.mjs";import"../_chunks/libs/@ungap/structured-clone.mjs";import"../_chunks/libs/hast-util-sanitize.mjs";import"../_chunks/libs/rehype-sanitize.mjs";import"../_chunks/libs/hast-util-to-html.mjs";import"../_chunks/libs/character-entities-legacy.mjs";import"../_chunks/libs/character-entities-html4.mjs";import"../_chunks/libs/ccount.mjs";import"../_chunks/libs/comma-separated-tokens.mjs";import"../_chunks/libs/rehype-stringify.mjs";import"../_chunks/libs/devlop.mjs";import"../_chunks/libs/mdast-util-from-markdown.mjs";import"../_chunks/libs/escape-string-regexp.mjs";import"../_chunks/libs/mdast-util-find-and-replace.mjs";import"../_chunks/libs/mdast-util-gfm.mjs";import"../_chunks/libs/markdown-table.mjs";import"../_chunks/libs/longest-streak.mjs";import"../_chunks/libs/character-entities.mjs";import"../_chunks/libs/decode-named-character-reference.mjs";import"../_chunks/libs/micromark-extension-gfm.mjs";import"../_chunks/libs/remark-gfm.mjs";import"../_chunks/libs/remark-github-blockquote-alert.mjs";import"../_chunks/libs/remark-parse.mjs";import"../_chunks/libs/mdast-util-to-hast.mjs";import"../_chunks/libs/remark-rehype.mjs";import"../_chunks/libs/bail.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/is-plain-obj.mjs";import"../_chunks/libs/trough.mjs";import"../_chunks/libs/unified.mjs";import"../_chunks/libs/@radix-ui/colors.mjs";import"../_chunks/libs/@mantine/colors-generator.mjs";import{t as u}from"../_chunks/assignTagColors.mjs";const d=[`none`,`normal`,`onormal`,`dot`,`odot`,`diamond`,`odiamond`,`crow`,`open`,`vee`];function f(t){return e.includes(t)}function p(e){return!f(e)}export{t as BorderStyles,n as DefaultTagColors,r as ElementShapes,s as IconPositions,c as LikeC4Styles,d as RelationshipArrowTypes,l as Sizes,e as ThemeColors,u as assignTagColors,o as computeColorValues,i as defaultTheme,p as isCustomColor,f as isThemeColor,a as styleDefaults};
1
+ import{B as e,F as t,I as n,L as r,M as i,N as a,P as o,R as s,j as c,z as l}from"../_chunks/types.mjs";import{t as u}from"../_chunks/assignTagColors.mjs";const d=[`none`,`normal`,`onormal`,`dot`,`odot`,`diamond`,`odiamond`,`crow`,`open`,`vee`];function f(t){return e.includes(t)}function p(e){return!f(e)}export{t as BorderStyles,n as DefaultTagColors,r as ElementShapes,s as IconPositions,c as LikeC4Styles,d as RelationshipArrowTypes,l as Sizes,e as ThemeColors,u as assignTagColors,o as computeColorValues,i as defaultTheme,p as isCustomColor,f as isThemeColor,a as styleDefaults};