yarramate 1.25.2 → 1.26.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.
- package/README.md +6 -2
- package/dist/adapters/mcp-cli.d.ts +45 -1
- package/dist/adapters/mcp-cli.js +297 -50
- package/dist/adapters/visual/protocol-contract.d.ts +29 -2
- package/dist/adapters/visual/session-server.js +27 -6
- package/dist/adapters/visual/session-store.js +1 -0
- package/dist/adapters/visual/wire.d.ts +18 -0
- package/dist/adapters/visual/workspace-model.js +11 -1
- package/dist/visual-app/assets/{elk.bundled-ZYNFKdcv.js → elk.bundled-CYZFv-C6.js} +1 -1
- package/dist/visual-app/assets/{index-CMqEmjU2.js → index-CRYHv5jy.js} +6 -2
- package/dist/visual-app/assets/index-DdE5s692.css +1 -0
- package/dist/visual-app/index.html +2 -2
- package/dist/visual-app-lib/editor.js +7812 -7485
- package/dist/visual-app-lib/styles.css +1 -1
- package/dist/visual-app-lib/types/adapters/visual/protocol-contract.d.ts +29 -2
- package/dist/visual-app-lib/types/adapters/visual/wire.d.ts +18 -0
- package/dist/visual-app-lib/types/visual-app/App.d.ts +7 -1
- package/dist/visual-app-lib/types/visual-app/context-menu-model.d.ts +36 -0
- package/dist/visual-app-lib/types/visual-app/mount.d.ts +9 -1
- package/dist/visual-app-lib/types/visual-app/open-questions.d.ts +18 -2
- package/dist/visual-app-lib/types/visual-app/question-verbs.d.ts +54 -0
- package/dist/visual-app-lib/types/visual-app/session-client.d.ts +3 -0
- package/dist/visual-app-lib/types/visual-app/state.d.ts +4 -1
- package/dist/visual-app-lib/types/visual-app/workspace-state.d.ts +13 -0
- package/docs/CONSUMING-YARRAMATE.md +17 -5
- package/package.json +1 -1
- package/schema/yarramate-visual-event.schema.json +324 -73
- package/schema/yarramate-visual-response.schema.json +230 -56
- package/skills/yarramate-architecture/SKILL.md +6 -2
- package/skills/yarramate-architecture/references/visual-conversations.md +21 -3
- package/dist/visual-app/assets/index-CJVWkpLt.css +0 -1
|
@@ -326,7 +326,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
326
326
|
${e.picking?`if(outColor.a == 0.0) discard;
|
|
327
327
|
else outColor = vIndex;`:``}
|
|
328
328
|
}
|
|
329
|
-
`);i.aPosition=t.getAttribLocation(i,`aPosition`),i.aIndex=t.getAttribLocation(i,`aIndex`),i.aVertType=t.getAttribLocation(i,`aVertType`),i.aTransform=t.getAttribLocation(i,`aTransform`),i.aAtlasId=t.getAttribLocation(i,`aAtlasId`),i.aTex=t.getAttribLocation(i,`aTex`),i.aPointAPointB=t.getAttribLocation(i,`aPointAPointB`),i.aPointCPointD=t.getAttribLocation(i,`aPointCPointD`),i.aLineWidth=t.getAttribLocation(i,`aLineWidth`),i.aColor=t.getAttribLocation(i,`aColor`),i.aCornerRadius=t.getAttribLocation(i,`aCornerRadius`),i.aBorderColor=t.getAttribLocation(i,`aBorderColor`),i.uPanZoomMatrix=t.getUniformLocation(i,`uPanZoomMatrix`),i.uAtlasSize=t.getUniformLocation(i,`uAtlasSize`),i.uBGColor=t.getUniformLocation(i,`uBGColor`),i.uZoom=t.getUniformLocation(i,`uZoom`),i.uTextures=[];for(var a=0;a<this.batchManager.getMaxAtlasesPerBatch();a++)i.uTextures.push(t.getUniformLocation(i,`uTexture${a}`));return i}},{key:`_createVAO`,value:function(){var e=[0,0,1,0,1,1,0,0,1,1,0,1];this.vertexCount=e.length/2;var t=this.maxInstances,n=this.gl,r=this.program,i=n.createVertexArray();return n.bindVertexArray(i),Xm(n,`vec2`,r.aPosition,e),this.transformBuffer=Qm(n,t,r.aTransform),this.indexBuffer=Zm(n,t,`vec4`,r.aIndex),this.vertTypeBuffer=Zm(n,t,`int`,r.aVertType),this.atlasIdBuffer=Zm(n,t,`int`,r.aAtlasId),this.texBuffer=Zm(n,t,`vec4`,r.aTex),this.pointAPointBBuffer=Zm(n,t,`vec4`,r.aPointAPointB),this.pointCPointDBuffer=Zm(n,t,`vec4`,r.aPointCPointD),this.lineWidthBuffer=Zm(n,t,`vec2`,r.aLineWidth),this.colorBuffer=Zm(n,t,`vec4`,r.aColor),this.cornerRadiusBuffer=Zm(n,t,`vec4`,r.aCornerRadius),this.borderColorBuffer=Zm(n,t,`vec4`,r.aBorderColor),n.bindVertexArray(null),i}},{key:`buffers`,get:function(){var e=this;return this._buffers||=Object.keys(this).filter(function(e){return ye(e,`Buffer`)}).map(function(t){return e[t]}),this._buffers}},{key:`startFrame`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:_h.SCREEN;this.panZoomMatrix=e,this.renderTarget=t,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()}},{key:`startBatch`,value:function(){this.instanceCount=0,this.batchManager.startBatch()}},{key:`endFrame`,value:function(){this.endBatch()}},{key:`_isVisible`,value:function(e,t){return e.visible()?t&&t.isVisible?t.isVisible(e):!0:!1}},{key:`drawTexture`,value:function(e,t,n){var r=this.atlasManager,i=this.batchManager,a=r.getRenderTypeOpts(n);if(this._isVisible(e,a)&&!(e.isEdge()&&!this._isValidEdge(e))){if(this.renderTarget.picking&&a.getTexPickingMode){var o=a.getTexPickingMode(e);if(o===vh.IGNORE)return;if(o==vh.USE_BB){this.drawPickingRectangle(e,t,n);return}}var s=E(r.getAtlasInfo(e,n)),c;try{for(s.s();!(c=s.n()).done;){var l=c.value,u=l.atlas,d=l.tex1,f=l.tex2;i.canAddToCurrentBatch(u)||this.endBatch();for(var p=i.getAtlasIndexForBatch(u),m=0,h=[[d,!0],[f,!1]];m<h.length;m++){var g=M(h[m],2),_=g[0],v=g[1];if(_.w!=0){var y=this.instanceCount;this.vertTypeBuffer.getView(y)[0]=yh,Wm(t,this.indexBuffer.getView(y));var b=this.atlasIdBuffer.getView(y);b[0]=p;var x=this.texBuffer.getView(y);x[0]=_.x,x[1]=_.y,x[2]=_.w,x[3]=_.h;var S=this.transformBuffer.getMatrixView(y);this.setTransformMatrix(e,S,a,l,v),this.instanceCount++,v||this.wrappedCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}catch(e){s.e(e)}finally{s.f()}}}},{key:`setTransformMatrix`,value:function(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=0;if(n.shapeProps&&n.shapeProps.padding&&(a=e.pstyle(n.shapeProps.padding).pfValue),r){var o=r.bb,s=r.tex1,c=r.tex2,l=s.w/(s.w+c.w);i||(l=1-l);var u=this._getAdjustedBB(o,a,i,l);this._applyTransformMatrix(t,u,n,e)}else{var d=n.getBoundingBox(e),f=this._getAdjustedBB(d,a,!0,1);this._applyTransformMatrix(t,f,n,e)}}},{key:`_applyTransformMatrix`,value:function(e,t,n,r){var i,a;nh(e);var o=n.getRotation?n.getRotation(r):0;if(o!==0){var s=n.getRotationPoint(r),c=s.x,l=s.y;ih(e,e,[c,l]),ah(e,e,o);var u=n.getRotationOffset(r);i=u.x+(t.xOffset||0),a=u.y+(t.yOffset||0)}else i=t.x1,a=t.y1;ih(e,e,[i,a]),oh(e,e,[t.w,t.h])}},{key:`_getAdjustedBB`,value:function(e,t,n,r){var i=e.x1,a=e.y1,o=e.w,s=e.h,c=e.yOffset;t&&(i-=t,a-=t,o+=2*t,s+=2*t);var l=0,u=o*r;return n&&r<1?o=u:!n&&r<1&&(l=o-u,i+=l,o=u),{x1:i,y1:a,w:o,h:s,xOffset:l,yOffset:c}}},{key:`drawPickingRectangle`,value:function(e,t,n){var r=this.atlasManager.getRenderTypeOpts(n),i=this.instanceCount;this.vertTypeBuffer.getView(i)[0]=Ch,Wm(t,this.indexBuffer.getView(i)),Um([0,0,0],1,this.colorBuffer.getView(i));var a=this.transformBuffer.getMatrixView(i);this.setTransformMatrix(e,a,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},{key:`drawNode`,value:function(e,t,n){var r=this.simpleShapeOptions.get(n);if(this._isVisible(e,r)){var i=r.shapeProps,a=this._getVertTypeForShape(e,i.shape);if(a===void 0||r.isSimple&&!r.isSimple(e,this.renderTarget)){this.drawTexture(e,t,n);return}var o=this.instanceCount;if(this.vertTypeBuffer.getView(o)[0]=a,a===wh||a===Th){var s=r.getBoundingBox(e),c=this._getCornerRadius(e,i.radius,s),l=this.cornerRadiusBuffer.getView(o);l[0]=c,l[1]=c,l[2]=c,l[3]=c,a===Th&&(l[0]=0,l[2]=0)}Wm(t,this.indexBuffer.getView(o));var u=this.renderTarget.picking?1:n===`node-body`?e.effectiveOpacity():1,d=this.renderTarget.picking?1:e.pstyle(i.opacity).value*u,f=e.pstyle(i.color).value;Um(f,d,this.colorBuffer.getView(o));var p=this.lineWidthBuffer.getView(o);if(p[0]=0,p[1]=0,i.border){var m=e.pstyle(`border-width`).value;if(m>0){var h=e.pstyle(`border-color`).value;Um(h,u*e.pstyle(`border-opacity`).value,this.borderColorBuffer.getView(o));var g=e.pstyle(`border-position`).value;if(g===`inside`)p[0]=0,p[1]=-m;else if(g===`outside`)p[0]=m,p[1]=0;else{var _=m/2;p[0]=_,p[1]=-_}}}var v=this.transformBuffer.getMatrixView(o);this.setTransformMatrix(e,v,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}},{key:`_getVertTypeForShape`,value:function(e,t){switch(e.pstyle(t).value){case`rectangle`:return Ch;case`ellipse`:return Eh;case`roundrectangle`:case`round-rectangle`:return wh;case`bottom-round-rectangle`:return Th;default:return}}},{key:`_getCornerRadius`,value:function(e,t,n){var r=n.w,i=n.h;if(e.pstyle(t).value===`auto`)return $r(r,i);var a=e.pstyle(t).pfValue,o=r/2,s=i/2;return Math.min(a,s,o)}},{key:`drawEdgeArrow`,value:function(e,t,n){if(e.visible()){var r=e._private.rscratch,i,a,o;if(n===`source`?(i=r.arrowStartX,a=r.arrowStartY,o=r.srcArrowAngle):(i=r.arrowEndX,a=r.arrowEndY,o=r.tgtArrowAngle),!(isNaN(i)||i==null||isNaN(a)||a==null||isNaN(o)||o==null)&&e.pstyle(n+`-arrow-shape`).value!==`none`){var s=e.pstyle(n+`-arrow-color`).value,c=e.pstyle(`opacity`).value*e.pstyle(`line-opacity`).value,l=e.pstyle(`width`).pfValue,u=e.pstyle(`arrow-scale`).value,d=this.r.getArrowWidth(l,u),f=this.instanceCount,p=this.transformBuffer.getMatrixView(f);nh(p),ih(p,p,[i,a]),oh(p,p,[d,d]),ah(p,p,o),this.vertTypeBuffer.getView(f)[0]=Sh,Wm(t,this.indexBuffer.getView(f)),Um(s,c,this.colorBuffer.getView(f)),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:`drawEdgeLine`,value:function(e,t){if(e.visible()){var n=this._getEdgePoints(e);if(n){var r=e.pstyle(`opacity`).value,i=e.pstyle(`line-opacity`).value,a=e.pstyle(`width`).pfValue,o=e.pstyle(`line-color`).value,s=r*i;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),n.length==4){var c=this.instanceCount;this.vertTypeBuffer.getView(c)[0]=bh,Wm(t,this.indexBuffer.getView(c)),Um(o,s,this.colorBuffer.getView(c));var l=this.lineWidthBuffer.getView(c);l[0]=a;var u=this.pointAPointBBuffer.getView(c);u[0]=n[0],u[1]=n[1],u[2]=n[2],u[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var d=0;d<n.length-2;d+=2){var f=this.instanceCount;this.vertTypeBuffer.getView(f)[0]=xh,Wm(t,this.indexBuffer.getView(f)),Um(o,s,this.colorBuffer.getView(f));var p=this.lineWidthBuffer.getView(f);p[0]=a;var m=n[d-2],h=n[d-1],g=n[d],_=n[d+1],v=n[d+2],y=n[d+3],b=n[d+4],x=n[d+5];d==0&&(m=2*g-v+.001,h=2*_-y+.001),d==n.length-4&&(b=2*v-g+.001,x=2*y-_+.001);var S=this.pointAPointBBuffer.getView(f);S[0]=m,S[1]=h,S[2]=g,S[3]=_;var C=this.pointCPointDBuffer.getView(f);C[0]=v,C[1]=y,C[2]=b,C[3]=x,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:`_isValidEdge`,value:function(e){var t=e._private.rscratch;return!(t.badLine||t.allpts==null||isNaN(t.allpts[0]))}},{key:`_getEdgePoints`,value:function(e){var t=e._private.rscratch;if(this._isValidEdge(e)){var n=t.allpts;if(n.length==4)return n;var r=this._getNumSegments(e);return this._getCurveSegmentPoints(n,r)}}},{key:`_getNumSegments`,value:function(e){return Math.min(15,this.maxInstances)}},{key:`_getCurveSegmentPoints`,value:function(e,t){if(e.length==4)return e;for(var n=Array((t+1)*2),r=0;r<=t;r++)if(r==0)n[0]=e[0],n[1]=e[1];else if(r==t)n[r*2]=e[e.length-2],n[r*2+1]=e[e.length-1];else{var i=r/t;this._setCurvePoint(e,i,n,r*2)}return n}},{key:`_setCurvePoint`,value:function(e,t,n,r){if(e.length<=2)n[r]=e[0],n[r+1]=e[1];else{for(var i=Array(e.length-2),a=0;a<i.length;a+=2){var o=(1-t)*e[a]+t*e[a+2],s=(1-t)*e[a+1]+t*e[a+3];i[a]=o,i[a+1]=s}return this._setCurvePoint(i,t,n,r)}}},{key:`endBatch`,value:function(){var e=this.gl,t=this.vao,n=this.vertexCount,r=this.instanceCount;if(r!==0){var i=this.renderTarget.picking?this.pickingProgram:this.program;e.useProgram(i),e.bindVertexArray(t);var a=E(this.buffers),o;try{for(a.s();!(o=a.n()).done;)o.value.bufferSubData(r)}catch(e){a.e(e)}finally{a.f()}for(var s=this.batchManager.getAtlases(),c=0;c<s.length;c++)s[c].bufferIfNeeded(e);for(var l=0;l<s.length;l++)e.activeTexture(e.TEXTURE0+l),e.bindTexture(e.TEXTURE_2D,s[l].texture),e.uniform1i(i.uTextures[l],l);e.uniform1f(i.uZoom,zm(this.r)),e.uniformMatrix3fv(i.uPanZoomMatrix,!1,this.panZoomMatrix),e.uniform1i(i.uAtlasSize,this.batchManager.getAtlasSize());var u=Um(this.bgColor,1);e.uniform4fv(i.uBGColor,u),e.drawArraysInstanced(e.TRIANGLES,0,n,r),e.bindVertexArray(null),e.bindTexture(e.TEXTURE_2D,null),this.debug&&this.batchDebugInfo.push({count:r,atlasCount:s.length}),this.startBatch()}}},{key:`getDebugInfo`,value:function(){var e=this.atlasManager.getDebugInfo(),t=e.reduce(function(e,t){return e+t.atlasCount},0),n=this.batchDebugInfo,r=n.reduce(function(e,t){return e+t.count},0);return{atlasInfo:e,totalAtlases:t,wrappedCount:this.wrappedCount,simpleCount:this.simpleCount,batchCount:n.length,batchInfo:n,totalInstances:r}}}])}(),Oh={};Oh.initWebgl=function(e,t){var n=this,r=n.data.contexts[n.WEBGL];e.bgColor=kh(n),e.webglTexSize=Math.min(e.webglTexSize,r.getParameter(r.MAX_TEXTURE_SIZE)),e.webglTexRows=Math.min(e.webglTexRows,54),e.webglTexRowsNodes=Math.min(e.webglTexRowsNodes,54),e.webglBatchSize=Math.min(e.webglBatchSize,16384),e.webglTexPerBatch=Math.min(e.webglTexPerBatch,r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS)),n.webglDebug=e.webglDebug,n.webglDebugShowAtlases=e.webglDebugShowAtlases,n.pickingFrameBuffer=$m(r),n.pickingFrameBuffer.needsDraw=!0,n.drawing=new Dh(n,r,e);var i=function(e){return function(t){return n.getTextAngle(t,e)}},a=function(e){return function(t){var n=t.pstyle(e);return n&&n.value}},o=function(e){return function(t){return t.pstyle(`${e}-opacity`).value>0}},s=function(e){return e.pstyle(`text-events`).strValue===`yes`?vh.USE_BB:vh.IGNORE},c=function(e){var t=e.position(),n=t.x,r=t.y,i=e.outerWidth(),a=e.outerHeight();return{w:i,h:a,x1:n-i/2,y1:r-a/2}};n.drawing.addAtlasCollection(`node`,{texRows:e.webglTexRowsNodes}),n.drawing.addAtlasCollection(`label`,{texRows:e.webglTexRows}),n.drawing.addTextureAtlasRenderType(`node-body`,{collection:`node`,getKey:t.getStyleKey,getBoundingBox:t.getElementBox,drawElement:t.drawElement}),n.drawing.addSimpleShapeRenderType(`node-body`,{getBoundingBox:c,isSimple:Vm,shapeProps:{shape:`shape`,color:`background-color`,opacity:`background-opacity`,radius:`corner-radius`,border:!0}}),n.drawing.addSimpleShapeRenderType(`node-overlay`,{getBoundingBox:c,isVisible:o(`overlay`),shapeProps:{shape:`overlay-shape`,color:`overlay-color`,opacity:`overlay-opacity`,padding:`overlay-padding`,radius:`overlay-corner-radius`}}),n.drawing.addSimpleShapeRenderType(`node-underlay`,{getBoundingBox:c,isVisible:o(`underlay`),shapeProps:{shape:`underlay-shape`,color:`underlay-color`,opacity:`underlay-opacity`,padding:`underlay-padding`,radius:`underlay-corner-radius`}}),n.drawing.addTextureAtlasRenderType(`label`,{collection:`label`,getTexPickingMode:s,getKey:jh(t.getLabelKey,null),getBoundingBox:Mh(t.getLabelBox,null),drawClipped:!0,drawElement:t.drawLabel,getRotation:i(null),getRotationPoint:t.getLabelRotationPoint,getRotationOffset:t.getLabelRotationOffset,isVisible:a(`label`)}),n.drawing.addTextureAtlasRenderType(`edge-source-label`,{collection:`label`,getTexPickingMode:s,getKey:jh(t.getSourceLabelKey,`source`),getBoundingBox:Mh(t.getSourceLabelBox,`source`),drawClipped:!0,drawElement:t.drawSourceLabel,getRotation:i(`source`),getRotationPoint:t.getSourceLabelRotationPoint,getRotationOffset:t.getSourceLabelRotationOffset,isVisible:a(`source-label`)}),n.drawing.addTextureAtlasRenderType(`edge-target-label`,{collection:`label`,getTexPickingMode:s,getKey:jh(t.getTargetLabelKey,`target`),getBoundingBox:Mh(t.getTargetLabelBox,`target`),drawClipped:!0,drawElement:t.drawTargetLabel,getRotation:i(`target`),getRotationPoint:t.getTargetLabelRotationPoint,getRotationOffset:t.getTargetLabelRotationOffset,isVisible:a(`target-label`)});var l=Dt(function(){console.log(`garbage collect flag set`),n.data.gc=!0},1e4);n.onUpdateEleCalcs(function(e,t){var r=!1;t&&t.length>0&&(r|=n.drawing.invalidate(t)),r&&l()}),Nh(n)};function kh(e){var t=e.cy.container();return Ne(t&&t.style&&t.style.backgroundColor||`white`)}function Ah(e,t){var n=e._private.rscratch;return _n(n,`labelWrapCachedLines`,t)||[]}var jh=function(e,t){return function(n){var r=e(n),i=Ah(n,t);return i.length>1?i.map(function(e,t){return`${r}_${t}`}):r}},Mh=function(e,t){return function(n,r){var i=e(n);if(typeof r==`string`){var a=r.indexOf(`_`);if(a>0){var o=Number(r.substring(a+1)),s=Ah(n,t),c=i.h/s.length,l=c*o,u=i.y1+l;return{x1:i.x1,w:i.w,y1:u,h:c,yOffset:l}}}return i}};function Nh(e){var t=e.render;e.render=function(n){n||={};var r=e.cy;e.webgl&&(r.zoom()>Dp?(Ph(e),t.call(e,n)):(Fh(e),Wh(e,n,_h.SCREEN)))};var n=e.matchCanvasSize;e.matchCanvasSize=function(t){n.call(e,t),e.pickingFrameBuffer.setFramebufferAttachmentSizes(e.canvasWidth,e.canvasHeight),e.pickingFrameBuffer.needsDraw=!0},e.findNearestElements=function(t,n,r,i){return Hh(e,t,n)};var r=e.invalidateCachedZSortedEles;e.invalidateCachedZSortedEles=function(){r.call(e),e.pickingFrameBuffer.needsDraw=!0};var i=e.notify;e.notify=function(t,n){i.call(e,t,n),t===`viewport`||t===`bounds`?e.pickingFrameBuffer.needsDraw=!0:t===`background`&&e.drawing.invalidate(n,{type:`node-body`})}}function Ph(e){var t=e.data.contexts[e.WEBGL];t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)}function Fh(e){var t=function(t){t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.canvasWidth,e.canvasHeight),t.restore()};t(e.data.contexts[e.NODE]),t(e.data.contexts[e.DRAG])}function Ih(e){var t=e.canvasWidth,n=e.canvasHeight,r=Rm(e),i=r.pan,a=r.zoom,o=th();ih(o,o,[i.x,i.y]),oh(o,o,[a,a]);var s=th();sh(s,t,n);var c=th();return rh(c,s,o),c}function Lh(e,t){var n=e.canvasWidth,r=e.canvasHeight,i=Rm(e),a=i.pan,o=i.zoom;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,n,r),t.translate(a.x,a.y),t.scale(o,o)}function Rh(e,t){e.drawSelectionRectangle(t,function(t){return Lh(e,t)})}function zh(e){var t=e.data.contexts[e.NODE];t.save(),Lh(e,t),t.strokeStyle=`rgba(0, 0, 0, 0.3)`,t.beginPath(),t.moveTo(-1e3,0),t.lineTo(1e3,0),t.stroke(),t.beginPath(),t.moveTo(0,-1e3),t.lineTo(0,1e3),t.stroke(),t.restore()}function Bh(e){var t=function(t,n,r){for(var i=t.atlasManager.getAtlasCollection(n),a=e.data.contexts[e.NODE],o=i.atlases,s=0;s<o.length;s++){var c=o[s].canvas;if(c){var l=c.width,u=c.height,d=l*s,f=c.height*r,p=.4;a.save(),a.scale(p,p),a.drawImage(c,d,f),a.strokeStyle=`black`,a.rect(d,f,l,u),a.stroke(),a.restore()}}},n=0;t(e.drawing,`node`,n++),t(e.drawing,`label`,n++)}function Vh(e,t,n,r,i){var a,o,s,c,l=Rm(e),u=l.pan,d=l.zoom,f=M(Bm(e,u,d,t,n),2),p=f[0],m=f[1],h=6;if(a=p-h/2,o=m-h/2,s=h,c=h,s===0||c===0)return[];var g=e.data.contexts[e.WEBGL];g.bindFramebuffer(g.FRAMEBUFFER,e.pickingFrameBuffer),e.pickingFrameBuffer.needsDraw&&(g.viewport(0,0,g.canvas.width,g.canvas.height),Wh(e,null,_h.PICKING),e.pickingFrameBuffer.needsDraw=!1);var _=s*c,v=new Uint8Array(_*4);g.readPixels(a,o,s,c,g.RGBA,g.UNSIGNED_BYTE,v),g.bindFramebuffer(g.FRAMEBUFFER,null);for(var y=new Set,b=0;b<_;b++){var x=Gm(v.slice(b*4,b*4+4))-1;x>=0&&y.add(x)}return y}function Hh(e,t,n){var r=Vh(e,t,n),i=e.getCachedZSortedEles(),a,o,s=E(r),c;try{for(s.s();!(c=s.n()).done;){var l=i[c.value];if(!a&&l.isNode()&&(a=l),!o&&l.isEdge()&&(o=l),a&&o)break}}catch(e){s.e(e)}finally{s.f()}return[a,o].filter(Boolean)}function Uh(e,t,n){var r=e.drawing;t+=1,n.isNode()?(r.drawNode(n,t,`node-underlay`),r.drawNode(n,t,`node-body`),r.drawTexture(n,t,`label`),r.drawNode(n,t,`node-overlay`)):(r.drawEdgeLine(n,t),r.drawEdgeArrow(n,t,`source`),r.drawEdgeArrow(n,t,`target`),r.drawTexture(n,t,`label`),r.drawTexture(n,t,`edge-source-label`),r.drawTexture(n,t,`edge-target-label`))}function Wh(e,t,n){var r;e.webglDebug&&(r=performance.now());var i=e.drawing,a=0;if(n.screen&&e.data.canvasNeedsRedraw[e.SELECT_BOX]&&Rh(e,t),e.data.canvasNeedsRedraw[e.NODE]||n.picking){var o=e.data.contexts[e.WEBGL];n.screen?(o.clearColor(0,0,0,0),o.enable(o.BLEND),o.blendFunc(o.ONE,o.ONE_MINUS_SRC_ALPHA)):o.disable(o.BLEND),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),o.viewport(0,0,o.canvas.width,o.canvas.height);var s=Ih(e),c=e.getCachedZSortedEles();if(a=c.length,i.startFrame(s,n),n.screen){for(var l=0;l<c.nondrag.length;l++)Uh(e,l,c.nondrag[l]);for(var u=0;u<c.drag.length;u++)Uh(e,u,c.drag[u])}else if(n.picking)for(var d=0;d<c.length;d++)Uh(e,d,c[d]);i.endFrame(),n.screen&&e.webglDebugShowAtlases&&(zh(e),Bh(e)),e.data.canvasNeedsRedraw[e.NODE]=!1,e.data.canvasNeedsRedraw[e.DRAG]=!1}if(e.webglDebug){var f=performance.now(),p=Math.ceil(f-r),m=i.getDebugInfo(),h=[`${a} elements`,`${m.totalInstances} instances`,`${m.batchCount} batches`,`${m.totalAtlases} atlases`,`${m.wrappedCount} wrapped textures`,`${m.simpleCount} simple shapes`].join(`, `);console.log(`WebGL (${n.name}) - frame time ${p}ms`),console.log(`Totals:`),console.log(` ${h}`),console.log(`Texture Atlases Used:`);var g=m.atlasInfo,_=E(g),v;try{for(_.s();!(v=_.n()).done;){var y=v.value;console.log(` ${y.type}: ${y.keyCount} keys, ${y.atlasCount} atlases`)}}catch(e){_.e(e)}finally{_.f()}console.log(``)}e.data.gc&&(console.log(`Garbage Collect!`),e.data.gc=!1,i.gc())}var Gh={};Gh.drawPolygonPath=function(e,t,n,r,i,a){var o=r/2,s=i/2;e.beginPath&&e.beginPath(),e.moveTo(t+o*a[0],n+s*a[1]);for(var c=1;c<a.length/2;c++)e.lineTo(t+o*a[c*2],n+s*a[c*2+1]);e.closePath()},Gh.drawRoundPolygonPath=function(e,t,n,r,i,a,o){o.forEach(function(t){return Gf(e,t)}),e.closePath()},Gh.drawRoundRectanglePath=function(e,t,n,r,i,a){var o=r/2,s=i/2,c=a===`auto`?$r(r,i):Math.min(a,s,o);e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.arcTo(t+o,n-s,t+o,n,c),e.arcTo(t+o,n+s,t,n+s,c),e.arcTo(t-o,n+s,t-o,n,c),e.arcTo(t-o,n-s,t,n-s,c),e.lineTo(t,n-s),e.closePath()},Gh.drawBottomRoundRectanglePath=function(e,t,n,r,i,a){var o=r/2,s=i/2,c=a===`auto`?$r(r,i):a;e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.lineTo(t+o,n-s),e.lineTo(t+o,n),e.arcTo(t+o,n+s,t,n+s,c),e.arcTo(t-o,n+s,t-o,n,c),e.lineTo(t-o,n-s),e.lineTo(t,n-s),e.closePath()},Gh.drawCutRectanglePath=function(e,t,n,r,i,a,o){var s=r/2,c=i/2,l=o===`auto`?ti():o;e.beginPath&&e.beginPath(),e.moveTo(t-s+l,n-c),e.lineTo(t+s-l,n-c),e.lineTo(t+s,n-c+l),e.lineTo(t+s,n+c-l),e.lineTo(t+s-l,n+c),e.lineTo(t-s+l,n+c),e.lineTo(t-s,n+c-l),e.lineTo(t-s,n-c+l),e.closePath()},Gh.drawBarrelPath=function(e,t,n,r,i){var a=r/2,o=i/2,s=t-a,c=t+a,l=n-o,u=n+o,d=ri(r,i),f=d.widthOffset,p=d.heightOffset,m=d.ctrlPtOffsetPct*f;e.beginPath&&e.beginPath(),e.moveTo(s,l+p),e.lineTo(s,u-p),e.quadraticCurveTo(s+m,u,s+f,u),e.lineTo(c-f,u),e.quadraticCurveTo(c-m,u,c,u-p),e.lineTo(c,l+p),e.quadraticCurveTo(c-m,l,c-f,l),e.lineTo(s+f,l),e.quadraticCurveTo(s+m,l,s,l+p),e.closePath()};for(var Kh=Math.sin(0),qh=Math.cos(0),Jh={},Yh={},Xh=Math.PI/40,Zh=0*Math.PI;Zh<2*Math.PI;Zh+=Xh)Jh[Zh]=Math.sin(Zh),Yh[Zh]=Math.cos(Zh);Gh.drawEllipsePath=function(e,t,n,r,i){if(e.beginPath&&e.beginPath(),e.ellipse)e.ellipse(t,n,r/2,i/2,0,0,2*Math.PI);else for(var a,o,s=r/2,c=i/2,l=0*Math.PI;l<2*Math.PI;l+=Xh)a=t-s*Jh[l]*Kh+s*Yh[l]*qh,o=n+c*Yh[l]*Kh+c*Jh[l]*qh,l===0?e.moveTo(a,o):e.lineTo(a,o);e.closePath()};var Qh={};Qh.createBuffer=function(e,t){var n=document.createElement(`canvas`);return n.width=e,n.height=t,[n,n.getContext(`2d`)]},Qh.bufferCanvasImage=function(e){var t=this.cy,n=t.mutableElements().boundingBox(),r=this.findContainerClientCoords(),i=e.full?Math.ceil(n.w):r[2],a=e.full?Math.ceil(n.h):r[3],o=Y(e.maxWidth)||Y(e.maxHeight),s=this.getPixelRatio(),c=1;if(e.scale!==void 0)i*=e.scale,a*=e.scale,c=e.scale;else if(o){var l=1/0,u=1/0;Y(e.maxWidth)&&(l=c*e.maxWidth/i),Y(e.maxHeight)&&(u=c*e.maxHeight/a),c=Math.min(l,u),i*=c,a*=c}o||(i*=s,a*=s,c*=s);var d=document.createElement(`canvas`);d.width=i,d.height=a,d.style.width=i+`px`,d.style.height=a+`px`;var f=d.getContext(`2d`);if(i>0&&a>0){f.clearRect(0,0,i,a),f.globalCompositeOperation=`source-over`;var p=this.getCachedZSortedEles();if(e.full)f.translate(-n.x1*c,-n.y1*c),f.scale(c,c),this.drawElements(f,p),f.scale(1/c,1/c),f.translate(n.x1*c,n.y1*c);else{var m=t.pan(),h={x:m.x*c,y:m.y*c};c*=t.zoom(),f.translate(h.x,h.y),f.scale(c,c),this.drawElements(f,p),f.scale(1/c,1/c),f.translate(-h.x,-h.y)}e.bg&&(f.globalCompositeOperation=`destination-over`,f.fillStyle=e.bg,f.rect(0,0,i,a),f.fill())}return d};function $h(e,t){for(var n=atob(e),r=new ArrayBuffer(n.length),i=new Uint8Array(r),a=0;a<n.length;a++)i[a]=n.charCodeAt(a);return new Blob([r],{type:t})}function eg(e){var t=e.indexOf(`,`);return e.substr(t+1)}function tg(e,t,n){var r=function(){return t.toDataURL(n,e.quality)};switch(e.output){case`blob-promise`:return new Pa(function(r,i){try{t.toBlob(function(e){e==null?i(Error("`canvas.toBlob()` sent a null value in its callback")):r(e)},n,e.quality)}catch(e){i(e)}});case`blob`:return $h(eg(r()),n);case`base64`:return eg(r());default:return r()}}Qh.png=function(e){return tg(e,this.bufferCanvasImage(e),`image/png`)},Qh.jpg=function(e){return tg(e,this.bufferCanvasImage(e),`image/jpeg`)};var ng={};ng.nodeShapeImpl=function(e,t,n,r,i,a,o,s){switch(e){case`ellipse`:return this.drawEllipsePath(t,n,r,i,a);case`polygon`:return this.drawPolygonPath(t,n,r,i,a,o);case`round-polygon`:return this.drawRoundPolygonPath(t,n,r,i,a,o,s);case`roundrectangle`:case`round-rectangle`:return this.drawRoundRectanglePath(t,n,r,i,a,s);case`cutrectangle`:case`cut-rectangle`:return this.drawCutRectanglePath(t,n,r,i,a,o,s);case`bottomroundrectangle`:case`bottom-round-rectangle`:return this.drawBottomRoundRectanglePath(t,n,r,i,a,s);case`barrel`:return this.drawBarrelPath(t,n,r,i,a)}};var rg=ag,ig=ag.prototype;ig.CANVAS_LAYERS=3,ig.SELECT_BOX=0,ig.DRAG=1,ig.NODE=2,ig.WEBGL=3,ig.CANVAS_TYPES=[`2d`,`2d`,`2d`,`webgl2`],ig.BUFFER_COUNT=3,ig.TEXTURE_BUFFER=0,ig.MOTIONBLUR_BUFFER_NODE=1,ig.MOTIONBLUR_BUFFER_DRAG=2;function ag(e){var t=this,n=t.cy.window().document;e.webgl&&(ig.CANVAS_LAYERS=t.CANVAS_LAYERS=4,console.log(`webgl rendering enabled`)),t.data={canvases:Array(ig.CANVAS_LAYERS),contexts:Array(ig.CANVAS_LAYERS),canvasNeedsRedraw:Array(ig.CANVAS_LAYERS),bufferCanvases:Array(ig.BUFFER_COUNT),bufferContexts:Array(ig.CANVAS_LAYERS)};var r=`-webkit-tap-highlight-color`,i=`rgba(0,0,0,0)`;t.data.canvasContainer=n.createElement(`div`);var a=t.data.canvasContainer.style;t.data.canvasContainer.style[r]=i,a.position=`relative`,a.zIndex=`0`,a.overflow=`hidden`;var o=e.cy.container();o.appendChild(t.data.canvasContainer),o.style[r]=i;var s={"-webkit-user-select":`none`,"-moz-user-select":`-moz-none`,"user-select":`none`,"-webkit-tap-highlight-color":`rgba(0,0,0,0)`,"outline-style":`none`};pe()&&(s[`-ms-touch-action`]=`none`,s[`touch-action`]=`none`);for(var c=0;c<ig.CANVAS_LAYERS;c++){var l=t.data.canvases[c]=n.createElement(`canvas`),u=ig.CANVAS_TYPES[c];t.data.contexts[c]=l.getContext(u),t.data.contexts[c]||rn(`Could not create canvas of type `+u),Object.keys(s).forEach(function(e){l.style[e]=s[e]}),l.style.position=`absolute`,l.setAttribute(`data-id`,`layer`+c),l.style.zIndex=String(ig.CANVAS_LAYERS-c),t.data.canvasContainer.appendChild(l),t.data.canvasNeedsRedraw[c]=!1}t.data.topCanvas=t.data.canvases[0],t.data.canvases[ig.NODE].setAttribute(`data-id`,`layer`+ig.NODE+`-node`),t.data.canvases[ig.SELECT_BOX].setAttribute(`data-id`,`layer`+ig.SELECT_BOX+`-selectbox`),t.data.canvases[ig.DRAG].setAttribute(`data-id`,`layer`+ig.DRAG+`-drag`),t.data.canvases[ig.WEBGL]&&t.data.canvases[ig.WEBGL].setAttribute(`data-id`,`layer`+ig.WEBGL+`-webgl`);for(var c=0;c<ig.BUFFER_COUNT;c++)t.data.bufferCanvases[c]=n.createElement(`canvas`),t.data.bufferContexts[c]=t.data.bufferCanvases[c].getContext(`2d`),t.data.bufferCanvases[c].style.position=`absolute`,t.data.bufferCanvases[c].setAttribute(`data-id`,`buffer`+c),t.data.bufferCanvases[c].style.zIndex=String(-c-1),t.data.bufferCanvases[c].style.visibility=`hidden`;t.pathsEnabled=!0;var d=mr(),f=function(e){return{x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2}},p=function(e){return{x:-e.w/2,y:-e.h/2}},m=function(e){var t=e[0]._private;return t.oldBackgroundTimestamp!==t.backgroundTimestamp},h=function(e){return e[0]._private.nodeKey},g=function(e){return e[0]._private.labelStyleKey},_=function(e){return e[0]._private.sourceLabelStyleKey},v=function(e){return e[0]._private.targetLabelStyleKey},y=function(e,n,r,i,a){return t.drawElement(e,n,r,!1,!1,a)},b=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,`main`,a)},x=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,`source`,a)},S=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,`target`,a)},C=function(e){return e.boundingBox(),e[0]._private.bodyBounds},w=function(e){return e.boundingBox(),e[0]._private.labelBounds.main||d},T=function(e){return e.boundingBox(),e[0]._private.labelBounds.source||d},E=function(e){return e.boundingBox(),e[0]._private.labelBounds.target||d},D=function(e,t){return t},O=function(e){return f(C(e))},k=function(e,t,n){var r=e?e+`-`:``;return{x:t.x+n.pstyle(r+`text-margin-x`).pfValue,y:t.y+n.pstyle(r+`text-margin-y`).pfValue}},A=function(e,t,n){var r=e[0]._private.rscratch;return{x:r[t],y:r[n]}},j=function(e){return k(``,A(e,`labelX`,`labelY`),e)},M=function(e){return k(`source`,A(e,`sourceLabelX`,`sourceLabelY`),e)},N=function(e){return k(`target`,A(e,`targetLabelX`,`targetLabelY`),e)},P=function(e){return p(C(e))},F=function(e){return p(T(e))},I=function(e){return p(E(e))},L=function(e){var t=w(e),n=p(w(e));if(e.isNode()){switch(wl(e.pstyle(`text-halign`).value)){case`left`:n.x=-t.w-(t.leftPad||0);break;case`right`:n.x=-(t.rightPad||0)}switch(Tl(e.pstyle(`text-valign`).value)){case`top`:n.y=-t.h-(t.topPad||0);break;case`bottom`:n.y=-(t.botPad||0)}}return n},R=t.data.eleTxrCache=new Up(t,{getKey:h,doesEleInvalidateKey:m,drawElement:y,getBoundingBox:C,getRotationPoint:O,getRotationOffset:P,allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),z=t.data.lblTxrCache=new Up(t,{getKey:g,drawElement:b,getBoundingBox:w,getRotationPoint:j,getRotationOffset:L,isVisible:D}),B=t.data.slbTxrCache=new Up(t,{getKey:_,drawElement:x,getBoundingBox:T,getRotationPoint:M,getRotationOffset:F,isVisible:D}),V=t.data.tlbTxrCache=new Up(t,{getKey:v,drawElement:S,getBoundingBox:E,getRotationPoint:N,getRotationOffset:I,isVisible:D}),H=t.data.lyrTxrCache=new om(t);t.onUpdateEleCalcs(function(e,t){R.invalidateElements(t),z.invalidateElements(t),B.invalidateElements(t),V.invalidateElements(t),H.invalidateElements(t);for(var n=0;n<t.length;n++){var r=t[n]._private;r.oldBackgroundTimestamp=r.backgroundTimestamp}});var U=function(e){for(var t=0;t<e.length;t++)H.enqueueElementRefinement(e[t].ele)};R.onDequeue(U),z.onDequeue(U),B.onDequeue(U),V.onDequeue(U),e.webgl&&t.initWebgl(e,{getStyleKey:h,getLabelKey:g,getSourceLabelKey:_,getTargetLabelKey:v,drawElement:y,drawLabel:b,drawSourceLabel:x,drawTargetLabel:S,getElementBox:C,getLabelBox:w,getSourceLabelBox:T,getTargetLabelBox:E,getElementRotationPoint:O,getElementRotationOffset:P,getLabelRotationPoint:j,getSourceLabelRotationPoint:M,getTargetLabelRotationPoint:N,getLabelRotationOffset:L,getSourceLabelRotationOffset:F,getTargetLabelRotationOffset:I})}ig.redrawHint=function(e,t){var n=this;switch(e){case`eles`:n.data.canvasNeedsRedraw[ig.NODE]=t;break;case`drag`:n.data.canvasNeedsRedraw[ig.DRAG]=t;break;case`select`:n.data.canvasNeedsRedraw[ig.SELECT_BOX]=t;break;case`gc`:n.data.gc=!0}};var og=typeof Path2D<`u`;ig.path2dEnabled=function(e){if(e===void 0)return this.pathsEnabled;this.pathsEnabled=!!e},ig.usePaths=function(){return og&&this.pathsEnabled},ig.setImgSmoothing=function(e,t){e.imageSmoothingEnabled==null?(e.webkitImageSmoothingEnabled=t,e.mozImageSmoothingEnabled=t,e.msImageSmoothingEnabled=t):e.imageSmoothingEnabled=t},ig.getImgSmoothing=function(e){return e.imageSmoothingEnabled==null?e.webkitImageSmoothingEnabled||e.mozImageSmoothingEnabled||e.msImageSmoothingEnabled:e.imageSmoothingEnabled},ig.makeOffscreenCanvas=function(e,t){var n;return(typeof OffscreenCanvas>`u`?`undefined`:I(OffscreenCanvas))===`undefined`?(n=this.cy.window().document.createElement(`canvas`),n.width=e,n.height=t):n=new OffscreenCanvas(e,t),n},[um,_m,wm,Em,Dm,Am,Mm,Oh,Gh,Qh,ng].forEach(function(e){X(ig,e)});var sg=[{type:`layout`,extensions:gf},{type:`renderer`,extensions:[{name:`null`,impl:_f},{name:`base`,impl:vp},{name:`canvas`,impl:rg}]}],cg={},lg={};function ug(e,t,n){var r=n,i=function(n){on("Can not register `"+t+"` for `"+e+"` since `"+n+"` already exists in the prototype and can not be overridden")};if(e===`core`){if(Dd.prototype[t])return i(t);Dd.prototype[t]=n}else if(e===`collection`){if(Hu.prototype[t])return i(t);Hu.prototype[t]=n}else if(e===`layout`){for(var a=function(e){this.options=e,n.call(this,e),J(this._private)||(this._private={}),this._private.cy=e.cy,this._private.listeners=[],this.createEmitter()},o=a.prototype=Object.create(n.prototype),s=[],c=0;c<s.length;c++){var l=s[c];o[l]=o[l]||function(){return this}}o.start&&!o.run?o.run=function(){return this.start(),this}:!o.start&&o.run&&(o.start=function(){return this.run(),this});var u=n.prototype.stop;o.stop=function(){var e=this.options;if(e&&e.animate){var t=this.animations;if(t)for(var n=0;n<t.length;n++)t[n].stop()}return u?u.call(this):this.emit(`layoutstop`),this},o.destroy||=function(){return this},o.cy=function(){return this._private.cy};var d=function(e){return e._private.cy},f={addEventFields:function(e,t){t.layout=e,t.cy=d(e),t.target=e},bubble:function(){return!0},parent:function(e){return d(e)}};X(o,{createEmitter:function(){return this._private.emitter=new uu(f,this),this},emitter:function(){return this._private.emitter},on:function(e,t){return this.emitter().on(e,t),this},one:function(e,t){return this.emitter().one(e,t),this},once:function(e,t){return this.emitter().one(e,t),this},removeListener:function(e,t){return this.emitter().removeListener(e,t),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},emit:function(e,t){return this.emitter().emit(e,t),this}}),Fc.eventAliasesOn(o),r=a}else if(e===`renderer`&&t!==`null`&&t!==`base`){var p=dg(`renderer`,`base`),m=p.prototype,h=n,g=n.prototype,_=function(){p.apply(this,arguments),h.apply(this,arguments)},v=_.prototype;for(var y in m){var b=m[y];if(g[y]!=null)return i(y);v[y]=b}for(var x in g)v[x]=g[x];m.clientFunctions.forEach(function(e){v[e]=v[e]||function(){rn("Renderer does not implement `renderer."+e+"()` on its prototype")}}),r=_}else if(e===`__proto__`||e===`constructor`||e===`prototype`)return rn(e+` is an illegal type to be registered, possibly lead to prototype pollutions`);return Fe({map:cg,keys:[e,t],value:r})}function dg(e,t){return Ie({map:cg,keys:[e,t]})}function fg(e,t,n,r,i){return Fe({map:lg,keys:[e,t,n,r],value:i})}function pg(e,t,n,r){return Ie({map:lg,keys:[e,t,n,r]})}var mg=function(){if(arguments.length===2)return dg.apply(null,arguments);if(arguments.length===3)return ug.apply(null,arguments);if(arguments.length===4)return pg.apply(null,arguments);if(arguments.length===5)return fg.apply(null,arguments);rn(`Invalid extension access syntax`)};Dd.prototype.extension=mg,sg.forEach(function(e){e.extensions.forEach(function(t){ug(e.type,t.name,t.impl)})});var hg=function(){if(!(this instanceof hg))return new hg;this.length=0},gg=hg.prototype;gg.instanceString=function(){return`stylesheet`},gg.selector=function(e){var t=this.length++;return this[t]={selector:e,properties:[]},this},gg.css=function(e,t){var n=this.length-1;if(G(e))this[n].properties.push({name:e,value:t});else if(J(e))for(var r=e,i=Object.keys(r),a=0;a<i.length;a++){var o=i[a],s=r[o];if(s!=null){var c=xd.properties[o]||xd.properties[ge(o)];if(c!=null){var l=c.name,u=s;this[n].properties.push({name:l,value:u})}}}return this},gg.style=gg.css,gg.generateStyle=function(e){var t=new xd(e);return this.appendToStyle(t)},gg.appendToStyle=function(e){for(var t=0;t<this.length;t++){var n=this[t],r=n.selector,i=n.properties;e.selector(r);for(var a=0;a<i.length;a++){var o=i[a];e.css(o.name,o.value)}}return e};var _g=`3.34.2`,vg=function(e){if(e===void 0&&(e={}),J(e))return new Dd(e);if(G(e))return mg.apply(mg,arguments)};vg.use=function(e){var t=Array.prototype.slice.call(arguments,1);return t.unshift(vg),e.apply(null,t),this},vg.warnings=function(e){return an(e)},vg.version=_g,vg.stylesheet=vg.Stylesheet=hg;function yg(e,t,n){let r=(e,t)=>{let r=new Set,i=n.get(e);for(;i!==void 0&&!r.has(i);){if(i===t)return!0;r.add(i),i=n.get(i)}return!1};return r(e,t)||r(t,e)}var bg=`yarramate/core@0.1#composition`,xg=`yarramate/core@0.1#assignment`,Sg={composition:bg,assignment:xg},Cg=new Set([`constraint`]),wg=`none`,Tg=(e,t)=>!t(e.to).endsWith(`Service`)||t(e.from).endsWith(`Interface`);function Eg(e,t,n){let r=new Map(t.map((e,t)=>[Sg[e],t])),i=e.filter(e=>r.has(e.kind)&&(e.kind!==xg||Tg(e,n))),a=new Map;for(let e of i){let t=a.get(e.to);t===void 0?a.set(e.to,[e]):t.push(e)}let o=new Map,s=[];for(let[e,t]of a){let n=Math.min(...t.map(e=>r.get(e.kind))),i=t.filter(e=>r.get(e.kind)===n);new Set(i.map(e=>e.from)).size===1?o.set(e,i[0].from):s.push({child:e,claims:i.map(e=>({edgeId:e.id,kind:e.kind,from:e.from}))})}let c=Og(o),l=new Set;for(let e of i)o.get(e.to)===e.from&&l.add(e.id);return{parentOf:o,consumedEdgeIds:l,conflicts:s,cycleMembers:c}}var Dg=(e,t,n)=>{let r=new Set([e]),i=n.get(e);for(;i!==void 0&&!r.has(i);){if(i===t)return!0;r.add(i),i=n.get(i)}return!1};function Og(e){let t=new Set;for(let n of e.keys()){let r=[],i=new Map,a=n;for(;a!==void 0;){let n=i.get(a);if(n!==void 0){for(let e of r.slice(n))t.add(e);break}i.set(a,r.length),r.push(a),a=e.get(a)}}for(let n of t)e.delete(n);return[...t]}var kg=(e,t)=>{let n=e=>{let n=[],r=new Set,i=e;for(;i!==void 0&&!r.has(i);)r.add(i),n.push(i),i=t.get(i);return n},[r,...i]=e;if(r===void 0)return;let a=i.map(e=>new Set(n(e)));return n(r).find(e=>a.every(t=>t.has(e)))};function Ag(e){let t=new Map(e.nodes.map(e=>[e.id,e.coreKind])),n=e=>t.get(e)??``,r=Eg(e.edges,e.nesting,n),i=new Map;for(let t of e.memberships){let e=i.get(t.member);e===void 0?i.set(t.member,new Set([t.instance])):e.add(t.instance)}let a=new Set;for(let t of e.memberships)t.wiring!==`context`&&a.add(t.member);let o=new Map(r.parentOf),s=[...new Set(e.memberships.map(({member:e})=>e).filter(e=>!o.has(e)&&a.has(e)&&!Cg.has(n(e))&&t.has(e)&&i.get(e)?.has(e)!==!0))];for(;s.length>0;){let e=[],t=!1;for(let n of s){let r=[...i.get(n)??[]];if(r.some(e=>s.includes(e)&&e!==n)){e.push(n);continue}t=!0;let a=r.length===1?r[0]:kg(r,o);a!==void 0&&a!==n&&(r.some(e=>Dg(e,n,o))||o.set(n,a))}if(!t)break;s=e}let c=[...r.cycleMembers,...Og(o)];return{parentOf:o,consumedEdgeIds:r.consumedEdgeIds,conflicts:r.conflicts,cycleMembers:c}}var jg=(e,t,n)=>`lift:${e}|${t}|${n}`,Mg=(e,t,n)=>{let r=e,i=t.get(e),a=new Set([e]);for(;i!==void 0&&!a.has(i);)a.add(i),n.has(i)&&(r=i),i=t.get(i);return r};function Ng(e,t,n){let r=new Map;for(let i of e.nodes)r.set(i.id,Mg(i.id,t.parentOf,n));let i=new Map;for(let t of e.nodes){let e=r.get(t.id);if(e===t.id)continue;let n=i.get(e);n===void 0?i.set(e,[t.id]):n.push(t.id)}let a=e.nodes.filter(e=>r.get(e.id)===e.id).map(e=>({...e,folded:n.has(e.id),insideIds:i.get(e.id)??[]})),o=[],s=new Map;for(let t of e.edges){let e=r.get(t.from)??t.from,n=r.get(t.to)??t.to;if(e===t.from&&n===t.to){o.push(t);continue}if(e===n)continue;let i=jg(e,n,t.kind),a=s.get(i);a===void 0?s.set(i,{edge:{id:i,kind:t.kind,from:e,to:n,count:1,relationshipIds:[t.id]},ids:[t.id]}):a.ids.push(t.id)}for(let{edge:e,ids:t}of s.values())o.push({...e,count:t.length,relationshipIds:t});return{nodes:a,edges:o}}var Pg=[`layered`,`routed`,`served-by`,`bands`],Fg=`served-by`,Ig=e=>e!==`layered`,Lg=e=>e===`served-by`||e===`bands`,Rg=e=>e===`bands`,zg=new Set([`serving`,`realization`,`specialization`]),Bg={motivation:0,strategy:1,business:2,application:3,technology:4,physical:5,implementation:6},Vg=e=>e==null?void 0:Bg[e],Hg=[`current`,`drafting`,`ink`,`tinted`,`dark`],Ug=[{id:`current`,title:`Current`,blurb:`ArchiMate pastels, 2px borders, grey edges with boxed labels.`},{id:`drafting`,title:`Drafting`,blurb:`The shell's own vocabulary on the canvas: paper-tinted fills, hairline ink rules, the body face, monospace edge readings with a paper halo.`},{id:`ink`,title:`Ink`,blurb:`Line-first and print-ready: white subjects, the layer carried by a coloured 1.5px border, ink edges, no boxes anywhere.`},{id:`tinted`,title:`Tinted`,blurb:`A contemporary muted palette in place of the pastels, 8px corners, slate edges, edge readings on small pills.`},{id:`dark`,title:`Dark`,blurb:`A dark ground with deep layer tints, light ink and light glyphs.`,canvas:`#12161b`,glyph:`#e5e9ed`}],Wg=`current`,Gg=`yarramate-visual.style`,Kg=()=>{try{let e=globalThis.localStorage?.getItem(Gg);return Yg(e)?e:Wg}catch{return Wg}},qg=e=>{try{globalThis.localStorage?.setItem(Gg,e)}catch{}},Jg=e=>Ug.find(t=>t.id===e)??Ug[0],Yg=e=>typeof e==`string`&&Hg.includes(e),Xg=`'Avenir Next', Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif`,Zg=`ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace`,Qg={motivation:{fill:`#dcd9ef`,border:`#6f6bb0`},strategy:{fill:`#ece2cd`,border:`#a2843f`},business:{fill:`#ecebc4`,border:`#9a9440`},application:{fill:`#cfe6e8`,border:`#3f8f8f`},technology:{fill:`#d3e6d3`,border:`#4f8f4f`},implementation:{fill:`#ebd9da`,border:`#b07a7a`},physical:{fill:`#e1e5e7`,border:`#7d868c`},composite:{fill:`#e1e5e7`,border:`#7d868c`}},$g={motivation:{fill:`#ffffff`,border:`#5b52c8`},strategy:{fill:`#ffffff`,border:`#b8862b`},business:{fill:`#ffffff`,border:`#a89a12`},application:{fill:`#ffffff`,border:`#1f8f8f`},technology:{fill:`#ffffff`,border:`#2f8f2f`},implementation:{fill:`#ffffff`,border:`#c2606a`},physical:{fill:`#ffffff`,border:`#6b7680`},composite:{fill:`#ffffff`,border:`#6b7680`}},e_={motivation:{fill:`#ede9fe`,border:`#7c3aed`},strategy:{fill:`#fef3c7`,border:`#b45309`},business:{fill:`#fef9c3`,border:`#a16207`},application:{fill:`#e0f2fe`,border:`#0369a1`},technology:{fill:`#d1fae5`,border:`#047857`},implementation:{fill:`#ffe4e6`,border:`#be123c`},physical:{fill:`#f1f5f9`,border:`#475569`},composite:{fill:`#f1f5f9`,border:`#475569`}},t_={motivation:{fill:`#2a2550`,border:`#8b7fe0`},strategy:{fill:`#3a2e14`,border:`#c9a355`},business:{fill:`#3a3a10`,border:`#c9c355`},application:{fill:`#10344a`,border:`#4fb8b8`},technology:{fill:`#10391f`,border:`#5fae5f`},implementation:{fill:`#3d1b22`,border:`#d89999`},physical:{fill:`#262c33`,border:`#6b7680`},composite:{fill:`#262c33`,border:`#6b7680`}},n_=(e,t=`16%`)=>[...Object.keys(e).map(t=>({selector:`node[layer = "${t}"]`,style:{"background-color":e[t].fill,"border-color":e[t].border}})),...Object.keys(e).map(n=>({selector:`node[layer = "${n}"][aspect = "passive-structure"]:childless`,style:{"background-fill":`linear-gradient`,"background-gradient-direction":`to-bottom`,"background-gradient-stop-colors":[e[n].border,e[n].fill],"background-gradient-stop-positions":[`0%`,t]}}))],r_=e=>[...n_(e.palette),{selector:`node`,style:{"border-width":e.nodeBorder,"corner-radius":`${e.corner}px`,"font-family":Xg,"font-size":12,"font-weight":500,color:e.ink}},{selector:`node:parent`,style:{...e.containerFill.color===null?{}:{"background-color":e.containerFill.color},"background-opacity":e.containerFill.opacity,...e.containerBorder.color===null?{}:{"border-color":e.containerBorder.color},"border-style":e.containerBorder.style,"border-width":1,"border-opacity":e.containerBorder.opacity,"corner-radius":`${e.corner+4}px`,"font-family":e.containerTitle.face,"font-size":e.containerTitle.size,"font-weight":e.containerTitle.weight,color:e.containerTitle.color,...e.containerTitle.upper?{"text-transform":`uppercase`}:{},"text-margin-y":-6}},{selector:`edge`,style:{"line-color":e.edge,"target-arrow-color":e.edge,"source-arrow-color":e.edge,width:e.edgeWidth,"line-cap":`round`,"arrow-scale":.85,"font-family":e.edgeLabelFace,"font-size":9.5,color:e.edgeLabelColor,"text-background-color":e.edgeLabelBackground.color,"text-background-opacity":e.edgeLabelBackground.opacity,"text-background-shape":e.edgeLabelBackground.shape,"text-background-padding":`2px`,...e.halo===null?{"text-outline-width":0}:{"text-outline-color":e.halo,"text-outline-width":2,"text-outline-opacity":1}}},{selector:`edge.lifted`,style:{"line-color":e.quiet,"target-arrow-color":e.quiet,width:e.edgeWidth+.5}},{selector:`node.selected`,style:{"border-color":e.select,"border-width":2,"overlay-color":e.select,"overlay-opacity":.12,"overlay-padding":6}},{selector:`edge.selected`,style:{"line-color":e.select,"target-arrow-color":e.select,width:e.edgeWidth+1}}],i_={current:()=>[],drafting:()=>r_({palette:Qg,ink:`#182228`,quiet:`#7d868c`,ground:`#e8eef0`,nodeBorder:1,corner:4,edge:`#6b7680`,edgeWidth:1.25,edgeLabelFace:Zg,edgeLabelColor:`#4a555e`,edgeLabelBackground:{color:`#e8eef0`,opacity:0,shape:`rectangle`},halo:`#e8eef0`,containerFill:{color:null,opacity:0},containerBorder:{color:`#182228`,style:`dashed`,opacity:.3},containerTitle:{face:Zg,size:10,weight:`500`,color:`#4a555e`,upper:!0},select:`#2457a6`}),ink:()=>r_({palette:$g,ink:`#182228`,quiet:`#6b7680`,ground:`#ffffff`,nodeBorder:1.5,corner:4,edge:`#182228`,edgeWidth:1.2,edgeLabelFace:Xg,edgeLabelColor:`#182228`,edgeLabelBackground:{color:`#ffffff`,opacity:0,shape:`rectangle`},halo:`#e8eef0`,containerFill:{color:`#182228`,opacity:.04},containerBorder:{color:`#182228`,style:`solid`,opacity:.35},containerTitle:{face:Xg,size:11,weight:`600`,color:`#182228`,upper:!0},select:`#2457a6`}),tinted:()=>r_({palette:e_,ink:`#0f172a`,quiet:`#94a3b8`,ground:`#e8eef0`,nodeBorder:1,corner:8,edge:`#64748b`,edgeWidth:1.5,edgeLabelFace:Xg,edgeLabelColor:`#475569`,edgeLabelBackground:{color:`#f8fafc`,opacity:1,shape:`roundrectangle`},halo:null,containerFill:{color:null,opacity:.35},containerBorder:{color:null,style:`solid`,opacity:.5},containerTitle:{face:Xg,size:11,weight:`600`,color:`#334155`,upper:!1},select:`#2563eb`}),dark:()=>r_({palette:t_,ink:`#e5e9ed`,quiet:`#97a3ae`,ground:`#12161b`,nodeBorder:1,corner:6,edge:`#7f8b96`,edgeWidth:1.25,edgeLabelFace:Xg,edgeLabelColor:`#b8c2cc`,edgeLabelBackground:{color:`#12161b`,opacity:0,shape:`rectangle`},halo:`#12161b`,containerFill:{color:`#1a2027`,opacity:.7},containerBorder:{color:`#3a444f`,style:`dashed`,opacity:1},containerTitle:{face:Xg,size:11,weight:`600`,color:`#97a3ae`,upper:!1},select:`#7ea6ec`})},a_=e=>i_[e]();function o_(e){return e===`planned`||e===`current`||e===`retired`}var s_=`#182228`,c_=`#416f65`,l_=`#a3403a`,u_=`#5f686d`,d_=[c_,`#8c4d18`,`#2457a6`,s_],f_=12;function p_(e){return`data:image/svg+xml;utf8,${encodeURIComponent(e)}`}function m_(e){return`<svg xmlns="http://www.w3.org/2000/svg" width="${f_}" height="${f_}" viewBox="0 0 12 12">${e}</svg>`}var h_={planned:m_(`<circle cx="6" cy="6" r="4" fill="none" stroke="${u_}" stroke-width="2"/>`),current:m_(`<circle cx="6" cy="6" r="5" fill="${c_}"/>`),retired:m_(`<circle cx="6" cy="6" r="5" fill="${l_}"/>`)},g_={planned:p_(h_.planned),current:p_(h_.current),retired:p_(h_.retired)},__=p_(m_(`<circle cx="6" cy="6" r="5" fill="${s_}"/><path d="M3.2 6.2 L5.2 8.2 L8.8 4.2" fill="none" stroke="#ffffff" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`));function v_(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t}function y_(e){if(e===null)return null;let t=v_(e);return d_[Math.abs(t)%d_.length]}function b_(e,t){return m_(`<circle cx="6" cy="6" r="5" fill="${y_(e)}"/><text x="6" y="7.5" font-size="8" font-weight="bold" fill="#ffffff" text-anchor="middle" dominant-baseline="middle">${t}</text>`)}function x_(e,t){return p_(b_(e,t))}function S_(e){let t=e>9?`9+`:String(e);return m_(`<circle cx="6" cy="6" r="5" fill="${u_}"/><text x="6" y="7.5" font-size="${t.length>1?6.5:8}" font-weight="bold" fill="#ffffff" text-anchor="middle" dominant-baseline="middle">${t}</text>`)}function C_(e){return p_(S_(e))}function w_(e){let t=e>99?`99+`:String(e),n=12+t.length*4;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${n} 12" width="${n}" height="12"><rect x="0" y="0" width="${n}" height="12" rx="3" fill="${s_}"/><path d="M4 3.5 L7.5 6 L4 8.5 Z" fill="#ffffff"/><text x="${n-3}" y="6.5" font-size="7" font-weight="bold" fill="#ffffff" text-anchor="end" dominant-baseline="middle">${t}</text></svg>`}function T_(e){return p_(w_(e))}function E_(e){if(e===null)return null;let t=(e.includes(`#`)?e.slice(e.indexOf(`#`)+1):e).split(/[-_\s]+/).filter(e=>e.length>0);if(t.length===0)return null;let n=t.slice(0,2).map(e=>e[0].toUpperCase()).join(``);return n.length>0?n:null}var D_=[`motivation`,`strategy`,`business`,`application`,`technology`,`physical`,`implementation`,`composite`],O_=(e,t,n)=>n.map(([n,r,i])=>({id:n,name:r,layer:e,aspect:t,...i===void 0?{}:{rigidity:i},inspiredBy:`archimate:${r}`})),k_=[...O_(`motivation`,`motivation`,[[`stakeholder`,`Stakeholder`,`anti-rigid`],[`driver`,`Driver`],[`assessment`,`Assessment`],[`goal`,`Goal`],[`outcome`,`Outcome`],[`principle`,`Principle`],[`requirement`,`Requirement`],[`constraint`,`Constraint`],[`meaning`,`Meaning`],[`value`,`Value`]]),...O_(`strategy`,`active-structure`,[[`resource`,`Resource`]]),...O_(`strategy`,`behavior`,[[`capability`,`Capability`],[`valueStream`,`Value stream`],[`courseOfAction`,`Course of action`]]),...O_(`business`,`active-structure`,[[`businessActor`,`Business actor`],[`businessRole`,`Business role`,`anti-rigid`],[`businessCollaboration`,`Business collaboration`,`anti-rigid`],[`businessInterface`,`Business interface`]]),...O_(`business`,`behavior`,[[`businessProcess`,`Business process`],[`businessFunction`,`Business function`],[`businessInteraction`,`Business interaction`],[`businessEvent`,`Business event`],[`businessService`,`Business service`]]),...O_(`business`,`passive-structure`,[[`businessObject`,`Business object`],[`contract`,`Contract`],[`representation`,`Representation`]]),...O_(`business`,`composite`,[[`product`,`Product`]]),...O_(`application`,`active-structure`,[[`applicationComponent`,`Application component`],[`applicationCollaboration`,`Application collaboration`,`anti-rigid`],[`applicationInterface`,`Application interface`]]),...O_(`application`,`behavior`,[[`applicationFunction`,`Application function`],[`applicationInteraction`,`Application interaction`],[`applicationProcess`,`Application process`],[`applicationEvent`,`Application event`],[`applicationService`,`Application service`]]),...O_(`application`,`passive-structure`,[[`dataObject`,`Data object`]]),...O_(`technology`,`active-structure`,[[`node`,`Node`],[`device`,`Device`],[`systemSoftware`,`System software`],[`technologyCollaboration`,`Technology collaboration`,`anti-rigid`],[`technologyInterface`,`Technology interface`],[`path`,`Path`],[`communicationNetwork`,`Communication network`]]),...O_(`technology`,`behavior`,[[`technologyFunction`,`Technology function`],[`technologyProcess`,`Technology process`],[`technologyInteraction`,`Technology interaction`],[`technologyEvent`,`Technology event`],[`technologyService`,`Technology service`]]),...O_(`technology`,`passive-structure`,[[`artifact`,`Artifact`]]),...O_(`physical`,`active-structure`,[[`equipment`,`Equipment`],[`facility`,`Facility`],[`distributionNetwork`,`Distribution network`]]),...O_(`physical`,`passive-structure`,[[`material`,`Material`]]),...O_(`implementation`,`behavior`,[[`workPackage`,`Work package`],[`implementationEvent`,`Implementation event`]]),...O_(`implementation`,`passive-structure`,[[`deliverable`,`Deliverable`]]),...O_(`implementation`,`composite`,[[`plateau`,`Plateau`],[`gap`,`Gap`]]),...O_(`composite`,`composite`,[[`grouping`,`Grouping`],[`location`,`Location`],[`andJunction`,`AND junction`],[`orJunction`,`OR junction`]])],A_=[`composition`,`aggregation`,`assignment`,`realization`,`serving`,`access`,`influence`,`association`,`triggering`,`flow`,`specialization`],j_=`#182228`,M_={motivation:{fill:`#CCCCFF`,border:`#8F8FE0`},strategy:{fill:`#F5DEAA`,border:`#C9A355`},business:{fill:`#FFFF99`,border:`#C9C355`},application:{fill:`#CCFFFF`,border:`#4FB8B8`},technology:{fill:`#CCFFCC`,border:`#5FAE5F`},implementation:{fill:`#FFE0E0`,border:`#D89999`},physical:{fill:`#F0F0F0`,border:`#999999`},composite:{fill:`#F0F0F0`,border:`#999999`}},N_={motivation:{shape:`octagon`},"active-structure":{shape:`rectangle`},behavior:{shape:`round-rectangle`},"passive-structure":{shape:`rectangle`,accent:`top-band`},composite:{shape:`rectangle`}},P_={grouping:{borderStyle:`dashed`}};function F_(e,t=j_){return`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14"><g fill="none" stroke="${t}" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">${e}</g></svg>`}function I_(e){return`data:image/svg+xml;utf8,${encodeURIComponent(e)}`}var L_={andJunction:`<circle cx="7" cy="7" r="2.6" fill="#182228"/>`,applicationCollaboration:`<circle cx="5.5" cy="7" r="4"/><circle cx="8.5" cy="7" r="4"/>`,applicationComponent:`<rect x="3" y="2" width="9" height="10"/><rect x="1" y="4" width="2.5" height="1.5"/><rect x="1" y="8" width="2.5" height="1.5"/>`,applicationEvent:`<path d="M3 3 H8 L11 7 L8 11 H3 Z"/>`,applicationFunction:`<rect x="2" y="3" width="10" height="8" rx="2"/><path d="M5.5 5 L8 7 L5.5 9"/>`,applicationInteraction:`<path d="M2 5 H9 M9 5 L7 3 M9 5 L7 7"/><path d="M12 9 H5 M5 9 L7 7 M5 9 L7 11"/>`,applicationInterface:`<line x1="1.5" y1="7" x2="6" y2="7"/><circle cx="9" cy="7" r="3"/>`,applicationProcess:`<path d="M2 7 H10 M10 7 L7.5 4.5 M10 7 L7.5 9.5"/>`,applicationService:`<rect x="1.5" y="4" width="11" height="6" rx="3"/>`,artifact:`<path d="M3 1.5 H9 L11 3.5 V12.5 H3 Z"/><path d="M9 1.5 V3.5 H11"/>`,assessment:`<circle cx="6" cy="6" r="3.5"/><path d="M8.5 8.5 L12 12"/>`,businessActor:`<circle cx="7" cy="3.5" r="1.8"/><path d="M7 5.3 V9 M4 7 H10 M7 9 L4.5 12.5 M7 9 L9.5 12.5"/>`,businessCollaboration:`<circle cx="5.5" cy="7" r="4"/><circle cx="8.5" cy="7" r="4"/>`,businessEvent:`<path d="M3 3 H8 L11 7 L8 11 H3 Z"/>`,businessFunction:`<rect x="2" y="3" width="10" height="8" rx="2"/><path d="M5 8 L7 5.5 L9 8"/>`,businessInteraction:`<path d="M2 5 H9 M9 5 L7 3 M9 5 L7 7"/><path d="M12 9 H5 M5 9 L7 7 M5 9 L7 11"/>`,businessInterface:`<line x1="1.5" y1="7" x2="6" y2="7"/><circle cx="9" cy="7" r="3"/>`,businessObject:`<rect x="2" y="3" width="10" height="8"/>`,businessProcess:`<path d="M2 7 H10 M10 7 L7.5 4.5 M10 7 L7.5 9.5"/>`,businessRole:`<circle cx="7" cy="6" r="4"/><path d="M5 9.5 L4 12.5 L7 11 L10 12.5 L9 9.5"/>`,businessService:`<rect x="1.5" y="4" width="11" height="6" rx="3"/>`,capability:`<rect x="2" y="2" width="10" height="10" rx="1"/><path d="M5 9 L9 5 M9 5 H6.5 M9 5 V7.5"/>`,communicationNetwork:`<circle cx="3.5" cy="4" r="1.2"/><circle cx="11" cy="4" r="1.2"/><circle cx="7" cy="10.5" r="1.2"/><path d="M3.5 4 L11 4 M3.5 4 L7 10.5 M11 4 L7 10.5"/>`,constraint:`<rect x="4" y="6.5" width="6" height="5.5" rx="0.5"/><path d="M5.2 6.5 V4.7 A1.8 1.8 0 0 1 8.8 4.7 V6.5"/>`,contract:`<rect x="2" y="2" width="10" height="10"/><path d="M2 4.5 H12 M2 6.5 H12"/>`,courseOfAction:`<path d="M7 2 V12.5"/><path d="M7 4 H11 L9.5 5.5 L11 7 H7 Z"/><path d="M7 8 H4 L5.5 9.5 L4 11 H7 Z"/>`,dataObject:`<rect x="2" y="2" width="10" height="10"/><path d="M2 5.5 H12"/>`,deliverable:`<path d="M3 1.5 H8 L11 4.5 V12.5 H3 Z"/><path d="M8 1.5 V4.5 H11"/><path d="M5 9.5 L7 12.5 L9 9.5"/>`,device:`<rect x="2" y="3" width="10" height="6" rx="0.5"/><path d="M4.5 9 V11 M9.5 9 V11 M3.5 11 H6 M8 11 H10.5"/>`,distributionNetwork:`<path d="M2 11 Q4 11 5 8 Q6 5 7 5 Q8 5 9 8 Q10 11 12 11"/><circle cx="2" cy="11" r="1"/><circle cx="12" cy="11" r="1"/><circle cx="7" cy="5" r="1"/>`,driver:`<circle cx="7" cy="7" r="5"/><path d="M7 2 V5 M7 9 V12 M2 7 H5 M9 7 H12"/>`,equipment:`<rect x="2" y="3" width="10" height="8"/><path d="M2 3 L7 6 L12 3 M7 6 V11"/>`,facility:`<path d="M2 12.5 V6 L7 2.5 L12 6 V12.5 Z"/><path d="M5.5 12.5 V8.5 H8.5 V12.5"/>`,gap:`<path d="M2 4 H6 M2 10 H6"/><path d="M8 4 H12 M8 10 H12"/><path d="M7 3 V11" stroke-dasharray="1.4 1.3"/>`,goal:`<circle cx="7" cy="7" r="5"/><circle cx="7" cy="7" r="2.2"/>`,grouping:`<rect x="2" y="2" width="10" height="10" rx="1" stroke-dasharray="2 1.4"/>`,implementationEvent:`<path d="M3 3 H8 L11 7 L8 11 H3 Z"/>`,location:`<path d="M7 12.5 C7 12.5 3 8 3 5.5 A4 4 0 0 1 11 5.5 C11 8 7 12.5 7 12.5 Z"/><circle cx="7" cy="5.5" r="1.3"/>`,material:`<rect x="2" y="8" width="4" height="4"/><rect x="6.5" y="6" width="4" height="6"/><rect x="4" y="2.5" width="4" height="4"/>`,meaning:`<path d="M2 3 H12 V9 H6 L4 11 V9 H2 Z"/><path d="M4.5 6 H9.5"/>`,node:`<path d="M2 5 L7 2.5 L12 5 L12 10 L7 12.5 L2 10 Z"/><path d="M2 5 L7 7.5 L12 5 M7 7.5 V12.5"/>`,orJunction:`<circle cx="7" cy="7" r="2.6"/>`,outcome:`<path d="M3 1.5 V12.5"/><path d="M3 2 H9 L7 4 L9 6 H3 Z"/>`,path:`<circle cx="3" cy="7" r="1.3"/><circle cx="11" cy="7" r="1.3"/><path d="M4.5 7 H9.5" stroke-dasharray="1.6 1.4"/>`,plateau:`<path d="M2 11 L4.5 4 H9.5 L12 11 Z"/><path d="M2 11 H12"/>`,principle:`<path d="M3 2.5 H11 V9 L7 11.5 L3 9 Z"/><path d="M5 6 L6.5 7.5 L9.5 4.5"/>`,product:`<rect x="2" y="5" width="10" height="7"/><path d="M2 5 L7 1.5 L12 5"/>`,representation:`<path d="M3 2 H11 V9 Q9.5 11 8 9.5 Q6.5 8 5 9.5 Q3.5 11 3 9 Z"/>`,requirement:`<path d="M3 2.5 H11 V9 L7 11.5 L3 9 Z"/><path d="M3 5 H11"/>`,resource:`<rect x="2" y="4.5" width="9" height="5" rx="1"/><rect x="11" y="6" width="1.5" height="2"/><path d="M4 6 V8 M6.5 6 V8 M9 6 V8"/>`,stakeholder:`<circle cx="7" cy="5" r="2.2"/><path d="M2.5 12.5 Q2.5 8 7 8 Q11.5 8 11.5 12.5"/>`,systemSoftware:`<rect x="2" y="2" width="10" height="10"/><rect x="4" y="4" width="4" height="3"/>`,technologyCollaboration:`<circle cx="5.5" cy="7" r="4"/><circle cx="8.5" cy="7" r="4"/>`,technologyEvent:`<path d="M3 3 H8 L11 7 L8 11 H3 Z"/>`,technologyFunction:`<circle cx="7" cy="7" r="4"/><path d="M7 2 V3.2 M7 10.8 V12 M2 7 H3.2 M10.8 7 H12 M3.5 3.5 L4.3 4.3 M9.7 9.7 L10.5 10.5 M3.5 10.5 L4.3 9.7 M9.7 4.3 L10.5 3.5"/>`,technologyInteraction:`<path d="M2 5 H9 M9 5 L7 3 M9 5 L7 7"/><path d="M12 9 H5 M5 9 L7 7 M5 9 L7 11"/>`,technologyInterface:`<line x1="1.5" y1="7" x2="6" y2="7"/><circle cx="9" cy="7" r="3"/>`,technologyProcess:`<path d="M2 7 H10 M10 7 L7.5 4.5 M10 7 L7.5 9.5"/>`,technologyService:`<rect x="1.5" y="4" width="11" height="6" rx="3"/>`,value:`<path d="M7 2 L11.5 7 L7 12 L2.5 7 Z"/>`,valueStream:`<path d="M2 5 H8 V3.5 L12 7 L8 10.5 V9 H2 Z"/>`,workPackage:`<rect x="2" y="5" width="10" height="7"/><path d="M5 5 V3.5 A1 1 0 0 1 6 2.5 H8 A1 1 0 0 1 9 3.5 V5"/>`},R_=k_.map(e=>({id:e.id,notation:e.name,layer:e.layer,aspect:e.aspect,...N_[e.aspect],...P_[e.id],glyph:L_[e.id]??null,colors:M_[e.layer]})),z_=Object.fromEntries(R_.map(e=>[e.id,e]));function B_(e,t=j_){let n=z_[e]?.glyph;return n==null?null:I_(F_(n,t))}var V_={composition:{lineStyle:`solid`,sourceArrow:{shape:`diamond`,fill:`filled`},targetArrow:{shape:`none`}},aggregation:{lineStyle:`solid`,sourceArrow:{shape:`diamond`,fill:`hollow`},targetArrow:{shape:`none`}},assignment:{lineStyle:`solid`,sourceArrow:{shape:`circle`,fill:`filled`},targetArrow:{shape:`triangle`,fill:`filled`}},realization:{lineStyle:`dotted`,sourceArrow:{shape:`none`},targetArrow:{shape:`triangle`,fill:`hollow`}},specialization:{lineStyle:`solid`,sourceArrow:{shape:`none`},targetArrow:{shape:`triangle`,fill:`hollow`}},serving:{lineStyle:`solid`,sourceArrow:{shape:`none`},targetArrow:{shape:`vee`}},access:{lineStyle:`dotted`,sourceArrow:{shape:`none`},targetArrow:{shape:`vee`}},influence:{lineStyle:`dashed`,sourceArrow:{shape:`none`},targetArrow:{shape:`vee`}},triggering:{lineStyle:`solid`,sourceArrow:{shape:`none`},targetArrow:{shape:`triangle`,fill:`filled`}},flow:{lineStyle:`dashed`,sourceArrow:{shape:`none`},targetArrow:{shape:`triangle`,fill:`filled`}},association:{lineStyle:`solid`,sourceArrow:{shape:`none`},targetArrow:{shape:`none`}}},H_=A_.map(e=>({id:e,...V_[e]}));Object.fromEntries(H_.map(e=>[e.id,e]));function U_(e,t){return B_(e,t)}var W_=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),$=o(((e,t)=>{t.exports=W_()}))(),G_=`application/x-yarramate-kind`,K_=`unlayered`,q_=`constraint`,J_=(e,t)=>{let n=e===1?`slot`:`slots`;return t===0?`${e} ${n}`:`${e} ${n}, ${t} required`},Y_=e=>e.slice(e.lastIndexOf(`/`)+1).replace(/\.ya?ml$/,``),X_=new Map(k_.map(e=>[e.id,e.layer])),Z_=(e=[])=>{let t=new Map;for(let n of e){let e=t.get(n.document);e===void 0?t.set(n.document,[n]):e.push(n)}return[...t].map(([e,t])=>({document:e,patterns:t}))},Q_=(e,t=[])=>{let n=new Set(t.flatMap(e=>e.slots.flatMap(e=>[...e.admits]))),r=e=>e.coreLabel===q_&&n.has(e.label),i=new Map,a=new Map;for(let t of e){let e=X_.get(t.coreLabel)??K_,n=r(t)?a:i,o=n.get(e);o===void 0?n.set(e,[t]):o.push(t)}return[...D_,K_].flatMap(e=>{let t=i.get(e),n=a.get(e);return t===void 0&&n===void 0?[]:[{layer:e,kinds:t??[],boundThroughSlot:n??[]}]})},$_=({kinds:e,patterns:t,onPick:n})=>{let[r,i]=(0,y.useState)(new Set),a=e=>i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,$.jsxs)(`div`,{className:`kind-palette`,children:[Z_(t).map(e=>{let t=r.has(e.document);return(0,$.jsxs)(`div`,{className:`kind-palette-layer`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`kind-palette-layer-name`,"aria-expanded":!t,title:e.document,onClick:()=>a(e.document),children:[(0,$.jsx)(`span`,{className:`kind-palette-caret`,"aria-hidden":`true`,children:t?`▸`:`▾`}),`patterns \u00b7 ${Y_(e.document)}`]}),t?null:(0,$.jsx)(`ul`,{className:`kind-palette-rows`,children:e.patterns.map(e=>{let t=e.slots.filter(e=>e.required).length;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`kind-palette-row kind-palette-pattern`,draggable:!0,"data-kind":e.label,"data-pattern":e.kind,onDragStart:t=>{t.dataTransfer.setData(G_,e.label),t.dataTransfer.effectAllowed=`copy`},onClick:()=>n(e.label),children:[(0,$.jsx)(`span`,{className:`kind-palette-stack`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:e.name??e.label}),(0,$.jsx)(`span`,{className:`kind-palette-slots`,children:J_(e.slots.length,t)})]})},e.kind)})})]},`pattern:${e.document}`)}),Q_(e,t).map(e=>{let t=r.has(e.layer);return(0,$.jsxs)(`div`,{className:`kind-palette-layer`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`kind-palette-layer-name`,"aria-expanded":!t,onClick:()=>a(e.layer),children:[(0,$.jsx)(`span`,{className:`kind-palette-caret`,"aria-hidden":`true`,children:t?`▸`:`▾`}),e.layer]}),t?null:(0,$.jsx)(`ul`,{className:`kind-palette-rows`,children:e.kinds.map(e=>{let t=U_(e.label)??U_(e.coreLabel);return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`kind-palette-row`,draggable:!0,"data-kind":e.label,onDragStart:t=>{t.dataTransfer.setData(G_,e.label),t.dataTransfer.effectAllowed=`copy`},onClick:()=>n(e.label),children:[t===null?null:(0,$.jsx)(`img`,{src:t,alt:``,width:14,height:14}),(0,$.jsx)(`span`,{children:e.label})]})},e.id)})}),t||e.boundThroughSlot.length===0?null:(0,$.jsx)(ev,{layer:e.layer,kinds:e.boundThroughSlot,onPick:n})]},e.layer)})]})},ev=({layer:e,kinds:t,onPick:n})=>{let[r,i]=(0,y.useState)(!1);return(0,$.jsxs)(`div`,{className:`kind-palette-bound`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`kind-palette-layer-name kind-palette-bound-name`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,$.jsx)(`span`,{className:`kind-palette-caret`,"aria-hidden":`true`,children:r?`▾`:`▸`}),`${e} \u00b7 ${t.length} kinds bound through a slot`]}),r?(0,$.jsx)(`ul`,{className:`kind-palette-rows`,children:t.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,className:`kind-palette-row`,draggable:!0,"data-kind":e.label,onDragStart:t=>{t.dataTransfer.setData(G_,e.label),t.dataTransfer.effectAllowed=`copy`},onClick:()=>n(e.label),children:(0,$.jsx)(`span`,{children:e.label})})},e.id))}):null]})},tv=e=>e.trim().toLowerCase();function nv(e,t,n,r){return e===``||t.toLowerCase().includes(e)||typeof n==`string`&&n.toLowerCase().includes(e)?!0:typeof r==`string`&&r.toLowerCase().includes(e)}var rv=(e,t)=>{let n=tv(t);return e.filter(e=>nv(n,e.id,e.name,e.kindLabel)).length},iv=c(o(((e,t)=>{(function(n){if(typeof e==`object`&&t!==void 0)t.exports=n();else if(typeof define==`function`&&define.amd)define([],n);else{var r=typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:this;r.ELK=n()}})(function(){return(function(){function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var c=typeof l==`function`&&l;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var u=Error(`Cannot find module '`+o+`'`);throw u.code=`MODULE_NOT_FOUND`,u}var d=n[o]={exports:{}};t[o][0].call(d.exports,function(e){var n=t[o][1][e];return i(n||e)},d,d.exports,e,t,n,r)}return n[o].exports}for(var a=typeof l==`function`&&l,o=0;o<r.length;o++)i(r[o]);return i}return e})()({1:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;function r(e){"@babel/helpers - typeof";return r=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},r(e)}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,s(r.key),r)}}function o(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){var t=c(e,`string`);return r(t)==`symbol`?t:t+``}function c(e,t){if(r(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t||`default`);if(r(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}n.default=function(){function e(){var t=this,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=n.defaultLayoutOptions,a=r===void 0?{}:r,o=n.algorithms,s=o===void 0?[`layered`,`stress`,`mrtree`,`radial`,`force`,`disco`,`sporeOverlap`,`sporeCompaction`,`rectpacking`]:o,c=n.workerFactory,u=n.workerUrl;if(i(this,e),this.defaultLayoutOptions=a,this.initialized=!1,u===void 0&&c===void 0)throw Error(`Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.`);var d=c;u!==void 0&&c===void 0&&(d=function(e){return new Worker(e)});var f=d(u);if(typeof f.postMessage!=`function`)throw TypeError(`Created worker does not provide the required 'postMessage' function.`);this.worker=new l(f),this.worker.postMessage({cmd:`register`,algorithms:s}).then(function(e){return t.initialized=!0}).catch(console.err)}return o(e,[{key:`layout`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.layoutOptions,r=n===void 0?this.defaultLayoutOptions:n,i=t.logging,a=i!==void 0&&i,o=t.measureExecutionTime,s=o!==void 0&&o;return e?this.worker.postMessage({cmd:`layout`,graph:e,layoutOptions:r,options:{logging:a,measureExecutionTime:s}}):Promise.reject(Error(`Missing mandatory parameter 'graph'.`))}},{key:`knownLayoutAlgorithms`,value:function(){return this.worker.postMessage({cmd:`algorithms`})}},{key:`knownLayoutOptions`,value:function(){return this.worker.postMessage({cmd:`options`})}},{key:`knownLayoutCategories`,value:function(){return this.worker.postMessage({cmd:`categories`})}},{key:`terminateWorker`,value:function(){this.worker&&this.worker.terminate()}}])}();var l=function(){function e(t){var n=this;if(i(this,e),t===void 0)throw Error(`Missing mandatory parameter 'worker'.`);this.resolvers={},this.worker=t,this.worker.onmessage=function(e){setTimeout(function(){n.receive(n,e)},0)}}return o(e,[{key:`postMessage`,value:function(e){var t=this.id||0;this.id=t+1,e.id=t;var n=this;return new Promise(function(r,i){n.resolvers[t]=function(e,t){e?(n.convertGwtStyleError(e),i(e)):r(t)},n.worker.postMessage(e)})}},{key:`receive`,value:function(e,t){var n=t.data,r=e.resolvers[n.id];r&&(delete e.resolvers[n.id],n.error?r(n.error):r(null,n.data))}},{key:`terminate`,value:function(){this.worker&&this.worker.terminate()}},{key:`convertGwtStyleError`,value:function(e){if(e){var t=e.__java$exception;t&&(t.cause&&t.cause.backingJsObject&&(e.cause=t.cause.backingJsObject,this.convertGwtStyleError(e.cause)),delete e.__java$exception)}}}])}()},{}],2:[function(e,t,n){var r=e("./elk-api.js").default;Object.defineProperty(t.exports,"__esModule",{value:!0}),t.exports=r,r.default=r},{"./elk-api.js":1}]},{},[2])(2)})}))(),1),av={serving:`serves`,access:`accesses`,realization:`realizes`,composition:`comprises`,aggregation:`aggregates`,assignment:`is assigned to`,triggering:`triggers`,flow:`flows to`,specialization:`specializes`,influence:`influences`,association:`is associated with`},ov={serving:`served by`,realization:`realized by`,specialization:`specialized by`},sv=e=>e.slice(e.indexOf(`#`)+1).replaceAll(/([a-z0-9])([A-Z])/g,`$1 $2`).replaceAll(`-`,` `).toLowerCase(),cv=(e,t=!1)=>(t?ov[e]:void 0)??av[e]??sv(e),lv=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),uv=function(e,t){return new URL(e,t).href},dv={},fv=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=uv(t,n),t=s(t),t in dv)return;dv[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:lv,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},pv=2.5,mv={"top-down":`DOWN`,"left-right":`RIGHT`},hv={"elk.spacing.nodeNode":`60`,"elk.layered.spacing.nodeNodeBetweenLayers":`100`,"elk.spacing.edgeNode":`30`,"elk.layered.spacing.edgeNodeBetweenLayers":`30`,"elk.spacing.edgeEdge":`20`,"elk.layered.spacing.edgeEdgeBetweenLayers":`20`,"elk.spacing.componentComponent":`80`,"elk.padding":`[top=52,left=30,bottom=30,right=30]`},gv=e=>Ig(e)?{...hv,"elk.spacing.edgeEdge":`60`}:{...hv},_v=(e,t)=>({"elk.algorithm":`layered`,"elk.direction":mv[e],"elk.layered.nodePlacement.strategy":`NETWORK_SIMPLEX`,"elk.aspectRatio":String(pv),...gv(t),...Ig(t)?{"elk.hierarchyHandling":`INCLUDE_CHILDREN`,"elk.edgeRouting":`ORTHOGONAL`,"elk.edgeLabels.inline":`true`,"elk.layered.considerModelOrder.strategy":`NODES_AND_EDGES`}:{},...Rg(t)?{"elk.partitioning.activate":`true`}:{}}),vv=(e,t,n)=>{if(typeof e.name==`string`&&e.name!==``)return e.name;if(!n)return``;let r=e.coreKindLabel??``,i=e.kindLabel??r,a=i!==r&&i!==``?sv(i):cv(r,Lg(t)&&zg.has(r)),o=typeof e.liftedCount==`number`?e.liftedCount:0;return o>1?`${a} ×${o}`:a},yv=e=>{let t=e.length*5.6+8,n=Math.max(1,Math.ceil(t/110));return{width:Math.min(110,Math.round(t)),height:12*n+4}};function bv(e,t){let{direction:n,mode:r,showKindLabels:i}=t,a=e.nodes(),o=new Set(a.map(e=>e.id())),s=new Map,c=[];a.forEach(e=>{let t=e.parent(),n=t.nonempty()?t.first().id():null;if(n!==null&&o.has(n)){let t=s.get(n);t===void 0?s.set(n,[e]):t.push(e)}else c.push(e)});let l=e=>{let t=s.get(e.id());if(t===void 0||t.length===0)return Vg(e.data(`layer`));let n=t.map(l).filter(e=>e!==void 0);return n.length===0?void 0:Math.min(...n)},u=gv(r),d=e=>{let t=s.get(e.id())??[],n={id:e.id()};if(t.length>0)n.children=t.map(d),n.layoutOptions={...u};else{let t=e.layoutDimensions({nodeDimensionsIncludeLabels:!1});n.width=t.w,n.height=t.h}if(Rg(r)){let t=l(e);t!==void 0&&(n.layoutOptions={...n.layoutOptions??{},"elk.partitioning.partition":String(t)})}return n},f=new Set,p=[];return e.edges().forEach(e=>{let t=e.source().id(),n=e.target().id();if(!o.has(t)||!o.has(n))return;let a=String(e.data(`coreKindLabel`)??``),s=Lg(r)&&zg.has(a);s&&f.add(e.id());let c={id:e.id(),sources:[s?n:t],targets:[s?t:n]};if(Ig(r)){let t=vv(e.data(),r,i);t!==``&&(c.labels=[{text:t,...yv(t)}])}p.push(c)}),{graph:{id:`root`,layoutOptions:_v(n,r),children:c.map(d),edges:p},reversed:f}}var xv=(e,t)=>[e.startPoint,...e.bendPoints??[],e.endPoint].map(e=>({x:e.x+t.x,y:e.y+t.y})),Sv=e=>{let t=0;for(let n=1;n<e.length;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t},Cv=(e,t)=>{let n=1/0,r=0,i=0;for(let a=1;a<e.length;a+=1){let o=e[a-1],s=e[a],c=s.x-o.x,l=s.y-o.y,u=Math.hypot(c,l)||1,d=Math.max(0,Math.min(1,((t.x-o.x)*c+(t.y-o.y)*l)/(u*u))),f=Math.hypot(t.x-(o.x+d*c),t.y-(o.y+d*l));f<n&&(n=f,r=i+d*u),i+=u}return r};function wv(e,t){let n=new Map([[e.id,{x:0,y:0}]]),r=new Map,i=(e,t,a)=>{for(let o of e.children??[]){let e=t+(o.x??0),s=a+(o.y??0);n.set(o.id,{x:e,y:s}),(o.children??[]).length===0&&r.set(o.id,{x:e+(o.width??0)/2,y:s+(o.height??0)/2}),i(o,e,s)}};i(e,0,0);let a=new Map,o=e=>{for(let r of e.edges??[]){let i=n.get(r.container??e.id)??{x:0,y:0},o=r.sections?.[0];if(o===void 0)continue;let s=xv(o,i),c=null,l=r.labels?.[0];if(l!==void 0&&l.x!==void 0&&l.y!==void 0&&(c=Cv(s,{x:l.x+i.x+(l.width??0)/2,y:l.y+i.y+(l.height??0)/2})),t.has(r.id)){let e=Sv(s);s=[...s].reverse(),c!==null&&(c=e-c)}a.set(r.id,{points:s,labelAt:c})}for(let t of e.children??[])o(t)};return o(e),{nodes:r,edges:a}}var Tv=e=>e.default??e,Ev=Tv(iv.default),Dv,Ov=()=>Dv??=fv(()=>import(`./elk.bundled-ZYNFKdcv.js`).then(e=>c(e.default,1)).then(e=>new(Tv(e))),[],import.meta.url),kv;function Av(e){let t=new Ev({workerFactory:()=>e()});return{layout:e=>t.layout(e),terminate:()=>t.terminateWorker?.()}}function jv(e){kv=e}var Mv=async e=>(kv??await Ov()).layout(e),Nv=[`curve-style`,`edge-distances`,`source-endpoint`,`target-endpoint`,`segment-weights`,`segment-distances`,`source-text-offset`],Pv=e=>`${Math.round(e*10)/10}px`;function Fv(e,t,n,r){let i=e[0],a=e[e.length-1];if(i===void 0||a===void 0)return{};let o=e.slice(1,-1),s=a.x-i.x,c=a.y-i.y,l=Math.hypot(s,c)||1,u=-c/l,d=s/l,f=[],p=[];for(let e of o){let t=e.x-i.x,n=e.y-i.y;f.push(((t*s+n*c)/(l*l)).toFixed(4)),p.push((t*u+n*d).toFixed(2))}let m={"curve-style":o.length>0?`segments`:`straight`,"edge-distances":`endpoints`,"source-endpoint":`${Pv(i.x-t.x)} ${Pv(i.y-t.y)}`,"target-endpoint":`${Pv(a.x-n.x)} ${Pv(a.y-n.y)}`,"source-text-offset":r===null?0:Math.round(r)};return o.length>0&&(m[`segment-weights`]=f.join(` `),m[`segment-distances`]=p.join(` `)),m}var Iv=1e-6;function Lv(e,t){if(e.isParent()){let n=e.descendants().filter(e=>!e.isParent());return n.length>0&&n.every(e=>Lv(e,t))}let n=t.nodes.get(e.id());if(n===void 0)return!1;let r=e.position();return Math.abs(r.x-n.x)<Iv&&Math.abs(r.y-n.y)<Iv}function Rv(e,t,n){let r=0;e.startBatch();try{for(let[i,a]of t.edges){let t=e.getElementById(i);t.empty()||!t.isEdge()||!n(t)||(t.style(Fv(a.points,t.source().position(),t.target().position(),a.labelAt)),t.scratch(Bv,a),t.addClass(`routed`),r+=1)}}finally{e.endBatch()}return r}function zv(e){e.removeClass(`routed`),e.removeStyle(Nv.join(` `)),e.removeScratch(Bv)}var Bv=`_route`;function Vv(e){let t={};return e.forEach(e=>{if(!e.hasClass(`routed`))return;let n=e.scratch(Bv);n!==void 0&&(t[e.id()]={points:n.points.map(e=>({x:e.x,y:e.y})),labelAt:n.labelAt})}),t}function Hv(e,t,n){let r={nodes:new Map(Object.entries(n).map(([e,t])=>[e,{x:t.x,y:t.y}])),edges:new Map(Object.entries(t).map(([e,t])=>[e,{points:t.points.map(e=>({x:e.x,y:e.y})),labelAt:t.labelAt}]))};return Rv(e,r,e=>!e.hasClass(`routed`)&&Lv(e.source(),r)&&Lv(e.target(),r))}function Uv(e){let t=e=>{let t=e.target;zv(t.union(t.ancestors()).union(t.descendants()).connectedEdges(`.routed`))};return e.on(`dragfree`,`node`,t),()=>{e.off(`dragfree`,`node`,t)}}var Wv=`#F0F0F0`,Gv=`#999999`,Kv=170,qv=50,Jv=150,Yv=``;function Xv(e){return e.replace(/([/._-])/g,`$1${Yv}`)}var Zv=20,Qv=1.25,$v=.02,ey=10;function ty(e,t){let n=t===1?e*Qv:e/Qv;return Math.min(ey,Math.max($v,n))}var ny=12;function ry(e,t,n,r,i,a){let o=[],s=U_(String(e.data(`kindLabel`)),a)??U_(String(e.data(`coreKindLabel`)),a);s!==null&&o.push({image:s,positionX:`0%`,positionY:`0%`,size:14});let c=e.data(`status`);t&&o_(c)&&o.push({image:g_[c],positionX:`100%`,positionY:`0%`,size:ny}),n&&e.data(`hasAttestations`)===!0&&o.push({image:__,positionX:`0%`,positionY:`100%`,size:ny});let l=e.data(`owner`),u=e.data(`ownerInitials`),d=r&&l!==null&&u!==null;d&&o.push({image:x_(l,u),positionX:`100%`,positionY:`100%`,size:ny});let f=e.data(`openQuestions`);return i&&typeof f==`number`&&f>0&&o.push({image:C_(f),positionX:d?`84%`:`96%`,positionY:d?`100%`:`88%`,size:ny}),o}var iy=[`added`,`removed`,`changed`],ay=e=>`deco-${e}`,oy=iy.map(ay).join(` `),sy={added:`#416F65`,removed:`#677074`,changed:`#8C4D18`};function cy(e,t){e.elements().removeClass(oy);for(let[n,r]of Object.entries(t)){let t=e.getElementById(n);t.nonempty()&&t.addClass(ay(r))}}function ly(e,t,n,r,i=!0,a=Fg,o=Wg){let s=Jg(o).glyph,c=e=>Xv(vv(e.data(),a,i)),l=new Map,u=i=>{let a=`${String(i.data(`status`))}\u0000${String(i.data(`hasAttestations`))}\u0000${String(i.data(`owner`))}\u0000${String(i.data(`ownerInitials`))}\u0000${String(i.data(`kindLabel`))}\u0000${String(i.data(`openQuestions`))}`,o=l.get(a);if(o!==void 0)return o;let c=ry(i,e,t,n,r,s),u={images:c.map(e=>e.image),positionsX:c.map(e=>e.positionX),positionsY:c.map(e=>e.positionY),sizes:c.map(e=>e.size),containments:c.map(()=>`over`),clips:c.map(()=>`none`)};return l.set(a,u),u},d=[{selector:`node`,style:{"background-color":Wv,"border-color":Gv,"border-width":2,shape:`roundrectangle`,width:Kv,height:qv,padding:`8px`,label:`data(wrapLabel)`,"font-size":12,"text-wrap":`wrap`,"text-max-width":`${Jv}px`,"text-halign":`center`,"text-valign":`center`,color:`#333333`}},{selector:`node`,style:{"background-image":e=>u(e).images,"background-position-x":e=>u(e).positionsX,"background-position-y":e=>u(e).positionsY,"background-width":e=>u(e).sizes,"background-height":e=>u(e).sizes,"background-image-containment":e=>u(e).containments,"background-clip":e=>u(e).clips}},...Object.entries(M_).map(([e,t])=>({selector:`node[layer = "${e}"]`,style:{"background-color":t.fill,"border-color":t.border}})),{selector:`node:parent`,style:{shape:`roundrectangle`,"background-opacity":.25,"border-width":2,"border-style":`dashed`,padding:`30px`,label:`data(wrapLabel)`,"font-size":13,"font-weight":`bold`,"text-halign":`center`,"text-valign":`top`,"text-margin-y":-8,color:`#333333`,"text-background-color":`#FFFFFF`,"text-background-opacity":1,"text-background-padding":`3px`}},{selector:`node.selected`,style:{"border-color":`#FF6B6B`,"border-width":4}},{selector:`node.folded`,style:{ghost:`yes`,"ghost-offset-x":4,"ghost-offset-y":4,"ghost-opacity":.35,"border-width":2}},{selector:`node.folded[insideCount > 0]`,style:{"background-image":e=>T_(Number(e.data(`insideCount`)??0)),"background-image-containment":`over`,"background-clip":`none`,"background-fit":`none`,"background-width":26,"background-height":12,"background-position-x":`100%`,"background-position-y":`100%`,"background-offset-x":-4,"background-offset-y":-4}},{selector:`edge.lifted`,style:{"line-style":`dashed`,"line-dash-pattern":[6,3],width:2}},{selector:`edge`,style:{"line-color":`#999999`,width:1.5,"curve-style":`taxi`,"target-arrow-shape":`triangle`,"target-arrow-color":`#999999`,label:c,"font-size":10,"text-wrap":`wrap`,"text-max-width":`110px`,"text-background-color":`#FFFFFF`,"text-background-padding":`3px`,"text-background-opacity":1}},{selector:`edge.parallel`,style:{"curve-style":`bezier`,"control-point-step-size":40}},{selector:`edge.routed`,style:{label:``,"source-label":c,"text-wrap":`wrap`,"text-max-width":`110px`}},{selector:`edge.selected`,style:{"line-color":`#FF6B6B`,"target-arrow-color":`#FF6B6B`,width:2.5}}],f=Object.entries(N_).map(([e,t])=>{let n={shape:t.shape};return t.accent===`top-band`&&(n[`background-fill`]=`linear-gradient`,n[`background-gradient-direction`]=`to-bottom`,n[`background-gradient-stop-colors`]=[Gv,Wv],n[`background-gradient-stop-positions`]=[`0%`,`20%`]),t.borderStyle===`dashed`&&(n[`border-style`]=`dashed`),{selector:`node[aspect = "${e}"]:childless`,style:n}}),p=H_.map(e=>{let t={"line-style":e.lineStyle,"source-arrow-shape":e.sourceArrow.shape,"target-arrow-shape":e.targetArrow.shape};return e.sourceArrow.fill!==void 0&&(t[`source-arrow-fill`]=e.sourceArrow.fill),e.targetArrow.fill!==void 0&&(t[`target-arrow-fill`]=e.targetArrow.fill),{selector:`edge[coreKindLabel = "${e.id}"]`,style:t}}),m=[{selector:`node.deco-added, edge.deco-added`,style:{"border-color":sy.added,"border-width":3,"line-color":sy.added,"target-arrow-color":sy.added}},{selector:`node.deco-removed, edge.deco-removed`,style:{"border-color":sy.removed,"border-width":3,"border-style":`dashed`,"line-color":sy.removed,"target-arrow-color":sy.removed,"line-style":`dashed`}},{selector:`node.deco-changed, edge.deco-changed`,style:{"border-color":sy.changed,"border-width":3,"line-color":sy.changed,"target-arrow-color":sy.changed}},{selector:`node.faulted, edge.faulted`,style:{"border-color":`#A3403A`,"border-width":4,"line-color":`#A3403A`,"target-arrow-color":`#A3403A`}}];return[...d,...f,...p,...a_(o),...m]}function uy(e){for(let t of e.conflicts){let e=new Set(t.claims.map(e=>e.from));console.warn(`Nesting conflict: "${t.child}" is claimed by ${e.size} different parents at the same precedence (${t.claims.map(e=>`${dy(e.kind)} from ${e.from}`).join(`, `)}) - rendering it unnested; every claim stays drawn as a regular edge.`)}e.cycleMembers.length>0&&console.warn(`Nesting cycle detected among: ${e.cycleMembers.join(`, `)} - rendering them unnested.`)}var dy=e=>e.split(`#`)[1]??e;function fy(e,t,n,r){new Map(e.nodes.map(e=>[e.id,e.coreKindLabel]));let i=Ag({nodes:e.nodes.map(e=>({id:e.id,kind:e.kind,coreKind:e.coreKindLabel})),edges:e.edges,memberships:r?.memberships??[],nesting:t});uy(i);let a=i.consumedEdgeIds,o=new Map;for(let e of i.parentOf.keys()){let t=i.parentOf.get(e),n=new Set([e]);for(;t!==void 0&&!n.has(t);){n.add(t);let r=o.get(t);r===void 0?o.set(t,[e]):r.push(e),t=i.parentOf.get(t)}}let s=r?.folded??new Set,c=e.nodes.map(e=>{let t=i.parentOf.get(e.id),r=o.get(e.id)??[],a=s.has(e.id);return{data:{id:e.id,label:e.name,wrapLabel:Xv(e.name),kind:e.kind,kindLabel:e.kindLabel,coreKindLabel:e.coreKindLabel,aspect:e.aspect,layer:e.layer,status:e.status,hasAttestations:e.attestations.length>0,owner:e.owner,ownerInitials:E_(e.owner),openQuestions:a?[e.id,...r].reduce((e,t)=>e+(n.get(t)??0),0):n.get(e.id)??0,insideCount:r.length,insideIds:r,...t===void 0?{}:{parent:t,compositionParent:t}},group:`nodes`,...a?{classes:`folded`}:{}}}),l=e.edges.filter(e=>!a.has(e.id)),u=new Map,d=e=>e.from<e.to?`${e.from}\u0000${e.to}`:`${e.to}\u0000${e.from}`;for(let e of l){let t=d(e);u.set(t,(u.get(t)??0)+1)}let f=l.map(e=>({data:{id:e.id,source:e.from,target:e.to,name:e.name??null,kindLabel:e.kindLabel,label:e.name??e.kindLabel,wrapLabel:Xv(e.name??e.kindLabel),coreKindLabel:e.coreKindLabel},group:`edges`,...u.get(d(e))>1?{classes:`parallel`}:{}})),p=s.size===0?[]:Ng({nodes:e.nodes,edges:l},i,s).edges.filter(e=>`count`in e).map(e=>({data:{id:e.id,source:e.from,target:e.to,label:e.count===1?dy(e.kind):`${dy(e.kind)} \u00d7${e.count}`,wrapLabel:Xv(dy(e.kind)),name:null,kindLabel:dy(e.kind),coreKindLabel:dy(e.kind),lifted:!0,liftedCount:e.count,relationshipIds:e.relationshipIds},group:`edges`,classes:`lifted`}));return[...c,...f,...p]}function py(e,t,n){let r=n.trim().toLowerCase(),i=t===null?null:new Set(t);return e.filter(e=>(i===null||i.has(e.id))&&nv(r,e.id,e.name,e.kindLabel)).length}function my(e,t,n){let r=n.trim().toLowerCase(),i=t===null?e.nodes().map(e=>e.id()):t,a=new Set(r===``?i:i.filter(t=>{let n=e.getElementById(t);return nv(r,t,n.data(`label`),n.data(`kindLabel`))})),o=new Set(a),s=t=>{let n=e.getElementById(t).data(`compositionParent`);return typeof n==`string`?n:void 0};for(let e of[...a]){let t=new Set([e]),n=s(e);for(;n!==void 0&&!t.has(n);)t.add(n),a.add(n),n=s(n)}for(let t of[...a]){let n=new Set([t]),r=s(t);for(;r!==void 0&&!n.has(r);){if(n.add(r),e.getElementById(r).hasClass(`folded`)){a.delete(t);break}r=s(r)}}let c=[];for(let t of e.nodes()){let e=s(t.id());if(e===void 0)continue;let n=a.has(t.id())&&a.has(e)?e:null;(t.parent().nonempty()?t.parent().first().id():null)!==n&&c.push({node:t.id(),parent:n})}for(let{node:t,parent:n}of c)e.getElementById(t).move({parent:n});for(let t of e.nodes(`.folded`)){let n=t.data(`insideIds`),r=Array.isArray(n)?n:[];t.data(`insideCount`,r.filter(t=>e.getElementById(t).nonempty()&&o.has(t)).length)}let l=new Set(_y(e.elements()).map(e=>e.id())),u=new Set(a);for(let t of e.edges()){let e=t.data(`source`),n=t.data(`target`);a.has(e)&&a.has(n)&&u.add(t.id())}for(let e of l)u.delete(e);e.elements().style(`display`,`none`),e.elements().filter(e=>u.has(e.id())).style(`display`,`element`)}var hy=`_layoutGeneration`;async function gy(e,t,n,r,i){let a=`elements`in e?e:e.cy(),o=`elements`in e?e.elements():e;if(o.nodes().empty())return;let s=_y(o),c=s.empty()?o:o.difference(s);zv(a.edges());let l=(a.scratch(hy)??0)+1;a.scratch(hy,l);let{graph:u,reversed:d}=bv(c,{direction:t,mode:n,showKindLabels:r}),f=await Mv(u);if(a.destroyed()||a.scratch(hy)!==l)return;let p=wv(f,d);c.layout({name:`preset`,positions:e=>p.nodes.get(e.id())??null,fit:!0,padding:Zv,animate:!1}).run(),Ig(n)&&(a.nodes().updateCompoundBounds(!0),Rv(a,p,e=>Lv(e.source(),p)&&Lv(e.target(),p)),i?.routes!==void 0&&Hv(a,i.routes,i.positions??{}))}var _y=e=>{let t=new Map;return e.nodes().forEach(e=>{let n=e.parent();n.length>0&&t.set(e.id(),n.first().id())}),t.size===0?e.edges().filter(()=>!1):e.edges().filter(e=>yg(e.source().id(),e.target().id(),t))};function vy(e,t,n=Fg,r=!0,i){return gy(e.elements(`:visible`),t,n,r,i)}async function yy(e,t,n,r,i,a){let o=i===null?null:e.getElementById(i),s=o!==null&&o.nonempty()?{...o.position()}:null;if(await vy(e,t,n,r,a),e.destroyed())return!1;if(s!==null&&o!==null&&o.nonempty()){let t=o.position(),n=s.x-t.x,r=s.y-t.y;(n!==0||r!==0)&&e.nodes().forEach(e=>{let t=e.position();e.position({x:t.x+n,y:t.y+r})})}let c=e.elements(`:visible`);if(c.empty())return!1;let l=c.boundingBox(),u=e.extent();return l.x2<u.x1||l.x1>u.x2||l.y2<u.y1||l.y1>u.y2?(e.fit(c,40),!0):!1}function by(e){let t=e.elements(`:visible`);return!t.empty()&&(e.fit(t,Zv),!0)}function xy(e){let t={};return e.forEach(e=>{let{x:n,y:r}=e.position();t[e.id()]={x:n,y:r}}),t}function Sy(e,t){t!==void 0&&e.nodes().forEach(e=>{if(!e.visible()||e.isParent())return;let n=t[e.id()];n!==void 0&&e.position(n)})}function Cy(e,t,n){return n.has(t)?void 0:e}function wy(e,t,n){return n.has(t)?void 0:e}function Ty(e,t,n){return e!==void 0&&(n??t).some(t=>e[t]!==void 0)}function Ey(e,t,n){return{x:(e.x-t.x)/n,y:(e.y-t.y)/n}}function Dy(e,t,n){let r=null,i=()=>{r!==null&&(clearTimeout(r),r=null)},a=()=>{i(),r=setTimeout(()=>{r=null;let i=t();if(i===``)return;let a=Vv(e.edges());n({projectionId:i,positions:xy(e.nodes()),...Object.keys(a).length===0?{}:{routes:a}})},500)};return e.on(`dragfree`,`node`,a),{cancelPending:i,dispose:()=>{e.off(`dragfree`,`node`,a),i()}}}function Oy({graph:e,selectedId:t,onSelect:n,onContextMenu:r,matchedIds:i,quickFilterText:a,nesting:o,faultedIds:s,decorations:c,activeViewId:l,direction:u,layout:d,showKindLabels:f,stylePreset:p,savedPositions:m,savedRoutes:h,onSaveLayout:g,onKindDrop:_,onCanvasReady:v,showLifecycle:b,showEvidence:x,showOwnership:S,showNudges:C,openQuestionCounts:w,folded:T,memberships:E}){let D=(0,y.useRef)(null),O=(0,y.useRef)(null),[k,A]=(0,y.useState)(()=>new Set),j=Cy(m,l,k),M=wy(h,l,k),N=(0,y.useRef)(n),P=(0,y.useRef)(v);P.current=v;let F=(0,y.useRef)(_);F.current=_;let I=(0,y.useRef)(r),L=(0,y.useRef)(!0),R=(0,y.useRef)(!0),z=(0,y.useRef)(l),B=(0,y.useRef)(u),V=(0,y.useRef)(d),H=(0,y.useRef)(!1),U=(0,y.useRef)(i),W=(0,y.useRef)(a),G=(0,y.useRef)(g),K=(0,y.useRef)(j),q=(0,y.useRef)(M),J=(0,y.useRef)(null),ee=(0,y.useRef)(null);(0,y.useEffect)(()=>{N.current=n},[n]),(0,y.useEffect)(()=>{I.current=r},[r]),(0,y.useEffect)(()=>{G.current=g},[g]),(0,y.useEffect)(()=>{K.current=j},[j]),(0,y.useEffect)(()=>{q.current=M},[M]),(0,y.useEffect)(()=>{J.current?.cancelPending()},[l]),(0,y.useEffect)(()=>{if(!D.current)return;let t=vg({container:D.current,elements:fy(e,o,w,{folded:T??new Set,memberships:E}),selectionType:`additive`,boxSelectionEnabled:!0,style:ly(b,x,S,C,f,d,p),wheelSensitivity:.1,layout:{name:`null`}});O.current=t,P.current?.(()=>t.png({full:!0,scale:2,bg:`#ffffff`})),t.on(`tap`,`node`,e=>{let t=e.target.id();N.current(t,`node`)}),t.on(`tap`,`edge`,e=>{let t=e.target.id();N.current(t,`edge`)});let n=e=>{let n=e.originalEvent;if(n!=null)return{x:n.clientX,y:n.clientY};let r=t.container()?.getBoundingClientRect(),i=e.renderedPosition;return{x:(r?.left??0)+(i?.x??0),y:(r?.top??0)+(i?.y??0)}};t.on(`cxttap`,`node`,e=>{I.current({type:`node`,id:e.target.id()},n(e))}),t.on(`cxttap`,`edge`,e=>{I.current({type:`edge`,id:e.target.id()},n(e))}),t.on(`cxttap`,e=>{e.target===t&&I.current({type:`canvas`,id:null},n(e))}),J.current=Dy(t,()=>z.current,e=>{A(t=>{if(!t.has(e.projectionId))return t;let n=new Set(t);return n.delete(e.projectionId),n}),G.current(e)});let r=Uv(t),i=()=>{ee.current={zoom:t.zoom(),pan:{...t.pan()}}};t.on(`layoutstop`,()=>{Sy(t,K.current),i()});let a=D.current,s=0,c=new ResizeObserver(()=>{cancelAnimationFrame(s),s=requestAnimationFrame(()=>{t.resize();let e=ee.current;if(e===null)return;let n=t.pan();if(!(Math.abs(t.zoom()-e.zoom)<1e-6&&Math.abs(n.x-e.pan.x)<.5&&Math.abs(n.y-e.pan.y)<.5))return;let r=t.elements(`:visible`);r.empty()||(t.fit(r,Zv),i())})});return c.observe(a),()=>{cancelAnimationFrame(s),c.disconnect(),r(),J.current?.dispose(),P.current?.(null),t.destroy(),O.current=null}},[]),(0,y.useEffect)(()=>{if(O.current){if(R.current){R.current=!1;return}O.current.style(ly(b,x,S,C,f,d,p))}},[b,x,S,C,f,d,p]),(0,y.useEffect)(()=>{if(O.current){if(L.current)L.current=!1;else{let t=fy(e,o,w,{folded:T??new Set,memberships:E});O.current.elements().remove(),O.current.add(t)}my(O.current,U.current,W.current),gy(O.current.elements(`:visible`),u,d,f,{positions:K.current,routes:q.current})}},[e,w,o,E]);let Y=(0,y.useRef)(null);(0,y.useEffect)(()=>{let t=O.current;if(t===null)return;let n=Y.current;if(Y.current=T??new Set,n===null)return;let r=T??new Set,s=[...[...r].filter(e=>!n.has(e)),...[...n].filter(e=>!r.has(e))];s.length!==0&&(t.elements().remove(),t.add(fy(e,o,w,{folded:r,memberships:E})),my(t,i,a),yy(t,u,d,f,s.length===1?s[0]:null,{positions:K.current,routes:q.current}))},[T]),(0,y.useEffect)(()=>{if(O.current){O.current.elements().removeClass(`faulted`);for(let e of s){let t=O.current.getElementById(e);t.nonempty()&&t.addClass(`faulted`)}}},[s,e]),(0,y.useEffect)(()=>{O.current&&cy(O.current,c)},[c,e]),(0,y.useEffect)(()=>{if(O.current&&(O.current.elements().removeClass(`selected`),t)){let e=O.current.getElementById(t);e.nonempty()&&e.addClass(`selected`)}},[t,e]),(0,y.useEffect)(()=>{(l!==z.current||u!==B.current||d!==V.current)&&(z.current=l,B.current=u,V.current=d,H.current=!0)},[l,u,d]),(0,y.useEffect)(()=>{if(!O.current)return;my(O.current,i,a);let e=i!==U.current;U.current=i;let t=a!==W.current;W.current=a,H.current||e?(H.current=!1,vy(O.current,u,d,f,{positions:K.current,routes:q.current})):t&&by(O.current)&&(ee.current={zoom:O.current.zoom(),pan:{...O.current.pan()}})},[i,a,e,u,d]);let te=()=>{A(e=>new Set(e).add(l)),K.current=void 0,q.current=void 0,J.current?.cancelPending(),O.current!==null&&vy(O.current,u,d,f)},ne=e=>{let t=O.current;t!==null&&t.zoom({level:ty(t.zoom(),e),renderedPosition:{x:t.width()/2,y:t.height()/2}})},re=()=>{let e=O.current;e!==null&&by(e)&&(ee.current={zoom:e.zoom(),pan:{...e.pan()}})},ie=Ty(j,e.nodes.map(e=>e.id),i);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{ref:D,style:{position:`relative`,width:`100%`,height:`100%`,...Jg(p).canvas===void 0?{}:{background:Jg(p).canvas}},onContextMenu:e=>e.preventDefault(),onDragOver:e=>{F.current!==void 0&&e.dataTransfer.types.includes(`application/x-yarramate-kind`)&&e.preventDefault()},onDrop:e=>{let t=e.dataTransfer.getData(G_);if(t===``||F.current===void 0)return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect(),r=O.current;F.current(t,Ey({x:e.clientX-n.left,y:e.clientY-n.top},r?.pan()??{x:0,y:0},r?.zoom()??1))}}),ie?(0,$.jsxs)(`div`,{className:`saved-layout-pill`,role:`status`,children:[(0,$.jsx)(`span`,{children:`Saved layout in force`}),(0,$.jsx)(`button`,{type:`button`,onClick:te,children:`Discard`})]}):null,(0,$.jsxs)(`div`,{className:`zoom-controls`,role:`group`,"aria-label":`Zoom controls`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`Zoom in`,onClick:()=>ne(1),children:`+`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Zoom out`,onClick:()=>ne(-1),children:`−`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Fit diagram`,onClick:re,children:`Fit`})]})]})}var ky=Symbol.for(`yaml.alias`),Ay=Symbol.for(`yaml.document`),jy=Symbol.for(`yaml.map`),My=Symbol.for(`yaml.pair`),Ny=Symbol.for(`yaml.scalar`),Py=Symbol.for(`yaml.seq`),Fy=Symbol.for(`yaml.node.type`),Iy=e=>!!e&&typeof e==`object`&&e[Fy]===ky,Ly=e=>!!e&&typeof e==`object`&&e[Fy]===Ay,Ry=e=>!!e&&typeof e==`object`&&e[Fy]===jy,zy=e=>!!e&&typeof e==`object`&&e[Fy]===My,By=e=>!!e&&typeof e==`object`&&e[Fy]===Ny,Vy=e=>!!e&&typeof e==`object`&&e[Fy]===Py;function Hy(e){if(e&&typeof e==`object`)switch(e[Fy]){case jy:case Py:return!0}return!1}function Uy(e){if(e&&typeof e==`object`)switch(e[Fy]){case ky:case jy:case Ny:case Py:return!0}return!1}var Wy=e=>(By(e)||Hy(e))&&!!e.anchor,Gy=Symbol(`break visit`),Ky=Symbol(`skip children`),qy=Symbol(`remove node`);function Jy(e,t){let n=Xy(t);Ly(e)?Yy(null,e.contents,n,Object.freeze([e]))===qy&&(e.contents=null):Yy(null,e,n,Object.freeze([]))}Jy.BREAK=Gy,Jy.SKIP=Ky,Jy.REMOVE=qy;function Yy(e,t,n,r){let i=Zy(e,t,n,r);if(Uy(i)||zy(i))return Qy(e,r,i),Yy(e,i,n,r);if(typeof i!=`symbol`){if(Hy(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=Yy(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===Gy)return Gy;else i===qy&&(t.items.splice(e,1),--e)}}else if(zy(t)){r=Object.freeze(r.concat(t));let e=Yy(`key`,t.key,n,r);if(e===Gy)return Gy;e===qy&&(t.key=null);let i=Yy(`value`,t.value,n,r);if(i===Gy)return Gy;i===qy&&(t.value=null)}}return i}function Xy(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Zy(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(Ry(t))return n.Map?.(e,t,r);if(Vy(t))return n.Seq?.(e,t,r);if(zy(t))return n.Pair?.(e,t,r);if(By(t))return n.Scalar?.(e,t,r);if(Iy(t))return n.Alias?.(e,t,r)}function Qy(e,t,n){let r=t[t.length-1];if(Hy(r))r.items[e]=n;else if(zy(r))e===`key`?r.key=n:r.value=n;else if(Ly(r))r.contents=n;else{let e=Iy(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var $y={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},eb=e=>e.replace(/[!,[\]{}]/g,e=>$y[e]),tb=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+eb(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&Uy(e.contents)){let t={};Jy(e.contents,(e,n)=>{Uy(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)(i!==`!!`||a!==`tag:yaml.org,2002:`)&&(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
|
|
329
|
+
`);i.aPosition=t.getAttribLocation(i,`aPosition`),i.aIndex=t.getAttribLocation(i,`aIndex`),i.aVertType=t.getAttribLocation(i,`aVertType`),i.aTransform=t.getAttribLocation(i,`aTransform`),i.aAtlasId=t.getAttribLocation(i,`aAtlasId`),i.aTex=t.getAttribLocation(i,`aTex`),i.aPointAPointB=t.getAttribLocation(i,`aPointAPointB`),i.aPointCPointD=t.getAttribLocation(i,`aPointCPointD`),i.aLineWidth=t.getAttribLocation(i,`aLineWidth`),i.aColor=t.getAttribLocation(i,`aColor`),i.aCornerRadius=t.getAttribLocation(i,`aCornerRadius`),i.aBorderColor=t.getAttribLocation(i,`aBorderColor`),i.uPanZoomMatrix=t.getUniformLocation(i,`uPanZoomMatrix`),i.uAtlasSize=t.getUniformLocation(i,`uAtlasSize`),i.uBGColor=t.getUniformLocation(i,`uBGColor`),i.uZoom=t.getUniformLocation(i,`uZoom`),i.uTextures=[];for(var a=0;a<this.batchManager.getMaxAtlasesPerBatch();a++)i.uTextures.push(t.getUniformLocation(i,`uTexture${a}`));return i}},{key:`_createVAO`,value:function(){var e=[0,0,1,0,1,1,0,0,1,1,0,1];this.vertexCount=e.length/2;var t=this.maxInstances,n=this.gl,r=this.program,i=n.createVertexArray();return n.bindVertexArray(i),Xm(n,`vec2`,r.aPosition,e),this.transformBuffer=Qm(n,t,r.aTransform),this.indexBuffer=Zm(n,t,`vec4`,r.aIndex),this.vertTypeBuffer=Zm(n,t,`int`,r.aVertType),this.atlasIdBuffer=Zm(n,t,`int`,r.aAtlasId),this.texBuffer=Zm(n,t,`vec4`,r.aTex),this.pointAPointBBuffer=Zm(n,t,`vec4`,r.aPointAPointB),this.pointCPointDBuffer=Zm(n,t,`vec4`,r.aPointCPointD),this.lineWidthBuffer=Zm(n,t,`vec2`,r.aLineWidth),this.colorBuffer=Zm(n,t,`vec4`,r.aColor),this.cornerRadiusBuffer=Zm(n,t,`vec4`,r.aCornerRadius),this.borderColorBuffer=Zm(n,t,`vec4`,r.aBorderColor),n.bindVertexArray(null),i}},{key:`buffers`,get:function(){var e=this;return this._buffers||=Object.keys(this).filter(function(e){return ye(e,`Buffer`)}).map(function(t){return e[t]}),this._buffers}},{key:`startFrame`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:_h.SCREEN;this.panZoomMatrix=e,this.renderTarget=t,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()}},{key:`startBatch`,value:function(){this.instanceCount=0,this.batchManager.startBatch()}},{key:`endFrame`,value:function(){this.endBatch()}},{key:`_isVisible`,value:function(e,t){return e.visible()?t&&t.isVisible?t.isVisible(e):!0:!1}},{key:`drawTexture`,value:function(e,t,n){var r=this.atlasManager,i=this.batchManager,a=r.getRenderTypeOpts(n);if(this._isVisible(e,a)&&!(e.isEdge()&&!this._isValidEdge(e))){if(this.renderTarget.picking&&a.getTexPickingMode){var o=a.getTexPickingMode(e);if(o===vh.IGNORE)return;if(o==vh.USE_BB){this.drawPickingRectangle(e,t,n);return}}var s=E(r.getAtlasInfo(e,n)),c;try{for(s.s();!(c=s.n()).done;){var l=c.value,u=l.atlas,d=l.tex1,f=l.tex2;i.canAddToCurrentBatch(u)||this.endBatch();for(var p=i.getAtlasIndexForBatch(u),m=0,h=[[d,!0],[f,!1]];m<h.length;m++){var g=M(h[m],2),_=g[0],v=g[1];if(_.w!=0){var y=this.instanceCount;this.vertTypeBuffer.getView(y)[0]=yh,Wm(t,this.indexBuffer.getView(y));var b=this.atlasIdBuffer.getView(y);b[0]=p;var x=this.texBuffer.getView(y);x[0]=_.x,x[1]=_.y,x[2]=_.w,x[3]=_.h;var S=this.transformBuffer.getMatrixView(y);this.setTransformMatrix(e,S,a,l,v),this.instanceCount++,v||this.wrappedCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}catch(e){s.e(e)}finally{s.f()}}}},{key:`setTransformMatrix`,value:function(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=0;if(n.shapeProps&&n.shapeProps.padding&&(a=e.pstyle(n.shapeProps.padding).pfValue),r){var o=r.bb,s=r.tex1,c=r.tex2,l=s.w/(s.w+c.w);i||(l=1-l);var u=this._getAdjustedBB(o,a,i,l);this._applyTransformMatrix(t,u,n,e)}else{var d=n.getBoundingBox(e),f=this._getAdjustedBB(d,a,!0,1);this._applyTransformMatrix(t,f,n,e)}}},{key:`_applyTransformMatrix`,value:function(e,t,n,r){var i,a;nh(e);var o=n.getRotation?n.getRotation(r):0;if(o!==0){var s=n.getRotationPoint(r),c=s.x,l=s.y;ih(e,e,[c,l]),ah(e,e,o);var u=n.getRotationOffset(r);i=u.x+(t.xOffset||0),a=u.y+(t.yOffset||0)}else i=t.x1,a=t.y1;ih(e,e,[i,a]),oh(e,e,[t.w,t.h])}},{key:`_getAdjustedBB`,value:function(e,t,n,r){var i=e.x1,a=e.y1,o=e.w,s=e.h,c=e.yOffset;t&&(i-=t,a-=t,o+=2*t,s+=2*t);var l=0,u=o*r;return n&&r<1?o=u:!n&&r<1&&(l=o-u,i+=l,o=u),{x1:i,y1:a,w:o,h:s,xOffset:l,yOffset:c}}},{key:`drawPickingRectangle`,value:function(e,t,n){var r=this.atlasManager.getRenderTypeOpts(n),i=this.instanceCount;this.vertTypeBuffer.getView(i)[0]=Ch,Wm(t,this.indexBuffer.getView(i)),Um([0,0,0],1,this.colorBuffer.getView(i));var a=this.transformBuffer.getMatrixView(i);this.setTransformMatrix(e,a,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},{key:`drawNode`,value:function(e,t,n){var r=this.simpleShapeOptions.get(n);if(this._isVisible(e,r)){var i=r.shapeProps,a=this._getVertTypeForShape(e,i.shape);if(a===void 0||r.isSimple&&!r.isSimple(e,this.renderTarget)){this.drawTexture(e,t,n);return}var o=this.instanceCount;if(this.vertTypeBuffer.getView(o)[0]=a,a===wh||a===Th){var s=r.getBoundingBox(e),c=this._getCornerRadius(e,i.radius,s),l=this.cornerRadiusBuffer.getView(o);l[0]=c,l[1]=c,l[2]=c,l[3]=c,a===Th&&(l[0]=0,l[2]=0)}Wm(t,this.indexBuffer.getView(o));var u=this.renderTarget.picking?1:n===`node-body`?e.effectiveOpacity():1,d=this.renderTarget.picking?1:e.pstyle(i.opacity).value*u,f=e.pstyle(i.color).value;Um(f,d,this.colorBuffer.getView(o));var p=this.lineWidthBuffer.getView(o);if(p[0]=0,p[1]=0,i.border){var m=e.pstyle(`border-width`).value;if(m>0){var h=e.pstyle(`border-color`).value;Um(h,u*e.pstyle(`border-opacity`).value,this.borderColorBuffer.getView(o));var g=e.pstyle(`border-position`).value;if(g===`inside`)p[0]=0,p[1]=-m;else if(g===`outside`)p[0]=m,p[1]=0;else{var _=m/2;p[0]=_,p[1]=-_}}}var v=this.transformBuffer.getMatrixView(o);this.setTransformMatrix(e,v,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}},{key:`_getVertTypeForShape`,value:function(e,t){switch(e.pstyle(t).value){case`rectangle`:return Ch;case`ellipse`:return Eh;case`roundrectangle`:case`round-rectangle`:return wh;case`bottom-round-rectangle`:return Th;default:return}}},{key:`_getCornerRadius`,value:function(e,t,n){var r=n.w,i=n.h;if(e.pstyle(t).value===`auto`)return $r(r,i);var a=e.pstyle(t).pfValue,o=r/2,s=i/2;return Math.min(a,s,o)}},{key:`drawEdgeArrow`,value:function(e,t,n){if(e.visible()){var r=e._private.rscratch,i,a,o;if(n===`source`?(i=r.arrowStartX,a=r.arrowStartY,o=r.srcArrowAngle):(i=r.arrowEndX,a=r.arrowEndY,o=r.tgtArrowAngle),!(isNaN(i)||i==null||isNaN(a)||a==null||isNaN(o)||o==null)&&e.pstyle(n+`-arrow-shape`).value!==`none`){var s=e.pstyle(n+`-arrow-color`).value,c=e.pstyle(`opacity`).value*e.pstyle(`line-opacity`).value,l=e.pstyle(`width`).pfValue,u=e.pstyle(`arrow-scale`).value,d=this.r.getArrowWidth(l,u),f=this.instanceCount,p=this.transformBuffer.getMatrixView(f);nh(p),ih(p,p,[i,a]),oh(p,p,[d,d]),ah(p,p,o),this.vertTypeBuffer.getView(f)[0]=Sh,Wm(t,this.indexBuffer.getView(f)),Um(s,c,this.colorBuffer.getView(f)),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:`drawEdgeLine`,value:function(e,t){if(e.visible()){var n=this._getEdgePoints(e);if(n){var r=e.pstyle(`opacity`).value,i=e.pstyle(`line-opacity`).value,a=e.pstyle(`width`).pfValue,o=e.pstyle(`line-color`).value,s=r*i;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),n.length==4){var c=this.instanceCount;this.vertTypeBuffer.getView(c)[0]=bh,Wm(t,this.indexBuffer.getView(c)),Um(o,s,this.colorBuffer.getView(c));var l=this.lineWidthBuffer.getView(c);l[0]=a;var u=this.pointAPointBBuffer.getView(c);u[0]=n[0],u[1]=n[1],u[2]=n[2],u[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var d=0;d<n.length-2;d+=2){var f=this.instanceCount;this.vertTypeBuffer.getView(f)[0]=xh,Wm(t,this.indexBuffer.getView(f)),Um(o,s,this.colorBuffer.getView(f));var p=this.lineWidthBuffer.getView(f);p[0]=a;var m=n[d-2],h=n[d-1],g=n[d],_=n[d+1],v=n[d+2],y=n[d+3],b=n[d+4],x=n[d+5];d==0&&(m=2*g-v+.001,h=2*_-y+.001),d==n.length-4&&(b=2*v-g+.001,x=2*y-_+.001);var S=this.pointAPointBBuffer.getView(f);S[0]=m,S[1]=h,S[2]=g,S[3]=_;var C=this.pointCPointDBuffer.getView(f);C[0]=v,C[1]=y,C[2]=b,C[3]=x,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:`_isValidEdge`,value:function(e){var t=e._private.rscratch;return!(t.badLine||t.allpts==null||isNaN(t.allpts[0]))}},{key:`_getEdgePoints`,value:function(e){var t=e._private.rscratch;if(this._isValidEdge(e)){var n=t.allpts;if(n.length==4)return n;var r=this._getNumSegments(e);return this._getCurveSegmentPoints(n,r)}}},{key:`_getNumSegments`,value:function(e){return Math.min(15,this.maxInstances)}},{key:`_getCurveSegmentPoints`,value:function(e,t){if(e.length==4)return e;for(var n=Array((t+1)*2),r=0;r<=t;r++)if(r==0)n[0]=e[0],n[1]=e[1];else if(r==t)n[r*2]=e[e.length-2],n[r*2+1]=e[e.length-1];else{var i=r/t;this._setCurvePoint(e,i,n,r*2)}return n}},{key:`_setCurvePoint`,value:function(e,t,n,r){if(e.length<=2)n[r]=e[0],n[r+1]=e[1];else{for(var i=Array(e.length-2),a=0;a<i.length;a+=2){var o=(1-t)*e[a]+t*e[a+2],s=(1-t)*e[a+1]+t*e[a+3];i[a]=o,i[a+1]=s}return this._setCurvePoint(i,t,n,r)}}},{key:`endBatch`,value:function(){var e=this.gl,t=this.vao,n=this.vertexCount,r=this.instanceCount;if(r!==0){var i=this.renderTarget.picking?this.pickingProgram:this.program;e.useProgram(i),e.bindVertexArray(t);var a=E(this.buffers),o;try{for(a.s();!(o=a.n()).done;)o.value.bufferSubData(r)}catch(e){a.e(e)}finally{a.f()}for(var s=this.batchManager.getAtlases(),c=0;c<s.length;c++)s[c].bufferIfNeeded(e);for(var l=0;l<s.length;l++)e.activeTexture(e.TEXTURE0+l),e.bindTexture(e.TEXTURE_2D,s[l].texture),e.uniform1i(i.uTextures[l],l);e.uniform1f(i.uZoom,zm(this.r)),e.uniformMatrix3fv(i.uPanZoomMatrix,!1,this.panZoomMatrix),e.uniform1i(i.uAtlasSize,this.batchManager.getAtlasSize());var u=Um(this.bgColor,1);e.uniform4fv(i.uBGColor,u),e.drawArraysInstanced(e.TRIANGLES,0,n,r),e.bindVertexArray(null),e.bindTexture(e.TEXTURE_2D,null),this.debug&&this.batchDebugInfo.push({count:r,atlasCount:s.length}),this.startBatch()}}},{key:`getDebugInfo`,value:function(){var e=this.atlasManager.getDebugInfo(),t=e.reduce(function(e,t){return e+t.atlasCount},0),n=this.batchDebugInfo,r=n.reduce(function(e,t){return e+t.count},0);return{atlasInfo:e,totalAtlases:t,wrappedCount:this.wrappedCount,simpleCount:this.simpleCount,batchCount:n.length,batchInfo:n,totalInstances:r}}}])}(),Oh={};Oh.initWebgl=function(e,t){var n=this,r=n.data.contexts[n.WEBGL];e.bgColor=kh(n),e.webglTexSize=Math.min(e.webglTexSize,r.getParameter(r.MAX_TEXTURE_SIZE)),e.webglTexRows=Math.min(e.webglTexRows,54),e.webglTexRowsNodes=Math.min(e.webglTexRowsNodes,54),e.webglBatchSize=Math.min(e.webglBatchSize,16384),e.webglTexPerBatch=Math.min(e.webglTexPerBatch,r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS)),n.webglDebug=e.webglDebug,n.webglDebugShowAtlases=e.webglDebugShowAtlases,n.pickingFrameBuffer=$m(r),n.pickingFrameBuffer.needsDraw=!0,n.drawing=new Dh(n,r,e);var i=function(e){return function(t){return n.getTextAngle(t,e)}},a=function(e){return function(t){var n=t.pstyle(e);return n&&n.value}},o=function(e){return function(t){return t.pstyle(`${e}-opacity`).value>0}},s=function(e){return e.pstyle(`text-events`).strValue===`yes`?vh.USE_BB:vh.IGNORE},c=function(e){var t=e.position(),n=t.x,r=t.y,i=e.outerWidth(),a=e.outerHeight();return{w:i,h:a,x1:n-i/2,y1:r-a/2}};n.drawing.addAtlasCollection(`node`,{texRows:e.webglTexRowsNodes}),n.drawing.addAtlasCollection(`label`,{texRows:e.webglTexRows}),n.drawing.addTextureAtlasRenderType(`node-body`,{collection:`node`,getKey:t.getStyleKey,getBoundingBox:t.getElementBox,drawElement:t.drawElement}),n.drawing.addSimpleShapeRenderType(`node-body`,{getBoundingBox:c,isSimple:Vm,shapeProps:{shape:`shape`,color:`background-color`,opacity:`background-opacity`,radius:`corner-radius`,border:!0}}),n.drawing.addSimpleShapeRenderType(`node-overlay`,{getBoundingBox:c,isVisible:o(`overlay`),shapeProps:{shape:`overlay-shape`,color:`overlay-color`,opacity:`overlay-opacity`,padding:`overlay-padding`,radius:`overlay-corner-radius`}}),n.drawing.addSimpleShapeRenderType(`node-underlay`,{getBoundingBox:c,isVisible:o(`underlay`),shapeProps:{shape:`underlay-shape`,color:`underlay-color`,opacity:`underlay-opacity`,padding:`underlay-padding`,radius:`underlay-corner-radius`}}),n.drawing.addTextureAtlasRenderType(`label`,{collection:`label`,getTexPickingMode:s,getKey:jh(t.getLabelKey,null),getBoundingBox:Mh(t.getLabelBox,null),drawClipped:!0,drawElement:t.drawLabel,getRotation:i(null),getRotationPoint:t.getLabelRotationPoint,getRotationOffset:t.getLabelRotationOffset,isVisible:a(`label`)}),n.drawing.addTextureAtlasRenderType(`edge-source-label`,{collection:`label`,getTexPickingMode:s,getKey:jh(t.getSourceLabelKey,`source`),getBoundingBox:Mh(t.getSourceLabelBox,`source`),drawClipped:!0,drawElement:t.drawSourceLabel,getRotation:i(`source`),getRotationPoint:t.getSourceLabelRotationPoint,getRotationOffset:t.getSourceLabelRotationOffset,isVisible:a(`source-label`)}),n.drawing.addTextureAtlasRenderType(`edge-target-label`,{collection:`label`,getTexPickingMode:s,getKey:jh(t.getTargetLabelKey,`target`),getBoundingBox:Mh(t.getTargetLabelBox,`target`),drawClipped:!0,drawElement:t.drawTargetLabel,getRotation:i(`target`),getRotationPoint:t.getTargetLabelRotationPoint,getRotationOffset:t.getTargetLabelRotationOffset,isVisible:a(`target-label`)});var l=Dt(function(){console.log(`garbage collect flag set`),n.data.gc=!0},1e4);n.onUpdateEleCalcs(function(e,t){var r=!1;t&&t.length>0&&(r|=n.drawing.invalidate(t)),r&&l()}),Nh(n)};function kh(e){var t=e.cy.container();return Ne(t&&t.style&&t.style.backgroundColor||`white`)}function Ah(e,t){var n=e._private.rscratch;return _n(n,`labelWrapCachedLines`,t)||[]}var jh=function(e,t){return function(n){var r=e(n),i=Ah(n,t);return i.length>1?i.map(function(e,t){return`${r}_${t}`}):r}},Mh=function(e,t){return function(n,r){var i=e(n);if(typeof r==`string`){var a=r.indexOf(`_`);if(a>0){var o=Number(r.substring(a+1)),s=Ah(n,t),c=i.h/s.length,l=c*o,u=i.y1+l;return{x1:i.x1,w:i.w,y1:u,h:c,yOffset:l}}}return i}};function Nh(e){var t=e.render;e.render=function(n){n||={};var r=e.cy;e.webgl&&(r.zoom()>Dp?(Ph(e),t.call(e,n)):(Fh(e),Wh(e,n,_h.SCREEN)))};var n=e.matchCanvasSize;e.matchCanvasSize=function(t){n.call(e,t),e.pickingFrameBuffer.setFramebufferAttachmentSizes(e.canvasWidth,e.canvasHeight),e.pickingFrameBuffer.needsDraw=!0},e.findNearestElements=function(t,n,r,i){return Hh(e,t,n)};var r=e.invalidateCachedZSortedEles;e.invalidateCachedZSortedEles=function(){r.call(e),e.pickingFrameBuffer.needsDraw=!0};var i=e.notify;e.notify=function(t,n){i.call(e,t,n),t===`viewport`||t===`bounds`?e.pickingFrameBuffer.needsDraw=!0:t===`background`&&e.drawing.invalidate(n,{type:`node-body`})}}function Ph(e){var t=e.data.contexts[e.WEBGL];t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)}function Fh(e){var t=function(t){t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.canvasWidth,e.canvasHeight),t.restore()};t(e.data.contexts[e.NODE]),t(e.data.contexts[e.DRAG])}function Ih(e){var t=e.canvasWidth,n=e.canvasHeight,r=Rm(e),i=r.pan,a=r.zoom,o=th();ih(o,o,[i.x,i.y]),oh(o,o,[a,a]);var s=th();sh(s,t,n);var c=th();return rh(c,s,o),c}function Lh(e,t){var n=e.canvasWidth,r=e.canvasHeight,i=Rm(e),a=i.pan,o=i.zoom;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,n,r),t.translate(a.x,a.y),t.scale(o,o)}function Rh(e,t){e.drawSelectionRectangle(t,function(t){return Lh(e,t)})}function zh(e){var t=e.data.contexts[e.NODE];t.save(),Lh(e,t),t.strokeStyle=`rgba(0, 0, 0, 0.3)`,t.beginPath(),t.moveTo(-1e3,0),t.lineTo(1e3,0),t.stroke(),t.beginPath(),t.moveTo(0,-1e3),t.lineTo(0,1e3),t.stroke(),t.restore()}function Bh(e){var t=function(t,n,r){for(var i=t.atlasManager.getAtlasCollection(n),a=e.data.contexts[e.NODE],o=i.atlases,s=0;s<o.length;s++){var c=o[s].canvas;if(c){var l=c.width,u=c.height,d=l*s,f=c.height*r,p=.4;a.save(),a.scale(p,p),a.drawImage(c,d,f),a.strokeStyle=`black`,a.rect(d,f,l,u),a.stroke(),a.restore()}}},n=0;t(e.drawing,`node`,n++),t(e.drawing,`label`,n++)}function Vh(e,t,n,r,i){var a,o,s,c,l=Rm(e),u=l.pan,d=l.zoom,f=M(Bm(e,u,d,t,n),2),p=f[0],m=f[1],h=6;if(a=p-h/2,o=m-h/2,s=h,c=h,s===0||c===0)return[];var g=e.data.contexts[e.WEBGL];g.bindFramebuffer(g.FRAMEBUFFER,e.pickingFrameBuffer),e.pickingFrameBuffer.needsDraw&&(g.viewport(0,0,g.canvas.width,g.canvas.height),Wh(e,null,_h.PICKING),e.pickingFrameBuffer.needsDraw=!1);var _=s*c,v=new Uint8Array(_*4);g.readPixels(a,o,s,c,g.RGBA,g.UNSIGNED_BYTE,v),g.bindFramebuffer(g.FRAMEBUFFER,null);for(var y=new Set,b=0;b<_;b++){var x=Gm(v.slice(b*4,b*4+4))-1;x>=0&&y.add(x)}return y}function Hh(e,t,n){var r=Vh(e,t,n),i=e.getCachedZSortedEles(),a,o,s=E(r),c;try{for(s.s();!(c=s.n()).done;){var l=i[c.value];if(!a&&l.isNode()&&(a=l),!o&&l.isEdge()&&(o=l),a&&o)break}}catch(e){s.e(e)}finally{s.f()}return[a,o].filter(Boolean)}function Uh(e,t,n){var r=e.drawing;t+=1,n.isNode()?(r.drawNode(n,t,`node-underlay`),r.drawNode(n,t,`node-body`),r.drawTexture(n,t,`label`),r.drawNode(n,t,`node-overlay`)):(r.drawEdgeLine(n,t),r.drawEdgeArrow(n,t,`source`),r.drawEdgeArrow(n,t,`target`),r.drawTexture(n,t,`label`),r.drawTexture(n,t,`edge-source-label`),r.drawTexture(n,t,`edge-target-label`))}function Wh(e,t,n){var r;e.webglDebug&&(r=performance.now());var i=e.drawing,a=0;if(n.screen&&e.data.canvasNeedsRedraw[e.SELECT_BOX]&&Rh(e,t),e.data.canvasNeedsRedraw[e.NODE]||n.picking){var o=e.data.contexts[e.WEBGL];n.screen?(o.clearColor(0,0,0,0),o.enable(o.BLEND),o.blendFunc(o.ONE,o.ONE_MINUS_SRC_ALPHA)):o.disable(o.BLEND),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),o.viewport(0,0,o.canvas.width,o.canvas.height);var s=Ih(e),c=e.getCachedZSortedEles();if(a=c.length,i.startFrame(s,n),n.screen){for(var l=0;l<c.nondrag.length;l++)Uh(e,l,c.nondrag[l]);for(var u=0;u<c.drag.length;u++)Uh(e,u,c.drag[u])}else if(n.picking)for(var d=0;d<c.length;d++)Uh(e,d,c[d]);i.endFrame(),n.screen&&e.webglDebugShowAtlases&&(zh(e),Bh(e)),e.data.canvasNeedsRedraw[e.NODE]=!1,e.data.canvasNeedsRedraw[e.DRAG]=!1}if(e.webglDebug){var f=performance.now(),p=Math.ceil(f-r),m=i.getDebugInfo(),h=[`${a} elements`,`${m.totalInstances} instances`,`${m.batchCount} batches`,`${m.totalAtlases} atlases`,`${m.wrappedCount} wrapped textures`,`${m.simpleCount} simple shapes`].join(`, `);console.log(`WebGL (${n.name}) - frame time ${p}ms`),console.log(`Totals:`),console.log(` ${h}`),console.log(`Texture Atlases Used:`);var g=m.atlasInfo,_=E(g),v;try{for(_.s();!(v=_.n()).done;){var y=v.value;console.log(` ${y.type}: ${y.keyCount} keys, ${y.atlasCount} atlases`)}}catch(e){_.e(e)}finally{_.f()}console.log(``)}e.data.gc&&(console.log(`Garbage Collect!`),e.data.gc=!1,i.gc())}var Gh={};Gh.drawPolygonPath=function(e,t,n,r,i,a){var o=r/2,s=i/2;e.beginPath&&e.beginPath(),e.moveTo(t+o*a[0],n+s*a[1]);for(var c=1;c<a.length/2;c++)e.lineTo(t+o*a[c*2],n+s*a[c*2+1]);e.closePath()},Gh.drawRoundPolygonPath=function(e,t,n,r,i,a,o){o.forEach(function(t){return Gf(e,t)}),e.closePath()},Gh.drawRoundRectanglePath=function(e,t,n,r,i,a){var o=r/2,s=i/2,c=a===`auto`?$r(r,i):Math.min(a,s,o);e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.arcTo(t+o,n-s,t+o,n,c),e.arcTo(t+o,n+s,t,n+s,c),e.arcTo(t-o,n+s,t-o,n,c),e.arcTo(t-o,n-s,t,n-s,c),e.lineTo(t,n-s),e.closePath()},Gh.drawBottomRoundRectanglePath=function(e,t,n,r,i,a){var o=r/2,s=i/2,c=a===`auto`?$r(r,i):a;e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.lineTo(t+o,n-s),e.lineTo(t+o,n),e.arcTo(t+o,n+s,t,n+s,c),e.arcTo(t-o,n+s,t-o,n,c),e.lineTo(t-o,n-s),e.lineTo(t,n-s),e.closePath()},Gh.drawCutRectanglePath=function(e,t,n,r,i,a,o){var s=r/2,c=i/2,l=o===`auto`?ti():o;e.beginPath&&e.beginPath(),e.moveTo(t-s+l,n-c),e.lineTo(t+s-l,n-c),e.lineTo(t+s,n-c+l),e.lineTo(t+s,n+c-l),e.lineTo(t+s-l,n+c),e.lineTo(t-s+l,n+c),e.lineTo(t-s,n+c-l),e.lineTo(t-s,n-c+l),e.closePath()},Gh.drawBarrelPath=function(e,t,n,r,i){var a=r/2,o=i/2,s=t-a,c=t+a,l=n-o,u=n+o,d=ri(r,i),f=d.widthOffset,p=d.heightOffset,m=d.ctrlPtOffsetPct*f;e.beginPath&&e.beginPath(),e.moveTo(s,l+p),e.lineTo(s,u-p),e.quadraticCurveTo(s+m,u,s+f,u),e.lineTo(c-f,u),e.quadraticCurveTo(c-m,u,c,u-p),e.lineTo(c,l+p),e.quadraticCurveTo(c-m,l,c-f,l),e.lineTo(s+f,l),e.quadraticCurveTo(s+m,l,s,l+p),e.closePath()};for(var Kh=Math.sin(0),qh=Math.cos(0),Jh={},Yh={},Xh=Math.PI/40,Zh=0*Math.PI;Zh<2*Math.PI;Zh+=Xh)Jh[Zh]=Math.sin(Zh),Yh[Zh]=Math.cos(Zh);Gh.drawEllipsePath=function(e,t,n,r,i){if(e.beginPath&&e.beginPath(),e.ellipse)e.ellipse(t,n,r/2,i/2,0,0,2*Math.PI);else for(var a,o,s=r/2,c=i/2,l=0*Math.PI;l<2*Math.PI;l+=Xh)a=t-s*Jh[l]*Kh+s*Yh[l]*qh,o=n+c*Yh[l]*Kh+c*Jh[l]*qh,l===0?e.moveTo(a,o):e.lineTo(a,o);e.closePath()};var Qh={};Qh.createBuffer=function(e,t){var n=document.createElement(`canvas`);return n.width=e,n.height=t,[n,n.getContext(`2d`)]},Qh.bufferCanvasImage=function(e){var t=this.cy,n=t.mutableElements().boundingBox(),r=this.findContainerClientCoords(),i=e.full?Math.ceil(n.w):r[2],a=e.full?Math.ceil(n.h):r[3],o=Y(e.maxWidth)||Y(e.maxHeight),s=this.getPixelRatio(),c=1;if(e.scale!==void 0)i*=e.scale,a*=e.scale,c=e.scale;else if(o){var l=1/0,u=1/0;Y(e.maxWidth)&&(l=c*e.maxWidth/i),Y(e.maxHeight)&&(u=c*e.maxHeight/a),c=Math.min(l,u),i*=c,a*=c}o||(i*=s,a*=s,c*=s);var d=document.createElement(`canvas`);d.width=i,d.height=a,d.style.width=i+`px`,d.style.height=a+`px`;var f=d.getContext(`2d`);if(i>0&&a>0){f.clearRect(0,0,i,a),f.globalCompositeOperation=`source-over`;var p=this.getCachedZSortedEles();if(e.full)f.translate(-n.x1*c,-n.y1*c),f.scale(c,c),this.drawElements(f,p),f.scale(1/c,1/c),f.translate(n.x1*c,n.y1*c);else{var m=t.pan(),h={x:m.x*c,y:m.y*c};c*=t.zoom(),f.translate(h.x,h.y),f.scale(c,c),this.drawElements(f,p),f.scale(1/c,1/c),f.translate(-h.x,-h.y)}e.bg&&(f.globalCompositeOperation=`destination-over`,f.fillStyle=e.bg,f.rect(0,0,i,a),f.fill())}return d};function $h(e,t){for(var n=atob(e),r=new ArrayBuffer(n.length),i=new Uint8Array(r),a=0;a<n.length;a++)i[a]=n.charCodeAt(a);return new Blob([r],{type:t})}function eg(e){var t=e.indexOf(`,`);return e.substr(t+1)}function tg(e,t,n){var r=function(){return t.toDataURL(n,e.quality)};switch(e.output){case`blob-promise`:return new Pa(function(r,i){try{t.toBlob(function(e){e==null?i(Error("`canvas.toBlob()` sent a null value in its callback")):r(e)},n,e.quality)}catch(e){i(e)}});case`blob`:return $h(eg(r()),n);case`base64`:return eg(r());default:return r()}}Qh.png=function(e){return tg(e,this.bufferCanvasImage(e),`image/png`)},Qh.jpg=function(e){return tg(e,this.bufferCanvasImage(e),`image/jpeg`)};var ng={};ng.nodeShapeImpl=function(e,t,n,r,i,a,o,s){switch(e){case`ellipse`:return this.drawEllipsePath(t,n,r,i,a);case`polygon`:return this.drawPolygonPath(t,n,r,i,a,o);case`round-polygon`:return this.drawRoundPolygonPath(t,n,r,i,a,o,s);case`roundrectangle`:case`round-rectangle`:return this.drawRoundRectanglePath(t,n,r,i,a,s);case`cutrectangle`:case`cut-rectangle`:return this.drawCutRectanglePath(t,n,r,i,a,o,s);case`bottomroundrectangle`:case`bottom-round-rectangle`:return this.drawBottomRoundRectanglePath(t,n,r,i,a,s);case`barrel`:return this.drawBarrelPath(t,n,r,i,a)}};var rg=ag,ig=ag.prototype;ig.CANVAS_LAYERS=3,ig.SELECT_BOX=0,ig.DRAG=1,ig.NODE=2,ig.WEBGL=3,ig.CANVAS_TYPES=[`2d`,`2d`,`2d`,`webgl2`],ig.BUFFER_COUNT=3,ig.TEXTURE_BUFFER=0,ig.MOTIONBLUR_BUFFER_NODE=1,ig.MOTIONBLUR_BUFFER_DRAG=2;function ag(e){var t=this,n=t.cy.window().document;e.webgl&&(ig.CANVAS_LAYERS=t.CANVAS_LAYERS=4,console.log(`webgl rendering enabled`)),t.data={canvases:Array(ig.CANVAS_LAYERS),contexts:Array(ig.CANVAS_LAYERS),canvasNeedsRedraw:Array(ig.CANVAS_LAYERS),bufferCanvases:Array(ig.BUFFER_COUNT),bufferContexts:Array(ig.CANVAS_LAYERS)};var r=`-webkit-tap-highlight-color`,i=`rgba(0,0,0,0)`;t.data.canvasContainer=n.createElement(`div`);var a=t.data.canvasContainer.style;t.data.canvasContainer.style[r]=i,a.position=`relative`,a.zIndex=`0`,a.overflow=`hidden`;var o=e.cy.container();o.appendChild(t.data.canvasContainer),o.style[r]=i;var s={"-webkit-user-select":`none`,"-moz-user-select":`-moz-none`,"user-select":`none`,"-webkit-tap-highlight-color":`rgba(0,0,0,0)`,"outline-style":`none`};pe()&&(s[`-ms-touch-action`]=`none`,s[`touch-action`]=`none`);for(var c=0;c<ig.CANVAS_LAYERS;c++){var l=t.data.canvases[c]=n.createElement(`canvas`),u=ig.CANVAS_TYPES[c];t.data.contexts[c]=l.getContext(u),t.data.contexts[c]||rn(`Could not create canvas of type `+u),Object.keys(s).forEach(function(e){l.style[e]=s[e]}),l.style.position=`absolute`,l.setAttribute(`data-id`,`layer`+c),l.style.zIndex=String(ig.CANVAS_LAYERS-c),t.data.canvasContainer.appendChild(l),t.data.canvasNeedsRedraw[c]=!1}t.data.topCanvas=t.data.canvases[0],t.data.canvases[ig.NODE].setAttribute(`data-id`,`layer`+ig.NODE+`-node`),t.data.canvases[ig.SELECT_BOX].setAttribute(`data-id`,`layer`+ig.SELECT_BOX+`-selectbox`),t.data.canvases[ig.DRAG].setAttribute(`data-id`,`layer`+ig.DRAG+`-drag`),t.data.canvases[ig.WEBGL]&&t.data.canvases[ig.WEBGL].setAttribute(`data-id`,`layer`+ig.WEBGL+`-webgl`);for(var c=0;c<ig.BUFFER_COUNT;c++)t.data.bufferCanvases[c]=n.createElement(`canvas`),t.data.bufferContexts[c]=t.data.bufferCanvases[c].getContext(`2d`),t.data.bufferCanvases[c].style.position=`absolute`,t.data.bufferCanvases[c].setAttribute(`data-id`,`buffer`+c),t.data.bufferCanvases[c].style.zIndex=String(-c-1),t.data.bufferCanvases[c].style.visibility=`hidden`;t.pathsEnabled=!0;var d=mr(),f=function(e){return{x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2}},p=function(e){return{x:-e.w/2,y:-e.h/2}},m=function(e){var t=e[0]._private;return t.oldBackgroundTimestamp!==t.backgroundTimestamp},h=function(e){return e[0]._private.nodeKey},g=function(e){return e[0]._private.labelStyleKey},_=function(e){return e[0]._private.sourceLabelStyleKey},v=function(e){return e[0]._private.targetLabelStyleKey},y=function(e,n,r,i,a){return t.drawElement(e,n,r,!1,!1,a)},b=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,`main`,a)},x=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,`source`,a)},S=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,`target`,a)},C=function(e){return e.boundingBox(),e[0]._private.bodyBounds},w=function(e){return e.boundingBox(),e[0]._private.labelBounds.main||d},T=function(e){return e.boundingBox(),e[0]._private.labelBounds.source||d},E=function(e){return e.boundingBox(),e[0]._private.labelBounds.target||d},D=function(e,t){return t},O=function(e){return f(C(e))},k=function(e,t,n){var r=e?e+`-`:``;return{x:t.x+n.pstyle(r+`text-margin-x`).pfValue,y:t.y+n.pstyle(r+`text-margin-y`).pfValue}},A=function(e,t,n){var r=e[0]._private.rscratch;return{x:r[t],y:r[n]}},j=function(e){return k(``,A(e,`labelX`,`labelY`),e)},M=function(e){return k(`source`,A(e,`sourceLabelX`,`sourceLabelY`),e)},N=function(e){return k(`target`,A(e,`targetLabelX`,`targetLabelY`),e)},P=function(e){return p(C(e))},F=function(e){return p(T(e))},I=function(e){return p(E(e))},L=function(e){var t=w(e),n=p(w(e));if(e.isNode()){switch(wl(e.pstyle(`text-halign`).value)){case`left`:n.x=-t.w-(t.leftPad||0);break;case`right`:n.x=-(t.rightPad||0)}switch(Tl(e.pstyle(`text-valign`).value)){case`top`:n.y=-t.h-(t.topPad||0);break;case`bottom`:n.y=-(t.botPad||0)}}return n},R=t.data.eleTxrCache=new Up(t,{getKey:h,doesEleInvalidateKey:m,drawElement:y,getBoundingBox:C,getRotationPoint:O,getRotationOffset:P,allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),z=t.data.lblTxrCache=new Up(t,{getKey:g,drawElement:b,getBoundingBox:w,getRotationPoint:j,getRotationOffset:L,isVisible:D}),B=t.data.slbTxrCache=new Up(t,{getKey:_,drawElement:x,getBoundingBox:T,getRotationPoint:M,getRotationOffset:F,isVisible:D}),V=t.data.tlbTxrCache=new Up(t,{getKey:v,drawElement:S,getBoundingBox:E,getRotationPoint:N,getRotationOffset:I,isVisible:D}),H=t.data.lyrTxrCache=new om(t);t.onUpdateEleCalcs(function(e,t){R.invalidateElements(t),z.invalidateElements(t),B.invalidateElements(t),V.invalidateElements(t),H.invalidateElements(t);for(var n=0;n<t.length;n++){var r=t[n]._private;r.oldBackgroundTimestamp=r.backgroundTimestamp}});var U=function(e){for(var t=0;t<e.length;t++)H.enqueueElementRefinement(e[t].ele)};R.onDequeue(U),z.onDequeue(U),B.onDequeue(U),V.onDequeue(U),e.webgl&&t.initWebgl(e,{getStyleKey:h,getLabelKey:g,getSourceLabelKey:_,getTargetLabelKey:v,drawElement:y,drawLabel:b,drawSourceLabel:x,drawTargetLabel:S,getElementBox:C,getLabelBox:w,getSourceLabelBox:T,getTargetLabelBox:E,getElementRotationPoint:O,getElementRotationOffset:P,getLabelRotationPoint:j,getSourceLabelRotationPoint:M,getTargetLabelRotationPoint:N,getLabelRotationOffset:L,getSourceLabelRotationOffset:F,getTargetLabelRotationOffset:I})}ig.redrawHint=function(e,t){var n=this;switch(e){case`eles`:n.data.canvasNeedsRedraw[ig.NODE]=t;break;case`drag`:n.data.canvasNeedsRedraw[ig.DRAG]=t;break;case`select`:n.data.canvasNeedsRedraw[ig.SELECT_BOX]=t;break;case`gc`:n.data.gc=!0}};var og=typeof Path2D<`u`;ig.path2dEnabled=function(e){if(e===void 0)return this.pathsEnabled;this.pathsEnabled=!!e},ig.usePaths=function(){return og&&this.pathsEnabled},ig.setImgSmoothing=function(e,t){e.imageSmoothingEnabled==null?(e.webkitImageSmoothingEnabled=t,e.mozImageSmoothingEnabled=t,e.msImageSmoothingEnabled=t):e.imageSmoothingEnabled=t},ig.getImgSmoothing=function(e){return e.imageSmoothingEnabled==null?e.webkitImageSmoothingEnabled||e.mozImageSmoothingEnabled||e.msImageSmoothingEnabled:e.imageSmoothingEnabled},ig.makeOffscreenCanvas=function(e,t){var n;return(typeof OffscreenCanvas>`u`?`undefined`:I(OffscreenCanvas))===`undefined`?(n=this.cy.window().document.createElement(`canvas`),n.width=e,n.height=t):n=new OffscreenCanvas(e,t),n},[um,_m,wm,Em,Dm,Am,Mm,Oh,Gh,Qh,ng].forEach(function(e){X(ig,e)});var sg=[{type:`layout`,extensions:gf},{type:`renderer`,extensions:[{name:`null`,impl:_f},{name:`base`,impl:vp},{name:`canvas`,impl:rg}]}],cg={},lg={};function ug(e,t,n){var r=n,i=function(n){on("Can not register `"+t+"` for `"+e+"` since `"+n+"` already exists in the prototype and can not be overridden")};if(e===`core`){if(Dd.prototype[t])return i(t);Dd.prototype[t]=n}else if(e===`collection`){if(Hu.prototype[t])return i(t);Hu.prototype[t]=n}else if(e===`layout`){for(var a=function(e){this.options=e,n.call(this,e),J(this._private)||(this._private={}),this._private.cy=e.cy,this._private.listeners=[],this.createEmitter()},o=a.prototype=Object.create(n.prototype),s=[],c=0;c<s.length;c++){var l=s[c];o[l]=o[l]||function(){return this}}o.start&&!o.run?o.run=function(){return this.start(),this}:!o.start&&o.run&&(o.start=function(){return this.run(),this});var u=n.prototype.stop;o.stop=function(){var e=this.options;if(e&&e.animate){var t=this.animations;if(t)for(var n=0;n<t.length;n++)t[n].stop()}return u?u.call(this):this.emit(`layoutstop`),this},o.destroy||=function(){return this},o.cy=function(){return this._private.cy};var d=function(e){return e._private.cy},f={addEventFields:function(e,t){t.layout=e,t.cy=d(e),t.target=e},bubble:function(){return!0},parent:function(e){return d(e)}};X(o,{createEmitter:function(){return this._private.emitter=new uu(f,this),this},emitter:function(){return this._private.emitter},on:function(e,t){return this.emitter().on(e,t),this},one:function(e,t){return this.emitter().one(e,t),this},once:function(e,t){return this.emitter().one(e,t),this},removeListener:function(e,t){return this.emitter().removeListener(e,t),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},emit:function(e,t){return this.emitter().emit(e,t),this}}),Fc.eventAliasesOn(o),r=a}else if(e===`renderer`&&t!==`null`&&t!==`base`){var p=dg(`renderer`,`base`),m=p.prototype,h=n,g=n.prototype,_=function(){p.apply(this,arguments),h.apply(this,arguments)},v=_.prototype;for(var y in m){var b=m[y];if(g[y]!=null)return i(y);v[y]=b}for(var x in g)v[x]=g[x];m.clientFunctions.forEach(function(e){v[e]=v[e]||function(){rn("Renderer does not implement `renderer."+e+"()` on its prototype")}}),r=_}else if(e===`__proto__`||e===`constructor`||e===`prototype`)return rn(e+` is an illegal type to be registered, possibly lead to prototype pollutions`);return Fe({map:cg,keys:[e,t],value:r})}function dg(e,t){return Ie({map:cg,keys:[e,t]})}function fg(e,t,n,r,i){return Fe({map:lg,keys:[e,t,n,r],value:i})}function pg(e,t,n,r){return Ie({map:lg,keys:[e,t,n,r]})}var mg=function(){if(arguments.length===2)return dg.apply(null,arguments);if(arguments.length===3)return ug.apply(null,arguments);if(arguments.length===4)return pg.apply(null,arguments);if(arguments.length===5)return fg.apply(null,arguments);rn(`Invalid extension access syntax`)};Dd.prototype.extension=mg,sg.forEach(function(e){e.extensions.forEach(function(t){ug(e.type,t.name,t.impl)})});var hg=function(){if(!(this instanceof hg))return new hg;this.length=0},gg=hg.prototype;gg.instanceString=function(){return`stylesheet`},gg.selector=function(e){var t=this.length++;return this[t]={selector:e,properties:[]},this},gg.css=function(e,t){var n=this.length-1;if(G(e))this[n].properties.push({name:e,value:t});else if(J(e))for(var r=e,i=Object.keys(r),a=0;a<i.length;a++){var o=i[a],s=r[o];if(s!=null){var c=xd.properties[o]||xd.properties[ge(o)];if(c!=null){var l=c.name,u=s;this[n].properties.push({name:l,value:u})}}}return this},gg.style=gg.css,gg.generateStyle=function(e){var t=new xd(e);return this.appendToStyle(t)},gg.appendToStyle=function(e){for(var t=0;t<this.length;t++){var n=this[t],r=n.selector,i=n.properties;e.selector(r);for(var a=0;a<i.length;a++){var o=i[a];e.css(o.name,o.value)}}return e};var _g=`3.34.2`,vg=function(e){if(e===void 0&&(e={}),J(e))return new Dd(e);if(G(e))return mg.apply(mg,arguments)};vg.use=function(e){var t=Array.prototype.slice.call(arguments,1);return t.unshift(vg),e.apply(null,t),this},vg.warnings=function(e){return an(e)},vg.version=_g,vg.stylesheet=vg.Stylesheet=hg;function yg(e,t,n){let r=(e,t)=>{let r=new Set,i=n.get(e);for(;i!==void 0&&!r.has(i);){if(i===t)return!0;r.add(i),i=n.get(i)}return!1};return r(e,t)||r(t,e)}var bg=`yarramate/core@0.1#composition`,xg=`yarramate/core@0.1#assignment`,Sg={composition:bg,assignment:xg},Cg=new Set([`constraint`]),wg=`none`,Tg=(e,t)=>!t(e.to).endsWith(`Service`)||t(e.from).endsWith(`Interface`);function Eg(e,t,n){let r=new Map(t.map((e,t)=>[Sg[e],t])),i=e.filter(e=>r.has(e.kind)&&(e.kind!==xg||Tg(e,n))),a=new Map;for(let e of i){let t=a.get(e.to);t===void 0?a.set(e.to,[e]):t.push(e)}let o=new Map,s=[];for(let[e,t]of a){let n=Math.min(...t.map(e=>r.get(e.kind))),i=t.filter(e=>r.get(e.kind)===n);new Set(i.map(e=>e.from)).size===1?o.set(e,i[0].from):s.push({child:e,claims:i.map(e=>({edgeId:e.id,kind:e.kind,from:e.from}))})}let c=Og(o),l=new Set;for(let e of i)o.get(e.to)===e.from&&l.add(e.id);return{parentOf:o,consumedEdgeIds:l,conflicts:s,cycleMembers:c}}var Dg=(e,t,n)=>{let r=new Set([e]),i=n.get(e);for(;i!==void 0&&!r.has(i);){if(i===t)return!0;r.add(i),i=n.get(i)}return!1};function Og(e){let t=new Set;for(let n of e.keys()){let r=[],i=new Map,a=n;for(;a!==void 0;){let n=i.get(a);if(n!==void 0){for(let e of r.slice(n))t.add(e);break}i.set(a,r.length),r.push(a),a=e.get(a)}}for(let n of t)e.delete(n);return[...t]}var kg=(e,t)=>{let n=e=>{let n=[],r=new Set,i=e;for(;i!==void 0&&!r.has(i);)r.add(i),n.push(i),i=t.get(i);return n},[r,...i]=e;if(r===void 0)return;let a=i.map(e=>new Set(n(e)));return n(r).find(e=>a.every(t=>t.has(e)))};function Ag(e){let t=new Map(e.nodes.map(e=>[e.id,e.coreKind])),n=e=>t.get(e)??``,r=Eg(e.edges,e.nesting,n),i=new Map;for(let t of e.memberships){let e=i.get(t.member);e===void 0?i.set(t.member,new Set([t.instance])):e.add(t.instance)}let a=new Set;for(let t of e.memberships)t.wiring!==`context`&&a.add(t.member);let o=new Map(r.parentOf),s=[...new Set(e.memberships.map(({member:e})=>e).filter(e=>!o.has(e)&&a.has(e)&&!Cg.has(n(e))&&t.has(e)&&i.get(e)?.has(e)!==!0))];for(;s.length>0;){let e=[],t=!1;for(let n of s){let r=[...i.get(n)??[]];if(r.some(e=>s.includes(e)&&e!==n)){e.push(n);continue}t=!0;let a=r.length===1?r[0]:kg(r,o);a!==void 0&&a!==n&&(r.some(e=>Dg(e,n,o))||o.set(n,a))}if(!t)break;s=e}let c=[...r.cycleMembers,...Og(o)];return{parentOf:o,consumedEdgeIds:r.consumedEdgeIds,conflicts:r.conflicts,cycleMembers:c}}var jg=(e,t,n)=>`lift:${e}|${t}|${n}`,Mg=(e,t,n)=>{let r=e,i=t.get(e),a=new Set([e]);for(;i!==void 0&&!a.has(i);)a.add(i),n.has(i)&&(r=i),i=t.get(i);return r};function Ng(e,t,n){let r=new Map;for(let i of e.nodes)r.set(i.id,Mg(i.id,t.parentOf,n));let i=new Map;for(let t of e.nodes){let e=r.get(t.id);if(e===t.id)continue;let n=i.get(e);n===void 0?i.set(e,[t.id]):n.push(t.id)}let a=e.nodes.filter(e=>r.get(e.id)===e.id).map(e=>({...e,folded:n.has(e.id),insideIds:i.get(e.id)??[]})),o=[],s=new Map;for(let t of e.edges){let e=r.get(t.from)??t.from,n=r.get(t.to)??t.to;if(e===t.from&&n===t.to){o.push(t);continue}if(e===n)continue;let i=jg(e,n,t.kind),a=s.get(i);a===void 0?s.set(i,{edge:{id:i,kind:t.kind,from:e,to:n,count:1,relationshipIds:[t.id]},ids:[t.id]}):a.ids.push(t.id)}for(let{edge:e,ids:t}of s.values())o.push({...e,count:t.length,relationshipIds:t});return{nodes:a,edges:o}}var Pg=[`layered`,`routed`,`served-by`,`bands`],Fg=`served-by`,Ig=e=>e!==`layered`,Lg=e=>e===`served-by`||e===`bands`,Rg=e=>e===`bands`,zg=new Set([`serving`,`realization`,`specialization`]),Bg={motivation:0,strategy:1,business:2,application:3,technology:4,physical:5,implementation:6},Vg=e=>e==null?void 0:Bg[e],Hg=[`current`,`drafting`,`ink`,`tinted`,`dark`],Ug=[{id:`current`,title:`Current`,blurb:`ArchiMate pastels, 2px borders, grey edges with boxed labels.`},{id:`drafting`,title:`Drafting`,blurb:`The shell's own vocabulary on the canvas: paper-tinted fills, hairline ink rules, the body face, monospace edge readings with a paper halo.`},{id:`ink`,title:`Ink`,blurb:`Line-first and print-ready: white subjects, the layer carried by a coloured 1.5px border, ink edges, no boxes anywhere.`},{id:`tinted`,title:`Tinted`,blurb:`A contemporary muted palette in place of the pastels, 8px corners, slate edges, edge readings on small pills.`},{id:`dark`,title:`Dark`,blurb:`A dark ground with deep layer tints, light ink and light glyphs.`,canvas:`#12161b`,glyph:`#e5e9ed`}],Wg=`current`,Gg=`yarramate-visual.style`,Kg=()=>{try{let e=globalThis.localStorage?.getItem(Gg);return Yg(e)?e:Wg}catch{return Wg}},qg=e=>{try{globalThis.localStorage?.setItem(Gg,e)}catch{}},Jg=e=>Ug.find(t=>t.id===e)??Ug[0],Yg=e=>typeof e==`string`&&Hg.includes(e),Xg=`'Avenir Next', Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif`,Zg=`ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace`,Qg={motivation:{fill:`#dcd9ef`,border:`#6f6bb0`},strategy:{fill:`#ece2cd`,border:`#a2843f`},business:{fill:`#ecebc4`,border:`#9a9440`},application:{fill:`#cfe6e8`,border:`#3f8f8f`},technology:{fill:`#d3e6d3`,border:`#4f8f4f`},implementation:{fill:`#ebd9da`,border:`#b07a7a`},physical:{fill:`#e1e5e7`,border:`#7d868c`},composite:{fill:`#e1e5e7`,border:`#7d868c`}},$g={motivation:{fill:`#ffffff`,border:`#5b52c8`},strategy:{fill:`#ffffff`,border:`#b8862b`},business:{fill:`#ffffff`,border:`#a89a12`},application:{fill:`#ffffff`,border:`#1f8f8f`},technology:{fill:`#ffffff`,border:`#2f8f2f`},implementation:{fill:`#ffffff`,border:`#c2606a`},physical:{fill:`#ffffff`,border:`#6b7680`},composite:{fill:`#ffffff`,border:`#6b7680`}},e_={motivation:{fill:`#ede9fe`,border:`#7c3aed`},strategy:{fill:`#fef3c7`,border:`#b45309`},business:{fill:`#fef9c3`,border:`#a16207`},application:{fill:`#e0f2fe`,border:`#0369a1`},technology:{fill:`#d1fae5`,border:`#047857`},implementation:{fill:`#ffe4e6`,border:`#be123c`},physical:{fill:`#f1f5f9`,border:`#475569`},composite:{fill:`#f1f5f9`,border:`#475569`}},t_={motivation:{fill:`#2a2550`,border:`#8b7fe0`},strategy:{fill:`#3a2e14`,border:`#c9a355`},business:{fill:`#3a3a10`,border:`#c9c355`},application:{fill:`#10344a`,border:`#4fb8b8`},technology:{fill:`#10391f`,border:`#5fae5f`},implementation:{fill:`#3d1b22`,border:`#d89999`},physical:{fill:`#262c33`,border:`#6b7680`},composite:{fill:`#262c33`,border:`#6b7680`}},n_=(e,t=`16%`)=>[...Object.keys(e).map(t=>({selector:`node[layer = "${t}"]`,style:{"background-color":e[t].fill,"border-color":e[t].border}})),...Object.keys(e).map(n=>({selector:`node[layer = "${n}"][aspect = "passive-structure"]:childless`,style:{"background-fill":`linear-gradient`,"background-gradient-direction":`to-bottom`,"background-gradient-stop-colors":[e[n].border,e[n].fill],"background-gradient-stop-positions":[`0%`,t]}}))],r_=e=>[...n_(e.palette),{selector:`node`,style:{"border-width":e.nodeBorder,"corner-radius":`${e.corner}px`,"font-family":Xg,"font-size":12,"font-weight":500,color:e.ink}},{selector:`node:parent`,style:{...e.containerFill.color===null?{}:{"background-color":e.containerFill.color},"background-opacity":e.containerFill.opacity,...e.containerBorder.color===null?{}:{"border-color":e.containerBorder.color},"border-style":e.containerBorder.style,"border-width":1,"border-opacity":e.containerBorder.opacity,"corner-radius":`${e.corner+4}px`,"font-family":e.containerTitle.face,"font-size":e.containerTitle.size,"font-weight":e.containerTitle.weight,color:e.containerTitle.color,...e.containerTitle.upper?{"text-transform":`uppercase`}:{},"text-margin-y":-6}},{selector:`edge`,style:{"line-color":e.edge,"target-arrow-color":e.edge,"source-arrow-color":e.edge,width:e.edgeWidth,"line-cap":`round`,"arrow-scale":.85,"font-family":e.edgeLabelFace,"font-size":9.5,color:e.edgeLabelColor,"text-background-color":e.edgeLabelBackground.color,"text-background-opacity":e.edgeLabelBackground.opacity,"text-background-shape":e.edgeLabelBackground.shape,"text-background-padding":`2px`,...e.halo===null?{"text-outline-width":0}:{"text-outline-color":e.halo,"text-outline-width":2,"text-outline-opacity":1}}},{selector:`edge.lifted`,style:{"line-color":e.quiet,"target-arrow-color":e.quiet,width:e.edgeWidth+.5}},{selector:`node.selected`,style:{"border-color":e.select,"border-width":2,"overlay-color":e.select,"overlay-opacity":.12,"overlay-padding":6}},{selector:`edge.selected`,style:{"line-color":e.select,"target-arrow-color":e.select,width:e.edgeWidth+1}}],i_={current:()=>[],drafting:()=>r_({palette:Qg,ink:`#182228`,quiet:`#7d868c`,ground:`#e8eef0`,nodeBorder:1,corner:4,edge:`#6b7680`,edgeWidth:1.25,edgeLabelFace:Zg,edgeLabelColor:`#4a555e`,edgeLabelBackground:{color:`#e8eef0`,opacity:0,shape:`rectangle`},halo:`#e8eef0`,containerFill:{color:null,opacity:0},containerBorder:{color:`#182228`,style:`dashed`,opacity:.3},containerTitle:{face:Zg,size:10,weight:`500`,color:`#4a555e`,upper:!0},select:`#2457a6`}),ink:()=>r_({palette:$g,ink:`#182228`,quiet:`#6b7680`,ground:`#ffffff`,nodeBorder:1.5,corner:4,edge:`#182228`,edgeWidth:1.2,edgeLabelFace:Xg,edgeLabelColor:`#182228`,edgeLabelBackground:{color:`#ffffff`,opacity:0,shape:`rectangle`},halo:`#e8eef0`,containerFill:{color:`#182228`,opacity:.04},containerBorder:{color:`#182228`,style:`solid`,opacity:.35},containerTitle:{face:Xg,size:11,weight:`600`,color:`#182228`,upper:!0},select:`#2457a6`}),tinted:()=>r_({palette:e_,ink:`#0f172a`,quiet:`#94a3b8`,ground:`#e8eef0`,nodeBorder:1,corner:8,edge:`#64748b`,edgeWidth:1.5,edgeLabelFace:Xg,edgeLabelColor:`#475569`,edgeLabelBackground:{color:`#f8fafc`,opacity:1,shape:`roundrectangle`},halo:null,containerFill:{color:null,opacity:.35},containerBorder:{color:null,style:`solid`,opacity:.5},containerTitle:{face:Xg,size:11,weight:`600`,color:`#334155`,upper:!1},select:`#2563eb`}),dark:()=>r_({palette:t_,ink:`#e5e9ed`,quiet:`#97a3ae`,ground:`#12161b`,nodeBorder:1,corner:6,edge:`#7f8b96`,edgeWidth:1.25,edgeLabelFace:Xg,edgeLabelColor:`#b8c2cc`,edgeLabelBackground:{color:`#12161b`,opacity:0,shape:`rectangle`},halo:`#12161b`,containerFill:{color:`#1a2027`,opacity:.7},containerBorder:{color:`#3a444f`,style:`dashed`,opacity:1},containerTitle:{face:Xg,size:11,weight:`600`,color:`#97a3ae`,upper:!1},select:`#7ea6ec`})},a_=e=>i_[e]();function o_(e){return e===`planned`||e===`current`||e===`retired`}var s_=`#182228`,c_=`#416f65`,l_=`#a3403a`,u_=`#5f686d`,d_=[c_,`#8c4d18`,`#2457a6`,s_],f_=12;function p_(e){return`data:image/svg+xml;utf8,${encodeURIComponent(e)}`}function m_(e){return`<svg xmlns="http://www.w3.org/2000/svg" width="${f_}" height="${f_}" viewBox="0 0 12 12">${e}</svg>`}var h_={planned:m_(`<circle cx="6" cy="6" r="4" fill="none" stroke="${u_}" stroke-width="2"/>`),current:m_(`<circle cx="6" cy="6" r="5" fill="${c_}"/>`),retired:m_(`<circle cx="6" cy="6" r="5" fill="${l_}"/>`)},g_={planned:p_(h_.planned),current:p_(h_.current),retired:p_(h_.retired)},__=p_(m_(`<circle cx="6" cy="6" r="5" fill="${s_}"/><path d="M3.2 6.2 L5.2 8.2 L8.8 4.2" fill="none" stroke="#ffffff" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>`));function v_(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t}function y_(e){if(e===null)return null;let t=v_(e);return d_[Math.abs(t)%d_.length]}function b_(e,t){return m_(`<circle cx="6" cy="6" r="5" fill="${y_(e)}"/><text x="6" y="7.5" font-size="8" font-weight="bold" fill="#ffffff" text-anchor="middle" dominant-baseline="middle">${t}</text>`)}function x_(e,t){return p_(b_(e,t))}function S_(e){let t=e>9?`9+`:String(e);return m_(`<circle cx="6" cy="6" r="5" fill="${u_}"/><text x="6" y="7.5" font-size="${t.length>1?6.5:8}" font-weight="bold" fill="#ffffff" text-anchor="middle" dominant-baseline="middle">${t}</text>`)}function C_(e){return p_(S_(e))}function w_(e){let t=e>99?`99+`:String(e),n=12+t.length*4;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${n} 12" width="${n}" height="12"><rect x="0" y="0" width="${n}" height="12" rx="3" fill="${s_}"/><path d="M4 3.5 L7.5 6 L4 8.5 Z" fill="#ffffff"/><text x="${n-3}" y="6.5" font-size="7" font-weight="bold" fill="#ffffff" text-anchor="end" dominant-baseline="middle">${t}</text></svg>`}function T_(e){return p_(w_(e))}function E_(e){if(e===null)return null;let t=(e.includes(`#`)?e.slice(e.indexOf(`#`)+1):e).split(/[-_\s]+/).filter(e=>e.length>0);if(t.length===0)return null;let n=t.slice(0,2).map(e=>e[0].toUpperCase()).join(``);return n.length>0?n:null}var D_=[`motivation`,`strategy`,`business`,`application`,`technology`,`physical`,`implementation`,`composite`],O_=(e,t,n)=>n.map(([n,r,i])=>({id:n,name:r,layer:e,aspect:t,...i===void 0?{}:{rigidity:i},inspiredBy:`archimate:${r}`})),k_=[...O_(`motivation`,`motivation`,[[`stakeholder`,`Stakeholder`,`anti-rigid`],[`driver`,`Driver`],[`assessment`,`Assessment`],[`goal`,`Goal`],[`outcome`,`Outcome`],[`principle`,`Principle`],[`requirement`,`Requirement`],[`constraint`,`Constraint`],[`meaning`,`Meaning`],[`value`,`Value`]]),...O_(`strategy`,`active-structure`,[[`resource`,`Resource`]]),...O_(`strategy`,`behavior`,[[`capability`,`Capability`],[`valueStream`,`Value stream`],[`courseOfAction`,`Course of action`]]),...O_(`business`,`active-structure`,[[`businessActor`,`Business actor`],[`businessRole`,`Business role`,`anti-rigid`],[`businessCollaboration`,`Business collaboration`,`anti-rigid`],[`businessInterface`,`Business interface`]]),...O_(`business`,`behavior`,[[`businessProcess`,`Business process`],[`businessFunction`,`Business function`],[`businessInteraction`,`Business interaction`],[`businessEvent`,`Business event`],[`businessService`,`Business service`]]),...O_(`business`,`passive-structure`,[[`businessObject`,`Business object`],[`contract`,`Contract`],[`representation`,`Representation`]]),...O_(`business`,`composite`,[[`product`,`Product`]]),...O_(`application`,`active-structure`,[[`applicationComponent`,`Application component`],[`applicationCollaboration`,`Application collaboration`,`anti-rigid`],[`applicationInterface`,`Application interface`]]),...O_(`application`,`behavior`,[[`applicationFunction`,`Application function`],[`applicationInteraction`,`Application interaction`],[`applicationProcess`,`Application process`],[`applicationEvent`,`Application event`],[`applicationService`,`Application service`]]),...O_(`application`,`passive-structure`,[[`dataObject`,`Data object`]]),...O_(`technology`,`active-structure`,[[`node`,`Node`],[`device`,`Device`],[`systemSoftware`,`System software`],[`technologyCollaboration`,`Technology collaboration`,`anti-rigid`],[`technologyInterface`,`Technology interface`],[`path`,`Path`],[`communicationNetwork`,`Communication network`]]),...O_(`technology`,`behavior`,[[`technologyFunction`,`Technology function`],[`technologyProcess`,`Technology process`],[`technologyInteraction`,`Technology interaction`],[`technologyEvent`,`Technology event`],[`technologyService`,`Technology service`]]),...O_(`technology`,`passive-structure`,[[`artifact`,`Artifact`]]),...O_(`physical`,`active-structure`,[[`equipment`,`Equipment`],[`facility`,`Facility`],[`distributionNetwork`,`Distribution network`]]),...O_(`physical`,`passive-structure`,[[`material`,`Material`]]),...O_(`implementation`,`behavior`,[[`workPackage`,`Work package`],[`implementationEvent`,`Implementation event`]]),...O_(`implementation`,`passive-structure`,[[`deliverable`,`Deliverable`]]),...O_(`implementation`,`composite`,[[`plateau`,`Plateau`],[`gap`,`Gap`]]),...O_(`composite`,`composite`,[[`grouping`,`Grouping`],[`location`,`Location`],[`andJunction`,`AND junction`],[`orJunction`,`OR junction`]])],A_=[`composition`,`aggregation`,`assignment`,`realization`,`serving`,`access`,`influence`,`association`,`triggering`,`flow`,`specialization`],j_=`#182228`,M_={motivation:{fill:`#CCCCFF`,border:`#8F8FE0`},strategy:{fill:`#F5DEAA`,border:`#C9A355`},business:{fill:`#FFFF99`,border:`#C9C355`},application:{fill:`#CCFFFF`,border:`#4FB8B8`},technology:{fill:`#CCFFCC`,border:`#5FAE5F`},implementation:{fill:`#FFE0E0`,border:`#D89999`},physical:{fill:`#F0F0F0`,border:`#999999`},composite:{fill:`#F0F0F0`,border:`#999999`}},N_={motivation:{shape:`octagon`},"active-structure":{shape:`rectangle`},behavior:{shape:`round-rectangle`},"passive-structure":{shape:`rectangle`,accent:`top-band`},composite:{shape:`rectangle`}},P_={grouping:{borderStyle:`dashed`}};function F_(e,t=j_){return`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14"><g fill="none" stroke="${t}" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">${e}</g></svg>`}function I_(e){return`data:image/svg+xml;utf8,${encodeURIComponent(e)}`}var L_={andJunction:`<circle cx="7" cy="7" r="2.6" fill="#182228"/>`,applicationCollaboration:`<circle cx="5.5" cy="7" r="4"/><circle cx="8.5" cy="7" r="4"/>`,applicationComponent:`<rect x="3" y="2" width="9" height="10"/><rect x="1" y="4" width="2.5" height="1.5"/><rect x="1" y="8" width="2.5" height="1.5"/>`,applicationEvent:`<path d="M3 3 H8 L11 7 L8 11 H3 Z"/>`,applicationFunction:`<rect x="2" y="3" width="10" height="8" rx="2"/><path d="M5.5 5 L8 7 L5.5 9"/>`,applicationInteraction:`<path d="M2 5 H9 M9 5 L7 3 M9 5 L7 7"/><path d="M12 9 H5 M5 9 L7 7 M5 9 L7 11"/>`,applicationInterface:`<line x1="1.5" y1="7" x2="6" y2="7"/><circle cx="9" cy="7" r="3"/>`,applicationProcess:`<path d="M2 7 H10 M10 7 L7.5 4.5 M10 7 L7.5 9.5"/>`,applicationService:`<rect x="1.5" y="4" width="11" height="6" rx="3"/>`,artifact:`<path d="M3 1.5 H9 L11 3.5 V12.5 H3 Z"/><path d="M9 1.5 V3.5 H11"/>`,assessment:`<circle cx="6" cy="6" r="3.5"/><path d="M8.5 8.5 L12 12"/>`,businessActor:`<circle cx="7" cy="3.5" r="1.8"/><path d="M7 5.3 V9 M4 7 H10 M7 9 L4.5 12.5 M7 9 L9.5 12.5"/>`,businessCollaboration:`<circle cx="5.5" cy="7" r="4"/><circle cx="8.5" cy="7" r="4"/>`,businessEvent:`<path d="M3 3 H8 L11 7 L8 11 H3 Z"/>`,businessFunction:`<rect x="2" y="3" width="10" height="8" rx="2"/><path d="M5 8 L7 5.5 L9 8"/>`,businessInteraction:`<path d="M2 5 H9 M9 5 L7 3 M9 5 L7 7"/><path d="M12 9 H5 M5 9 L7 7 M5 9 L7 11"/>`,businessInterface:`<line x1="1.5" y1="7" x2="6" y2="7"/><circle cx="9" cy="7" r="3"/>`,businessObject:`<rect x="2" y="3" width="10" height="8"/>`,businessProcess:`<path d="M2 7 H10 M10 7 L7.5 4.5 M10 7 L7.5 9.5"/>`,businessRole:`<circle cx="7" cy="6" r="4"/><path d="M5 9.5 L4 12.5 L7 11 L10 12.5 L9 9.5"/>`,businessService:`<rect x="1.5" y="4" width="11" height="6" rx="3"/>`,capability:`<rect x="2" y="2" width="10" height="10" rx="1"/><path d="M5 9 L9 5 M9 5 H6.5 M9 5 V7.5"/>`,communicationNetwork:`<circle cx="3.5" cy="4" r="1.2"/><circle cx="11" cy="4" r="1.2"/><circle cx="7" cy="10.5" r="1.2"/><path d="M3.5 4 L11 4 M3.5 4 L7 10.5 M11 4 L7 10.5"/>`,constraint:`<rect x="4" y="6.5" width="6" height="5.5" rx="0.5"/><path d="M5.2 6.5 V4.7 A1.8 1.8 0 0 1 8.8 4.7 V6.5"/>`,contract:`<rect x="2" y="2" width="10" height="10"/><path d="M2 4.5 H12 M2 6.5 H12"/>`,courseOfAction:`<path d="M7 2 V12.5"/><path d="M7 4 H11 L9.5 5.5 L11 7 H7 Z"/><path d="M7 8 H4 L5.5 9.5 L4 11 H7 Z"/>`,dataObject:`<rect x="2" y="2" width="10" height="10"/><path d="M2 5.5 H12"/>`,deliverable:`<path d="M3 1.5 H8 L11 4.5 V12.5 H3 Z"/><path d="M8 1.5 V4.5 H11"/><path d="M5 9.5 L7 12.5 L9 9.5"/>`,device:`<rect x="2" y="3" width="10" height="6" rx="0.5"/><path d="M4.5 9 V11 M9.5 9 V11 M3.5 11 H6 M8 11 H10.5"/>`,distributionNetwork:`<path d="M2 11 Q4 11 5 8 Q6 5 7 5 Q8 5 9 8 Q10 11 12 11"/><circle cx="2" cy="11" r="1"/><circle cx="12" cy="11" r="1"/><circle cx="7" cy="5" r="1"/>`,driver:`<circle cx="7" cy="7" r="5"/><path d="M7 2 V5 M7 9 V12 M2 7 H5 M9 7 H12"/>`,equipment:`<rect x="2" y="3" width="10" height="8"/><path d="M2 3 L7 6 L12 3 M7 6 V11"/>`,facility:`<path d="M2 12.5 V6 L7 2.5 L12 6 V12.5 Z"/><path d="M5.5 12.5 V8.5 H8.5 V12.5"/>`,gap:`<path d="M2 4 H6 M2 10 H6"/><path d="M8 4 H12 M8 10 H12"/><path d="M7 3 V11" stroke-dasharray="1.4 1.3"/>`,goal:`<circle cx="7" cy="7" r="5"/><circle cx="7" cy="7" r="2.2"/>`,grouping:`<rect x="2" y="2" width="10" height="10" rx="1" stroke-dasharray="2 1.4"/>`,implementationEvent:`<path d="M3 3 H8 L11 7 L8 11 H3 Z"/>`,location:`<path d="M7 12.5 C7 12.5 3 8 3 5.5 A4 4 0 0 1 11 5.5 C11 8 7 12.5 7 12.5 Z"/><circle cx="7" cy="5.5" r="1.3"/>`,material:`<rect x="2" y="8" width="4" height="4"/><rect x="6.5" y="6" width="4" height="6"/><rect x="4" y="2.5" width="4" height="4"/>`,meaning:`<path d="M2 3 H12 V9 H6 L4 11 V9 H2 Z"/><path d="M4.5 6 H9.5"/>`,node:`<path d="M2 5 L7 2.5 L12 5 L12 10 L7 12.5 L2 10 Z"/><path d="M2 5 L7 7.5 L12 5 M7 7.5 V12.5"/>`,orJunction:`<circle cx="7" cy="7" r="2.6"/>`,outcome:`<path d="M3 1.5 V12.5"/><path d="M3 2 H9 L7 4 L9 6 H3 Z"/>`,path:`<circle cx="3" cy="7" r="1.3"/><circle cx="11" cy="7" r="1.3"/><path d="M4.5 7 H9.5" stroke-dasharray="1.6 1.4"/>`,plateau:`<path d="M2 11 L4.5 4 H9.5 L12 11 Z"/><path d="M2 11 H12"/>`,principle:`<path d="M3 2.5 H11 V9 L7 11.5 L3 9 Z"/><path d="M5 6 L6.5 7.5 L9.5 4.5"/>`,product:`<rect x="2" y="5" width="10" height="7"/><path d="M2 5 L7 1.5 L12 5"/>`,representation:`<path d="M3 2 H11 V9 Q9.5 11 8 9.5 Q6.5 8 5 9.5 Q3.5 11 3 9 Z"/>`,requirement:`<path d="M3 2.5 H11 V9 L7 11.5 L3 9 Z"/><path d="M3 5 H11"/>`,resource:`<rect x="2" y="4.5" width="9" height="5" rx="1"/><rect x="11" y="6" width="1.5" height="2"/><path d="M4 6 V8 M6.5 6 V8 M9 6 V8"/>`,stakeholder:`<circle cx="7" cy="5" r="2.2"/><path d="M2.5 12.5 Q2.5 8 7 8 Q11.5 8 11.5 12.5"/>`,systemSoftware:`<rect x="2" y="2" width="10" height="10"/><rect x="4" y="4" width="4" height="3"/>`,technologyCollaboration:`<circle cx="5.5" cy="7" r="4"/><circle cx="8.5" cy="7" r="4"/>`,technologyEvent:`<path d="M3 3 H8 L11 7 L8 11 H3 Z"/>`,technologyFunction:`<circle cx="7" cy="7" r="4"/><path d="M7 2 V3.2 M7 10.8 V12 M2 7 H3.2 M10.8 7 H12 M3.5 3.5 L4.3 4.3 M9.7 9.7 L10.5 10.5 M3.5 10.5 L4.3 9.7 M9.7 4.3 L10.5 3.5"/>`,technologyInteraction:`<path d="M2 5 H9 M9 5 L7 3 M9 5 L7 7"/><path d="M12 9 H5 M5 9 L7 7 M5 9 L7 11"/>`,technologyInterface:`<line x1="1.5" y1="7" x2="6" y2="7"/><circle cx="9" cy="7" r="3"/>`,technologyProcess:`<path d="M2 7 H10 M10 7 L7.5 4.5 M10 7 L7.5 9.5"/>`,technologyService:`<rect x="1.5" y="4" width="11" height="6" rx="3"/>`,value:`<path d="M7 2 L11.5 7 L7 12 L2.5 7 Z"/>`,valueStream:`<path d="M2 5 H8 V3.5 L12 7 L8 10.5 V9 H2 Z"/>`,workPackage:`<rect x="2" y="5" width="10" height="7"/><path d="M5 5 V3.5 A1 1 0 0 1 6 2.5 H8 A1 1 0 0 1 9 3.5 V5"/>`},R_=k_.map(e=>({id:e.id,notation:e.name,layer:e.layer,aspect:e.aspect,...N_[e.aspect],...P_[e.id],glyph:L_[e.id]??null,colors:M_[e.layer]})),z_=Object.fromEntries(R_.map(e=>[e.id,e]));function B_(e,t=j_){let n=z_[e]?.glyph;return n==null?null:I_(F_(n,t))}var V_={composition:{lineStyle:`solid`,sourceArrow:{shape:`diamond`,fill:`filled`},targetArrow:{shape:`none`}},aggregation:{lineStyle:`solid`,sourceArrow:{shape:`diamond`,fill:`hollow`},targetArrow:{shape:`none`}},assignment:{lineStyle:`solid`,sourceArrow:{shape:`circle`,fill:`filled`},targetArrow:{shape:`triangle`,fill:`filled`}},realization:{lineStyle:`dotted`,sourceArrow:{shape:`none`},targetArrow:{shape:`triangle`,fill:`hollow`}},specialization:{lineStyle:`solid`,sourceArrow:{shape:`none`},targetArrow:{shape:`triangle`,fill:`hollow`}},serving:{lineStyle:`solid`,sourceArrow:{shape:`none`},targetArrow:{shape:`vee`}},access:{lineStyle:`dotted`,sourceArrow:{shape:`none`},targetArrow:{shape:`vee`}},influence:{lineStyle:`dashed`,sourceArrow:{shape:`none`},targetArrow:{shape:`vee`}},triggering:{lineStyle:`solid`,sourceArrow:{shape:`none`},targetArrow:{shape:`triangle`,fill:`filled`}},flow:{lineStyle:`dashed`,sourceArrow:{shape:`none`},targetArrow:{shape:`triangle`,fill:`filled`}},association:{lineStyle:`solid`,sourceArrow:{shape:`none`},targetArrow:{shape:`none`}}},H_=A_.map(e=>({id:e,...V_[e]}));Object.fromEntries(H_.map(e=>[e.id,e]));function U_(e,t){return B_(e,t)}var W_=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),$=o(((e,t)=>{t.exports=W_()}))(),G_=`application/x-yarramate-kind`,K_=`unlayered`,q_=`constraint`,J_=(e,t)=>{let n=e===1?`slot`:`slots`;return t===0?`${e} ${n}`:`${e} ${n}, ${t} required`},Y_=e=>e.slice(e.lastIndexOf(`/`)+1).replace(/\.ya?ml$/,``),X_=new Map(k_.map(e=>[e.id,e.layer])),Z_=(e=[])=>{let t=new Map;for(let n of e){let e=t.get(n.document);e===void 0?t.set(n.document,[n]):e.push(n)}return[...t].map(([e,t])=>({document:e,patterns:t}))},Q_=(e,t=[])=>{let n=new Set(t.flatMap(e=>e.slots.flatMap(e=>[...e.admits]))),r=e=>e.coreLabel===q_&&n.has(e.label),i=new Map,a=new Map;for(let t of e){let e=X_.get(t.coreLabel)??K_,n=r(t)?a:i,o=n.get(e);o===void 0?n.set(e,[t]):o.push(t)}return[...D_,K_].flatMap(e=>{let t=i.get(e),n=a.get(e);return t===void 0&&n===void 0?[]:[{layer:e,kinds:t??[],boundThroughSlot:n??[]}]})},$_=({kinds:e,patterns:t,onPick:n})=>{let[r,i]=(0,y.useState)(new Set),a=e=>i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,$.jsxs)(`div`,{className:`kind-palette`,children:[Z_(t).map(e=>{let t=r.has(e.document);return(0,$.jsxs)(`div`,{className:`kind-palette-layer`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`kind-palette-layer-name`,"aria-expanded":!t,title:e.document,onClick:()=>a(e.document),children:[(0,$.jsx)(`span`,{className:`kind-palette-caret`,"aria-hidden":`true`,children:t?`▸`:`▾`}),`patterns \u00b7 ${Y_(e.document)}`]}),t?null:(0,$.jsx)(`ul`,{className:`kind-palette-rows`,children:e.patterns.map(e=>{let t=e.slots.filter(e=>e.required).length;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`kind-palette-row kind-palette-pattern`,draggable:!0,"data-kind":e.label,"data-pattern":e.kind,onDragStart:t=>{t.dataTransfer.setData(G_,e.label),t.dataTransfer.effectAllowed=`copy`},onClick:()=>n(e.label),children:[(0,$.jsx)(`span`,{className:`kind-palette-stack`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:e.name??e.label}),(0,$.jsx)(`span`,{className:`kind-palette-slots`,children:J_(e.slots.length,t)})]})},e.kind)})})]},`pattern:${e.document}`)}),Q_(e,t).map(e=>{let t=r.has(e.layer);return(0,$.jsxs)(`div`,{className:`kind-palette-layer`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`kind-palette-layer-name`,"aria-expanded":!t,onClick:()=>a(e.layer),children:[(0,$.jsx)(`span`,{className:`kind-palette-caret`,"aria-hidden":`true`,children:t?`▸`:`▾`}),e.layer]}),t?null:(0,$.jsx)(`ul`,{className:`kind-palette-rows`,children:e.kinds.map(e=>{let t=U_(e.label)??U_(e.coreLabel);return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`kind-palette-row`,draggable:!0,"data-kind":e.label,onDragStart:t=>{t.dataTransfer.setData(G_,e.label),t.dataTransfer.effectAllowed=`copy`},onClick:()=>n(e.label),children:[t===null?null:(0,$.jsx)(`img`,{src:t,alt:``,width:14,height:14}),(0,$.jsx)(`span`,{children:e.label})]})},e.id)})}),t||e.boundThroughSlot.length===0?null:(0,$.jsx)(ev,{layer:e.layer,kinds:e.boundThroughSlot,onPick:n})]},e.layer)})]})},ev=({layer:e,kinds:t,onPick:n})=>{let[r,i]=(0,y.useState)(!1);return(0,$.jsxs)(`div`,{className:`kind-palette-bound`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`kind-palette-layer-name kind-palette-bound-name`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,$.jsx)(`span`,{className:`kind-palette-caret`,"aria-hidden":`true`,children:r?`▾`:`▸`}),`${e} \u00b7 ${t.length} kinds bound through a slot`]}),r?(0,$.jsx)(`ul`,{className:`kind-palette-rows`,children:t.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,className:`kind-palette-row`,draggable:!0,"data-kind":e.label,onDragStart:t=>{t.dataTransfer.setData(G_,e.label),t.dataTransfer.effectAllowed=`copy`},onClick:()=>n(e.label),children:(0,$.jsx)(`span`,{children:e.label})})},e.id))}):null]})},tv=e=>e.trim().toLowerCase();function nv(e,t,n,r){return e===``||t.toLowerCase().includes(e)||typeof n==`string`&&n.toLowerCase().includes(e)?!0:typeof r==`string`&&r.toLowerCase().includes(e)}var rv=(e,t)=>{let n=tv(t);return e.filter(e=>nv(n,e.id,e.name,e.kindLabel)).length},iv=c(o(((e,t)=>{(function(n){if(typeof e==`object`&&t!==void 0)t.exports=n();else if(typeof define==`function`&&define.amd)define([],n);else{var r=typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:this;r.ELK=n()}})(function(){return(function(){function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var c=typeof l==`function`&&l;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var u=Error(`Cannot find module '`+o+`'`);throw u.code=`MODULE_NOT_FOUND`,u}var d=n[o]={exports:{}};t[o][0].call(d.exports,function(e){var n=t[o][1][e];return i(n||e)},d,d.exports,e,t,n,r)}return n[o].exports}for(var a=typeof l==`function`&&l,o=0;o<r.length;o++)i(r[o]);return i}return e})()({1:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;function r(e){"@babel/helpers - typeof";return r=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},r(e)}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,s(r.key),r)}}function o(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){var t=c(e,`string`);return r(t)==`symbol`?t:t+``}function c(e,t){if(r(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t||`default`);if(r(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}n.default=function(){function e(){var t=this,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=n.defaultLayoutOptions,a=r===void 0?{}:r,o=n.algorithms,s=o===void 0?[`layered`,`stress`,`mrtree`,`radial`,`force`,`disco`,`sporeOverlap`,`sporeCompaction`,`rectpacking`]:o,c=n.workerFactory,u=n.workerUrl;if(i(this,e),this.defaultLayoutOptions=a,this.initialized=!1,u===void 0&&c===void 0)throw Error(`Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.`);var d=c;u!==void 0&&c===void 0&&(d=function(e){return new Worker(e)});var f=d(u);if(typeof f.postMessage!=`function`)throw TypeError(`Created worker does not provide the required 'postMessage' function.`);this.worker=new l(f),this.worker.postMessage({cmd:`register`,algorithms:s}).then(function(e){return t.initialized=!0}).catch(console.err)}return o(e,[{key:`layout`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.layoutOptions,r=n===void 0?this.defaultLayoutOptions:n,i=t.logging,a=i!==void 0&&i,o=t.measureExecutionTime,s=o!==void 0&&o;return e?this.worker.postMessage({cmd:`layout`,graph:e,layoutOptions:r,options:{logging:a,measureExecutionTime:s}}):Promise.reject(Error(`Missing mandatory parameter 'graph'.`))}},{key:`knownLayoutAlgorithms`,value:function(){return this.worker.postMessage({cmd:`algorithms`})}},{key:`knownLayoutOptions`,value:function(){return this.worker.postMessage({cmd:`options`})}},{key:`knownLayoutCategories`,value:function(){return this.worker.postMessage({cmd:`categories`})}},{key:`terminateWorker`,value:function(){this.worker&&this.worker.terminate()}}])}();var l=function(){function e(t){var n=this;if(i(this,e),t===void 0)throw Error(`Missing mandatory parameter 'worker'.`);this.resolvers={},this.worker=t,this.worker.onmessage=function(e){setTimeout(function(){n.receive(n,e)},0)}}return o(e,[{key:`postMessage`,value:function(e){var t=this.id||0;this.id=t+1,e.id=t;var n=this;return new Promise(function(r,i){n.resolvers[t]=function(e,t){e?(n.convertGwtStyleError(e),i(e)):r(t)},n.worker.postMessage(e)})}},{key:`receive`,value:function(e,t){var n=t.data,r=e.resolvers[n.id];r&&(delete e.resolvers[n.id],n.error?r(n.error):r(null,n.data))}},{key:`terminate`,value:function(){this.worker&&this.worker.terminate()}},{key:`convertGwtStyleError`,value:function(e){if(e){var t=e.__java$exception;t&&(t.cause&&t.cause.backingJsObject&&(e.cause=t.cause.backingJsObject,this.convertGwtStyleError(e.cause)),delete e.__java$exception)}}}])}()},{}],2:[function(e,t,n){var r=e("./elk-api.js").default;Object.defineProperty(t.exports,"__esModule",{value:!0}),t.exports=r,r.default=r},{"./elk-api.js":1}]},{},[2])(2)})}))(),1),av={serving:`serves`,access:`accesses`,realization:`realizes`,composition:`comprises`,aggregation:`aggregates`,assignment:`is assigned to`,triggering:`triggers`,flow:`flows to`,specialization:`specializes`,influence:`influences`,association:`is associated with`},ov={serving:`served by`,realization:`realized by`,specialization:`specialized by`},sv=e=>e.slice(e.indexOf(`#`)+1).replaceAll(/([a-z0-9])([A-Z])/g,`$1 $2`).replaceAll(`-`,` `).toLowerCase(),cv=(e,t=!1)=>(t?ov[e]:void 0)??av[e]??sv(e),lv=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),uv=function(e,t){return new URL(e,t).href},dv={},fv=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=uv(t,n),t=s(t),t in dv)return;dv[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:lv,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},pv=2.5,mv={"top-down":`DOWN`,"left-right":`RIGHT`},hv={"elk.spacing.nodeNode":`60`,"elk.layered.spacing.nodeNodeBetweenLayers":`100`,"elk.spacing.edgeNode":`30`,"elk.layered.spacing.edgeNodeBetweenLayers":`30`,"elk.spacing.edgeEdge":`20`,"elk.layered.spacing.edgeEdgeBetweenLayers":`20`,"elk.spacing.componentComponent":`80`,"elk.padding":`[top=52,left=30,bottom=30,right=30]`},gv=e=>Ig(e)?{...hv,"elk.spacing.edgeEdge":`60`}:{...hv},_v=(e,t)=>({"elk.algorithm":`layered`,"elk.direction":mv[e],"elk.layered.nodePlacement.strategy":`NETWORK_SIMPLEX`,"elk.aspectRatio":String(pv),...gv(t),...Ig(t)?{"elk.hierarchyHandling":`INCLUDE_CHILDREN`,"elk.edgeRouting":`ORTHOGONAL`,"elk.edgeLabels.inline":`true`,"elk.layered.considerModelOrder.strategy":`NODES_AND_EDGES`}:{},...Rg(t)?{"elk.partitioning.activate":`true`}:{}}),vv=(e,t,n)=>{if(typeof e.name==`string`&&e.name!==``)return e.name;if(!n)return``;let r=e.coreKindLabel??``,i=e.kindLabel??r,a=i!==r&&i!==``?sv(i):cv(r,Lg(t)&&zg.has(r)),o=typeof e.liftedCount==`number`?e.liftedCount:0;return o>1?`${a} ×${o}`:a},yv=e=>{let t=e.length*5.6+8,n=Math.max(1,Math.ceil(t/110));return{width:Math.min(110,Math.round(t)),height:12*n+4}};function bv(e,t){let{direction:n,mode:r,showKindLabels:i}=t,a=e.nodes(),o=new Set(a.map(e=>e.id())),s=new Map,c=[];a.forEach(e=>{let t=e.parent(),n=t.nonempty()?t.first().id():null;if(n!==null&&o.has(n)){let t=s.get(n);t===void 0?s.set(n,[e]):t.push(e)}else c.push(e)});let l=e=>{let t=s.get(e.id());if(t===void 0||t.length===0)return Vg(e.data(`layer`));let n=t.map(l).filter(e=>e!==void 0);return n.length===0?void 0:Math.min(...n)},u=gv(r),d=e=>{let t=s.get(e.id())??[],n={id:e.id()};if(t.length>0)n.children=t.map(d),n.layoutOptions={...u};else{let t=e.layoutDimensions({nodeDimensionsIncludeLabels:!1});n.width=t.w,n.height=t.h}if(Rg(r)){let t=l(e);t!==void 0&&(n.layoutOptions={...n.layoutOptions??{},"elk.partitioning.partition":String(t)})}return n},f=new Set,p=[];return e.edges().forEach(e=>{let t=e.source().id(),n=e.target().id();if(!o.has(t)||!o.has(n))return;let a=String(e.data(`coreKindLabel`)??``),s=Lg(r)&&zg.has(a);s&&f.add(e.id());let c={id:e.id(),sources:[s?n:t],targets:[s?t:n]};if(Ig(r)){let t=vv(e.data(),r,i);t!==``&&(c.labels=[{text:t,...yv(t)}])}p.push(c)}),{graph:{id:`root`,layoutOptions:_v(n,r),children:c.map(d),edges:p},reversed:f}}var xv=(e,t)=>[e.startPoint,...e.bendPoints??[],e.endPoint].map(e=>({x:e.x+t.x,y:e.y+t.y})),Sv=e=>{let t=0;for(let n=1;n<e.length;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t},Cv=(e,t)=>{let n=1/0,r=0,i=0;for(let a=1;a<e.length;a+=1){let o=e[a-1],s=e[a],c=s.x-o.x,l=s.y-o.y,u=Math.hypot(c,l)||1,d=Math.max(0,Math.min(1,((t.x-o.x)*c+(t.y-o.y)*l)/(u*u))),f=Math.hypot(t.x-(o.x+d*c),t.y-(o.y+d*l));f<n&&(n=f,r=i+d*u),i+=u}return r};function wv(e,t){let n=new Map([[e.id,{x:0,y:0}]]),r=new Map,i=(e,t,a)=>{for(let o of e.children??[]){let e=t+(o.x??0),s=a+(o.y??0);n.set(o.id,{x:e,y:s}),(o.children??[]).length===0&&r.set(o.id,{x:e+(o.width??0)/2,y:s+(o.height??0)/2}),i(o,e,s)}};i(e,0,0);let a=new Map,o=e=>{for(let r of e.edges??[]){let i=n.get(r.container??e.id)??{x:0,y:0},o=r.sections?.[0];if(o===void 0)continue;let s=xv(o,i),c=null,l=r.labels?.[0];if(l!==void 0&&l.x!==void 0&&l.y!==void 0&&(c=Cv(s,{x:l.x+i.x+(l.width??0)/2,y:l.y+i.y+(l.height??0)/2})),t.has(r.id)){let e=Sv(s);s=[...s].reverse(),c!==null&&(c=e-c)}a.set(r.id,{points:s,labelAt:c})}for(let t of e.children??[])o(t)};return o(e),{nodes:r,edges:a}}var Tv=e=>e.default??e,Ev=Tv(iv.default),Dv,Ov=()=>Dv??=fv(()=>import(`./elk.bundled-CYZFv-C6.js`).then(e=>c(e.default,1)).then(e=>new(Tv(e))),[],import.meta.url),kv;function Av(e){let t=new Ev({workerFactory:()=>e()});return{layout:e=>t.layout(e),terminate:()=>t.terminateWorker?.()}}function jv(e){kv=e}var Mv=async e=>(kv??await Ov()).layout(e),Nv=[`curve-style`,`edge-distances`,`source-endpoint`,`target-endpoint`,`segment-weights`,`segment-distances`,`source-text-offset`],Pv=e=>`${Math.round(e*10)/10}px`;function Fv(e,t,n,r){let i=e[0],a=e[e.length-1];if(i===void 0||a===void 0)return{};let o=e.slice(1,-1),s=a.x-i.x,c=a.y-i.y,l=Math.hypot(s,c)||1,u=-c/l,d=s/l,f=[],p=[];for(let e of o){let t=e.x-i.x,n=e.y-i.y;f.push(((t*s+n*c)/(l*l)).toFixed(4)),p.push((t*u+n*d).toFixed(2))}let m={"curve-style":o.length>0?`segments`:`straight`,"edge-distances":`endpoints`,"source-endpoint":`${Pv(i.x-t.x)} ${Pv(i.y-t.y)}`,"target-endpoint":`${Pv(a.x-n.x)} ${Pv(a.y-n.y)}`,"source-text-offset":r===null?0:Math.round(r)};return o.length>0&&(m[`segment-weights`]=f.join(` `),m[`segment-distances`]=p.join(` `)),m}var Iv=1e-6;function Lv(e,t){if(e.isParent()){let n=e.descendants().filter(e=>!e.isParent());return n.length>0&&n.every(e=>Lv(e,t))}let n=t.nodes.get(e.id());if(n===void 0)return!1;let r=e.position();return Math.abs(r.x-n.x)<Iv&&Math.abs(r.y-n.y)<Iv}function Rv(e,t,n){let r=0;e.startBatch();try{for(let[i,a]of t.edges){let t=e.getElementById(i);t.empty()||!t.isEdge()||!n(t)||(t.style(Fv(a.points,t.source().position(),t.target().position(),a.labelAt)),t.scratch(Bv,a),t.addClass(`routed`),r+=1)}}finally{e.endBatch()}return r}function zv(e){e.removeClass(`routed`),e.removeStyle(Nv.join(` `)),e.removeScratch(Bv)}var Bv=`_route`;function Vv(e){let t={};return e.forEach(e=>{if(!e.hasClass(`routed`))return;let n=e.scratch(Bv);n!==void 0&&(t[e.id()]={points:n.points.map(e=>({x:e.x,y:e.y})),labelAt:n.labelAt})}),t}function Hv(e,t,n){let r={nodes:new Map(Object.entries(n).map(([e,t])=>[e,{x:t.x,y:t.y}])),edges:new Map(Object.entries(t).map(([e,t])=>[e,{points:t.points.map(e=>({x:e.x,y:e.y})),labelAt:t.labelAt}]))};return Rv(e,r,e=>!e.hasClass(`routed`)&&Lv(e.source(),r)&&Lv(e.target(),r))}function Uv(e){let t=e=>{let t=e.target;zv(t.union(t.ancestors()).union(t.descendants()).connectedEdges(`.routed`))};return e.on(`dragfree`,`node`,t),()=>{e.off(`dragfree`,`node`,t)}}var Wv=`#F0F0F0`,Gv=`#999999`,Kv=170,qv=50,Jv=150,Yv=``;function Xv(e){return e.replace(/([/._-])/g,`$1${Yv}`)}var Zv=20,Qv=1.25,$v=.02,ey=10;function ty(e,t){let n=t===1?e*Qv:e/Qv;return Math.min(ey,Math.max($v,n))}var ny=12;function ry(e,t,n,r,i,a){let o=[],s=U_(String(e.data(`kindLabel`)),a)??U_(String(e.data(`coreKindLabel`)),a);s!==null&&o.push({image:s,positionX:`0%`,positionY:`0%`,size:14});let c=e.data(`status`);t&&o_(c)&&o.push({image:g_[c],positionX:`100%`,positionY:`0%`,size:ny}),n&&e.data(`hasAttestations`)===!0&&o.push({image:__,positionX:`0%`,positionY:`100%`,size:ny});let l=e.data(`owner`),u=e.data(`ownerInitials`),d=r&&l!==null&&u!==null;d&&o.push({image:x_(l,u),positionX:`100%`,positionY:`100%`,size:ny});let f=e.data(`openQuestions`);return i&&typeof f==`number`&&f>0&&o.push({image:C_(f),positionX:d?`84%`:`96%`,positionY:d?`100%`:`88%`,size:ny}),o}var iy=[`added`,`removed`,`changed`],ay=e=>`deco-${e}`,oy=iy.map(ay).join(` `),sy={added:`#416F65`,removed:`#677074`,changed:`#8C4D18`};function cy(e,t){e.elements().removeClass(oy);for(let[n,r]of Object.entries(t)){let t=e.getElementById(n);t.nonempty()&&t.addClass(ay(r))}}function ly(e,t,n,r,i=!0,a=Fg,o=Wg){let s=Jg(o).glyph,c=e=>Xv(vv(e.data(),a,i)),l=new Map,u=i=>{let a=`${String(i.data(`status`))}\u0000${String(i.data(`hasAttestations`))}\u0000${String(i.data(`owner`))}\u0000${String(i.data(`ownerInitials`))}\u0000${String(i.data(`kindLabel`))}\u0000${String(i.data(`openQuestions`))}`,o=l.get(a);if(o!==void 0)return o;let c=ry(i,e,t,n,r,s),u={images:c.map(e=>e.image),positionsX:c.map(e=>e.positionX),positionsY:c.map(e=>e.positionY),sizes:c.map(e=>e.size),containments:c.map(()=>`over`),clips:c.map(()=>`none`)};return l.set(a,u),u},d=[{selector:`node`,style:{"background-color":Wv,"border-color":Gv,"border-width":2,shape:`roundrectangle`,width:Kv,height:qv,padding:`8px`,label:`data(wrapLabel)`,"font-size":12,"text-wrap":`wrap`,"text-max-width":`${Jv}px`,"text-halign":`center`,"text-valign":`center`,color:`#333333`}},{selector:`node`,style:{"background-image":e=>u(e).images,"background-position-x":e=>u(e).positionsX,"background-position-y":e=>u(e).positionsY,"background-width":e=>u(e).sizes,"background-height":e=>u(e).sizes,"background-image-containment":e=>u(e).containments,"background-clip":e=>u(e).clips}},...Object.entries(M_).map(([e,t])=>({selector:`node[layer = "${e}"]`,style:{"background-color":t.fill,"border-color":t.border}})),{selector:`node:parent`,style:{shape:`roundrectangle`,"background-opacity":.25,"border-width":2,"border-style":`dashed`,padding:`30px`,label:`data(wrapLabel)`,"font-size":13,"font-weight":`bold`,"text-halign":`center`,"text-valign":`top`,"text-margin-y":-8,color:`#333333`,"text-background-color":`#FFFFFF`,"text-background-opacity":1,"text-background-padding":`3px`}},{selector:`node.selected`,style:{"border-color":`#FF6B6B`,"border-width":4}},{selector:`node.folded`,style:{ghost:`yes`,"ghost-offset-x":4,"ghost-offset-y":4,"ghost-opacity":.35,"border-width":2}},{selector:`node.folded[insideCount > 0]`,style:{"background-image":e=>T_(Number(e.data(`insideCount`)??0)),"background-image-containment":`over`,"background-clip":`none`,"background-fit":`none`,"background-width":26,"background-height":12,"background-position-x":`100%`,"background-position-y":`100%`,"background-offset-x":-4,"background-offset-y":-4}},{selector:`edge.lifted`,style:{"line-style":`dashed`,"line-dash-pattern":[6,3],width:2}},{selector:`edge`,style:{"line-color":`#999999`,width:1.5,"curve-style":`taxi`,"target-arrow-shape":`triangle`,"target-arrow-color":`#999999`,label:c,"font-size":10,"text-wrap":`wrap`,"text-max-width":`110px`,"text-background-color":`#FFFFFF`,"text-background-padding":`3px`,"text-background-opacity":1}},{selector:`edge.parallel`,style:{"curve-style":`bezier`,"control-point-step-size":40}},{selector:`edge.routed`,style:{label:``,"source-label":c,"text-wrap":`wrap`,"text-max-width":`110px`}},{selector:`edge.selected`,style:{"line-color":`#FF6B6B`,"target-arrow-color":`#FF6B6B`,width:2.5}}],f=Object.entries(N_).map(([e,t])=>{let n={shape:t.shape};return t.accent===`top-band`&&(n[`background-fill`]=`linear-gradient`,n[`background-gradient-direction`]=`to-bottom`,n[`background-gradient-stop-colors`]=[Gv,Wv],n[`background-gradient-stop-positions`]=[`0%`,`20%`]),t.borderStyle===`dashed`&&(n[`border-style`]=`dashed`),{selector:`node[aspect = "${e}"]:childless`,style:n}}),p=H_.map(e=>{let t={"line-style":e.lineStyle,"source-arrow-shape":e.sourceArrow.shape,"target-arrow-shape":e.targetArrow.shape};return e.sourceArrow.fill!==void 0&&(t[`source-arrow-fill`]=e.sourceArrow.fill),e.targetArrow.fill!==void 0&&(t[`target-arrow-fill`]=e.targetArrow.fill),{selector:`edge[coreKindLabel = "${e.id}"]`,style:t}}),m=[{selector:`node.deco-added, edge.deco-added`,style:{"border-color":sy.added,"border-width":3,"line-color":sy.added,"target-arrow-color":sy.added}},{selector:`node.deco-removed, edge.deco-removed`,style:{"border-color":sy.removed,"border-width":3,"border-style":`dashed`,"line-color":sy.removed,"target-arrow-color":sy.removed,"line-style":`dashed`}},{selector:`node.deco-changed, edge.deco-changed`,style:{"border-color":sy.changed,"border-width":3,"line-color":sy.changed,"target-arrow-color":sy.changed}},{selector:`node.faulted, edge.faulted`,style:{"border-color":`#A3403A`,"border-width":4,"line-color":`#A3403A`,"target-arrow-color":`#A3403A`}}];return[...d,...f,...p,...a_(o),...m]}function uy(e){for(let t of e.conflicts){let e=new Set(t.claims.map(e=>e.from));console.warn(`Nesting conflict: "${t.child}" is claimed by ${e.size} different parents at the same precedence (${t.claims.map(e=>`${dy(e.kind)} from ${e.from}`).join(`, `)}) - rendering it unnested; every claim stays drawn as a regular edge.`)}e.cycleMembers.length>0&&console.warn(`Nesting cycle detected among: ${e.cycleMembers.join(`, `)} - rendering them unnested.`)}var dy=e=>e.split(`#`)[1]??e;function fy(e,t,n,r){new Map(e.nodes.map(e=>[e.id,e.coreKindLabel]));let i=Ag({nodes:e.nodes.map(e=>({id:e.id,kind:e.kind,coreKind:e.coreKindLabel})),edges:e.edges,memberships:r?.memberships??[],nesting:t});uy(i);let a=i.consumedEdgeIds,o=new Map;for(let e of i.parentOf.keys()){let t=i.parentOf.get(e),n=new Set([e]);for(;t!==void 0&&!n.has(t);){n.add(t);let r=o.get(t);r===void 0?o.set(t,[e]):r.push(e),t=i.parentOf.get(t)}}let s=r?.folded??new Set,c=e.nodes.map(e=>{let t=i.parentOf.get(e.id),r=o.get(e.id)??[],a=s.has(e.id);return{data:{id:e.id,label:e.name,wrapLabel:Xv(e.name),kind:e.kind,kindLabel:e.kindLabel,coreKindLabel:e.coreKindLabel,aspect:e.aspect,layer:e.layer,status:e.status,hasAttestations:e.attestations.length>0,owner:e.owner,ownerInitials:E_(e.owner),openQuestions:a?[e.id,...r].reduce((e,t)=>e+(n.get(t)??0),0):n.get(e.id)??0,insideCount:r.length,insideIds:r,...t===void 0?{}:{parent:t,compositionParent:t}},group:`nodes`,...a?{classes:`folded`}:{}}}),l=e.edges.filter(e=>!a.has(e.id)),u=new Map,d=e=>e.from<e.to?`${e.from}\u0000${e.to}`:`${e.to}\u0000${e.from}`;for(let e of l){let t=d(e);u.set(t,(u.get(t)??0)+1)}let f=l.map(e=>({data:{id:e.id,source:e.from,target:e.to,name:e.name??null,kindLabel:e.kindLabel,label:e.name??e.kindLabel,wrapLabel:Xv(e.name??e.kindLabel),coreKindLabel:e.coreKindLabel},group:`edges`,...u.get(d(e))>1?{classes:`parallel`}:{}})),p=s.size===0?[]:Ng({nodes:e.nodes,edges:l},i,s).edges.filter(e=>`count`in e).map(e=>({data:{id:e.id,source:e.from,target:e.to,label:e.count===1?dy(e.kind):`${dy(e.kind)} \u00d7${e.count}`,wrapLabel:Xv(dy(e.kind)),name:null,kindLabel:dy(e.kind),coreKindLabel:dy(e.kind),lifted:!0,liftedCount:e.count,relationshipIds:e.relationshipIds},group:`edges`,classes:`lifted`}));return[...c,...f,...p]}function py(e,t,n){let r=n.trim().toLowerCase(),i=t===null?null:new Set(t);return e.filter(e=>(i===null||i.has(e.id))&&nv(r,e.id,e.name,e.kindLabel)).length}function my(e,t,n){let r=n.trim().toLowerCase(),i=t===null?e.nodes().map(e=>e.id()):t,a=new Set(r===``?i:i.filter(t=>{let n=e.getElementById(t);return nv(r,t,n.data(`label`),n.data(`kindLabel`))})),o=new Set(a),s=t=>{let n=e.getElementById(t).data(`compositionParent`);return typeof n==`string`?n:void 0};for(let e of[...a]){let t=new Set([e]),n=s(e);for(;n!==void 0&&!t.has(n);)t.add(n),a.add(n),n=s(n)}for(let t of[...a]){let n=new Set([t]),r=s(t);for(;r!==void 0&&!n.has(r);){if(n.add(r),e.getElementById(r).hasClass(`folded`)){a.delete(t);break}r=s(r)}}let c=[];for(let t of e.nodes()){let e=s(t.id());if(e===void 0)continue;let n=a.has(t.id())&&a.has(e)?e:null;(t.parent().nonempty()?t.parent().first().id():null)!==n&&c.push({node:t.id(),parent:n})}for(let{node:t,parent:n}of c)e.getElementById(t).move({parent:n});for(let t of e.nodes(`.folded`)){let n=t.data(`insideIds`),r=Array.isArray(n)?n:[];t.data(`insideCount`,r.filter(t=>e.getElementById(t).nonempty()&&o.has(t)).length)}let l=new Set(_y(e.elements()).map(e=>e.id())),u=new Set(a);for(let t of e.edges()){let e=t.data(`source`),n=t.data(`target`);a.has(e)&&a.has(n)&&u.add(t.id())}for(let e of l)u.delete(e);e.elements().style(`display`,`none`),e.elements().filter(e=>u.has(e.id())).style(`display`,`element`)}var hy=`_layoutGeneration`;async function gy(e,t,n,r,i){let a=`elements`in e?e:e.cy(),o=`elements`in e?e.elements():e;if(o.nodes().empty())return;let s=_y(o),c=s.empty()?o:o.difference(s);zv(a.edges());let l=(a.scratch(hy)??0)+1;a.scratch(hy,l);let{graph:u,reversed:d}=bv(c,{direction:t,mode:n,showKindLabels:r}),f=await Mv(u);if(a.destroyed()||a.scratch(hy)!==l)return;let p=wv(f,d);c.layout({name:`preset`,positions:e=>p.nodes.get(e.id())??null,fit:!0,padding:Zv,animate:!1}).run(),Ig(n)&&(a.nodes().updateCompoundBounds(!0),Rv(a,p,e=>Lv(e.source(),p)&&Lv(e.target(),p)),i?.routes!==void 0&&Hv(a,i.routes,i.positions??{}))}var _y=e=>{let t=new Map;return e.nodes().forEach(e=>{let n=e.parent();n.length>0&&t.set(e.id(),n.first().id())}),t.size===0?e.edges().filter(()=>!1):e.edges().filter(e=>yg(e.source().id(),e.target().id(),t))};function vy(e,t,n=Fg,r=!0,i){return gy(e.elements(`:visible`),t,n,r,i)}async function yy(e,t,n,r,i,a){let o=i===null?null:e.getElementById(i),s=o!==null&&o.nonempty()?{...o.position()}:null;if(await vy(e,t,n,r,a),e.destroyed())return!1;if(s!==null&&o!==null&&o.nonempty()){let t=o.position(),n=s.x-t.x,r=s.y-t.y;(n!==0||r!==0)&&e.nodes().forEach(e=>{let t=e.position();e.position({x:t.x+n,y:t.y+r})})}let c=e.elements(`:visible`);if(c.empty())return!1;let l=c.boundingBox(),u=e.extent();return l.x2<u.x1||l.x1>u.x2||l.y2<u.y1||l.y1>u.y2?(e.fit(c,40),!0):!1}function by(e){let t=e.elements(`:visible`);return!t.empty()&&(e.fit(t,Zv),!0)}function xy(e){let t={};return e.forEach(e=>{let{x:n,y:r}=e.position();t[e.id()]={x:n,y:r}}),t}function Sy(e,t){t!==void 0&&e.nodes().forEach(e=>{if(!e.visible()||e.isParent())return;let n=t[e.id()];n!==void 0&&e.position(n)})}function Cy(e,t,n){return n.has(t)?void 0:e}function wy(e,t,n){return n.has(t)?void 0:e}function Ty(e,t,n){return e!==void 0&&(n??t).some(t=>e[t]!==void 0)}function Ey(e,t,n){return{x:(e.x-t.x)/n,y:(e.y-t.y)/n}}function Dy(e,t,n){let r=null,i=()=>{r!==null&&(clearTimeout(r),r=null)},a=()=>{i(),r=setTimeout(()=>{r=null;let i=t();if(i===``)return;let a=Vv(e.edges());n({projectionId:i,positions:xy(e.nodes()),...Object.keys(a).length===0?{}:{routes:a}})},500)};return e.on(`dragfree`,`node`,a),{cancelPending:i,dispose:()=>{e.off(`dragfree`,`node`,a),i()}}}function Oy({graph:e,selectedId:t,onSelect:n,onContextMenu:r,matchedIds:i,quickFilterText:a,nesting:o,faultedIds:s,decorations:c,activeViewId:l,direction:u,layout:d,showKindLabels:f,stylePreset:p,savedPositions:m,savedRoutes:h,onSaveLayout:g,onKindDrop:_,onCanvasReady:v,showLifecycle:b,showEvidence:x,showOwnership:S,showNudges:C,openQuestionCounts:w,folded:T,memberships:E}){let D=(0,y.useRef)(null),O=(0,y.useRef)(null),[k,A]=(0,y.useState)(()=>new Set),j=Cy(m,l,k),M=wy(h,l,k),N=(0,y.useRef)(n),P=(0,y.useRef)(v);P.current=v;let F=(0,y.useRef)(_);F.current=_;let I=(0,y.useRef)(r),L=(0,y.useRef)(!0),R=(0,y.useRef)(!0),z=(0,y.useRef)(l),B=(0,y.useRef)(u),V=(0,y.useRef)(d),H=(0,y.useRef)(!1),U=(0,y.useRef)(i),W=(0,y.useRef)(a),G=(0,y.useRef)(g),K=(0,y.useRef)(j),q=(0,y.useRef)(M),J=(0,y.useRef)(null),ee=(0,y.useRef)(null);(0,y.useEffect)(()=>{N.current=n},[n]),(0,y.useEffect)(()=>{I.current=r},[r]),(0,y.useEffect)(()=>{G.current=g},[g]),(0,y.useEffect)(()=>{K.current=j},[j]),(0,y.useEffect)(()=>{q.current=M},[M]),(0,y.useEffect)(()=>{J.current?.cancelPending()},[l]),(0,y.useEffect)(()=>{if(!D.current)return;let t=vg({container:D.current,elements:fy(e,o,w,{folded:T??new Set,memberships:E}),selectionType:`additive`,boxSelectionEnabled:!0,style:ly(b,x,S,C,f,d,p),wheelSensitivity:.1,layout:{name:`null`}});O.current=t,P.current?.(()=>t.png({full:!0,scale:2,bg:`#ffffff`})),t.on(`tap`,`node`,e=>{let t=e.target.id();N.current(t,`node`)}),t.on(`tap`,`edge`,e=>{let t=e.target.id();N.current(t,`edge`)});let n=e=>{let n=e.originalEvent;if(n!=null)return{x:n.clientX,y:n.clientY};let r=t.container()?.getBoundingClientRect(),i=e.renderedPosition;return{x:(r?.left??0)+(i?.x??0),y:(r?.top??0)+(i?.y??0)}};t.on(`cxttap`,`node`,e=>{I.current({type:`node`,id:e.target.id()},n(e))}),t.on(`cxttap`,`edge`,e=>{I.current({type:`edge`,id:e.target.id()},n(e))}),t.on(`cxttap`,e=>{e.target===t&&I.current({type:`canvas`,id:null},n(e))}),J.current=Dy(t,()=>z.current,e=>{A(t=>{if(!t.has(e.projectionId))return t;let n=new Set(t);return n.delete(e.projectionId),n}),G.current(e)});let r=Uv(t),i=()=>{ee.current={zoom:t.zoom(),pan:{...t.pan()}}};t.on(`layoutstop`,()=>{Sy(t,K.current),i()});let a=D.current,s=0,c=new ResizeObserver(()=>{cancelAnimationFrame(s),s=requestAnimationFrame(()=>{t.resize();let e=ee.current;if(e===null)return;let n=t.pan();if(!(Math.abs(t.zoom()-e.zoom)<1e-6&&Math.abs(n.x-e.pan.x)<.5&&Math.abs(n.y-e.pan.y)<.5))return;let r=t.elements(`:visible`);r.empty()||(t.fit(r,Zv),i())})});return c.observe(a),()=>{cancelAnimationFrame(s),c.disconnect(),r(),J.current?.dispose(),P.current?.(null),t.destroy(),O.current=null}},[]),(0,y.useEffect)(()=>{if(O.current){if(R.current){R.current=!1;return}O.current.style(ly(b,x,S,C,f,d,p))}},[b,x,S,C,f,d,p]),(0,y.useEffect)(()=>{if(O.current){if(L.current)L.current=!1;else{let t=fy(e,o,w,{folded:T??new Set,memberships:E});O.current.elements().remove(),O.current.add(t)}my(O.current,U.current,W.current),gy(O.current.elements(`:visible`),u,d,f,{positions:K.current,routes:q.current})}},[e,w,o,E]);let Y=(0,y.useRef)(null);(0,y.useEffect)(()=>{let t=O.current;if(t===null)return;let n=Y.current;if(Y.current=T??new Set,n===null)return;let r=T??new Set,s=[...[...r].filter(e=>!n.has(e)),...[...n].filter(e=>!r.has(e))];s.length!==0&&(t.elements().remove(),t.add(fy(e,o,w,{folded:r,memberships:E})),my(t,i,a),yy(t,u,d,f,s.length===1?s[0]:null,{positions:K.current,routes:q.current}))},[T]),(0,y.useEffect)(()=>{if(O.current){O.current.elements().removeClass(`faulted`);for(let e of s){let t=O.current.getElementById(e);t.nonempty()&&t.addClass(`faulted`)}}},[s,e]),(0,y.useEffect)(()=>{O.current&&cy(O.current,c)},[c,e]),(0,y.useEffect)(()=>{if(O.current&&(O.current.elements().removeClass(`selected`),t)){let e=O.current.getElementById(t);e.nonempty()&&e.addClass(`selected`)}},[t,e]),(0,y.useEffect)(()=>{(l!==z.current||u!==B.current||d!==V.current)&&(z.current=l,B.current=u,V.current=d,H.current=!0)},[l,u,d]),(0,y.useEffect)(()=>{if(!O.current)return;my(O.current,i,a);let e=i!==U.current;U.current=i;let t=a!==W.current;W.current=a,H.current||e?(H.current=!1,vy(O.current,u,d,f,{positions:K.current,routes:q.current})):t&&by(O.current)&&(ee.current={zoom:O.current.zoom(),pan:{...O.current.pan()}})},[i,a,e,u,d]);let te=()=>{A(e=>new Set(e).add(l)),K.current=void 0,q.current=void 0,J.current?.cancelPending(),O.current!==null&&vy(O.current,u,d,f)},ne=e=>{let t=O.current;t!==null&&t.zoom({level:ty(t.zoom(),e),renderedPosition:{x:t.width()/2,y:t.height()/2}})},re=()=>{let e=O.current;e!==null&&by(e)&&(ee.current={zoom:e.zoom(),pan:{...e.pan()}})},ie=Ty(j,e.nodes.map(e=>e.id),i);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{ref:D,style:{position:`relative`,width:`100%`,height:`100%`,...Jg(p).canvas===void 0?{}:{background:Jg(p).canvas}},onContextMenu:e=>e.preventDefault(),onDragOver:e=>{F.current!==void 0&&e.dataTransfer.types.includes(`application/x-yarramate-kind`)&&e.preventDefault()},onDrop:e=>{let t=e.dataTransfer.getData(G_);if(t===``||F.current===void 0)return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect(),r=O.current;F.current(t,Ey({x:e.clientX-n.left,y:e.clientY-n.top},r?.pan()??{x:0,y:0},r?.zoom()??1))}}),ie?(0,$.jsxs)(`div`,{className:`saved-layout-pill`,role:`status`,children:[(0,$.jsx)(`span`,{children:`Saved layout in force`}),(0,$.jsx)(`button`,{type:`button`,onClick:te,children:`Discard`})]}):null,(0,$.jsxs)(`div`,{className:`zoom-controls`,role:`group`,"aria-label":`Zoom controls`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`Zoom in`,onClick:()=>ne(1),children:`+`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Zoom out`,onClick:()=>ne(-1),children:`−`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Fit diagram`,onClick:re,children:`Fit`})]})]})}var ky=Symbol.for(`yaml.alias`),Ay=Symbol.for(`yaml.document`),jy=Symbol.for(`yaml.map`),My=Symbol.for(`yaml.pair`),Ny=Symbol.for(`yaml.scalar`),Py=Symbol.for(`yaml.seq`),Fy=Symbol.for(`yaml.node.type`),Iy=e=>!!e&&typeof e==`object`&&e[Fy]===ky,Ly=e=>!!e&&typeof e==`object`&&e[Fy]===Ay,Ry=e=>!!e&&typeof e==`object`&&e[Fy]===jy,zy=e=>!!e&&typeof e==`object`&&e[Fy]===My,By=e=>!!e&&typeof e==`object`&&e[Fy]===Ny,Vy=e=>!!e&&typeof e==`object`&&e[Fy]===Py;function Hy(e){if(e&&typeof e==`object`)switch(e[Fy]){case jy:case Py:return!0}return!1}function Uy(e){if(e&&typeof e==`object`)switch(e[Fy]){case ky:case jy:case Ny:case Py:return!0}return!1}var Wy=e=>(By(e)||Hy(e))&&!!e.anchor,Gy=Symbol(`break visit`),Ky=Symbol(`skip children`),qy=Symbol(`remove node`);function Jy(e,t){let n=Xy(t);Ly(e)?Yy(null,e.contents,n,Object.freeze([e]))===qy&&(e.contents=null):Yy(null,e,n,Object.freeze([]))}Jy.BREAK=Gy,Jy.SKIP=Ky,Jy.REMOVE=qy;function Yy(e,t,n,r){let i=Zy(e,t,n,r);if(Uy(i)||zy(i))return Qy(e,r,i),Yy(e,i,n,r);if(typeof i!=`symbol`){if(Hy(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=Yy(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===Gy)return Gy;else i===qy&&(t.items.splice(e,1),--e)}}else if(zy(t)){r=Object.freeze(r.concat(t));let e=Yy(`key`,t.key,n,r);if(e===Gy)return Gy;e===qy&&(t.key=null);let i=Yy(`value`,t.value,n,r);if(i===Gy)return Gy;i===qy&&(t.value=null)}}return i}function Xy(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Zy(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(Ry(t))return n.Map?.(e,t,r);if(Vy(t))return n.Seq?.(e,t,r);if(zy(t))return n.Pair?.(e,t,r);if(By(t))return n.Scalar?.(e,t,r);if(Iy(t))return n.Alias?.(e,t,r)}function Qy(e,t,n){let r=t[t.length-1];if(Hy(r))r.items[e]=n;else if(zy(r))e===`key`?r.key=n:r.value=n;else if(Ly(r))r.contents=n;else{let e=Iy(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var $y={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},eb=e=>e.replace(/[!,[\]{}]/g,e=>$y[e]),tb=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+eb(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&Uy(e.contents)){let t={};Jy(e.contents,(e,n)=>{Uy(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)(i!==`!!`||a!==`tag:yaml.org,2002:`)&&(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
|
|
330
330
|
`)}};tb.defaultYaml={explicit:!1,version:`1.2`},tb.defaultTags={"!!":`tag:yaml.org,2002:`};function nb(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function rb(e){let t=new Set;return Jy(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function ib(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function ab(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=rb(e);let a=ib(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(By(t.node)||Hy(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function ob(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=ob(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=ob(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=ob(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=ob(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function sb(e,t,n){if(Array.isArray(e))return e.map((e,t)=>sb(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!Wy(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var cb=class{constructor(e){Object.defineProperty(this,Fy,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Ly(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=sb(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?ob(i,{"":o},``,o):o}},lb=class extends cb{constructor(e){super(ky),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],Jy(e,{Node:(e,t)=>{(Iy(t)||Wy(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}return r}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r,t);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(sb(a,null,t),n.get(a)),o?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=ub(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(nb(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function ub(e,t,n){if(Iy(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(Hy(t)){let r=0;for(let i of t.items){let t=ub(e,i,n);t>r&&(r=t)}return r}if(zy(t)){let r=ub(e,t.key,n),i=ub(e,t.value,n);return Math.max(r,i)}return 1}var db=e=>!e||typeof e!=`function`&&typeof e!=`object`,fb=class extends cb{constructor(e){super(Ny),this.value=e}toJSON(e,t){return t?.keep?this.value:sb(this.value,e,t)}toString(){return String(this.value)}};fb.BLOCK_FOLDED=`BLOCK_FOLDED`,fb.BLOCK_LITERAL=`BLOCK_LITERAL`,fb.PLAIN=`PLAIN`,fb.QUOTE_DOUBLE=`QUOTE_DOUBLE`,fb.QUOTE_SINGLE=`QUOTE_SINGLE`;var pb=`tag:yaml.org,2002:`;function mb(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function hb(e,t,n){if(Ly(e)&&(e=e.contents),Uy(e))return e;if(zy(e)){let t=n.schema[jy].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new lb(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=pb+t.slice(2));let l=mb(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new fb(e);return c&&(c.node=t),t}l=e instanceof Map?o[jy]:Symbol.iterator in Object(e)?o[Py]:o[jy]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new fb(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function gb(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return hb(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var _b=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,vb=class extends cb{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>Uy(t)||zy(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(_b(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(Hy(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,gb(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(Hy(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&By(i)?i.value:i:Hy(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!zy(t))return!1;let n=t.value;return n==null||e&&By(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return Hy(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(Hy(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,gb(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},yb=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function bb(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var xb=(e,t,n)=>e.endsWith(`
|
|
331
331
|
`)?bb(n,t):n.includes(`
|
|
332
332
|
`)?`
|
|
@@ -366,4 +366,8 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
366
366
|
`:` `)}return Ib({comment:e,type:t,value:s},r,i,a)}};function Ox(e,t){if(Vy(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!zy(r)){if(Ry(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new Qb(new fb(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=zy(r)?r:new Qb(r)}}else t(`Expected a sequence for this tag`);return e}function kx(e,t,n){let{replacer:r}=n,i=new ox(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(Zb(o,s,n))}return i}var Ax={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:Ox,createNode:kx},jx=class e extends ox{constructor(){super(),this.add=ix.prototype.add.bind(this),this.delete=ix.prototype.delete.bind(this),this.get=ix.prototype.get.bind(this),this.has=ix.prototype.has.bind(this),this.set=ix.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(zy(e)?(r=sb(e.key,``,t),i=sb(e.value,r,t)):r=sb(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=kx(e,t,n),i=new this;return i.items=r.items,i}};jx.tag=`tag:yaml.org,2002:omap`;var Mx={collection:`seq`,identify:e=>e instanceof Map,nodeClass:jx,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=Ox(e,t),r=[];for(let{key:e}of n.items)By(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new jx,n)},createNode:(e,t,n)=>jx.from(e,t,n)};function Nx({value:e,source:t},n){return t&&(e?Px:Fx).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var Px={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new fb(!0),stringify:Nx},Fx={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new fb(!1),stringify:Nx},Ix={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:fx},Lx={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():fx(e)}},Rx={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new fb(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:fx},zx=e=>typeof e==`bigint`||Number.isInteger(e);function Bx(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function Vx(e,t,n){let{value:r}=e;if(zx(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return fx(e)}var Hx={identify:zx,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>Bx(e,2,2,n),stringify:e=>Vx(e,2,`0b`)},Ux={identify:zx,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>Bx(e,1,8,n),stringify:e=>Vx(e,8,`0`)},Wx={identify:zx,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>Bx(e,0,10,n),stringify:fx},Gx={identify:zx,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>Bx(e,2,16,n),stringify:e=>Vx(e,16,`0x`)},Kx=class e extends ix{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=zy(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new Qb(e.key,null):new Qb(e,null),rx(this.items,t.key)||this.items.push(t)}get(e,t){let n=rx(this.items,e);return!t&&zy(n)?By(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=rx(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new Qb(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(Zb(e,null,n));return i}};Kx.tag=`tag:yaml.org,2002:set`;var qx={collection:`map`,identify:e=>e instanceof Set,nodeClass:Kx,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>Kx.from(e,t,n),resolve(e,t){if(Ry(e)){if(e.hasAllNullValues(!0))return Object.assign(new Kx,e);t(`Set items must all have null values`)}else t(`Expected a mapping for this tag`);return e}};function Jx(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function Yx(e){let{value:t}=e,n=e=>e;if(typeof t==`bigint`)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return fx(e);let r=``;t<0&&(r=`-`,t*=n(-1));let i=n(60),a=[t%i];return t<60?a.unshift(0):(t=(t-a[0])/i,a.unshift(t%i),t>=60&&(t=(t-a[0])/i,a.unshift(t))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}var Xx={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>Jx(e,n),stringify:Yx},Zx={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Jx(e,!1),stringify:Yx},Qx={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(Qx.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,i,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+`00`).substr(1,3)):0,l=Date.UTC(n,r-1,i,a||0,o||0,s||0,c),u=t[8];if(u&&u!==`Z`){let e=Jx(u,!1);Math.abs(e)<30&&(e*=60),l-=6e4*e}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``},$x=[ax,cx,lx,ux,Px,Fx,Hx,Ux,Wx,Gx,Ix,Lx,Rx,Dx,Wb,Mx,Ax,qx,Xx,Zx,Qx],eS=new Map([[`core`,Sx],[`failsafe`,[ax,cx,lx]],[`json`,Ex],[`yaml11`,$x],[`yaml-1.1`,$x]]),tS={binary:Dx,bool:dx,float:hx,floatExp:mx,floatNaN:px,floatTime:Zx,int:bx,intHex:xx,intOct:yx,intTime:Xx,map:ax,merge:Wb,null:ux,omap:Mx,pairs:Ax,seq:cx,set:qx,timestamp:Qx},nS={"tag:yaml.org,2002:binary":Dx,"tag:yaml.org,2002:merge":Wb,"tag:yaml.org,2002:omap":Mx,"tag:yaml.org,2002:pairs":Ax,"tag:yaml.org,2002:set":qx,"tag:yaml.org,2002:timestamp":Qx};function rS(e,t,n){let r=eS.get(t);if(r&&!e)return n&&!r.includes(Wb)?r.concat(Wb):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(eS.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(Wb)),i.reduce((e,t)=>{let n=typeof t==`string`?tS[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(tS).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}var iS=(e,t)=>e.key<t.key?-1:+(e.key>t.key),aS=class e{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?rS(e,`compat`):e?rS(null,e):null,this.name=typeof i==`string`&&i||`core`,this.knownTags=r?nS:{},this.tags=rS(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,jy,{value:ax}),Object.defineProperty(this,Ny,{value:lx}),Object.defineProperty(this,Py,{value:cx}),this.sortMapEntries=typeof a==`function`?a:a===!0?iS:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function oS(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(n.push(t),r=!0):e.directives.docStart&&(r=!0)}r&&n.push(`---`);let i=Lb(e,t),{commentString:a}=i.options;if(e.commentBefore){n.length!==1&&n.unshift(``);let t=a(e.commentBefore);n.unshift(bb(t,``))}let o=!1,s=null;if(e.contents){if(Uy(e.contents)){if(e.contents.spaceBefore&&r&&n.push(``),e.contents.commentBefore){let t=a(e.contents.commentBefore);n.push(bb(t,``))}i.forceBlockIndent=!!e.comment,s=e.contents.comment}let t=s?void 0:()=>o=!0,c=Bb(e.contents,i,()=>s=null,t);s&&(c+=xb(c,``,a(s))),(c[0]===`|`||c[0]===`>`)&&n[n.length-1]===`---`?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(Bb(e.contents,i));if(e.directives?.docEnd){if(e.comment){let t=a(e.comment);t.includes(`
|
|
367
367
|
`)?(n.push(`...`),n.push(bb(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(bb(a(t),``)))}return n.join(`
|
|
368
368
|
`)+`
|
|
369
|
-
`}var sS=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Fy,{value:Ay});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new tb({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[Fy]:{value:Ay}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=Uy(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){cS(this.contents)&&this.contents.add(e)}addIn(e,t){cS(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=rb(this);e.anchor=!t||n.has(t)?ib(t||`a`,n):t}return new lb(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=ab(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=hb(e,l,p);return o&&Hy(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new Qb(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return cS(this.contents)?this.contents.delete(e):!1}deleteIn(e){return _b(e)?this.contents!=null&&(this.contents=null,!0):cS(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Hy(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return _b(e)?!t&&By(this.contents)?this.contents.value:this.contents:Hy(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Hy(this.contents)?this.contents.has(e):!1}hasIn(e){return _b(e)?this.contents!==void 0:Hy(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=gb(this.schema,[e],t):cS(this.contents)&&this.contents.set(e,t)}setIn(e,t){_b(e)?this.contents=t:this.contents==null?this.contents=gb(this.schema,Array.from(e),t):cS(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new tb({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new tb({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new aS(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=sb(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?ob(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return oS(this,e)}};function cS(e){if(Hy(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var lS=Symbol(`break visit`),uS=Symbol(`skip children`),dS=Symbol(`remove item`);function fS(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),pS(Object.freeze([]),e,t)}fS.BREAK=lS,fS.SKIP=uS,fS.REMOVE=dS,fS.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},fS.parentCollection=(e,t)=>{let n=fS.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function pS(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=pS(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===lS)return lS;else r===dS&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function mS(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return Ly(e)&&!r?e.toString(n):new sS(e,r,n).toString(n)}var hS=e=>mS(e,{version:`1.1`})!==mS(e,{version:`1.2`}),gS=(e,t={})=>{let n=new sS(e);return Jy(n,{Scalar(e,t){typeof t.value==`string`&&hS(t.value)&&(t.type=fb.QUOTE_DOUBLE)}}),n.toString(t)},_S=`.yarramate/projections`,vS=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t.length===0?`view`:/^[a-z]/.test(t)?t:`view-${t}`},yS=(e,t)=>{if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;return`${e}-${n}`},bS=(e,t)=>yS(vS(e),t),xS=e=>`${_S}/${e}.yaml`,SS=e=>e.presentation?.folder??``,CS=(e,t)=>({path:e.path,projection:TS({id:e.id,title:t,description:e.description,query:e.query,presentation:e.presentation})}),wS=(e,t)=>{let n=`${e.title} copy`,r=bS(n,t);return{path:xS(r),projection:TS({id:r,title:n,description:e.description,query:e.query,presentation:e.presentation})}},TS=e=>{let{title:t,description:n,...r}=e.presentation??{};return{format:`yarramate/projection/v1`,id:e.id,version:`1.0`,query:e.query,presentation:{...r,...e.title.trim()===``?{}:{title:e.title},...e.description.trim()===``?{}:{description:e.description}}}},ES=e=>e.subjects!==void 0,DS=(e,t,n)=>{if(!ES(e.query))return OS(e,t,n);let r=e.query.subjects,i=r.includes(t);return(n===`add`?i:!i)?null:{...e,query:{...e.query,subjects:n===`add`?[...r,t]:r.filter(e=>e!==t)}}},OS=(e,t,n)=>{let r=e.query.exclude??[],i=r.includes(t);if(n===`add`?!i:i)return null;let a=n===`add`?r.filter(e=>e!==t):[...r,t],{exclude:o,...s}=e.query;return{...e,query:a.length===0?s:{...s,exclude:a}}},kS=(e,t)=>{if(!ES(e)&&!ES(t)){let n=e.exclude??[],r=t.exclude??[];return[...n.filter(e=>!r.includes(e)).map(e=>`+${e}`),...r.filter(e=>!n.includes(e)).map(e=>`-${e}`)]}return!ES(e)||!ES(t)?[]:[...t.subjects.filter(t=>!e.subjects.includes(t)).map(e=>`+${e}`),...e.subjects.filter(e=>!t.subjects.includes(e)).map(e=>`-${e}`)]},AS=(e,t)=>jS(e)===jS(t),jS=e=>Array.isArray(e)?`[${e.map(jS).join(`,`)}]`:typeof e==`object`&&e?`{${Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:1).map(([e,t])=>`${JSON.stringify(e)}:${jS(t)}`).join(`,`)}}`:JSON.stringify(e)??`null`,MS={subjects:[],documents:[],kinds:[],layers:[],statuses:[],excludeStatuses:[],states:[],owners:[],constraints:[],relationshipKinds:[],kindMatching:``,relationships:``,isolatedConcepts:``},NS=[`planned`,`current`,`retired`],PS=e=>e===null?MS:{subjects:e.subjects??[],documents:e.documents??[],kinds:e.kinds??[],layers:e.layers??[],statuses:e.statuses??[],excludeStatuses:e.excludeStatuses??[],states:e.states??[],owners:e.owners??[],constraints:e.constraints??[],relationshipKinds:e.relationshipKinds??[],kindMatching:e.kindMatching??``,relationships:e.relationships??``,isolatedConcepts:e.isolatedConcepts??``},FS=e=>({...e.subjects.length>0?{subjects:e.subjects}:{},...e.documents.length>0?{documents:e.documents}:{},...e.kinds.length>0?{kinds:e.kinds}:{},...e.layers.length>0?{layers:e.layers}:{},...e.statuses.length>0?{statuses:e.statuses}:{},...e.excludeStatuses.length>0?{excludeStatuses:e.excludeStatuses}:{},...e.states.length>0?{states:e.states}:{},...e.owners.length>0?{owners:e.owners}:{},...e.constraints.length>0?{constraints:e.constraints}:{},...e.relationshipKinds.length>0?{relationshipKinds:e.relationshipKinds}:{},...e.kindMatching===``?{}:{kindMatching:e.kindMatching},...e.relationships===``?{}:{relationships:e.relationships},...e.isolatedConcepts===``?{}:{isolatedConcepts:e.isolatedConcepts}}),IS=({id:e,label:t,values:n,onChange:r})=>{let[i,a]=(0,y.useState)(``),o=()=>{let e=i.trim();a(``),!(e===``||n.includes(e))&&r([...n,e])};return(0,$.jsxs)(`div`,{className:`filter-field`,children:[(0,$.jsx)(`label`,{htmlFor:e,children:t}),(0,$.jsxs)(`div`,{className:`tag-input`,children:[n.map(e=>(0,$.jsxs)(`span`,{className:`tag-chip`,children:[e,(0,$.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>r(n.filter(t=>t!==e)),children:`×`})]},e)),(0,$.jsx)(`input`,{id:e,type:`text`,value:i,placeholder:`Add…`,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`||e.key===`,`?(e.preventDefault(),o()):e.key===`Backspace`&&i===``&&n.length>0&&r(n.slice(0,-1))},onBlur:o})]})]})},LS=({legend:e,values:t,onChange:n})=>(0,$.jsxs)(`fieldset`,{className:`filter-field filter-checkbox-group`,children:[(0,$.jsx)(`legend`,{children:e}),NS.map(e=>(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.includes(e),onChange:r=>n(r.target.checked?[...t,e]:t.filter(t=>t!==e))}),e]},e))]}),RS=({id:e,label:t,value:n,options:r,onChange:i})=>(0,$.jsxs)(`div`,{className:`filter-field`,children:[(0,$.jsx)(`label`,{htmlFor:e,children:t}),(0,$.jsxs)(`select`,{id:e,value:n,onChange:e=>i(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`Any`}),r.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))]})]}),zS=(e,t)=>n=>e(t,n);function BS({fields:e,onChange:t}){return(0,$.jsxs)(`div`,{className:`filter-grid`,children:[(0,$.jsx)(IS,{id:`filter-subjects`,label:`Subjects`,values:e.subjects,onChange:e=>t(`subjects`,e)}),(0,$.jsx)(IS,{id:`filter-documents`,label:`Documents`,values:e.documents,onChange:e=>t(`documents`,e)}),(0,$.jsx)(IS,{id:`filter-kinds`,label:`Kinds`,values:e.kinds,onChange:e=>t(`kinds`,e)}),(0,$.jsx)(IS,{id:`filter-layers`,label:`Layers`,values:e.layers,onChange:e=>t(`layers`,e)}),(0,$.jsx)(IS,{id:`filter-states`,label:`States`,values:e.states,onChange:e=>t(`states`,e)}),(0,$.jsx)(IS,{id:`filter-owners`,label:`Owners`,values:e.owners,onChange:e=>t(`owners`,e)}),(0,$.jsx)(IS,{id:`filter-constraints`,label:`Constraints`,values:e.constraints,onChange:e=>t(`constraints`,e)}),(0,$.jsx)(IS,{id:`filter-relationship-kinds`,label:`Relationship kinds`,values:e.relationshipKinds,onChange:e=>t(`relationshipKinds`,e)}),(0,$.jsx)(LS,{legend:`Statuses`,values:e.statuses,onChange:e=>t(`statuses`,e)}),(0,$.jsx)(LS,{legend:`Exclude statuses`,values:e.excludeStatuses,onChange:e=>t(`excludeStatuses`,e)}),(0,$.jsx)(RS,{id:`filter-kind-matching`,label:`Kind matching`,value:e.kindMatching,options:[`exact`,`descendants`],onChange:e=>t(`kindMatching`,e)}),(0,$.jsx)(RS,{id:`filter-relationships`,label:`Relationships`,value:e.relationships,options:[`between`,`connected`,`none`],onChange:e=>t(`relationships`,e)}),(0,$.jsx)(RS,{id:`filter-isolated-concepts`,label:`Isolated concepts`,value:e.isolatedConcepts,options:[`include`,`exclude`],onChange:e=>t(`isolatedConcepts`,e)})]})}function VS({showLifecycle:e,showEvidence:t,showOwnership:n,showKindLabels:r,showNudges:i,onTogglePresentation:a}){return(0,$.jsxs)(`fieldset`,{className:`filter-field filter-presentation-group`,children:[(0,$.jsx)(`legend`,{children:`Presentation`}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>zS(a,`showLifecycle`)(e.currentTarget.checked)}),`Lifecycle badges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>zS(a,`showEvidence`)(e.currentTarget.checked)}),`Evidence badges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>zS(a,`showOwnership`)(e.currentTarget.checked)}),`Ownership badges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>zS(a,`showKindLabels`)(e.currentTarget.checked)}),`Kind labels`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>zS(a,`showNudges`)(e.currentTarget.checked)}),`Open-question badges`]})]})}var HS=[{id:`view-query`,label:`View query`}],US=e=>JSON.stringify(Object.entries(e??{}).sort(([e],[t])=>e<t?-1:1)),WS=(e,t)=>US(e)===US(t),GS={exclude:`Taken out of this view`,states:`States`,subjects:`Subjects`,instances:`Not inside a named instance`,documents:`Documents`,kinds:`Kinds`,layers:`Layers`,statuses:`Statuses`,excludeStatuses:`Excluded statuses`,owners:`Owners`,constraints:`Constraints`,isolatedConcepts:`Isolated concepts`,unreported:`Not reported`},KS=Object.keys(GS),qS=(e,t,n)=>{if(t===null)return[];let r=new Set(t),i=n===null?null:new Map(n.map(({id:e,facet:t})=>[e,t])),a=new Map;for(let t of e){if(r.has(t.id))continue;let e=i===null?`unreported`:i.get(t.id)??`isolatedConcepts`,n=a.get(e)??[];n.push({id:t.id,title:t.name}),a.set(e,n)}return KS.flatMap(e=>{let t=a.get(e);return t===void 0?[]:[{reason:e,label:GS[e],subjects:t}]})},JS=(e,t)=>{if(t===null)return e.length;let n=new Set(t);return e.filter(e=>n.has(e.id)).length},YS=(e,t)=>{if(e===null||t===null)return 0;let n=new Set(e);return t.filter(({id:e})=>n.has(e)).length},XS=(e,t,n)=>{let r=e.presentation??{},i=e=>r[e]!==void 0||t[e]!==n[e]?{[e]:t[e]}:{};return{...r,...i(`showLifecycle`),...i(`showEvidence`),...i(`showOwnership`),...i(`showKindLabels`)}},ZS=({view:e,query:t,badges:n,opened:r})=>TS({id:e.id,title:e.title,description:e.description,query:t,presentation:XS(e,n,r)}),QS=e=>({op:`write-view`,path:e.view.path,projection:ZS(e)}),$S=e=>{let t=ZS(e),n=TS({id:e.view.id,title:e.view.title,description:e.view.description,query:e.view.query,presentation:e.view.presentation});return US(t.query)!==US(n.query)||US(t.presentation)!==US(n.presentation)};function eC({nodes:e,activeFilter:t,view:n,open:r,tab:i,showLifecycle:a,showEvidence:o,showOwnership:s,showKindLabels:c,showNudges:l,onTogglePresentation:u,onToggleOpen:d,onSelectTab:f,onApply:p,onStage:m,readOnly:h=!1}){let g=(0,y.useRef)(null),[_,v]=(0,y.useState)(()=>PS(n?.query??t?.query??null)),[b,x]=(0,y.useState)(!1),[S]=(0,y.useState)(()=>({showLifecycle:a,showEvidence:o,showOwnership:s,showKindLabels:c})),C=e=>{g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{g.current=null,p(FS(e))},300)},w=(e,t)=>{x(!1),v(n=>{let r={...n,[e]:t};return C(r),r})},T=FS(_),E=t?.matchedIds??null,D=JS(e,E),O=qS(e,E,t?.excluded??null),k=YS(E,t?.excluded??null),A=t===null?Object.keys(T).length===0:WS(T,t.query),j=n===null?null:{view:n,query:T,badges:{showLifecycle:a,showEvidence:o,showOwnership:s,showKindLabels:c},opened:S};return(0,$.jsxs)(`section`,{className:`bottom-panel`,"aria-label":`Canvas panels`,children:[(0,$.jsxs)(`div`,{className:`bottom-panel-tabs`,role:`tablist`,"aria-label":`Canvas panels`,children:[HS.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,id:`bottom-tab-${e.id}`,className:`bottom-panel-tab`,"aria-selected":r&&i===e.id,"aria-controls":`bottom-panel-${e.id}`,onClick:()=>{if(r&&i===e.id){d();return}f(e.id)},children:e.label},e.id)),(0,$.jsxs)(`span`,{className:`bottom-panel-summary`,role:`status`,children:[D,` `,D===1?`subject`:`subjects`,O.length===0?``:` · ${O.reduce((e,t)=>e+t.subjects.length,0)} excluded`]}),(0,$.jsx)(`button`,{type:`button`,className:`bottom-panel-collapse`,"aria-expanded":r,"aria-controls":`bottom-panel-${i}`,"aria-label":r?`Collapse panel`:`Expand panel`,onClick:d,children:r?`▾`:`▴`})]}),r?(0,$.jsx)(`div`,{className:`bottom-panel-body`,id:`bottom-panel-${i}`,role:`tabpanel`,"aria-labelledby":`bottom-tab-${i}`,children:(0,$.jsxs)(`div`,{className:`query-tab`,children:[(0,$.jsxs)(`div`,{className:`query-tab-fields`,children:[(0,$.jsx)(BS,{fields:_,onChange:w}),(0,$.jsx)(VS,{showLifecycle:a,showEvidence:o,showOwnership:s,showKindLabels:c,showNudges:l,onTogglePresentation:u})]}),(0,$.jsxs)(`div`,{className:`query-tab-outcome`,children:[(0,$.jsx)(`h3`,{children:`Matches`}),(0,$.jsxs)(`p`,{className:`query-match-count`,children:[(0,$.jsx)(`strong`,{children:D}),` `,D===1?`subject`:`subjects`,` of `,e.length]}),A?null:(0,$.jsx)(`p`,{className:`query-outcome-stale`,children:`Describing the query on the canvas, not the edit in progress.`}),D===0&&E!==null?(0,$.jsx)(`p`,{className:`query-outcome-empty`,children:`This query selects nothing.`}):null,k===0?null:(0,$.jsxs)(`p`,{className:`query-outcome-note`,children:[k,` a facet dropped `,k===1?`is`:`are`,` drawn anyway: `,(0,$.jsx)(`code`,{children:`relationships: connected`}),` takes the other end of a relationship with it.`]}),(0,$.jsx)(`h3`,{children:`Excluded, and why`}),O.length===0?(0,$.jsx)(`p`,{className:`query-outcome-note`,children:`Nothing is left out of this view.`}):(0,$.jsx)(`ul`,{className:`query-exclusions`,children:O.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{className:`query-exclusion-facet`,children:e.label}),` `,(0,$.jsx)(`span`,{className:`query-exclusion-count`,children:e.subjects.length}),(0,$.jsxs)(`ul`,{children:[e.subjects.slice(0,12).map(e=>(0,$.jsx)(`li`,{title:e.id,children:e.title},e.id)),e.subjects.length>12?(0,$.jsxs)(`li`,{className:`query-exclusion-more`,children:[`and `,e.subjects.length-12,` more`]}):null]})]},e.reason))})]}),(0,$.jsxs)(`div`,{className:`query-tab-document`,children:[(0,$.jsx)(`h3`,{children:`Document`}),j===null?(0,$.jsx)(`p`,{className:`query-outcome-note`,children:h?`No view is active, so this query has no document. Pick one in the tree.`:`No view is active, so this query has no document yet. Pick one in the tree, or save this query as a new view.`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`query-document`,children:gS(ZS(j))}),h?null:(0,$.jsxs)(`div`,{className:`query-tab-actions`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:!$S(j),onClick:()=>{m(QS(j)),x(!0)},children:`Stage view change`}),(0,$.jsx)(`span`,{role:`status`,className:`query-stage-status`,children:b?`Staged. It lands when the changeset is committed.`:``})]})]})]})]})}):null]})}function tC({value:e,onChange:t}){return(0,$.jsx)(`input`,{type:`search`,name:`quick-filter`,className:`quick-filter`,value:e,onChange:e=>t(e.currentTarget.value),placeholder:`Filter by name or id…`,"aria-label":`Quick filter`})}var nC=`views`,rC=`model`,iC=e=>`view-folder:${e}`,aC=e=>`model-layer:${e}`,oC=e=>`model-folder:${e}`,sC=`unlayered`,cC=(e,t)=>t===``||e.toLowerCase().includes(t),lC=(e,t)=>cC(e,tv(t)),uC=e=>e.presentation?.folder??``,dC=({views:e,stagedOperations:t,activeViewId:n,activeSubjects:r,filterText:i})=>{let a=tv(i),o=a!==``,s=r===null?null:rv(r,i),c=new Map,l=(e,t)=>{let n=c.get(e);n===void 0?c.set(e,[t]):n.push(t)},u=new Map;for(let e of t)u.set(e.path,e);for(let t of e){let e=u.get(t.path);u.delete(t.path);let r=e?.op===`write-view`?e.projection:null,i=e===void 0?null:r===null?`delete`:`overwrite`,c=r===null?t.title:r.presentation?.title??r.id,d=r===null?uC(t):r.presentation?.folder??``,f=t.id===n;!cC(c,a)&&!cC(d,a)||l(d,{id:t.id,title:c,path:t.path,subjectCount:f&&s!==null?s:o?null:t.subjectCount,active:f,staged:i})}for(let e of u.values()){if(e.op!==`write-view`)continue;let{projection:t}=e,n=t.presentation?.title??t.id,r=t.presentation?.folder??``;!cC(n,a)&&!cC(r,a)||l(r,{id:t.id,title:n,path:e.path,subjectCount:null,active:!1,staged:`new`})}let d=(e,t)=>e.title.localeCompare(t.title),f=[...c.get(``)??[]].sort(d),p=[...c.entries()].filter(([e])=>e!==``).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:iC(e),name:e,views:[...t].sort(d)}));return{folders:p,loose:f,matched:f.length+p.reduce((e,t)=>e+t.views.length,0)}},fC=({nodes:e,inViewIds:t,filterText:n,folded:r,insideCounts:i})=>{let a=tv(n),o=new Map,s=new Map;for(let n of e){let e=n.layer,c=n.folder,l=c??e??`unlayered`;if(!nv(a,n.id,n.name,n.kindLabel)&&!cC(l,a))continue;let u={id:n.id,name:n.name,kindLabel:n.kindLabel,layer:e,folder:c,inView:t===null||t.has(n.id),foldedCount:r?.has(n.id)===!0?i?.get(n.id)??0:null},d=c===null?s:o,f=d.get(l);f===void 0?d.set(l,[u]):f.push(u)}let c=(e,t)=>e.name.localeCompare(t.name),l=[...o.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:oC(e),label:e,grouping:`folder`,subjects:[...t].sort(c)})),u=[...D_,sC];return[...l,...u.flatMap(e=>{let t=s.get(e);return t===void 0||t.length===0?[]:[{key:aC(e),label:e,grouping:`layer`,subjects:[...t].sort(c)}]})]},pC=`All subjects`,mC=`M2 3.5 5 6.5 8 3.5`,hC=`M3.5 2 6.5 5 3.5 8`;function gC({open:e}){return(0,$.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`none`,"aria-hidden":!0,children:(0,$.jsx)(`path`,{d:e?mC:hC,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function _C(){return(0,$.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":!0,children:[(0,$.jsx)(`rect`,{x:`1.5`,y:`2.5`,width:`9`,height:`7`,stroke:`currentColor`,strokeWidth:`1.2`}),(0,$.jsx)(`path`,{d:`M1.5 5h9`,stroke:`currentColor`,strokeWidth:`1.2`})]})}function vC({layer:e}){let t=e===null?null:M_[e];return(0,$.jsx)(`span`,{className:`tree-swatch`,style:t==null?void 0:{background:t.fill,borderColor:t.border},"aria-hidden":!0})}var yC=(e,t)=>n=>{n.preventDefault(),t(e,{x:n.clientX,y:n.clientY})};function bC({row:e,depth:t,onSelect:n,onMenu:r}){let i=e.staged!==`new`;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`tree-row tree-view tree-depth-${t}${e.active?` tree-row-active`:``}${e.staged===null?``:` tree-row-staged`}${e.staged===`delete`?` tree-row-staged-delete`:``}`,title:e.title,"aria-current":e.active?`true`:void 0,onClick:i?()=>n(e.id):void 0,onContextMenu:i?yC({kind:`view`,id:e.id},r):void 0,children:[(0,$.jsx)(_C,{}),(0,$.jsx)(`span`,{className:`tree-label`,children:e.title}),e.staged===null?null:(0,$.jsx)(`span`,{className:`tree-staged`,children:e.staged===`delete`?`staged delete`:`staged`}),e.subjectCount===null?null:(0,$.jsx)(`span`,{className:`tree-count`,children:e.subjectCount})]})})}function xC({label:e,open:t,count:n,depth:r,onToggle:i}){return(0,$.jsxs)(`button`,{type:`button`,className:`tree-row tree-branch tree-depth-${r}`,"aria-expanded":t,onClick:i,children:[(0,$.jsx)(gC,{open:t}),(0,$.jsx)(`span`,{className:`tree-label`,children:e}),n===void 0?null:(0,$.jsx)(`span`,{className:`tree-count`,children:n})]})}function SC({views:e,stagedViewOperations:t,activeViewId:n,nodes:r,inViewIds:i,folded:a,insideCounts:o,filterText:s,collapsed:c,onFilterChange:l,onToggle:u,onSelectView:d,onClearView:f,onNewView:p,onSelectSubject:m,onRowMenu:h,readOnly:g=!1,onHide:_}){let v=dC({views:e,stagedOperations:t,activeViewId:n,activeSubjects:i===null?null:r.filter(e=>i.has(e.id)),filterText:s}),y=fC({nodes:r,inViewIds:i,filterText:s,folded:a,insideCounts:o}),b=!c.has(nC),x=!c.has(rC),S=s.trim()!==``,C=n===``&&i===null,w=lC(pC,s);return(0,$.jsxs)(`aside`,{className:`view-tree`,"aria-label":`Views and model`,children:[(0,$.jsxs)(`div`,{className:`view-tree-head`,children:[(0,$.jsx)(`input`,{type:`search`,name:`view-tree-filter`,className:`view-tree-filter`,placeholder:`Filter tree`,"aria-label":`Filter views and subjects`,value:s,onChange:e=>l(e.currentTarget.value)}),_===void 0?null:(0,$.jsx)(`button`,{type:`button`,className:`rail-hide`,title:`Hide the view tree`,"aria-label":`Hide the view tree`,onClick:_,children:`«`}),g?null:(0,$.jsx)(`button`,{type:`button`,className:`view-tree-new`,title:`New view`,"aria-label":`New view`,onClick:p,children:(0,$.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":!0,children:(0,$.jsx)(`path`,{d:`M7 3v8M3 7h8`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinecap:`round`})})})]}),(0,$.jsxs)(`div`,{className:`view-tree-body`,children:[(0,$.jsx)(xC,{label:`Views`,open:b,depth:0,onToggle:()=>u(nC)}),b?(0,$.jsxs)(`ul`,{className:`tree-list`,children:[w?(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`tree-row tree-view tree-depth-1${C?` tree-row-active`:``}`,"aria-current":C?`true`:void 0,onClick:f,onContextMenu:yC({kind:`view`,id:``},h),children:[(0,$.jsx)(_C,{}),(0,$.jsx)(`span`,{className:`tree-label`,children:pC}),(0,$.jsx)(`span`,{className:`tree-count`,children:rv(r,s)})]})}):null,v.loose.map(e=>(0,$.jsx)(bC,{row:e,depth:1,onSelect:d,onMenu:h},e.id)),v.folders.map(e=>{let t=S||!c.has(e.key);return(0,$.jsxs)(`li`,{children:[(0,$.jsx)(xC,{label:e.name,open:t,count:t?void 0:e.views.length,depth:1,onToggle:()=>u(e.key)}),t?(0,$.jsx)(`ul`,{className:`tree-list`,children:e.views.map(e=>(0,$.jsx)(bC,{row:e,depth:2,onSelect:d,onMenu:h},e.id))}):null]},e.key)}),!S||v.matched!==0||w?null:(0,$.jsx)(`li`,{className:`tree-empty`,children:`No view matches that.`})]}):null,(0,$.jsx)(xC,{label:`Model`,open:x,depth:0,onToggle:()=>u(rC)}),x?(0,$.jsxs)(`ul`,{className:`tree-list`,children:[y.map(e=>{let t=S||!c.has(e.key);return(0,$.jsxs)(`li`,{children:[(0,$.jsx)(xC,{label:e.label,open:t,count:t?void 0:e.subjects.length,depth:1,onToggle:()=>u(e.key)}),t?(0,$.jsx)(`ul`,{className:`tree-list`,children:e.subjects.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`tree-row tree-subject tree-depth-2${e.inView?``:` tree-row-quiet`}`,title:e.foldedCount===null?`${e.name} — ${e.kindLabel}`:`${e.name} — ${e.kindLabel}, folded over ${e.foldedCount} ${e.foldedCount===1?`subject`:`subjects`}`,onClick:()=>m(e.id),onContextMenu:yC({kind:`subject`,id:e.id},h),children:[(0,$.jsx)(vC,{layer:e.layer}),e.foldedCount===null?null:(0,$.jsx)(`span`,{className:`tree-fold`,"aria-hidden":`true`,children:`▸`}),(0,$.jsx)(`span`,{className:`tree-label`,children:e.name}),e.foldedCount===null||e.foldedCount===0?null:(0,$.jsx)(`span`,{className:`tree-count`,children:e.foldedCount}),e.inView?null:(0,$.jsx)(`span`,{className:`tree-count`,children:`not in view`})]})},e.id))}):null]},e.key)}),y.length!==0||!S?null:(0,$.jsx)(`li`,{className:`tree-empty`,children:`No subject matches that.`})]}):null]})]})}var CC=({id:e,taken:t,path:n,declared:r,folder:i,title:a,description:o,query:s,layout:c,direction:l,showLifecycle:u,showEvidence:d,showOwnership:f,showKindLabels:p})=>{let m=e??bS(a,t);return{op:`write-view`,path:n??xS(m),projection:TS({id:m,title:a,description:o,query:s??{},presentation:{...r??{},layout:c,direction:l,...i===void 0||i===``?{}:{folder:i},showLifecycle:u,showEvidence:d,showOwnership:f,showKindLabels:p}})}};function wC({activeView:e,presetFolder:t,onSubmit:n,onCancel:r}){let[i,a]=(0,y.useState)(e?.title??``),[o,s]=(0,y.useState)(e?.description??``),c=i.trim()===``||o.trim()===``,l=t!==void 0;return(0,$.jsx)(`div`,{className:`save-view-panel`,children:(0,$.jsx)(`div`,{id:`save-view-panel-body`,className:`save-view-panel-body`,children:(0,$.jsxs)(`form`,{className:`save-view-form`,onSubmit:t=>{t.preventDefault(),!c&&n(l?void 0:e?.id,i,o)},children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`save-view-title`,children:`Title`}),(0,$.jsx)(`input`,{id:`save-view-title`,type:`text`,value:i,onChange:e=>a(e.currentTarget.value),required:!0})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`save-view-description`,children:`Description`}),(0,$.jsx)(`textarea`,{id:`save-view-description`,value:o,onChange:e=>s(e.currentTarget.value),required:!0})]}),(0,$.jsxs)(`div`,{className:`save-view-actions`,children:[(0,$.jsx)(`button`,{type:`submit`,disabled:e===null||c||l,title:l?`Save overwrites the active view and keeps its own folder — Save As New puts the first view in "${t}".`:void 0,children:`Save`}),(0,$.jsx)(`button`,{type:`button`,disabled:c,onClick:()=>{c||n(void 0,i,o)},children:`Save As New`}),(0,$.jsx)(`button`,{type:`button`,onClick:r,children:`Cancel`})]})]})})})}function TC({views:e,activeViewId:t,query:n,layout:r,direction:i,showLifecycle:a,showEvidence:o,showOwnership:s,showKindLabels:c,open:l,folder:u,onClose:d,onStage:f}){let p=e.find(e=>e.id===t)??null,m=(t,l,d)=>{f(CC({id:t,taken:new Set(e.map(e=>e.id)),path:t===void 0?void 0:p?.path,declared:t===void 0?void 0:p?.presentation,folder:t===void 0?u:p?.presentation?.folder,title:l,description:d,query:n,layout:r,direction:i,showLifecycle:a,showEvidence:o,showOwnership:s,showKindLabels:c}))};return l?(0,$.jsx)(`div`,{className:`save-view-control`,children:(0,$.jsx)(wC,{activeView:p,presetFolder:u,onSubmit:(e,t,n)=>{m(e,t,n),d()},onCancel:d},t)}):null}function EC(e){if((e.relationships===`connected`||e.relationships===`between`)&&e.subjects!==void 0&&e.subjects.length>0){let t=`${e.relationships===`connected`?`connected to`:`between`} ${e.subjects.join(`, `)}`;return e.exclude===void 0||e.exclude.length===0?t:`${t} · except: ${e.exclude.join(`, `)}`}let t=[],n=(e,n)=>{n!==void 0&&n.length>0&&t.push(`${e}: ${n.join(`, `)}`)};return n(`subjects`,e.subjects),n(`documents`,e.documents),n(`layers`,e.layers),n(e.kindMatching===`descendants`?`kinds (and descendants)`:`kinds`,e.kinds),n(`statuses`,e.statuses),n(`excluding statuses`,e.excludeStatuses),n(`states`,e.states),n(`owners`,e.owners),n(`constraints`,e.constraints),n(`relationship kinds`,e.relationshipKinds),n(`except`,e.exclude),e.isolatedConcepts===`exclude`&&t.push(`connected concepts only`),e.isolatedConcepts===`include`&&t.push(`including isolated concepts`),t.length>0?t.join(` · `):`all`}var DC=(e,t)=>{if(!e.nodes.some(({id:e})=>e===t))return[];let n=new Set([t]);for(let r of e.edges)r.from===t?n.add(r.to):r.to===t&&n.add(r.from);return[...n]},OC=(e,t)=>{let n=e.edges.find(({id:e})=>e===t);return n===void 0?[]:[n.from,n.to]},kC=(e,t)=>{let n=new Set(t.nodes.map(e=>e.id));for(let e of t.edges)n.add(e.id);let r=0;for(let t of e)(t.subjects??[]).some(e=>n.has(e))&&(r+=1);return{total:e.length,onCanvas:r,elsewhere:e.length-r}},AC=e=>{let t=new Set;for(let n of e)for(let e of n.subjects??[])t.add(e);return t},jC=(e,t,n)=>{let r=n=>n.document===e&&n.localId===t,i=n?.nodes.find(r);if(i!==void 0)return i.name;let a=n?.edges.find(r);return a?.name!==void 0&&a.name!==null?a.name:t},MC=(e,t,n)=>[...e.operations.map(e=>PC(e,t)),...e.viewOperations.map(e=>NC(e,n))],NC=(e,t)=>{if(e.op===`delete-view`)return{verb:e.op,subjectName:e.path,fields:[],removedFields:[],scope:`view`};let n=t.find(t=>t.path===e.path),r=n===void 0?[]:kS(n.query,e.projection.query);return{verb:e.op,subjectName:e.projection.presentation?.title??e.projection.id,fields:r.length>0?r:[e.path],removedFields:[],scope:`view`}},PC=(e,t)=>{let n=e.op===`update-concept`||e.op===`update-relationship`||e.op===`update-observation`?e.remove??[]:[];if(`observation`in e){let{subject:r,claim:i,key:a,...o}=e.observation,s=jC(e.document,r??i,t);return{verb:e.op,subjectName:a===void 0?s:`${s} (${a})`,fields:Object.keys(o),removedFields:n,scope:`model`}}let r=`concept`in e?e.concept:e.relationship;return{verb:e.op,subjectName:jC(e.document,r.id,t),fields:Object.keys(r).filter(e=>e!==`id`),removedFields:n,scope:`model`}},FC=e=>{let t=[...e.fields,...e.removedFields.map(e=>`remove: ${e}`)];return t.length===0?`${e.verb} · ${e.subjectName}`:`${e.verb} · ${e.subjectName} · ${t.join(`, `)}`},IC=/^\/operations\/(\d+)(\/|$)/,LC=e=>{let t=new Map,n=[];for(let r of e){let e=IC.exec(r.pointer);if(e===null){n.push(r);continue}let i=Number(e[1]),a=t.get(i);a===void 0?t.set(i,[r]):a.push(r)}return{byRow:t,batch:n}},RC=(e,t,n)=>{let r=t[e];if(r===void 0)return null;let i=n?.sourceDigests[e]??n?.projectionDigests[e];return i===void 0||i===r?null:e},zC=({diagnostic:e})=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{className:`code`,children:e.code}),` `,e.message,e.path===``?null:(0,$.jsxs)(`span`,{className:`where`,children:[e.path,`:`,e.line,`:`,e.column]})]}),BC=({index:e,row:t,diagnostics:n,conflict:r,onDiscard:i})=>(0,$.jsxs)(`li`,{className:r===null?`changeset-row`:`changeset-row conflicted`,children:[(0,$.jsxs)(`div`,{className:`changeset-row-line`,children:[(0,$.jsx)(`span`,{className:`changeset-row-label`,children:FC(t)}),(0,$.jsx)(`span`,{className:`changeset-row-scope changeset-scope-${t.scope}`,children:t.scope}),(0,$.jsx)(`button`,{type:`button`,className:`changeset-row-discard`,onClick:i,children:`Discard`})]}),r===null?null:(0,$.jsxs)(`p`,{className:`changeset-row-conflict`,role:`status`,children:[r,` changed after this edit was staged`]}),n.length===0?null:(0,$.jsx)(`ul`,{className:`changeset-row-diagnostics`,children:n.map(e=>(0,$.jsx)(zC,{diagnostic:e},`${e.code}-${e.pointer}`))})]}),VC=({state:e,onDiscardChange:t,onClearChangeset:n,onUndoChangeset:r,onRedoChangeset:i,onCommitChangeset:a})=>{let o=e.model?.graph??null,s=MC(e.pendingChangeset,o,e.views);if(s.length===0&&e.commitNotice===null&&e.commitDiagnostics===null&&e.undoStack.length===0&&e.redoStack.length===0)return null;let{byRow:c,batch:l}=LC(e.commitDiagnostics??[]),u=e.commitStatus===`committing`;return(0,$.jsxs)(`section`,{className:`changeset-tray`,"aria-labelledby":`changeset-heading`,children:[(0,$.jsxs)(`div`,{className:`changeset-heading-row`,children:[(0,$.jsx)(`h2`,{id:`changeset-heading`,children:`Pending changes`}),(0,$.jsxs)(`div`,{className:`changeset-history-controls`,children:[(0,$.jsx)(`button`,{type:`button`,className:`changeset-undo`,disabled:e.undoStack.length===0,onClick:r,children:`Undo`}),(0,$.jsx)(`button`,{type:`button`,className:`changeset-redo`,disabled:e.redoStack.length===0,onClick:i,children:`Redo`}),s.length===0?null:(0,$.jsx)(`button`,{type:`button`,className:`changeset-discard-all`,onClick:n,children:`Discard all`})]})]}),e.commitDiagnostics===null||e.commitDiagnostics.length===0||o===null?null:(0,$.jsx)(`p`,{className:`changeset-fault-summary`,role:`status`,children:(()=>{let t=kC(e.commitDiagnostics,o);return`${t.total} problem${t.total===1?``:`s`}: ${t.onCanvas} marked on the diagram, ${t.elsewhere} not on it.`})()}),l.length===0?null:(0,$.jsx)(`ul`,{className:`changeset-batch-diagnostics`,role:`alert`,children:l.map(e=>(0,$.jsx)(zC,{diagnostic:e},`${e.code}-${e.pointer}`))}),s.length===0?null:(0,$.jsx)(`ol`,{className:`changeset-rows`,children:s.map((n,r)=>(0,$.jsx)(BC,{index:r,row:n,diagnostics:c.get(r)??[],conflict:RC(r<e.pendingChangeset.operations.length?e.pendingChangeset.operations[r].document:e.pendingChangeset.viewOperations[r-e.pendingChangeset.operations.length].path,e.pendingChangeset.sourceDigests,e.model),onDiscard:()=>t(r)},r))}),(0,$.jsx)(`div`,{className:`changeset-actions`,children:(0,$.jsx)(`button`,{type:`button`,className:`changeset-commit`,disabled:s.length===0||u,"aria-busy":u,onClick:a,children:u?`Committing…`:`Commit changes`})}),e.commitNotice===null?null:(0,$.jsxs)(`div`,{className:`changeset-notice`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[`Committed · `,e.commitNotice.length,` `,e.commitNotice.length===1?`file`:`files`]}),(0,$.jsx)(`ul`,{children:e.commitNotice.map(e=>(0,$.jsx)(`li`,{children:e},e))})]})]})},HC=e=>e.slice(e.lastIndexOf(`#`)+1),UC=e=>e.name===void 0||e.name===e.label?e.label:`${e.name} (${e.label})`,WC={a:`access`,c:`composition`,f:`flow`,g:`aggregation`,i:`assignment`,n:`influence`,o:`association`,r:`realization`,s:`specialization`,t:`triggering`,v:`serving`},GC=`applicationCollaboration.applicationComponent.applicationEvent.applicationFunction.applicationInteraction.applicationInterface.applicationProcess.applicationService.artifact.assessment.businessActor.businessCollaboration.businessEvent.businessFunction.businessInteraction.businessInterface.businessObject.businessProcess.businessRole.businessService.capability.communicationNetwork.constraint.contract.courseOfAction.dataObject.deliverable.device.distributionNetwork.driver.equipment.facility.gap.goal.grouping.implementationEvent.andJunction.orJunction.location.material.meaning.node.outcome.path.plateau.principle.product.representation.requirement.resource.stakeholder.systemSoftware.technologyCollaboration.technologyEvent.technologyFunction.technologyInteraction.technologyInterface.technologyProcess.technologyService.value.valueStream.workPackage`.split(`.`),KC={applicationCollaboration:`cfgostv fgortv fiortv fiortv fiortv cfgortv fiortv fiortv ao no fotv fotv fortv fortv fortv fortv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,applicationComponent:`fotv cfgorstv fiortv fiortv fiortv cfgortv fiortv fiortv ao no fotv fotv fortv fortv fortv fortv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,applicationEvent:`fotv fotv cfgostv fotv fotv fotv fotv fotv ao no fotv fotv fortv fotv fotv fotv ao fotv fotv fotv o fotv nor ao o ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no o o`,applicationFunction:`fotv fotv fotv cfgostv cfgotv fotv cfgotv fortv ao no fotv fotv fotv fortv fortv fotv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,applicationInteraction:`fotv fotv fotv cfgotv cfgostv fotv cfgotv fortv ao no fotv fotv fotv fortv fortv fotv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,applicationInterface:`fotv fotv fotv fotv fotv cfgostv fotv fiotv ao no fotv fotv fotv fotv fotv fortv ao fotv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,applicationProcess:`fotv fotv fotv cfgotv cfgotv fotv cfgostv fortv ao no fotv fotv fotv fortv fortv fotv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,applicationService:`fotv fotv fotv fotv fotv fotv fotv cfgostv ao no fotv fotv fotv fotv fotv fotv ao fotv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,artifact:`or or or or or or or or cgors no o o or or or or or or o or or o nor or or or o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o o nor or no or o or or or or or or no or o`,assessment:`o o o o o o o o o cgnos o o o o o o o o o o o o no o o o o o o no o o o no cgnos o acfginorstv acfginorstv o o no o no o o no o o no o no o o o o o o o o no o o`,businessActor:`fotv fotv fotv fotv fotv fotv fotv fotv ao no cfgostv fotv fiotv fiotv fiotv cfgiotv ao fiotv fiotv fiortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv io acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or ino fotv fotv fotv fotv fotv fotv fotv fotv no or io`,businessCollaboration:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fgotv cfgostv fiotv fiotv fiotv cfgiotv ao fiotv fgiotv fiortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv io acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or ino fotv fotv fotv fotv fotv fotv fotv fotv no or io`,businessEvent:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv cfgostv fotv fotv fotv ao fotv fotv fotv o fotv nor ao o ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no o o`,businessFunction:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv fotv cfgostv cfgotv fotv ao cfgotv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,businessInteraction:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv fotv cfgotv cfgostv fotv ao cfgotv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,businessInterface:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv fotv fotv fotv cfgostv ao fotv fotv fiotv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,businessObject:`o o o o o o o o o no o o o o o o cgos o o o or o nor cgos or o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o o nor or no o o o o o o o o no or o`,businessProcess:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv fotv cfgotv cfgotv fotv ao cfgostv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,businessRole:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv fiotv fiotv fiotv cfgotv ao fiotv cfgostv fiortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv io acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or ino fotv fotv fotv fotv fotv fotv fotv fotv no or io`,businessService:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv fotv fotv fotv fotv ao fotv fotv cfgostv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,capability:`o o o o o o o o o no o o o o o o o o o o cfgostv o nor o fortv o o o o no o o o nor cfgnorstv o acfginorstv acfginorstv o o no o nor o o nor o o nor fotv no o o o o o o o o no fotv o`,communicationNetwork:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fortv fortv fortv fortv fortv fortv ao fortv fortv fortv or cfgostv nor ao or ao o fgortv fotv no fortv fortv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fortv nor fortv o nor fotv ao nor or nor fgiortv fortv fiortv fiortv fiortv fgiortv fiortv fiortv no or o`,constraint:`o o o o o o o o o no o o o o o o o o o o o o cgnos o o o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o o cgnos o no o o o o o o o o no o o`,contract:`o o o o o o o o o no o o o o o o cgos o o o or o nor cgos or o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o o nor or no o o o o o o o o no or o`,courseOfAction:`o o o o o o o o o no o o o o o o o o o o fotv o nor o cfgostv o o o o no o o o nor cfgnorstv o acfginorstv acfginorstv o o no o nor o o nor o o nor fotv no o o o o o o o o no fotv o`,dataObject:`o o o o o o o o o no o o o o o o or o o o or o nor or or cgos o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o o nor or no o o o o o o o o no or o`,deliverable:`or or or or or or or or or no or or or or or or or or or or or or nor or or or cgos or or no or or o nor cgnors o acfginorstv acfginorstv or or no or nor or or nor or or nor or nor or or or or or or or or no or o`,device:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fotv fotv fortv fortv fortv fortv ao fortv fotv fortv or fotv nor ao or ao o cfgostv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no cfgiortv fotv fiortv fiortv fiortv cfgiortv fiortv fiortv no or o`,distributionNetwork:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fiortv fiortv fiortv fiortv fiortv fiortv ao fiortv fiortv fiortv or fotv nor ao or ao o fgiortv cfgostv no fgiortv fgiortv o nor acfginorstv io acfginorstv acfginorstv fotv aio no fgiortv nor fortv o nor fotv ao nor or inor fgiortv fortv fiortv fiortv fiortv fgiortv fiortv fiortv no or io`,driver:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o cgnos o o o no cgnos o acfginorstv acfginorstv o o no o no o o no o o no o no o o o o o o o o no o o`,equipment:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fotv fotv fortv fortv fortv fortv ao fortv fotv fortv or fotv nor ao or ao o cfgortv fotv no cfgorstv fotv o nor acfginorstv o acfginorstv acfginorstv fotv aio no fotv nor fotv o nor fotv ao nor or no cfgiortv fotv fiortv fiortv fiortv cfgiortv fiortv fiortv no or o`,facility:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fiotv fiotv fiortv fiortv fiortv fiortv ao fiortv fiotv fiortv or fotv nor ao or ao o cfgiortv fotv no cfgiortv cfgiostv o nor acfginorstv io acfginorstv acfginorstv fotv aio no cfgiotv nor fotv o nor fotv ao nor or ino cfgiortv fotv fiortv fiortv fiortv cfgiortv fiortv fiortv no or io`,gap:`o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o cgos o cgos o acfginorstv acfginorstv o o o o o o o o o o o o o o o o o o o o o o o o`,goal:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o no o o o cgnos cgnos o acfginorstv acfginorstv o o no o no o o no o o no o no o o o o o o o o no o o`,grouping:`cfgorstv cfgorstv cfgiorstv cfgiorstv cfgiorstv cfgorstv cfgiorstv cfgiorstv acgiors cgnos cfgiorstv cfgiorstv cfgiorstv cfgiorstv cfgiorstv cfgiorstv acgors cfgiorstv cfgiorstv cfgiorstv cfgiorstv cfgorstv cgnors acgors cfgorstv acgors acgors cfgiorstv cfgorstv cgnos cfgiorstv cfgiorstv cgos cgnors acfginorstv cfgiost acfginorstv acfginorstv cfgorstv acgiors cgnos cfgiorstv cgnors cfgorstv cfgorst cgnors cfgorstv acgors cgnors cfgorstv cginors cfgiorstv cfgorstv cfgiorstv cfgiorstv cfgiorstv cfgiorstv cfgiorstv cfgiorstv cgnos cfgiorstv cfgiost`,implementationEvent:`o o o o o o o o o no o o o o o o o o o o o o no o o o ao o o no o o o no acfgnost cfgost acfginorstv acfginorstv o o no o no o fot no o o no o no o o o o o o o o no o fot`,andJunction:`fortv fortv fiortv fiortv fiortv fortv fiortv fiortv aior no fiortv fiortv fiortv fiortv fiortv fiortv aor fiortv fiortv fiortv fiortv fortv nor aor fortv aor aor fiortv fortv no fiortv fiortv o nor afinortv fiot acfginorstv acfginorstv fortv aior no fiortv nor fortv fort nor fortv aor nor fortv inor fiortv fortv fiortv fiortv fiortv fiortv fiortv fiortv no fiortv fiot`,orJunction:`fortv fortv fiortv fiortv fiortv fortv fiortv fiortv aior no fiortv fiortv fiortv fiortv fiortv fiortv aor fiortv fiortv fiortv fiortv fortv nor aor fortv aor aor fiortv fortv no fiortv fiortv o nor afinortv fiot acfginorstv acfginorstv fortv aior no fiortv nor fortv fort nor fortv aor nor fortv inor fiortv fortv fiortv fiortv fiortv fiortv fiortv fiortv no fiortv fiot`,location:`cfgortv cfgortv cfgiortv cfgiortv cfgiortv cfgortv cfgiortv cfgiortv acgio cgno cfgiortv cfgiortv cfgiortv cfgiortv cfgiortv cfgiortv acgo cfgiortv cfgiortv cfgiortv cgor cfgotv cgnor acgo cgor acgo cgo cfgiortv cfgotv cgno cfgiortv cfgiortv cgo cgnor acfginorstv cgio acfginorstv acfginorstv cfgostv acgio cgno cfgiortv cgnor cfgortv cgo cgnor cfgotv acgo cgnor cgor cginor cfgiortv cfgortv cfgiortv cfgiortv cfgiortv cfgiortv cfgiortv cfgiortv cgno cgor cgio`,material:`or or or or or or or or or no o o or or or or or or o or or o nor or or or o or o no or o o nor cgnors o acfginorstv acfginorstv o cgors no o nor o o nor o o nor or no or o or or or or or or no or o`,meaning:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o no o o o no cgnos o acfginorstv acfginorstv o o cgnos o no o o no o o no o no o o o o o o o o no o o`,node:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fiotv fiotv fiortv fiortv fiortv fiortv ao fiortv fiotv fiortv or fotv nor ao or ao o cfgiortv fotv no cfgiortv cfgiotv o nor acfginorstv io acfginorstv acfginorstv fotv aio no cfgiostv nor fotv o nor fotv ao nor or ino cfgiortv fotv fiortv fiortv fiortv cfgiortv fiortv fiortv no or io`,outcome:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o cgnos o o no o o no o no o o o o o o o o no o o`,path:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fiotv fiotv fiortv fiortv fiortv fiortv ao fiortv fiotv fiortv or fotv nor ao or ao o fgiortv fotv no fgiortv fgiotv o nor acfginorstv io acfginorstv acfginorstv fotv aio no fgiotv nor cfgostv o nor fotv ao nor or ino fgiortv fgotv fiortv fiortv fiortv fgiortv fiortv fiortv no or io`,plateau:`cgor cgor cgor cgor cgor cgor cgor cgor cgor no cgor cgor cgor cgor cgor cgor cgor cgor cgor cgor cgor cgor cgnor cgor cgor cgor ao cgor cgor no cgor cgor o cgnor acfginorst fot acfginorstv acfginorstv cgor cgor no cgor cgnor cgor cfgost nor cgor cgor cgnor cgor inor cgor cgor cgor cgor cgor cgor cgor cgor no cgor fot`,principle:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o cgnos o o no o no o o o o o o o o no o o`,product:`fortv fortv fortv fortv fortv fortv fortv cfgortv acgo no fotv fotv fortv fortv fortv fortv acgo fortv fotv cfgortv or fotv nor acgo or acgo o fortv fotv no fortv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv acgo no fotv nor fotv o nor cfgostv acgo nor or no fortv fotv fortv fortv fortv fortv fortv cfgortv no or o`,representation:`o o o o o o o o o no o o o o o o or o o o or o nor or or o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o cgos nor or no o o o o o o o o no or o`,requirement:`o o o o o o o o o no o o o o o o o o o o o o cgnos o o o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o o cgnos o no o o o o o o o o no o o`,resource:`o o o o o o o o o no o o o o o o o o o o fiotv o nor o fortv o o o o no o o o nor cfginorstv o acfginorstv acfginorstv o o no o nor o o nor o o nor cfgostv no o o o o o o o o no fiotv o`,stakeholder:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o no o o o no cgnos o acfginorstv acfginorstv o o no o no o o no o o no o cgnos o o o o o o o o no o o`,systemSoftware:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fotv fotv fortv fortv fortv fortv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no cfgiorstv fotv fiortv fiortv fiortv cfgiortv fiortv fiortv no or o`,technologyCollaboration:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fiotv fiotv fiortv fiortv fiortv fiortv ao fiortv fiotv fiortv or fotv nor ao or ao o fgiortv fotv no fgiortv fgiotv o nor acfginorstv io acfginorstv acfginorstv fotv aio no fgiotv nor fotv o nor fotv ao nor or ino fgiortv cfgostv fiortv fiortv fiortv cfgiortv fiortv fiortv no or io`,technologyEvent:`fotv fotv fortv fotv fotv fotv fotv fotv ao no fotv fotv fortv fotv fotv fotv ao fotv fotv fotv o fotv nor ao o ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv cfgostv fotv fotv fotv fotv fotv no o o`,technologyFunction:`fotv fotv fotv fortv fortv fotv fortv fortv ao no fotv fotv fotv fortv fortv fotv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv cfgostv cfgotv fotv cfgotv fortv no or o`,technologyInteraction:`fotv fotv fotv fortv fortv fotv fortv fortv ao no fotv fotv fotv fortv fortv fotv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv cfgotv cfgostv fotv cfgotv fortv no or o`,technologyInterface:`fotv fotv fotv fotv fotv fortv fotv fortv ao no fotv fotv fotv fotv fotv fortv ao fotv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no fotv fotv fotv fotv fotv cfgostv fotv fiotv no or o`,technologyProcess:`fotv fotv fotv fortv fortv fotv fortv fortv ao no fotv fotv fotv fortv fortv fotv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv cfgotv cfgotv fotv cfgostv fortv no or o`,technologyService:`fotv fotv fotv fotv fotv fotv fotv fortv ao no fotv fotv fotv fotv fotv fotv ao fotv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv cfgostv no or o`,value:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o no o o o no cgnos o acfginorstv acfginorstv o o no o no o o no o o no o no o o o o o o o o cgnos o o`,valueStream:`o o o o o o o o o no o o o o o o o o o o fotv o nor o fortv o o o o no o o o nor cfgnorstv o acfginorstv acfginorstv o o no o nor o o nor o o nor fotv no o o o o o o o o no cfgostv o`,workPackage:`or or or or or or or or or no or or or or or or or or or or or or nor or or or aor or or no or or o nor acfgnorst fot acfginorstv acfginorstv or or no or nor or fort nor or or nor or nor or or or or or or or or no or cfgost`},qC=new Map(GC.map((e,t)=>[e,t])),JC=new Map(Object.entries(WC)),YC=new Map;for(let e of GC){let t=KC[e].split(` `);for(let[n,r]of GC.entries()){let i=t[n]??`-`,a=new Set;for(let e of i){let t=JC.get(e);t!==void 0&&a.add(t)}YC.set(`${e}>${r}`,a)}}var XC=new Set,ZC=e=>qC.has(e),QC=(e,t)=>YC.get(`${e}>${t}`)??XC;new Map(k_.map(e=>[e.id,e.aspect])),new Set(GC),new Set(A_);var $C=A_,ew=(e,t,n)=>{let r=e.nodes.find(e=>e.id===t),i=e.nodes.find(e=>e.id===n);if(r===void 0||i===void 0||!ZC(r.coreKindLabel)||!ZC(i.coreKindLabel))return[];let a=[...QC(r.coreKindLabel,i.coreKindLabel)].sort();if(r.portKinds.length===0||i.portKinds.length===0)return a;let o=new Set(i.portKinds),s=a.filter(e=>r.portKinds.includes(e)&&o.has(e));return s.length===0?a:s},tw=(e,t,n,r,i=[])=>{let a=new Set([...e.nodes.map(e=>e.id),...e.edges.map(e=>e.id),...i]),o=`${t}-${n}-${r}`;if(!a.has(o))return o;for(let e=2;;e+=1){let t=`${o}-${e}`;if(!a.has(t))return t}},nw=(e,t,n,r,i=[])=>{if(!ew(e,t,r).includes(n))return null;let a=e.nodes.find(e=>e.id===t);return a===void 0?null:{op:`add-relationship`,document:a.document,relationship:{id:tw(e,t,n,r,i),kind:n,from:t,to:r}}},rw=e=>e.flatMap(e=>{let t=e.op===`rename-concept`||e.op===`rename-relationship`?[e.to]:[];return`relationship`in e?[e.relationship.id,...t]:`concept`in e?[e.concept.id,...t]:t}),iw=(e,t,n,r)=>{let i=new Set(ew(e,t.from,t.to));if(i.size===0)return{options:n,narrowed:!1};let a=new Set($C);return{options:n.filter(e=>i.has(e.coreLabel)||!a.has(e.coreLabel)||e.label===r),narrowed:!0}},aw=[`kind`,`name`,`description`,`status`,`owner`],ow=[`aka`,`constraints`,`references`,`presentIn`,`attestations`,`distinctFrom`,`supersedes`],sw=[`kind`,`from`,`to`,`name`,`description`,`status`,`mode`,`content`],cw=[`references`,`presentIn`],lw=(e,t)=>{if(e===t)return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`)return!1;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>lw(e,t[n]));let n=e,r=t,i=Object.keys(n),a=Object.keys(r);return i.length===a.length&&i.every(e=>lw(n[e],r[e]))},uw=(e,t)=>t===(e??``)?{kind:`none`}:t===``?{kind:`remove`}:{kind:`set`,value:t},dw=(e,t)=>lw(e,t)?{kind:`none`}:t.length>=e.length&&e.every((e,n)=>lw(e,t[n]))?{kind:`append`,added:t.slice(e.length)}:{kind:`replace`,next:t},fw=(e,t,n,r,i)=>r?{op:`update-concept`,document:e,concept:{id:t,[n]:i}}:{op:`update-concept`,document:e,concept:{id:t},remove:[n]},pw=(e,t,n,r)=>r===null?{op:`update-concept`,document:e,concept:{id:t},remove:[n]}:{op:`update-concept`,document:e,concept:{id:t,[n]:r}},mw=(e,t,n,r,i)=>r?{op:`update-relationship`,document:e,relationship:{id:t,[n]:i}}:{op:`update-relationship`,document:e,relationship:{id:t},remove:[n]},hw=(e,t,n,r)=>r===null?{op:`update-relationship`,document:e,relationship:{id:t},remove:[n]}:{op:`update-relationship`,document:e,relationship:{id:t,[n]:r}},gw=(e,t,n,r,i)=>{let a=uw(r,i);return a.kind===`none`?[]:a.kind===`remove`?[fw(e,t,n,!1,``)]:[fw(e,t,n,!0,a.value)]},_w=(e,t,n,r,i)=>{let a=uw(r,i);return a.kind===`none`?[]:a.kind===`remove`?[mw(e,t,n,!1,``)]:[mw(e,t,n,!0,a.value)]},vw=(e,t,n,r,i)=>{let a=dw(r,i);if(a.kind===`none`)return[];if(a.kind===`append`)return a.added.length===0?[]:[pw(e,t,n,a.added)];let o=[pw(e,t,n,null)];return a.next.length>0&&o.push(pw(e,t,n,a.next)),o},yw=(e,t,n,r,i)=>{let a=dw(r,i);if(a.kind===`none`)return[];if(a.kind===`append`)return a.added.length===0?[]:[hw(e,t,n,a.added)];let o=[hw(e,t,n,null)];return a.next.length>0&&o.push(hw(e,t,n,a.next)),o},bw=e=>e.expects===null?{id:e.id,ref:e.ref}:{id:e.id,ref:e.ref,expects:e.expects},xw=(e,t,n,r)=>{let i=dw(n,r);if(i.kind===`none`)return[];if(i.kind===`append`)return i.added.length===0?[]:[pw(e,t,`constraints`,i.added.map(bw))];let a=[pw(e,t,`constraints`,null)];return i.next.length>0&&a.push(pw(e,t,`constraints`,i.next.map(bw))),a},Sw=e=>({topic:e.topic,by:e.by,recordedBy:e.recordedBy??``,on:e.on}),Cw=(e,t,n,r)=>{let i=dw(n,r);if(i.kind===`none`)return[];if(i.kind===`append`)return i.added.length===0?[]:[pw(e,t,`attestations`,i.added.map(Sw))];let a=[pw(e,t,`attestations`,null)];return i.next.length>0&&a.push(pw(e,t,`attestations`,i.next.map(Sw))),a},ww=(e,t)=>{let n={...e},r=t.concept;for(let e of aw)r[e]!==void 0&&(n[e]=r[e]);for(let e of ow){let t=r[e];t!==void 0&&t.length>0&&(n[e]=[...n[e],...t])}for(let e of t.remove??[])n[e]=ow.includes(e)?[]:null;return n},Tw=(e,t)=>{let n=e;for(let r of t)r.op===`update-concept`&&r.document===e.document&&r.concept.id===e.localId&&(n=ww(n,r));return n},Ew=(e,t)=>{let n={...e},r=t.relationship;for(let e of sw)r[e]!==void 0&&(n[e]=r[e]);for(let e of cw){let t=r[e];t!==void 0&&t.length>0&&(n[e]=[...n[e],...t])}for(let e of t.remove??[])n[e]=cw.includes(e)?[]:null;return n},Dw=(e,t)=>{let n=e;for(let r of t)r.op===`update-relationship`&&r.document===e.document&&r.relationship.id===e.localId&&(n=Ew(n,r));return n},Ow=e=>`subject-${e.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}`,kw=({label:e,value:t,options:n,onCommit:r})=>(0,$.jsxs)(`label`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,$.jsx)(`select`,{name:Ow(e),value:t,onChange:e=>r(e.target.value),children:n.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),Aw=({label:e,value:t,onCommit:n})=>{let[r,i]=(0,y.useState)(t);return(0,y.useEffect)(()=>i(t),[t]),(0,$.jsxs)(`label`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,$.jsx)(`input`,{type:`text`,name:Ow(e),value:r,onChange:e=>i(e.target.value),onBlur:()=>n(r)})]})},jw=({label:e,values:t,emptyRow:n,isRowFilled:r,renderRow:i,onCommit:a})=>{let[o,s]=(0,y.useState)(t);(0,y.useEffect)(()=>s(t),[t]);let c=e=>{s(e),a(e.filter(r))};return(0,$.jsxs)(`div`,{className:`subject-form-field subject-form-list`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,$.jsxs)(`div`,{className:`subject-form-list-body`,children:[o.map((e,t)=>(0,$.jsxs)(`div`,{className:`subject-form-row`,children:[i(e,{set:e=>s(o.map((n,r)=>r===t?e:n)),commit:()=>c(o),replace:e=>c(o.map((n,r)=>r===t?e:n))}),(0,$.jsx)(`button`,{type:`button`,className:`subject-form-row-remove`,onClick:()=>c(o.filter((e,n)=>n!==t)),children:`Remove`})]},t)),(0,$.jsxs)(`button`,{type:`button`,className:`subject-form-row-add`,onClick:()=>s([...o,n]),children:[`Add `,e]})]})]})},Mw=({label:e,values:t,onCommit:n})=>(0,$.jsx)(jw,{label:e,values:t,emptyRow:``,isRowFilled:e=>e.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n})=>(0,$.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),onBlur:n})}),Nw={id:``,ref:``},Pw=({label:e,values:t,onCommit:n})=>(0,$.jsx)(jw,{label:e,values:t,emptyRow:Nw,isRowFilled:e=>e.id.trim()!==``&&e.ref.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n})=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`input`,{type:`text`,placeholder:`id`,value:e.id,onChange:n=>t({...e,id:n.target.value}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`ref`,value:e.ref,onChange:n=>t({...e,ref:n.target.value}),onBlur:n})]})}),Fw={id:``,ref:``,expects:null},Iw=({label:e,values:t,onCommit:n})=>(0,$.jsx)(jw,{label:e,values:t,emptyRow:Fw,isRowFilled:e=>e.id.trim()!==``&&e.ref.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n,replace:r})=>(0,$.jsxs)(`div`,{className:`subject-form-row-body`,children:[(0,$.jsx)(`input`,{type:`text`,placeholder:`id`,value:e.id,onChange:n=>t({...e,id:n.target.value}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`ref`,value:e.ref,onChange:n=>t({...e,ref:n.target.value}),onBlur:n}),(0,$.jsxs)(`label`,{className:`subject-form-toggle`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.expects!==null,onChange:t=>r({...e,expects:t.target.checked?{provider:``,key:``,value:``}:null})}),`Expects`]}),e.expects===null?null:(0,$.jsxs)(`div`,{className:`subject-form-row-body`,children:[(0,$.jsx)(`input`,{type:`text`,placeholder:`provider`,value:e.expects.provider,onChange:n=>e.expects!==null&&t({...e,expects:{...e.expects,provider:n.target.value}}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`key`,value:e.expects.key,onChange:n=>e.expects!==null&&t({...e,expects:{...e.expects,key:n.target.value}}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`value`,value:e.expects.value,onChange:n=>e.expects!==null&&t({...e,expects:{...e.expects,value:n.target.value}}),onBlur:n})]})]})}),Lw={topic:``,by:``,on:``,recordedBy:null},Rw=({label:e,values:t,onCommit:n})=>(0,$.jsx)(jw,{label:e,values:t,emptyRow:Lw,isRowFilled:e=>e.topic.trim()!==``&&e.by.trim()!==``&&e.on.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n})=>(0,$.jsxs)(`div`,{className:`subject-form-row-body`,children:[(0,$.jsx)(`input`,{type:`text`,placeholder:`topic`,value:e.topic,onChange:n=>t({...e,topic:n.target.value}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`by`,value:e.by,onChange:n=>t({...e,by:n.target.value}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`on`,value:e.on,onChange:n=>t({...e,on:n.target.value}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`recorded by`,value:e.recordedBy??``,onChange:n=>t({...e,recordedBy:n.target.value}),onBlur:n})]})}),zw={value:``,label:`— unset —`},Bw=[zw,{value:`planned`,label:`planned`},{value:`current`,label:`current`},{value:`retired`,label:`retired`}],Vw=[zw,{value:`read`,label:`read`},{value:`write`,label:`write`},{value:`read-write`,label:`read-write`},{value:`unspecified`,label:`unspecified`}],Hw=(e,t)=>t.find(t=>t.id===e)?.label??HC(e),Uw=(e,t)=>{let n=t.find(t=>t.id===e);return n===void 0?HC(e):UC(n)},Ww=({node:e,model:t,operations:n,onStageChange:r})=>{let i=Tw(e,n),a=e.document,o=e.localId,s=e=>e.forEach(r),c=t.vocabulary.conceptKinds.map(e=>({value:e.label,label:UC(e)})),l=Hw(i.kind,t.vocabulary.conceptKinds);return(0,$.jsxs)(`div`,{className:`subject-form`,children:[(0,$.jsxs)(`div`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,$.jsx)(`code`,{children:e.id})]}),(0,$.jsx)(kw,{label:`Kind`,value:l,options:c,onCommit:e=>s(gw(a,o,`kind`,l,e))}),(0,$.jsx)(Aw,{label:`Name`,value:i.name,onCommit:e=>s(gw(a,o,`name`,i.name,e))}),(0,$.jsx)(Aw,{label:`Description`,value:i.description??``,onCommit:e=>s(gw(a,o,`description`,i.description,e))}),(0,$.jsx)(kw,{label:`Status`,value:i.status??``,options:Bw,onCommit:e=>s(gw(a,o,`status`,i.status,e))}),(0,$.jsx)(Aw,{label:`Owner`,value:i.owner??``,onCommit:e=>s(gw(a,o,`owner`,i.owner,e))}),(0,$.jsx)(Mw,{label:`Aka`,values:i.aka,onCommit:e=>s(vw(a,o,`aka`,i.aka,e))}),(0,$.jsx)(Mw,{label:`Distinct from`,values:i.distinctFrom,onCommit:e=>s(vw(a,o,`distinctFrom`,i.distinctFrom,e))}),(0,$.jsx)(Mw,{label:`Supersedes`,values:i.supersedes,onCommit:e=>s(vw(a,o,`supersedes`,i.supersedes,e))}),(0,$.jsx)(Mw,{label:`Present in`,values:i.presentIn,onCommit:e=>s(vw(a,o,`presentIn`,i.presentIn,e))}),(0,$.jsx)(Pw,{label:`References`,values:i.references,onCommit:e=>s(vw(a,o,`references`,i.references,e))}),(0,$.jsx)(Iw,{label:`Constraints`,values:i.constraints,onCommit:e=>s(xw(a,o,i.constraints,e))}),(0,$.jsx)(Rw,{label:`Attestations`,values:i.attestations,onCommit:e=>s(Cw(a,o,i.attestations,e))})]})},Gw=({label:e,value:t})=>t===``?null:(0,$.jsxs)(`div`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,$.jsx)(`span`,{className:`subject-fact-value`,children:t})]}),Kw=({node:e,model:t})=>(0,$.jsxs)(`div`,{className:`subject-form subject-facts`,children:[(0,$.jsxs)(`div`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,$.jsx)(`code`,{children:e.id})]}),(0,$.jsx)(Gw,{label:`Kind`,value:Uw(e.kind,t.vocabulary.conceptKinds)}),(0,$.jsx)(Gw,{label:`Name`,value:e.name}),(0,$.jsx)(Gw,{label:`Status`,value:e.status??``}),(0,$.jsx)(Gw,{label:`Owner`,value:e.owner??``}),(0,$.jsx)(Gw,{label:`Aka`,value:e.aka.join(`, `)}),(0,$.jsx)(Gw,{label:`Distinct from`,value:e.distinctFrom.join(`, `)}),(0,$.jsx)(Gw,{label:`Supersedes`,value:e.supersedes.join(`, `)}),(0,$.jsx)(Gw,{label:`Present in`,value:e.presentIn.join(`, `)}),(0,$.jsx)(Gw,{label:`References`,value:e.references.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,$.jsx)(Gw,{label:`Constraints`,value:e.constraints.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,$.jsx)(Gw,{label:`Attestations`,value:e.attestations.map(e=>`${e.topic} by ${e.by} on ${e.on}`).join(`; `)})]}),qw=({edge:e,model:t})=>{let n=e=>t.graph.nodes.find(t=>t.id===e)?.name??e;return(0,$.jsxs)(`div`,{className:`subject-form subject-facts`,children:[(0,$.jsxs)(`div`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,$.jsx)(`code`,{children:e.id})]}),(0,$.jsx)(Gw,{label:`Kind`,value:Uw(e.kind,t.vocabulary.relationshipKinds)}),(0,$.jsx)(Gw,{label:`From`,value:n(e.from)}),(0,$.jsx)(Gw,{label:`To`,value:n(e.to)}),(0,$.jsx)(Gw,{label:`Name`,value:e.name??``}),(0,$.jsx)(Gw,{label:`Mode`,value:e.mode??``}),(0,$.jsx)(Gw,{label:`Content`,value:e.content??``}),(0,$.jsx)(Gw,{label:`Status`,value:e.status??``}),(0,$.jsx)(Gw,{label:`References`,value:e.references.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,$.jsx)(Gw,{label:`Present in`,value:e.presentIn.join(`, `)})]})},Jw=({edge:e,model:t,operations:n,onStageChange:r})=>{let i=Dw(e,n),a=e.document,o=e.localId,s=e=>e.forEach(r),c=Hw(i.kind,t.vocabulary.relationshipKinds),l=iw(t.graph,{from:i.from,to:i.to},t.vocabulary.relationshipKinds,c).options.map(e=>({value:e.label,label:UC(e)})),u=t.graph.nodes.map(e=>({value:e.id,label:e.name}));return(0,$.jsxs)(`div`,{className:`subject-form`,children:[(0,$.jsxs)(`div`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,$.jsx)(`code`,{children:e.id})]}),(0,$.jsx)(kw,{label:`Kind`,value:c,options:l,onCommit:e=>s(_w(a,o,`kind`,c,e))}),(0,$.jsx)(kw,{label:`From`,value:i.from,options:u,onCommit:e=>s(_w(a,o,`from`,i.from,e))}),(0,$.jsx)(kw,{label:`To`,value:i.to,options:u,onCommit:e=>s(_w(a,o,`to`,i.to,e))}),(0,$.jsx)(Aw,{label:`Name`,value:i.name??``,onCommit:e=>s(_w(a,o,`name`,i.name,e))}),(0,$.jsx)(Aw,{label:`Description`,value:i.description??``,onCommit:e=>s(_w(a,o,`description`,i.description,e))}),(0,$.jsx)(kw,{label:`Mode`,value:i.mode??``,options:Vw,onCommit:e=>s(_w(a,o,`mode`,i.mode,e))}),(0,$.jsx)(Aw,{label:`Content`,value:i.content??``,onCommit:e=>s(_w(a,o,`content`,i.content,e))}),(0,$.jsx)(kw,{label:`Status`,value:i.status??``,options:Bw,onCommit:e=>s(_w(a,o,`status`,i.status,e))}),(0,$.jsx)(Pw,{label:`References`,values:i.references,onCommit:e=>s(yw(a,o,`references`,i.references,e))}),(0,$.jsx)(Mw,{label:`Present in`,values:i.presentIn,onCommit:e=>s(yw(a,o,`presentIn`,i.presentIn,e))})]})};function Yw({overlay:e,selectedId:t}){let n=t===null?e.workspace:e.subjects[t]??[],r=t===null?`Whole-model questions. Select a subject to see what names it.`:null;return(0,$.jsxs)(`div`,{className:`open-questions`,children:[r===null?null:(0,$.jsx)(`p`,{className:`open-questions-scope`,children:r}),n.length===0?(0,$.jsx)(`p`,{className:`section-empty`,children:t===null?`Nothing open at the whole-model level.`:`No open questions name this subject.`}):(0,$.jsx)(`ul`,{className:`question-list`,children:n.map(e=>(0,$.jsx)(Xw,{entry:e},e.questionId))}),(0,$.jsxs)(`p`,{className:`open-questions-catalogue`,children:[`Catalogue `,e.catalogue,` · answers land through the changeset, never here.`]})]})}var Xw=({entry:e})=>(0,$.jsxs)(`li`,{className:`question-row`,children:[(0,$.jsx)(`span`,{className:`question-text`,children:e.question}),(0,$.jsxs)(`span`,{className:`question-meta`,children:[(0,$.jsx)(`span`,{className:`question-authority question-authority-${e.authority}`,children:e.authority}),e.since===void 0?null:(0,$.jsxs)(`span`,{className:`question-since`,children:[`since `,e.since]})]})]}),Zw={layered:`Layered`,routed:`Routed`,"served-by":`Served-by`,bands:`Layer bands`},Qw=[`top-down`,`left-right`],$w={"top-down":`Top-down`,"left-right":`Left-right`};function eT({layout:e,direction:t,onLayoutChange:n,onDirectionChange:r,stylePreset:i,onStyleChange:a}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`select`,{className:`canvas-select`,"aria-label":`Layout`,value:e,onChange:e=>n(e.currentTarget.value),children:Pg.map(e=>(0,$.jsx)(`option`,{value:e,children:Zw[e]},e))}),(0,$.jsx)(`select`,{className:`canvas-select`,"aria-label":`Direction`,value:t,onChange:e=>r(e.currentTarget.value),children:Qw.map(e=>(0,$.jsx)(`option`,{value:e,children:$w[e]},e))}),(0,$.jsx)(`select`,{className:`canvas-select`,"aria-label":`Style`,value:i,onChange:e=>a(e.currentTarget.value),children:Ug.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.title},e.id))})]})}var tT=[`composition`],nT=`top-down`,rT=e=>{let t=e?.trim()??``;return t===``?null:t},iT=e=>({type:`element`,id:e.id,title:e.name,kind:e.kindLabel,description:rT(e.description)}),aT=(e,t)=>{let n=e.from,r=e.to;return{type:`relationship`,id:e.id,sourceId:n,sourceTitle:t.get(n)??n,targetId:r,targetTitle:t.get(r)??r,label:rT(e.name),description:rT(e.description),kind:e.kindLabel}},oT=e=>new Map(e.nodes.map(e=>[e.id,e.name])),sT=(e,t)=>{let n=e.nodes.find(e=>e.id===t);return n===void 0?null:iT(n)},cT=(e,t)=>{let n=e.edges.find(e=>e.id===t);return n===void 0?null:aT(n,oT(e))},lT=(e,t,n,r)=>({select:n=>{let{graph:r}=e();if(r===null)return!1;let i=sT(r,n)??cT(r,n);return i!==null&&(t({type:`subject.selected`,subject:i}),!0)},openDraft:r=>{let{graph:i,readOnly:a}=e();return a||i===null?!1:(n(r?.kind),t({type:`subject.draft.opened`}),!0)},startConnection:n=>{let{graph:r,readOnly:i}=e();return i||r===null||!r.nodes.some(e=>e.id===n)?!1:(t({type:`connection.started`,from:n}),!0)},stagedPins:()=>e().stagedPins,setDecorations:e=>(r(e),!0)}),uT=[`palette`,`properties`,`questions`,`changes`,`chat`],dT=e=>({min:96,max:Math.max(96,e-160)}),fT=(e,t)=>{let{min:n,max:r}=dT(t);return Math.min(r,Math.max(n,e))},pT=.45,mT=(e,t)=>e.length===t.length&&new Set([...e,...t]).size===new Set(e).size,hT=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),gT=e=>{let t=[];return t.push({type:`layout.set`,layout:e?.layout??`served-by`}),t.push({type:`nesting.set`,nesting:e?.nesting??tT}),t.push({type:`fold.set`,mode:e?.fold??`none`,folded:[],unfolded:[]}),t.push({type:`direction.set`,direction:e?.direction??`top-down`}),e?.showLifecycle!==void 0&&t.push({type:`presentation.toggled`,flag:`showLifecycle`,value:e.showLifecycle}),e?.showEvidence!==void 0&&t.push({type:`presentation.toggled`,flag:`showEvidence`,value:e.showEvidence}),e?.showOwnership!==void 0&&t.push({type:`presentation.toggled`,flag:`showOwnership`,value:e.showOwnership}),e?.showKindLabels!==void 0&&t.push({type:`presentation.toggled`,flag:`showKindLabels`,value:e.showKindLabels}),t},_T=(e,t,n,r)=>!r||e===``||e===n?null:t.find(t=>t.id===e)??null,vT=e=>({min:320,max:Math.max(320,Math.min(640,e*pT))}),yT=(e,t)=>{let{min:n,max:r}=vT(t);return Math.min(r,Math.max(n,e))},bT=480,xT=(e,t)=>{let{min:n,max:r}=vT(t);return Math.min(Math.min(r,bT),Math.max(n,e))},ST=(e,t=0)=>({railHidden:!1,conversation:{width:xT(e*.28,e),hidden:!1,unread:0,collapsed:[],changesHeight:200,chatHeight:300},viewportWidth:e,viewportHeight:t,selectedSubject:null,descriptionExpanded:!1,detailsOpen:!1,bottomPanel:{open:!1,tab:`view-query`},tree:{filterText:``,collapsed:[]},connection:null,draftingSubject:!1,pendingDeletion:null,pendingViewDeletion:null,pendingViewRename:null,contextMenu:null,nesting:tT,foldMode:wg,folded:[],unfolded:[],direction:nT,layout:Fg,showLifecycle:!0,showEvidence:!0,showKindLabels:!0,showOwnership:!1,showNudges:!0,stylePreset:Kg()}),CT=(e,t)=>{switch(t.type){case`section.toggled`:{let n=e.conversation.collapsed.includes(t.section);return{...e,conversation:{...e.conversation,collapsed:n?e.conversation.collapsed.filter(e=>e!==t.section):[...e.conversation.collapsed,t.section],unread:t.section===`chat`&&n?0:e.conversation.unread}}}case`section.resized`:{let n=fT(t.height,e.viewportHeight),r=t.section===`chat`?`chatHeight`:`changesHeight`;return e.conversation[r]===n?e:{...e,conversation:{...e.conversation,[r]:n}}}case`conversation.resized`:{if(e.conversation.hidden)return e;let n=yT(t.width,e.viewportWidth);return n===e.conversation.width?e:{...e,conversation:{...e.conversation,width:n}}}case`rail.toggled`:return{...e,railHidden:!e.railHidden};case`conversation.toggled`:{let t=!e.conversation.hidden;return{...e,conversation:{...e.conversation,hidden:t,unread:!t&&!e.conversation.collapsed.includes(`chat`)?0:e.conversation.unread}}}case`viewport.resized`:{let n=yT(e.conversation.width,t.viewportWidth),r=t.viewportHeight??e.viewportHeight,i=fT(e.conversation.changesHeight,r),a=fT(e.conversation.chatHeight,r);return n===e.conversation.width&&i===e.conversation.changesHeight&&a===e.conversation.chatHeight&&t.viewportWidth===e.viewportWidth&&r===e.viewportHeight?e:{...e,conversation:{...e.conversation,width:n,changesHeight:i,chatHeight:a},viewportWidth:t.viewportWidth,viewportHeight:r}}case`attention.received`:return e.conversation.hidden||e.conversation.collapsed.includes(`chat`)?{...e,conversation:{...e.conversation,unread:e.conversation.unread+1}}:e;case`menu.opened`:return{...e,contextMenu:{target:t.target,x:t.x,y:t.y}};case`menu.dismissed`:return e.contextMenu===null?e:{...e,contextMenu:null};case`connection.started`:return{...e,connection:{from:t.from,to:null},draftingSubject:!1,contextMenu:null};case`connection.targeted`:return e.connection===null?e:t.to===e.connection.from?{...e,connection:null}:{...e,connection:{...e.connection,to:t.to}};case`connection.cancelled`:return e.connection===null?e:{...e,connection:null};case`subject.draft.opened`:return{...e,draftingSubject:!0,connection:null,contextMenu:null};case`subject.draft.closed`:return e.draftingSubject?{...e,draftingSubject:!1}:e;case`deletion.asked`:return{...e,pendingDeletion:t.id,connection:null,draftingSubject:!1,contextMenu:null};case`deletion.dismissed`:return e.pendingDeletion===null?e:{...e,pendingDeletion:null};case`viewDeletion.asked`:return{...e,pendingViewDeletion:t.id,contextMenu:null};case`viewDeletion.dismissed`:return e.pendingViewDeletion===null?e:{...e,pendingViewDeletion:null};case`viewRename.asked`:return{...e,pendingViewRename:t.id,contextMenu:null};case`viewRename.dismissed`:return e.pendingViewRename===null?e:{...e,pendingViewRename:null};case`subject.selected`:return{...e,conversation:{...e.conversation,collapsed:e.conversation.collapsed.filter(e=>e!==`properties`)},selectedSubject:t.subject,descriptionExpanded:!1,contextMenu:null};case`subject.cleared`:return e.selectedSubject===null?e:{...e,selectedSubject:null,descriptionExpanded:!1};case`description.toggled`:return e.selectedSubject===null?e:{...e,descriptionExpanded:!e.descriptionExpanded};case`details.toggled`:return{...e,detailsOpen:!e.detailsOpen};case`bottomPanel.toggled`:return{...e,bottomPanel:{...e.bottomPanel,open:!e.bottomPanel.open}};case`bottomPanel.tabSelected`:return e.bottomPanel.open&&e.bottomPanel.tab===t.tab?e:{...e,bottomPanel:{open:!0,tab:t.tab}};case`tree.filtered`:return e.tree.filterText===t.filterText?e:{...e,tree:{...e.tree,filterText:t.filterText}};case`tree.toggled`:{let n=e.tree.collapsed.includes(t.key);return{...e,tree:{...e.tree,collapsed:n?e.tree.collapsed.filter(e=>e!==t.key):[...e.tree.collapsed,t.key]}}}case`nesting.set`:return hT(e.nesting,t.nesting)?e:{...e,nesting:t.nesting};case`fold.set`:return e.foldMode===t.mode&&mT(e.folded,t.folded)&&mT(e.unfolded,t.unfolded)?e:{...e,foldMode:t.mode,folded:t.folded,unfolded:t.unfolded};case`fold.toggled`:{let n=e.folded.includes(t.id)||e.foldMode===`instances`&&!e.unfolded.includes(t.id);return{...e,folded:n?e.folded.filter(e=>e!==t.id):[...e.folded.filter(e=>e!==t.id),t.id],unfolded:n?[...e.unfolded.filter(e=>e!==t.id),t.id]:e.unfolded.filter(e=>e!==t.id)}}case`fold.all`:return t.folded?{...e,folded:[...t.ids],unfolded:[]}:{...e,folded:[],unfolded:[...t.ids]};case`direction.set`:return e.direction===t.direction?e:{...e,direction:t.direction};case`layout.set`:return e.layout===t.layout?e:{...e,layout:t.layout};case`presentation.toggled`:return{...e,[t.flag]:t.value};case`style.set`:return e.stylePreset===t.preset?e:{...e,stylePreset:t.preset};case`model.replaced`:{let n=e.contextMenu===null?e:{...e,contextMenu:null},r=n.selectedSubject;if(r===null)return n;let i=t.graph,a=i===null?null:r.type===`element`?sT(i,r.id):cT(i,r.id);return a===null?{...n,selectedSubject:null,descriptionExpanded:!1}:{...n,selectedSubject:a}}}},wT=(e,t)=>{let n=e.trim();if(t===null)return n;if(t.type===`element`)return`About element “${t.title}” (${t.id}): ${n}`;let r=`${t.sourceTitle} → ${t.targetTitle}`;return`About relationship “${t.label===null?r:`${r} — ${t.label}`}”: ${n}`};function TT({id:e,label:t,meta:n,open:r,onToggle:i,children:a}){return(0,$.jsxs)(`section`,{className:`stack-section stack-section-${e}`,children:[(0,$.jsxs)(`h2`,{className:`section-head`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`section-toggle`,"aria-expanded":r,"aria-controls":`section-${e}`,onClick:i,children:[(0,$.jsx)(`span`,{className:`section-chevron`,"aria-hidden":`true`,children:r?`▾`:`▸`}),(0,$.jsx)(`span`,{className:`section-label`,children:t})]}),n===void 0?null:(0,$.jsx)(`span`,{className:`section-meta`,children:n})]}),(0,$.jsx)(`div`,{className:`section-body`,id:`section-${e}`,hidden:!r,children:a})]})}function ET({label:e,height:t,viewportHeight:n,onResize:r}){let i=dT(n),a=(0,y.useRef)(null),o=e=>{let t=a.current;t?.pointerId===e.pointerId&&r(t.startHeight+t.startY-e.clientY)},s=e=>{a.current={pointerId:e.pointerId,startY:e.clientY,startHeight:t},e.currentTarget.setPointerCapture(e.pointerId)},c=e=>{a.current?.pointerId===e.pointerId&&(a.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,$.jsx)(`div`,{className:`section-splitter`,role:`separator`,"aria-label":e,"aria-orientation":`horizontal`,"aria-valuenow":Math.round(t),"aria-valuemin":i.min,"aria-valuemax":Math.round(i.max),tabIndex:0,onPointerDown:s,onPointerMove:o,onPointerUp:c,onPointerCancel:c,onKeyDown:e=>{if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault();let n=e.shiftKey?32:8;r(t+(e.key===`ArrowUp`?n:-n))}})}var DT=(e,t,n)=>uT.filter(t=>e.includes(t)).flatMap((e,r)=>{let i=r===0?void 0:n[e];return[...i===void 0?[]:[(0,$.jsx)(y.Fragment,{children:i},`splitter-${e}`)],(0,$.jsx)(y.Fragment,{children:t[e]},e)]}),OT={messageBytes:65536,modelBytes:5242880,transcriptBytes:5242880,pendingEvents:32,reconnectMs:3e5,staleSessionMs:864e5}.reconnectMs,kT=`Returning control to the main agent`,AT={operations:[],viewOperations:[],sourceDigests:{}},jT=e=>e.operations.length===0&&e.viewOperations.length===0,MT={lifecycle:`connecting`,authority:`canonical`,title:``,description:``,chatEnabled:!1,model:null,styleNonce:``,activeView:``,transcript:[],views:[],choices:null,agentStatus:null,diagnostics:[],handoff:null,composerEnabled:!1,awaitingAgent:!1,localRecords:0,lastSequence:0,frozen:!1,activeFilter:null,focusReturn:null,quickFilterText:``,closedReason:null,pendingChangeset:AT,undoStack:[],redoStack:[],commitStatus:`idle`,commitDiagnostics:null,commitNotice:null,layoutNotice:null},NT=e=>({authority:e.authority,title:e.title,description:e.description,chatEnabled:e.chatEnabled,model:e.model,transcript:e.transcript,agentTurnOpen:e.agentTurnOpen,choices:e.pendingChoice,styleNonce:e.styleNonce,lastSequence:e.lastSequence,frozen:e.frozen,views:e.views}),PT=(e,t)=>t-e<OT,FT=(e,t,n)=>({id:`local-${e.localRecords}`,speaker:t,text:n}),IT=(e,t)=>e.transcript.some(e=>e.id===t.id)?e.transcript:[...e.transcript,t],LT=e=>e.initialView,RT={awaitingAgent:!1,agentStatus:null},zT=e=>{let t=(e,t)=>Object.keys(e).filter(e=>!t.includes(e)).sort().join(`:`);if(`concept`in e){let n=e.concept;return`${e.op}:${e.document}:concept:${n.id}:${t(n,[`id`])}`}if(`relationship`in e){let n=e.relationship;return`${e.op}:${e.document}:relationship:${n.id}:${t(n,[`id`])}`}let n=e.observation,r=`${n.subject??n.claim}:${n.key??``}`;return`${e.op}:${e.document}:observation:${r}:${t(n,[`subject`,`claim`,`key`])}`},BT=(e,t,n,r)=>{let i={},a=(e,t)=>{if(i[e]!==void 0)return;let r=n[e]??t;r!==void 0&&(i[e]=r)};for(let t of e)a(t.document,r?.sourceDigests[t.document]);for(let e of t)a(e.path,r?.projectionDigests[e.path]);return i},VT=(e,t,n)=>{let r=n.operations??e.operations,i=n.viewOperations??e.viewOperations;return{operations:r,viewOperations:i,sourceDigests:BT(r,i,e.sourceDigests,t)}},HT=(e,t)=>{switch(t.type){case`session.loaded`:return{...e,...t.snapshot,lifecycle:e.lifecycle===`ending`?`ending`:`active`,activeView:LT(t.snapshot.model),transcript:[...t.snapshot.transcript,...e.transcript.filter(e=>e.speaker===`session`)],awaitingAgent:t.snapshot.agentTurnOpen,agentStatus:t.snapshot.agentTurnOpen?e.agentStatus:null,lastSequence:Math.max(e.lastSequence,t.snapshot.lastSequence)};case`model.received`:return{...e,model:t.model,views:t.views,diagnostics:[]};case`diagnostic.received`:return{...e,diagnostics:t.diagnostics,...RT};case`chat.sent`:return{...e,transcript:IT(e,FT(e,`reviewer`,t.text)),localRecords:e.localRecords+1,choices:null,awaitingAgent:!0};case`chat.received`:return{...e,transcript:IT(e,{id:t.id,speaker:`agent`,text:t.text}),...RT};case`status.received`:return{...e,agentStatus:t.status};case`choice.presented`:return{...e,choices:t.choice,...RT};case`choice.sent`:{let n=e.choices?.options.find(e=>e.id===t.optionId);return n===void 0?e:{...e,transcript:IT(e,FT(e,`reviewer`,n.label)),localRecords:e.localRecords+1,choices:null,awaitingAgent:!0}}case`view.navigated`:return e.activeView===t.viewId?e:{...e,activeView:t.viewId,focusReturn:null};case`handoff.received`:return{...e,handoff:t.handoff,transcript:IT(e,{id:t.id,speaker:`agent`,text:t.handoff.summary}),...RT};case`event.acknowledged`:return{...e,lastSequence:Math.max(e.lastSequence,t.sequence)};case`input.refused`:{let n=e=>t.refused===void 0||t.refused===e;return{...e,diagnostics:t.diagnostics,frozen:e.frozen||t.frozen,...n(`changeset.commit`)?{commitStatus:`idle`,commitDiagnostics:t.diagnostics}:{},...n(`chat.message`)||n(`choice.selected`)?RT:{}}}case`end.requested`:return{...e,lifecycle:`ending`,choices:null,transcript:IT(e,FT(e,`session`,kT)),localRecords:e.localRecords+1};case`connection.lost`:return{...e,lifecycle:`disconnected`};case`session.closed`:return{...e,lifecycle:`closed`,closedReason:t.reason};case`filter.applied`:return{...e,focusReturn:t.source===`focus`?e.activeFilter?.source===`focus`?e.focusReturn:{activeView:e.activeView,activeFilter:e.activeFilter}:null,activeFilter:{query:t.query,matchedIds:t.matchedIds,excluded:t.excluded,source:t.source},activeView:t.source===`view`||t.source===`editor`?e.activeView:``};case`filter.cleared`:return e.focusReturn===null?{...e,activeFilter:null,activeView:``,focusReturn:null}:{...e,activeFilter:e.focusReturn.activeFilter,activeView:e.focusReturn.activeView,focusReturn:null};case`quickFilter.changed`:return e.quickFilterText===t.text?e:{...e,quickFilterText:t.text};case`changeset.staged`:{let n=zT(t.operation),r=[...e.pendingChangeset.operations.filter(e=>zT(e)!==n),t.operation];return{...e,pendingChangeset:VT(e.pendingChangeset,e.model,{operations:r}),undoStack:[...e.undoStack,e.pendingChangeset],redoStack:[],commitDiagnostics:null,commitNotice:null}}case`changeset.viewStaged`:{let n=e.pendingChangeset.viewOperations.filter(e=>e.path!==t.operation.path);return{...e,pendingChangeset:VT(e.pendingChangeset,e.model,{viewOperations:[...n,t.operation]}),undoStack:[...e.undoStack,e.pendingChangeset],redoStack:[],commitDiagnostics:null,commitNotice:null}}case`changeset.viewMembership`:{let n=e.views.find(({id:e})=>e===t.viewId);if(n===void 0)return e;let r=e.pendingChangeset.viewOperations.find(e=>e.path===n.path),i=TS({id:n.id,title:n.title,description:n.description,query:n.query,presentation:n.presentation}),a=DS(r?.op===`write-view`?r.projection:i,t.subjectId,t.membership);if(a===null)return e;let o=e.pendingChangeset.viewOperations.filter(e=>e.path!==n.path),s=AS(a,i);return{...e,pendingChangeset:VT(e.pendingChangeset,e.model,{viewOperations:s?o:[...o,{op:`write-view`,path:n.path,projection:a}]}),undoStack:[...e.undoStack,e.pendingChangeset],redoStack:[],commitDiagnostics:null,commitNotice:null}}case`changeset.discarded`:{let{index:n}=t,r=e.pendingChangeset.operations.length,i=r+e.pendingChangeset.viewOperations.length;if(n<0||n>=i)return e;let a=n<r?{operations:e.pendingChangeset.operations.filter((e,t)=>t!==n)}:{viewOperations:e.pendingChangeset.viewOperations.filter((e,t)=>t!==n-r)};return{...e,pendingChangeset:VT(e.pendingChangeset,e.model,a),undoStack:[...e.undoStack,e.pendingChangeset],redoStack:[],commitDiagnostics:null}}case`changeset.cleared`:{let t=jT(e.pendingChangeset);return{...e,pendingChangeset:AT,undoStack:t?e.undoStack:[...e.undoStack,e.pendingChangeset],redoStack:t?e.redoStack:[],commitDiagnostics:null}}case`changeset.undone`:{let t=e.undoStack.at(-1);return t===void 0?e:{...e,pendingChangeset:t,undoStack:e.undoStack.slice(0,-1),redoStack:[...e.redoStack,e.pendingChangeset],commitDiagnostics:null}}case`changeset.redone`:{let t=e.redoStack.at(-1);return t===void 0?e:{...e,pendingChangeset:t,redoStack:e.redoStack.slice(0,-1),undoStack:[...e.undoStack,e.pendingChangeset],commitDiagnostics:null}}case`changeset.commit.sent`:return{...e,commitStatus:`committing`,commitDiagnostics:null};case`changeset.committed`:return{...e,pendingChangeset:AT,undoStack:[],redoStack:[],commitStatus:`idle`,commitDiagnostics:null,commitNotice:t.documents};case`apply.failed`:return{...e,commitStatus:`idle`,commitDiagnostics:t.diagnostics};case`layout.saved`:{let n=t.result.ok?`Layout saved`:t.result.message;return{...e,layoutNotice:n}}}},UT=e=>e.lifecycle===`active`&&e.chatEnabled&&!e.frozen&&!e.awaitingAgent;function WT(e,t){if(e.lifecycle===`closed`)return e;let n=HT(e,t);return n===e?e:{...n,composerEnabled:UT(n)}}var GT=(e,t)=>{let n=t.lastSequence;switch(e.kind){case`chat`:return{type:`chat.message`,lastAcknowledgedSequence:n,payload:{text:e.text}};case`choice`:return{type:`choice.selected`,lastAcknowledgedSequence:n,payload:{choiceId:e.choiceId,optionId:e.optionId}};case`navigate`:return{type:`view.navigate`,lastAcknowledgedSequence:n,payload:{viewId:e.viewId,requiresAttention:!1}};case`end`:return{type:`session.end`,lastAcknowledgedSequence:n,payload:{reason:`user-ended`}};case`filter`:return{type:`filter.query`,lastAcknowledgedSequence:n,payload:{query:e.query,...e.nesting===void 0?{}:{nesting:e.nesting}}};case`commit-changeset`:return{type:`changeset.commit`,lastAcknowledgedSequence:n,payload:t.pendingChangeset};case`save-layout`:return{type:`layout.save`,lastAcknowledgedSequence:n,payload:e.payload}}},KT=e=>{if(e.focusReturn===null)return;let t=e.focusReturn.activeView;return e.views.find(({id:e})=>e===t)?.title},qT=e=>{let t=e.views.find(({id:t})=>t===e.activeView);if(t===void 0)return null;let n=e.pendingChangeset.viewOperations.find(e=>e.path===t.path),r=n?.op===`write-view`?n.projection.query:t.query;return ES(r)?{kind:`enumerated`,subjects:r.subjects}:{kind:`faceted`,excluded:r.exclude??[]}},JT=(e,t)=>{if(e.kind!==`model`||t.activeFilter===null)return null;let n=t.activeFilter.source===`view`||t.activeFilter.source===`editor`,r=e.views.find(({id:e})=>e===t.activeView);return{query:n&&r!==void 0?r.query:t.activeFilter.query,source:t.activeFilter.source}},YT=(e,t=`panel`)=>{switch(e.kind){case`ready`:return[{type:`session.loaded`,snapshot:NT(e.snapshot)}];case`accepted`:return[{type:`event.acknowledged`,sequence:e.sequence}];case`rejected`:return[{type:`input.refused`,...e.refused===void 0?{}:{refused:e.refused},diagnostics:e.diagnostics,frozen:e.frozen!==void 0}];case`model`:return[{type:`model.received`,model:e.model,views:e.views}];case`closing`:return[{type:`session.closed`,reason:e.reason}];case`filter-result`:return[{type:`filter.applied`,query:e.result.query,matchedIds:e.result.matchedIds,excluded:e.result.excluded,source:t}];case`response`:switch(e.response.type){case`chat.response`:{let t=[{type:`chat.received`,id:e.response.responseId,text:e.response.payload.text}],n=e.response.payload.appliedQuery;return n&&t.push({type:`filter.applied`,query:n.query,matchedIds:n.matchedIds??[],excluded:null,source:`chat`}),t}case`agent.status`:return[{type:`status.received`,status:e.response.payload}];case`choice.present`:return[{type:`choice.presented`,choice:e.response.payload}];case`handoff.complete`:return[{type:`handoff.received`,id:e.response.responseId,handoff:e.response.payload}];case`diagnostic`:return[{type:`diagnostic.received`,diagnostics:e.response.payload.diagnostics}]}case`apply-result`:{let t=[];return e.result.ok?t.push({type:`changeset.committed`,documents:e.result.result.documents}):t.push({type:`apply.failed`,diagnostics:e.result.diagnostics}),t}case`layout-save-result`:return[{type:`layout.saved`,result:e.result}]}},XT=e=>{let[t,n]=(0,y.useReducer)(WT,MT),[r,i]=(0,y.useState)(!1),a=(0,y.useRef)(t);a.current=t;let o=(0,y.useRef)(`panel`),s=(0,y.useRef)(e);s.current=e,(0,y.useEffect)(()=>s.current.open({frame:e=>{for(let t of YT(e,o.current))n(t);let t=JT(e,a.current);t!==null&&(o.current=t.source,s.current.send(GT({kind:`filter`,query:t.query},a.current)))},connected:i,lost:()=>n({type:`connection.lost`}),session:()=>({lastSequence:a.current.lastSequence,closed:a.current.lifecycle===`closed`})}),[]);let c=(0,y.useCallback)(e=>{s.current.send(GT(e,a.current))},[]),l=(0,y.useCallback)(e=>{n({type:`chat.sent`,text:e}),c({kind:`chat`,text:e})},[c]),u=(0,y.useCallback)(e=>{let t=a.current.choices?.choiceId;t!==void 0&&(n({type:`choice.sent`,optionId:e}),c({kind:`choice`,choiceId:t,optionId:e}))},[c]),d=(0,y.useCallback)(e=>{n({type:`view.navigated`,viewId:e}),c({kind:`navigate`,viewId:e})},[c]),f=(0,y.useCallback)((e,t=`panel`,n)=>{o.current=t,c({kind:`filter`,query:e,...n===void 0?{}:{nesting:n}})},[c]),p=(0,y.useCallback)(()=>{n({type:`filter.cleared`})},[]),m=(0,y.useCallback)(e=>{n({type:`quickFilter.changed`,text:e})},[]),h=(0,y.useCallback)(e=>{n({type:`changeset.staged`,operation:e})},[]);return{state:t,connected:r,ask:l,choose:u,navigate:d,filter:f,clearFilter:p,setQuickFilterText:m,stageViewChange:(0,y.useCallback)(e=>{n({type:`changeset.viewStaged`,operation:e})},[]),stageViewMembership:(0,y.useCallback)((e,t,r)=>{n({type:`changeset.viewMembership`,viewId:e,subjectId:t,membership:r})},[]),stageChange:h,discardChange:(0,y.useCallback)(e=>{n({type:`changeset.discarded`,index:e})},[]),clearChangeset:(0,y.useCallback)(()=>{n({type:`changeset.cleared`})},[]),undoChangeset:(0,y.useCallback)(()=>{n({type:`changeset.undone`})},[]),redoChangeset:(0,y.useCallback)(()=>{n({type:`changeset.redone`})},[]),commitChangeset:(0,y.useCallback)(()=>{jT(a.current.pendingChangeset)||(n({type:`changeset.commit.sent`}),c({kind:`commit-changeset`}))},[c]),saveLayout:(0,y.useCallback)(e=>{c({kind:`save-layout`,payload:e})},[c]),end:(0,y.useCallback)(()=>{n({type:`end.requested`}),c({kind:`end`})},[c])}},ZT=(e,t,n,r=8)=>{let i=n.trim().toLowerCase();if(i===``)return{matches:[],more:0};let a=e.nodes.filter(e=>e.id!==t).filter(e=>e.name.toLowerCase().includes(i)||e.id.toLowerCase().includes(i)).map(e=>({id:e.id,name:e.name})).sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id));return{matches:a.slice(0,r),more:Math.max(0,a.length-r)}},QT=({graph:e,from:t,onTarget:n})=>{let[r,i]=(0,y.useState)(``),{matches:a,more:o}=ZT(e,t,r);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`connection-search-label`,htmlFor:`connection-target-search`,children:`Search targets`}),(0,$.jsx)(`input`,{id:`connection-target-search`,className:`connection-search`,type:`search`,autoComplete:`off`,placeholder:`Target name or id`,value:r,onChange:e=>i(e.currentTarget.value)}),r.trim()===``?null:a.length===0?(0,$.jsx)(`p`,{className:`connection-empty`,children:`No subject matches.`}):(0,$.jsxs)(`ul`,{className:`connection-targets`,children:[a.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),children:[e.name,(0,$.jsxs)(`span`,{className:`connection-target-id`,children:[` `,e.id]})]})},e.id)),o===0?null:(0,$.jsxs)(`li`,{className:`connection-targets-more`,children:[o,` more match`]})]})]})},$T=({draft:e,graph:t,reservedIds:n,onTarget:r,onStage:i,onCancel:a})=>{let o=e=>t.nodes.find(t=>t.id===e)?.name??e;if(e.to===null)return(0,$.jsxs)(`section`,{className:`connection-panel`,"aria-label":`Connect subjects`,children:[(0,$.jsxs)(`p`,{className:`connection-prompt`,children:[`Connecting from `,(0,$.jsx)(`strong`,{children:o(e.from)}),`. Choose a target on the diagram, or search for one.`]}),(0,$.jsx)(QT,{graph:t,from:e.from,onTarget:r}),(0,$.jsx)(`button`,{type:`button`,onClick:a,children:`Cancel`})]});let s=e.to,c=ew(t,e.from,s);return(0,$.jsxs)(`section`,{className:`connection-panel`,"aria-label":`Connect subjects`,children:[(0,$.jsxs)(`p`,{className:`connection-prompt`,children:[(0,$.jsx)(`strong`,{children:o(e.from)}),` to`,` `,(0,$.jsx)(`strong`,{children:o(s)})]}),c.length===0?(0,$.jsx)(`p`,{className:`connection-empty`,children:`No relationship is defined between these kinds. One of them is outside the ArchiMate vocabulary the table covers.`}):(0,$.jsx)(`ul`,{className:`connection-kinds`,children:c.map(r=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>{let o=nw(t,e.from,r,s,n);o!==null&&i(o),a()},children:r})},r))}),(0,$.jsx)(`button`,{type:`button`,onClick:a,children:`Cancel`})]})},eE=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,tE=(e,t,n=[])=>{let r=t.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase();if(r===``||!eE.test(r))return null;let i=new Set([...e.nodes.map(e=>e.id),...e.edges.map(e=>e.id),...n]);if(!i.has(r))return r;for(let e=2;;e+=1){let t=`${r}-${e}`;if(!i.has(t))return t}},nE=(e,t,n,r=[])=>{if(t.document===``||!n.includes(t.kind))return null;let i=t.name.trim();if(i===``)return null;let a=tE(e,i,r);return a===null?null:{op:`add-concept`,document:t.document,concept:{id:a,kind:t.kind,name:i}}},rE=(e,t,n,r=[])=>{if(t.document===``)return null;let i=t.name.trim();if(i===``)return null;let a=new Set(r),o=[],s={};for(let r of t.slots){let i=n.get(r.name)??null;if(i===null){if(r.required)return null;continue}if(i.mode===`existing`){if(i.subject===``)return null;s[r.name]=i.subject;continue}if(!r.admits.includes(i.kind))return null;let c=i.name.trim();if(c===``)return null;let l=tE(e,c,a);if(l===null)return null;a.add(l),o.push({op:`add-concept`,document:t.document,concept:{id:l,kind:i.kind,name:c}}),s[r.name]=l}let c=tE(e,i,a);return c===null?null:[...o,{op:`add-concept`,document:t.document,concept:{id:c,kind:t.kind,name:i,...Object.keys(s).length===0?{}:{parts:s}}}]},iE=(e,t,n,r=[])=>{if(n===null||t.document===``||t.slot===``)return null;if(n.mode===`existing`)return n.subject===``?null:[{op:`update-concept`,document:t.document,concept:{id:t.instance,parts:{[t.slot]:n.subject}}}];if(!t.admits.includes(n.kind))return null;let i=n.name.trim();if(i===``)return null;let a=tE(e,i,r);return a===null?null:[{op:`add-concept`,document:t.document,concept:{id:a,kind:n.kind,name:i}},{op:`update-concept`,document:t.document,concept:{id:t.instance,parts:{[t.slot]:a}}}]},aE=({graph:e,pattern:t,documents:n,defaultDocument:r,reservedIds:i,onStage:a,onCancel:o})=>{let[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(r),[d,f]=(0,y.useState)(new Map),p=(e,t)=>f(n=>{let r=new Map(n);return t===null?r.delete(e):r.set(e,t),r}),m=t=>e.nodes.filter(e=>t.includes(e.kindLabel)),h=rE(e,{name:s,document:l,kind:t.label,slots:t.slots.map(e=>({name:e.name,required:e.required,admits:e.admits}))},d,i);return(0,$.jsxs)(`section`,{className:`subject-draft instance-draft`,"aria-label":`Add an instance`,children:[(0,$.jsx)(`h3`,{children:t.name??t.label}),(0,$.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`instance-draft-name`,children:[(0,$.jsx)(`span`,{children:`Name`}),(0,$.jsx)(`input`,{id:`instance-draft-name`,value:s,onChange:e=>c(e.target.value)})]}),(0,$.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`instance-draft-document`,children:[(0,$.jsx)(`span`,{children:`Document`}),(0,$.jsx)(`select`,{id:`instance-draft-document`,value:l,onChange:e=>u(e.target.value),children:n.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}),(0,$.jsx)(`ul`,{className:`instance-draft-slots`,children:t.slots.map(e=>{let t=d.get(e.name)??null,n=m(e.admits),r=t===null?``:t.mode===`new`?`__new__`:t.subject;return(0,$.jsxs)(`li`,{className:`instance-draft-slot`,children:[(0,$.jsxs)(`label`,{htmlFor:`instance-slot-${e.name}`,children:[(0,$.jsx)(`span`,{className:`instance-draft-slot-name`,children:e.name}),e.required?(0,$.jsx)(`span`,{className:`instance-draft-required`,children:`required`}):null,e.wiring===`context`?(0,$.jsx)(`span`,{className:`instance-draft-context`,children:`context`}):null]}),(0,$.jsxs)(`select`,{id:`instance-slot-${e.name}`,value:r,onChange:t=>{let n=t.target.value;if(n===``)return p(e.name,null);if(n===`__new__`)return p(e.name,{mode:`new`,name:``,kind:e.admits[0]??``});p(e.name,{mode:`existing`,subject:n})},children:[(0,$.jsx)(`option`,{value:``,children:e.required?`Choose one`:`Leave for later`}),n.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)),(0,$.jsx)(`option`,{value:`__new__`,children:`New…`})]}),t?.mode===`new`?(0,$.jsxs)(`div`,{className:`instance-draft-new`,children:[(0,$.jsx)(`input`,{"aria-label":`New ${e.name} name`,value:t.name,onChange:n=>p(e.name,{...t,name:n.target.value})}),e.admits.length<2?null:(0,$.jsx)(`select`,{"aria-label":`New ${e.name} kind`,value:t.kind,onChange:n=>p(e.name,{...t,kind:n.target.value}),children:e.admits.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}):null]},e.name)})}),t.wiring.length===0?null:(0,$.jsxs)(`div`,{className:`instance-draft-wiring`,children:[(0,$.jsx)(`h4`,{children:`The compiler will mint`}),(0,$.jsx)(`ul`,{children:t.wiring.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`code`,{children:`${e.from} ${e.kind} ${e.to}`})},`${e.from}-${e.kind}-${e.to}`))})]}),(0,$.jsx)(`button`,{type:`button`,disabled:h===null,onClick:()=>{if(h!==null){for(let e of h)a(e);o()}},children:`Add instance`}),(0,$.jsx)(`button`,{type:`button`,onClick:o,children:`Cancel`})]})},oE=({graph:e,kinds:t,documents:n,defaultDocument:r,initialKind:i,reservedIds:a,onStage:o,onCancel:s})=>{let[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(i??``),[f,p]=(0,y.useState)(r),m=c.trim()===``?null:tE(e,c,a),h=m===null?null:nE(e,{name:c,kind:u,document:f},t.map(e=>e.label),a);return(0,$.jsxs)(`section`,{className:`subject-draft-panel`,"aria-label":`Add a subject`,children:[(0,$.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`subject-draft-name`,children:[(0,$.jsx)(`span`,{children:`Name`}),(0,$.jsx)(`input`,{id:`subject-draft-name`,type:`text`,value:c,onChange:e=>l(e.target.value)})]}),(0,$.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`subject-draft-kind`,children:[(0,$.jsx)(`span`,{children:`Kind`}),(0,$.jsxs)(`select`,{id:`subject-draft-kind`,value:u,onChange:e=>d(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`Choose a kind`}),t.map(e=>(0,$.jsx)(`option`,{value:e.label,children:UC(e)},e.id))]})]}),(0,$.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`subject-draft-document`,children:[(0,$.jsx)(`span`,{children:`Document`}),(0,$.jsx)(`select`,{id:`subject-draft-document`,value:f,onChange:e=>p(e.target.value),children:n.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}),(0,$.jsx)(`p`,{className:`subject-draft-id`,children:u===``?`Choose a kind.`:c.trim()===``?`Give it a name.`:m===null?`That name makes no id. An id starts with a letter and is made of letters, digits and hyphens.`:(0,$.jsxs)($.Fragment,{children:[`Id: `,(0,$.jsx)(`code`,{children:m})]})}),(0,$.jsx)(`button`,{type:`button`,disabled:h===null,onClick:()=>{h!==null&&(o(h),s())},children:`Add`}),(0,$.jsx)(`button`,{type:`button`,onClick:s,children:`Cancel`})]})};function sE({title:e,message:t,confirmLabel:n,cancelLabel:r,onConfirm:i,onCancel:a}){return(0,$.jsx)(`div`,{className:`confirm-dialog-backdrop`,role:`presentation`,onClick:a,children:(0,$.jsxs)(`div`,{className:`confirm-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`confirm-dialog-title`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(`h2`,{id:`confirm-dialog-title`,children:e}),(0,$.jsx)(`p`,{children:t}),(0,$.jsxs)(`div`,{className:`confirm-dialog-actions`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:a,children:r}),(0,$.jsx)(`button`,{type:`button`,onClick:i,children:n})]})]})})}function cE({title:e,label:t,initialValue:n,confirmLabel:r,cancelLabel:i,onConfirm:a,onCancel:o}){let[s,c]=(0,y.useState)(n),l=s.trim()===``;return(0,$.jsx)(`div`,{className:`confirm-dialog-backdrop`,role:`presentation`,onClick:o,children:(0,$.jsxs)(`div`,{className:`confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-dialog-title`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(`h2`,{id:`prompt-dialog-title`,children:e}),(0,$.jsxs)(`form`,{className:`prompt-dialog-form`,onSubmit:e=>{e.preventDefault(),!l&&a(s.trim())},children:[(0,$.jsx)(`label`,{htmlFor:`prompt-dialog-value`,children:t}),(0,$.jsx)(`input`,{id:`prompt-dialog-value`,type:`text`,value:s,autoFocus:!0,onChange:e=>c(e.currentTarget.value),onKeyDown:e=>{e.key===`Escape`&&o()}}),(0,$.jsxs)(`div`,{className:`confirm-dialog-actions`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:o,children:i}),(0,$.jsx)(`button`,{type:`submit`,disabled:l,children:r})]})]})]})})}var lE=new Set([`subject.inspect`,`relationship.inspect`,`view.open`,`view.clear`,`subject.focus`,`subject.focus-instance`,`relationship.focus`,`subject.fold`,`subject.unfold`,`subject.unfold-all`,`selection.fold`,`selection.unfold`,`canvas.fold-all`,`canvas.unfold-all`,`view.copy-path`,`canvas.export-png`]),uE=(e,t)=>t.membership===null?[]:[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:[(t.membership.kind===`enumerated`?t.membership.subjects.includes(e):!t.membership.excluded.includes(e))?{key:`view.remove-subject`,label:`Remove from view`,intent:{type:`view.remove-subject`,id:e}}:{key:`view.add-subject`,label:`Add to this view`,intent:{type:`view.add-subject`,id:e}}]}],dE={key:`view.new`,label:`New view…`,intent:{type:`view.new`}},fE={key:`view.new-folder`,label:`New folder…`,intent:{type:`view.new-folder`}},pE={key:`view.clear`,label:`Show all subjects`,intent:{type:`view.clear`}},mE=e=>e.focusReturnLabel===void 0?pE:{key:`view.clear`,label:`Back to ${e.focusReturnLabel}`,intent:{type:`view.clear`}},hE=(e,t)=>({key:`delete`,scope:`model`,label:null,destructive:!0,items:[{key:`delete`,label:t,intent:e}]}),gE=(e,t)=>t.instanceIds?.has(e)===!0?[{key:`focus-instance`,label:`Focus on this instance`,intent:{type:`subject.focus-instance`,id:e}}]:[],_E=(e,t,n)=>[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:[{key:`focus`,label:`Focus on this`,intent:e},...e.type===`subject.focus`?gE(e.id,n):[],...t.flatMap(e=>e.items),...n.filtered?[mE(n)]:[]]}],vE=(e,t)=>{if(t.containerIds?.has(e)!==!0)return[];let n=t.selectedIds??[],r=n.length>1&&n.includes(e),i=t.folded?.has(e)===!0;return[{key:`fold`,scope:`view`,label:`Fold`,destructive:!1,items:r?[{key:`selection-fold`,label:`Fold ${n.length} selected`,intent:{type:`selection.fold`,ids:n}},{key:`selection-unfold`,label:`Unfold ${n.length} selected`,intent:{type:`selection.unfold`,ids:n}}]:i?[{key:`unfold`,label:`Unfold`,intent:{type:`subject.unfold`,id:e}},{key:`unfold-all`,label:`Unfold everything inside`,intent:{type:`subject.unfold-all`,id:e}}]:[{key:`fold`,label:`Fold`,intent:{type:`subject.fold`,id:e}}]}]},yE=(e,t)=>t.graph?.nodes.find(t=>t.id===e)===void 0?[]:[..._E({type:`subject.focus`,id:e},uE(e,t),t),...vE(e,t),{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`inspect`,label:`Properties`,intent:{type:`subject.inspect`,id:e}},{key:`connect`,label:`Connect from here…`,intent:{type:`subject.connect`,from:e}}]},hE({type:`subject.delete`,id:e},`Delete from model…`)],bE=(e,t)=>{let n=t.graph,r=n?.edges.find(t=>t.id===e);if(n==null||r===void 0)return[];let i=iw(n,{from:r.from,to:r.to},t.relationshipKinds,r.kindLabel),a=[..._E({type:`relationship.focus`,id:e},[],t),{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`inspect`,label:`Properties`,intent:{type:`relationship.inspect`,id:e}}]}];return i.options.length>1&&a.push({key:`kind`,scope:`model`,label:`Change kind`,destructive:!1,items:i.options.map(t=>({key:`kind:${t.label}`,label:t.label,intent:{type:`relationship.retype`,id:e,kind:t.label},...t.label===r.kindLabel?{current:!0}:{}}))}),a.push(hE({type:`relationship.delete`,id:e},`Delete from model…`)),a},xE=e=>e.graph===null?[]:[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:[dE,fE,...e.filtered?[pE]:[],{key:`canvas.export-png`,label:`Export PNG`,intent:{type:`canvas.export-png`}},...e.containerIds!==void 0&&e.containerIds.size>0?[{key:`canvas.fold-all`,label:`Fold every instance`,intent:{type:`canvas.fold-all`}},{key:`canvas.unfold-all`,label:`Unfold everything`,intent:{type:`canvas.unfold-all`}}]:[]]},{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`add`,label:`Add subject…`,intent:{type:`canvas.draft-subject`}}]}],SE=(e,t)=>{let n=[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:e===``?[pE,dE,fE]:[{key:`view.open`,label:`Open view`,intent:{type:`view.open`,id:e},...e===t.activeViewId?{current:!0}:{}},{key:`view.rename`,label:`Rename…`,intent:{type:`view.rename`,id:e}},{key:`view.duplicate`,label:`Duplicate`,intent:{type:`view.duplicate`,id:e}},{key:`view.new-in-folder`,label:`New view in this folder…`,intent:{type:`view.new-in-folder`,id:e}},dE,fE,{key:`view.copy-path`,label:`Copy projection path`,intent:{type:`view.copy-path`,id:e}}]}];return e!==``&&n.push({key:`delete`,scope:`view`,label:null,destructive:!0,items:[{key:`delete`,label:`Delete view…`,intent:{type:`view.delete`,id:e}}]}),n},CE=(e,t)=>t.graph?.nodes.find(t=>t.id===e)===void 0?[]:[...uE(e,t),...gE(e,t).length===0?[]:[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:gE(e,t)}],...vE(e,t),{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`inspect`,label:`Properties`,intent:{type:`subject.inspect`,id:e}}]},hE({type:`subject.delete`,id:e},`Delete from model…`)],wE=(e,t)=>{let n=(()=>{switch(e.kind){case`subject`:return yE(e.id,t);case`relationship`:return bE(e.id,t);case`canvas`:return xE(t);case`view-row`:return SE(e.id,t);case`model-row`:return CE(e.id,t)}})();return t.readOnly===!0?n.flatMap(e=>{let t=e.items.filter(e=>lE.has(e.intent.type));return t.length===0?[]:[{...e,items:t}]}):n},TE=(e,t,n)=>({left:Math.max(0,e.x+t.width<=n.width?e.x:Math.min(e.x-t.width,n.width-t.width)),top:Math.max(0,e.y+t.height<=n.height?e.y:Math.min(e.y-t.height,n.height-t.height))});function EE({groups:e,x:t,y:n,onChoose:r,onDismiss:i}){let a=(0,y.useRef)(null),[o,s]=(0,y.useState)(null);return(0,y.useLayoutEffect)(()=>{let e=a.current;if(e===null)return;let r=e.getBoundingClientRect();s(TE({x:t,y:n},{width:r.width,height:r.height},{width:window.innerWidth,height:window.innerHeight})),e.focus()},[t,n,e]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()},t=e=>{let t=e.target;a.current!==null&&t instanceof Node&&a.current.contains(t)||i()};return window.addEventListener(`keydown`,e),window.addEventListener(`pointerdown`,t,!0),window.addEventListener(`contextmenu`,t,!0),window.addEventListener(`resize`,i),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`contextmenu`,t,!0),window.removeEventListener(`resize`,i)}},[i]),e.length===0?null:(0,$.jsx)(`div`,{ref:a,className:`context-menu`,role:`dialog`,"aria-label":`Actions`,tabIndex:-1,style:o===null?{left:0,top:0,visibility:`hidden`}:{left:`${o.left}px`,top:`${o.top}px`},children:e.map(e=>(0,$.jsxs)(`div`,{className:`context-menu-group context-menu-${e.scope}${e.destructive?` context-menu-destructive`:``}`,children:[e.label===null?null:(0,$.jsx)(`p`,{className:`context-menu-heading`,children:e.label}),(0,$.jsx)(`ul`,{children:e.items.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`context-menu-item`,"aria-current":e.current===!0?`true`:void 0,onClick:()=>r(e.intent),children:[(0,$.jsx)(`span`,{className:`context-menu-tick`,"aria-hidden":!0,children:e.current===!0?`•`:``}),(0,$.jsx)(`span`,{className:`context-menu-label`,children:e.label})]})},e.key))})]},e.key))})}function DE(e,t=[],n=[],r=[]){let i=t.filter(({instance:t})=>t===e),a=n.filter(({instance:t})=>t===e);if(i.length===0&&a.length===0)return null;let o=new Map;for(let t of r){let n=t.op===`update-concept`||t.op===`add-concept`?t.concept:void 0;if(n===void 0)continue;let r=e.slice(e.lastIndexOf(`#`)+1);if(n.id===r||n.id===e)for(let[e,t]of Object.entries(n.parts??{}))typeof t==`string`&&o.set(e,t)}let s=new Map;for(let e of t){let t=s.get(e.member);t===void 0?s.set(e.member,new Set([e.instance])):t.add(e.instance)}let c=(e,t)=>e.slot.localeCompare(t.slot),l=[...[...i].sort(c).map(e=>({slot:e.slot,member:e.member,wiring:e.wiring,required:!1,sharedWith:(s.get(e.member)?.size??1)-1})),...[...a].sort(c).map(e=>{let t=o.get(e.slot);return t===void 0?{slot:e.slot,member:null,wiring:void 0,required:e.required,sharedWith:0}:{slot:e.slot,member:t,wiring:void 0,required:e.required,sharedWith:0,staged:!0}})],u=l.filter(e=>e.staged===!0).length;return{pattern:i[0]?.pattern??a[0]?.pattern??``,rows:l,boundCount:i.length+u,vacantCount:a.length-u}}function OE(e){if(e.member===null)return e.required?`to decide — required`:`to decide`;let t=[];return e.staged===!0&&t.push(`staged`),e.wiring===`context`&&t.push(`context`),e.sharedWith>0&&t.push(e.sharedWith===1?`shared with 1 other`:`shared with ${e.sharedWith} others`),t.length===0?e.member:`${e.member} (${t.join(`, `)})`}var kE=(e,t)=>{let n=[];for(let r of e.nodes)r.id!==t&&(r.owner===t&&n.push({by:r.id,field:`owner`}),r.distinctFrom.includes(t)&&n.push({by:r.id,field:`distinctFrom`}),r.supersedes.includes(t)&&n.push({by:r.id,field:`supersedes`}),r.constraints.some(e=>e.ref===t)&&n.push({by:r.id,field:`constraint`}),r.references.some(e=>e.ref===t)&&n.push({by:r.id,field:`reference`}));return n},AE=(e,t)=>{let n=e.edges.find(e=>e.id===t);if(n!==void 0)return[{op:`delete-relationship`,document:n.document,relationship:{id:n.id}}];let r=e.nodes.find(e=>e.id===t);return r===void 0?[]:[...e.edges.filter(e=>e.from===t||e.to===t).map(e=>({op:`delete-relationship`,document:e.document,relationship:{id:e.id}})),{op:`delete-concept`,document:r.document,concept:{id:r.id}}]},jE=(e,t)=>{let n=e.edges.find(e=>e.id===t);if(n!==void 0)return`Delete the ${n.kindLabel} relationship from "${e.nodes.find(e=>e.id===n.from)?.name??n.from}" to "${e.nodes.find(e=>e.id===n.to)?.name??n.to}"?`;let r=e.nodes.find(e=>e.id===t);if(r===void 0)return null;let i=e.edges.filter(e=>e.from===t||e.to===t).length,a=kE(e,t),o=i===0?`Delete "${r.name}"?`:`Delete "${r.name}" and the ${i} ${i===1?`relationship that names`:`relationships that name`} it?`;if(a.length===0)return o;let s=[...new Set(a.map(t=>e.nodes.find(e=>e.id===t.by)?.name??t.by))],c=s.slice(0,3),l=s.length>c.length?` and others`:``;return`${o} It is still named by ${c.join(`, `)}${l}, so this may be refused.`},ME={reviewer:`You`,agent:`Agent`,session:`Session`},NE={thinking:`Agent is thinking`,compiling:`Agent is compiling the model`,waiting:`Agent is waiting`,idle:`Agent is idle`},PE=(e,t)=>{switch(e.lifecycle){case`connecting`:return`Opening`;case`active`:return t?`Live`:`Reconnecting`;case`ending`:return`Ending`;case`disconnected`:return`Reconnecting`;case`closed`:return`Closed`}},FE=e=>e.lifecycle===`closed`?`Visual conversation ended. Continue in the main agent.`:e.lifecycle===`ending`?e.handoff===null?`Ending conversation — preparing a handoff for the main agent.`:`Handoff ready — returning control to the main agent.`:``,IE=({state:e,connection:t})=>(0,$.jsxs)(`header`,{className:`command-strip`,children:[(0,$.jsxs)(`div`,{className:`command-identity`,children:[(0,$.jsx)(`h1`,{children:e.title===``?`Opening the session`:e.title}),(0,$.jsx)(`span`,{className:`beta-badge`,children:`Beta`}),(0,$.jsx)(`span`,{className:`authority`,children:`Checked YarraMate model`}),(0,$.jsx)(`span`,{className:`connection-state`,role:`status`,children:t})]}),e.description===``?null:(0,$.jsx)(`p`,{className:`session-description`,title:e.description,children:e.description})]}),LE=({choices:e,disabled:t,onChoice:n})=>(0,$.jsxs)(`div`,{className:`choices`,children:[(0,$.jsx)(`p`,{className:`question`,children:e.question}),(0,$.jsx)(`ul`,{children:e.options.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),disabled:t,children:[(0,$.jsx)(`span`,{className:`label`,children:e.label}),e.description===void 0?null:(0,$.jsx)(`span`,{className:`detail`,children:e.description})]})},e.id))})]}),RE=({diagnostics:e})=>e.length===0?null:(0,$.jsxs)(`div`,{className:`faults`,role:`alert`,children:[(0,$.jsx)(`p`,{className:`faults-title`,children:`The workspace did not compile. The diagram still shows the model that did.`}),(0,$.jsx)(`ul`,{children:e.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{className:`code`,children:e.code}),` `,e.message,(0,$.jsxs)(`span`,{className:`where`,children:[e.path,`:`,e.line]})]},`${e.code}-${e.pointer}`))})]}),zE=({state:e,selectedId:t,waiting:n,layout:r,nesting:i,folded:a,memberships:o,direction:s,onLayoutChange:c,onDirectionChange:l,stylePreset:u,onStyleChange:d,showLifecycle:f,showEvidence:p,showOwnership:m,showKindLabels:h,showNudges:g,openQuestionCounts:_,decorations:v,connection:b,onConnectTarget:x,onConnectCancel:S,onConnectStage:C,onDraftStage:w,draftingSubject:T,draftInitialKind:E,draftPattern:D,onKindDrop:O,onDraftSubject:k,onDraftSubjectClose:A,pendingDeletion:j,onDeletionDismiss:M,onSelect:N,onCanvasMenu:P,onClearFilter:F,onSaveLayout:I,onCanvasReady:L,onQuickFilterChange:R,view:z,bottomPanel:B,onTogglePresentation:V,onToggleBottomPanel:H,onSelectBottomTab:U,onApplyFilter:W,onStageView:G,readOnly:K,paletteReachable:q})=>{let J=(0,y.useMemo)(()=>new Map((e.model?.graph.nodes??[]).map(e=>[e.id,e.name])),[e.model]),ee=e.model?.graph.nodes??[],Y=KT(e),te=e.activeFilter?.matchedIds??null,ne=ee.length>0&&(e.activeFilter!==null||e.quickFilterText.trim()!==``)&&py(ee,te,e.quickFilterText)===0,re=e.activeFilter!==null&&py(ee,te,``)===0;return(0,$.jsxs)(`section`,{className:`diagram-workspace`,"aria-label":`Architecture diagram`,children:[e.activeFilter!==null&&e.activeFilter.source!==`view`&&e.activeFilter.source!==`editor`?(0,$.jsxs)(`div`,{className:`filter-pill`,role:`status`,children:[(0,$.jsxs)(`span`,{children:[`Filtered by `,e.activeFilter.source,`:`,` `,(0,$.jsx)(`code`,{children:EC(e.activeFilter.query)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:F,children:Y===void 0?`Show all`:`Back to ${Y}`})]}):null,(0,$.jsxs)(`div`,{className:`canvas`,children:[e.model===null?null:(0,$.jsxs)(`div`,{className:`canvas-controls`,children:[(0,$.jsx)(tC,{value:e.quickFilterText,onChange:R}),(0,$.jsx)(eT,{layout:r,direction:s,onLayoutChange:c,onDirectionChange:l,stylePreset:u,onStyleChange:d}),K||q?null:(0,$.jsx)(`button`,{type:`button`,className:`subject-draft-open`,onClick:k,children:`Add subject`})]}),!T||e.model===null||D===void 0?null:(0,$.jsx)(aE,{graph:e.model.graph,pattern:D,documents:e.model.documents,reservedIds:rw(e.pendingChangeset.operations),defaultDocument:(t===null?void 0:e.model.graph.nodes.find(e=>e.id===t)?.document)??e.model.documents[0]??``,onStage:w,onCancel:A},`pattern:${D.kind}`),!T||e.model===null||D!==void 0?null:(0,$.jsx)(oE,{initialKind:E,graph:e.model.graph,kinds:e.model.vocabulary.conceptKinds,documents:e.model.documents,reservedIds:rw(e.pendingChangeset.operations),defaultDocument:(t===null?void 0:e.model.graph.nodes.find(e=>e.id===t)?.document)??e.model.documents[0]??``,onStage:w,onCancel:A},E??``),j===null||e.model===null?null:(0,$.jsx)(sE,{title:`Delete`,message:jE(e.model.graph,j)??`That subject is no longer on the diagram.`,confirmLabel:`Delete`,cancelLabel:`Keep`,onConfirm:()=>{for(let t of AE(e.model.graph,j))C(t);M()},onCancel:M}),b===null||e.model===null?null:(0,$.jsx)($T,{draft:b,graph:e.model.graph,reservedIds:rw(e.pendingChangeset.operations),onTarget:x,onStage:C,onCancel:S}),e.model===null?null:(0,$.jsx)(Oy,{graph:e.model.graph,selectedId:t,onSelect:(t,n)=>{let r=e.model.graph;if(n===`node`){if(b!==null){x(t);return}let e=r.nodes.find(e=>e.id===t);e!==void 0&&N(iT(e))}else{let e=r.edges.find(e=>e.id===t);e!==void 0&&N(aT(e,J))}},onContextMenu:P,matchedIds:e.activeFilter?.matchedIds??null,quickFilterText:e.quickFilterText,nesting:i,folded:a,memberships:o,faultedIds:AC(e.commitDiagnostics??[]),decorations:v,showLifecycle:f,showEvidence:p,showOwnership:m,showNudges:g,openQuestionCounts:_,activeViewId:e.activeView,direction:s,layout:r,showKindLabels:h,stylePreset:u,savedPositions:e.model.layouts[e.activeView],savedRoutes:e.model.routes?.[e.activeView],onSaveLayout:K?()=>void 0:I,onKindDrop:K?void 0:O,onCanvasReady:L}),ne?(0,$.jsx)(`div`,{className:`filter-empty-pill`,role:`status`,children:re&&e.activeFilter!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{children:[`Nothing matches this filter:`,` `,(0,$.jsx)(`code`,{children:EC(e.activeFilter.query)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:F,children:`Show all`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{children:[`Nothing matches “`,e.quickFilterText.trim(),`”`]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>R(``),children:`Clear filter`})]})}):null,e.layoutNotice===null?null:(0,$.jsx)(`div`,{className:`layout-notice-pill`,role:`status`,children:(0,$.jsx)(`span`,{children:e.layoutNotice})}),n===null?null:(0,$.jsx)(`p`,{className:`waiting`,children:n})]}),(0,$.jsx)(eC,{nodes:e.model?.graph.nodes??[],activeFilter:e.activeFilter,view:z,open:B.open,tab:B.tab,showLifecycle:f,showEvidence:p,showOwnership:m,showKindLabels:h,showNudges:g,onTogglePresentation:V,onToggleOpen:H,onSelectTab:U,onApply:W,onStage:G,readOnly:K},e.activeView),(0,$.jsx)(RE,{diagnostics:e.diagnostics})]})},BE=({text:e,expanded:t,onToggle:n})=>{let r=e??`No description declared in this model`,i=(0,y.useRef)(null),[a,o]=(0,y.useState)(!1);return(0,y.useLayoutEffect)(()=>{let e=i.current;if(e===null||t)return;let n=()=>o(e.scrollHeight>e.clientHeight+1);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[r,t]),(0,$.jsxs)(`div`,{className:`subject-description`,children:[(0,$.jsx)(`p`,{ref:i,className:t?`description-expanded`:`description-clamped`,children:r}),a||t?(0,$.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:n,children:t?`Show less`:`Show more`}):null]})},VE=({subject:e,model:t,operations:n,expanded:r,onToggleDescription:i,onClear:a,onConnect:o,onDelete:s,onStageChange:c,readOnly:l})=>{let u=e.type===`element`?t.graph.nodes.find(t=>t.id===e.id):void 0,d=e.type===`relationship`?t.graph.edges.find(t=>t.id===e.id):void 0;return(0,$.jsxs)(`section`,{className:`subject-inspector`,"aria-labelledby":`subject-heading`,children:[(0,$.jsxs)(`div`,{className:`subject-heading-row`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`subject-type`,children:e.type===`element`?`Selected element`:`Selected relationship`}),(0,$.jsx)(`h2`,{id:`subject-heading`,children:e.type===`element`?e.title:`${e.sourceTitle} → ${e.targetTitle}`})]}),e.type===`element`&&!l?(0,$.jsx)(`button`,{type:`button`,className:`subject-connect`,onClick:()=>o(e.id),children:`Connect`}):null,l?null:(0,$.jsx)(`button`,{type:`button`,className:`subject-delete`,onClick:()=>s(e.id),children:`Delete`}),(0,$.jsx)(`button`,{type:`button`,className:`subject-clear`,onClick:a,children:`Clear`})]}),u===void 0?null:l?(0,$.jsx)(Kw,{node:u,model:t}):(0,$.jsx)(Ww,{node:u,model:t,operations:n,onStageChange:c}),d===void 0?null:l?(0,$.jsx)(qw,{edge:d,model:t}):(0,$.jsx)(Jw,{edge:d,model:t,operations:n,onStageChange:c}),u===void 0?null:(0,$.jsx)(UE,{id:u.id,model:t,operations:n,reservedIds:rw(n),onStage:c,readOnly:l}),(0,$.jsx)(BE,{text:e.description,expanded:r,onToggle:i})]})},HE=({graph:e,instance:t,slot:n,document:r,admits:i,reservedIds:a,onStage:o,fallback:s})=>{let[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(``),f=e.nodes.filter(e=>i.includes(e.kindLabel));if(i.length===0)return(0,$.jsx)($.Fragment,{children:s});let p=s=>{let c=iE(e,{instance:t,slot:n,document:r,admits:i},s,a);if(c!==null){for(let e of c)o(e);l(!1),d(``)}};return(0,$.jsxs)(`span`,{className:`subject-slot-filler`,children:[(0,$.jsxs)(`select`,{"aria-label":`Fill ${n}`,value:``,onChange:e=>{let t=e.target.value;if(t!==``){if(t===`__new__`)return l(!0);p({mode:`existing`,subject:t})}},children:[(0,$.jsx)(`option`,{value:``,children:`to decide`}),f.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)),(0,$.jsx)(`option`,{value:`__new__`,children:`New…`})]}),c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`input`,{"aria-label":`New ${n} name`,value:u,onChange:e=>d(e.target.value)}),(0,$.jsx)(`button`,{type:`button`,disabled:u.trim()===``,onClick:()=>p({mode:`new`,name:u,kind:i[0]??``}),children:`Add`})]}):null]})},UE=({id:e,model:t,operations:n,reservedIds:r,onStage:i,readOnly:a})=>{let o=DE(e,t.memberships,t.vacancies,n);if(o===null)return null;let s=t.graph.nodes.find(t=>t.id===e),c=(t.vocabulary.patterns??[]).find(e=>e.kind===s?.kind);return(0,$.jsxs)(`section`,{className:`subject-slots`,"aria-labelledby":`slots-heading`,children:[(0,$.jsxs)(`h3`,{id:`slots-heading`,className:`subject-slots-heading`,children:[`Slots`,(0,$.jsx)(`span`,{className:`tree-count`,children:o.vacantCount===0?`${o.boundCount}`:`${o.boundCount} of ${o.boundCount+o.vacantCount}`})]}),(0,$.jsx)(`dl`,{className:`subject-slots-list`,children:o.rows.map(n=>(0,$.jsxs)(`div`,{className:`subject-slot-row`,children:[(0,$.jsx)(`dt`,{className:`subject-slot-name`,children:n.slot}),(0,$.jsx)(`dd`,{className:n.member===null?`subject-slot-value subject-slot-vacant`:`subject-slot-value`,children:n.member!==null||a||c===void 0||s===void 0?OE(n):(0,$.jsx)(HE,{graph:t.graph,instance:e,slot:n.slot,document:s.document,admits:c.slots.find(e=>e.name===n.slot)?.admits??[],reservedIds:r,onStage:i,fallback:OE(n)})})]},n.slot))})]})},WE=e=>e.lifecycle===`active`?e.awaitingAgent?NE[e.agentStatus?.state??`thinking`]??`working`:`agent idle`:`closed`,GE=({state:e,disabled:t,selectedSubject:n,onSend:r,onChoice:i,onClearSubject:a,onEnd:o})=>{let[s,c]=(0,y.useState)(``),l=e.lifecycle===`active`&&e.awaitingAgent,u=e.lifecycle===`active`?e.agentStatus:null;return(0,$.jsxs)(`div`,{className:`talk`,children:[(0,$.jsxs)(`div`,{className:`conversation-scroll`,children:[(0,$.jsx)(`ol`,{className:`ledger`,role:`log`,"aria-live":`polite`,children:e.transcript.length===0?(0,$.jsx)(`li`,{className:`empty`,children:(0,$.jsx)(`p`,{children:`Nothing asked yet. Question anything on the diagram.`})}):e.transcript.map(e=>(0,$.jsxs)(`li`,{className:`said said-${e.speaker}`,children:[(0,$.jsx)(`p`,{className:`who`,children:ME[e.speaker]}),(0,$.jsx)(`p`,{className:`words`,children:e.text})]},e.id))}),e.choices===null?null:(0,$.jsx)(LE,{choices:e.choices,disabled:t,onChoice:i})]}),(0,$.jsxs)(`form`,{className:`composer`,onSubmit:e=>{e.preventDefault();let n=s.trim();n===``||t||(r(n),c(``))},children:[n===null?null:(0,$.jsxs)(`div`,{className:`subject-chip`,children:[(0,$.jsx)(`span`,{children:n.type===`element`?n.title:`${n.sourceTitle} → ${n.targetTitle}`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Remove selected diagram context`,onClick:a,children:`Remove`})]}),(0,$.jsx)(`label`,{className:`offscreen`,htmlFor:`composer-text`,children:`Ask about this design`}),(0,$.jsx)(`textarea`,{id:`composer-text`,name:`question`,rows:3,value:s,disabled:t,placeholder:e.chatEnabled?n?.type===`element`?`Ask about this element`:n?.type===`relationship`?`Ask about this relationship`:`Ask about this design`:`This session is read-only`,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,$.jsxs)(`div`,{className:`composer-foot`,children:[(0,$.jsxs)(`p`,{className:`agent-status`,role:`status`,"aria-live":`polite`,"aria-busy":l,children:[l?(0,$.jsx)(`span`,{className:`agent-spinner`,"aria-hidden":`true`}):null,(0,$.jsx)(`span`,{children:u===null?l?`Awaiting agent response`:`\xA0`:NE[u.state]??`\xA0`})]}),(0,$.jsx)(`button`,{type:`submit`,disabled:t||s.trim()===``,children:`Send`})]}),(0,$.jsxs)(`div`,{className:`session-foot`,children:[(0,$.jsx)(`span`,{className:`end-transition-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:FE(e)}),(0,$.jsx)(`button`,{type:`button`,className:`end-session`,onClick:o,disabled:e.lifecycle!==`active`,children:e.lifecycle===`ending`||e.lifecycle===`closed`?`Returning…`:`Return to agent`})]})]})]})},KE=({width:e,viewportWidth:t,onResize:n})=>{let r=vT(t),i=(0,y.useRef)(null),a=e=>{let t=i.current;t?.pointerId===e.pointerId&&n(t.startWidth+t.startX-e.clientX)},o=t=>{i.current={pointerId:t.pointerId,startX:t.clientX,startWidth:e},t.currentTarget.setPointerCapture(t.pointerId)},s=e=>{i.current?.pointerId===e.pointerId&&(i.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,$.jsx)(`div`,{className:`conversation-separator`,role:`separator`,"aria-label":`Resize conversation`,"aria-orientation":`vertical`,"aria-valuemin":r.min,"aria-valuemax":r.max,"aria-valuenow":Math.round(e),tabIndex:0,onPointerDown:o,onPointerMove:a,onPointerUp:s,onPointerCancel:s,onKeyDown:t=>{if(t.key!==`ArrowLeft`&&t.key!==`ArrowRight`)return;t.preventDefault();let r=t.shiftKey?32:8;n(e+(t.key===`ArrowLeft`?r:-r))}})},qE=({host:e,sections:t=uT,readOnly:n=!1,decorations:r,onReady:i})=>{let{state:a,connected:o,ask:s,choose:c,navigate:l,filter:u,clearFilter:d,setQuickFilterText:f,stageViewChange:p,stageViewMembership:m,saveLayout:h,discardChange:g,stageChange:_,clearChangeset:v,undoChangeset:b,redoChangeset:x,commitChangeset:S,end:C}=XT(e),[w,T]=(0,y.useReducer)(CT,{width:window.innerWidth,height:window.innerHeight},({width:e,height:t})=>ST(e,t)),[E,D]=(0,y.useState)(null),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(void 0),[P,F]=(0,y.useState)(void 0),[I,L]=(0,y.useState)(r??{}),R=(0,y.useRef)(null),z=(0,y.useRef)({graph:null,readOnly:n,stagedPins:{}});z.current={graph:a.model?.graph??null,readOnly:n,stagedPins:a.pendingChangeset.sourceDigests},(0,y.useEffect)(()=>{i?.(lT(()=>z.current,T,F,L))},[i]),(0,y.useEffect)(()=>{let e=()=>T({type:`viewport.resized`,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight});return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let B=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(a.activeView===``){B.current=null;return}let e=_T(a.activeView,a.views,B.current,o);if(e!==null){B.current=e.id,u(e.query,`view`,e.presentation?.nesting);for(let t of gT(e.presentation))T(t)}},[a.activeView,a.views,o,u]);let V=(0,y.useRef)({transcriptLength:a.transcript.length,choices:a.choices,diagnostics:a.diagnostics});(0,y.useEffect)(()=>{let e=V.current,t=!1;for(let n=e.transcriptLength;n<a.transcript.length;n+=1)if(a.transcript[n]?.speaker===`agent`){t=!0;break}let n=t||a.choices!==null&&a.choices!==e.choices||a.diagnostics.length>0&&a.diagnostics!==e.diagnostics;V.current={transcriptLength:a.transcript.length,choices:a.choices,diagnostics:a.diagnostics},n&&T({type:`attention.received`})},[a.transcript.length,a.choices,a.diagnostics]);let H=(0,y.useRef)(a.model);(0,y.useEffect)(()=>{a.model!==H.current&&(H.current=a.model,T({type:`model.replaced`,graph:a.model?.graph??null}))},[a.model]);let U=a.model===null?a.lifecycle===`connecting`?`Reading the session`:`No model to draw`:E,W=a.pendingChangeset.operations.length+a.pendingChangeset.viewOperations.length,G=e=>!w.conversation.collapsed.includes(e),K=a.model?.interrogation,q=(0,y.useMemo)(()=>new Map(Object.entries(K?.subjects??{}).map(([e,t])=>[e,t.length])),[K]),J=(0,y.useMemo)(()=>{let e=a.model?.graph;if(e===void 0)return{folded:new Set,insideCounts:new Map,insideIds:new Map};let t=Ag({nodes:e.nodes.map(e=>({id:e.id,kind:e.kind,coreKind:e.coreKindLabel})),edges:e.edges,memberships:a.model?.memberships??[],nesting:w.nesting}),n=new Map,r=new Map;for(let e of t.parentOf.keys()){let i=t.parentOf.get(e),a=new Set([e]);for(;i!==void 0&&!a.has(i);){a.add(i),n.set(i,(n.get(i)??0)+1);let o=r.get(i);o===void 0?r.set(i,[e]):o.push(e),i=t.parentOf.get(i)}}let i=new Set;for(let e of n.keys()){let t=w.folded.includes(e),n=w.unfolded.includes(e);(t||w.foldMode===`instances`&&!n)&&i.add(e)}return{folded:i,insideCounts:n,insideIds:r}},[a.model,w.nesting,w.foldMode,w.folded,w.unfolded]),ee=J.folded,Y=n?t.filter(e=>e!==`palette`&&e!==`changes`):t,te=K===void 0?Y.filter(e=>e!==`questions`):Y,ne=w.selectedSubject?.type===`element`?w.selectedSubject.id:null,re=K===void 0?void 0:ne===null?K.workspace.length:q.get(ne)??0,ie=a.model?.vocabulary.conceptKinds??[],ae=a.model?.vocabulary.patterns,oe=(0,y.useMemo)(()=>new Set(w.tree.collapsed),[w.tree.collapsed]),se=w.conversation.hidden,ce={"--conversation-width":se?`0px`:`${w.conversation.width}px`,"--changes-height":G(`changes`)?`${w.conversation.changesHeight}px`:`auto`,"--chat-height":G(`chat`)?`${w.conversation.chatHeight}px`:`auto`},le=e=>{F(e),T({type:`subject.draft.opened`})},ue=(e,t)=>T({type:`menu.opened`,target:e,x:t.x,y:t.y}),de=a.views.find(({id:e})=>e===a.activeView)?.title,fe=w.contextMenu===null?[]:wE(w.contextMenu.target,{graph:a.model?.graph??null,relationshipKinds:a.model?.vocabulary.relationshipKinds??[],activeViewId:a.activeView,filtered:a.activeFilter!==null,membership:qT(a),folded:ee,containerIds:new Set(J.insideCounts.keys()),instanceIds:new Set((a.model?.memberships??[]).map(({instance:e})=>e)),selectedIds:w.selectedSubject===null?[]:[w.selectedSubject.id],...KT(a)===void 0?{}:{focusReturnLabel:KT(a)},readOnly:n}),pe=e=>{let t=a.model?.graph??null;switch(e.type){case`subject.inspect`:{let n=t?.nodes.find(t=>t.id===e.id);if(n===void 0)return;T({type:`subject.selected`,subject:iT(n)});return}case`relationship.inspect`:{let n=t?.edges.find(t=>t.id===e.id);if(n===void 0||t===null)return;T({type:`subject.selected`,subject:aT(n,new Map(t.nodes.map(e=>[e.id,e.name])))});return}case`subject.connect`:T({type:`connection.started`,from:e.from});return;case`subject.delete`:case`relationship.delete`:T({type:`deletion.asked`,id:e.id});return;case`relationship.retype`:{let n=t?.edges.find(t=>t.id===e.id);if(n===void 0)return;for(let t of _w(n.document,n.localId,`kind`,n.kindLabel,e.kind))_(t);T({type:`menu.dismissed`});return}case`canvas.draft-subject`:F(void 0),T({type:`subject.draft.opened`});return;case`view.add-subject`:case`view.remove-subject`:m(a.activeView,e.id,e.type===`view.add-subject`?`add`:`remove`),T({type:`menu.dismissed`});return;case`view.open`:l(e.id),T({type:`menu.dismissed`});return;case`view.clear`:d(),T({type:`menu.dismissed`});return;case`subject.fold`:case`subject.unfold`:T({type:`fold.toggled`,id:e.id}),T({type:`menu.dismissed`});return;case`subject.unfold-all`:{let t=J.insideIds.get(e.id)??[];T({type:`fold.all`,folded:!1,ids:[e.id,...t]}),T({type:`menu.dismissed`});return}case`selection.fold`:case`selection.unfold`:for(let t of e.ids)ee.has(t)!==(e.type===`selection.fold`)&&T({type:`fold.toggled`,id:t});T({type:`menu.dismissed`});return;case`canvas.fold-all`:case`canvas.unfold-all`:T({type:`fold.all`,folded:e.type===`canvas.fold-all`,ids:[...J.insideCounts.keys()]}),T({type:`menu.dismissed`});return;case`subject.focus-instance`:u({instances:[e.id],relationships:`between`},`focus`,w.nesting),T({type:`menu.dismissed`});return;case`subject.focus`:case`relationship.focus`:{let t=a.model?.graph??null;if(t===null){T({type:`menu.dismissed`});return}let n=e.type===`subject.focus`?DC(t,e.id):OC(t,e.id);if(n.length===0){T({type:`menu.dismissed`});return}u({subjects:[...n],relationships:`between`},`focus`,w.nesting),T({type:`menu.dismissed`});return}case`view.new`:N(void 0),k(!0),T({type:`menu.dismissed`});return;case`view.delete`:T({type:`viewDeletion.asked`,id:e.id});return;case`view.rename`:T({type:`viewRename.asked`,id:e.id});return;case`view.new-folder`:j(!0),T({type:`menu.dismissed`});return;case`view.duplicate`:{let t=a.views.find(t=>t.id===e.id);if(t===void 0)return;let n=wS(t,new Set(a.views.map(e=>e.id)));p({op:`write-view`,...n}),T({type:`menu.dismissed`});return}case`view.new-in-folder`:{let t=a.views.find(t=>t.id===e.id);if(t===void 0)return;N(SS(t)),k(!0),T({type:`menu.dismissed`});return}case`view.copy-path`:{let t=a.views.find(t=>t.id===e.id);if(t===void 0)return;navigator.clipboard?.writeText(t.path),T({type:`menu.dismissed`});return}case`canvas.export-png`:{let e=R.current;if(e===null)return;let t=document.createElement(`a`);t.href=e(),t.download=`${a.activeView===``?`all-subjects`:a.activeView}.png`,t.click(),T({type:`menu.dismissed`});return}}},me=w.pendingViewDeletion===null?null:a.views.find(e=>e.id===w.pendingViewDeletion)??null,he=w.pendingViewRename===null?null:a.views.find(e=>e.id===w.pendingViewRename)??null,ge=[`Show the session panel`,...w.conversation.unread===0?[]:[`${w.conversation.unread} unread`],...a.choices===null?[]:[`the agent is waiting on a choice`]].join(`, `);return(0,$.jsxs)(`main`,{className:`visual-shell`,style:ce,children:[(0,$.jsx)(IE,{state:a,connection:PE(a,o)}),(0,$.jsxs)(`div`,{className:`workspace`,"data-rail":w.railHidden?`hidden`:void 0,children:[w.railHidden?(0,$.jsx)(`button`,{type:`button`,className:`rail-reopen`,title:`Show the view tree`,"aria-label":de===void 0?`Show the view tree`:`Show the view tree, showing ${de}`,onClick:()=>T({type:`rail.toggled`}),children:(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`»`})}):(0,$.jsx)(SC,{views:a.views,stagedViewOperations:a.pendingChangeset.viewOperations,activeViewId:a.activeView,nodes:a.model?.graph.nodes??[],folded:ee,insideCounts:J.insideCounts,inViewIds:a.activeFilter===null?null:new Set(a.activeFilter.matchedIds),filterText:w.tree.filterText,collapsed:oe,onFilterChange:e=>T({type:`tree.filtered`,filterText:e}),onToggle:e=>T({type:`tree.toggled`,key:e}),onSelectView:e=>l(e),onClearView:d,onNewView:()=>{N(void 0),k(!0)},onSelectSubject:e=>{let t=a.model?.graph.nodes.find(t=>t.id===e);t!==void 0&&T({type:`subject.selected`,subject:iT(t)})},onRowMenu:(e,t)=>ue(e.kind===`view`?{kind:`view-row`,id:e.id}:{kind:`model-row`,id:e.id},t),readOnly:n,onHide:()=>T({type:`rail.toggled`})}),(0,$.jsx)(zE,{state:a,selectedId:w.selectedSubject?.id??null,waiting:U,layout:w.layout,nesting:w.nesting,folded:ee,memberships:a.model?.memberships,direction:w.direction,onLayoutChange:e=>T({type:`layout.set`,layout:e}),onDirectionChange:e=>T({type:`direction.set`,direction:e}),stylePreset:w.stylePreset,onStyleChange:e=>{qg(e),T({type:`style.set`,preset:e})},decorations:I,connection:w.connection,onConnectTarget:e=>T({type:`connection.targeted`,to:e}),onConnectCancel:()=>T({type:`connection.cancelled`}),onConnectStage:_,onDraftStage:e=>{_(e),e.op===`add-concept`&&m(a.activeView,e.concept.id,`add`)},draftingSubject:w.draftingSubject,draftInitialKind:P,draftPattern:(a.model?.vocabulary.patterns??[]).find(e=>e.label===P),onKindDrop:e=>le(e),onDraftSubject:()=>{F(void 0),T({type:`subject.draft.opened`})},onDraftSubjectClose:()=>T({type:`subject.draft.closed`}),pendingDeletion:w.pendingDeletion,onDeletionDismiss:()=>T({type:`deletion.dismissed`}),showLifecycle:w.showLifecycle,showEvidence:w.showEvidence,showOwnership:w.showOwnership,showKindLabels:w.showKindLabels,showNudges:w.showNudges,openQuestionCounts:q,onSelect:e=>T({type:`subject.selected`,subject:e}),onCanvasMenu:(e,t)=>ue(e.type===`node`?{kind:`subject`,id:e.id??``}:e.type===`edge`?{kind:`relationship`,id:e.id??``}:{kind:`canvas`},t),onClearFilter:d,onSaveLayout:e=>h({...e,folded:[...w.folded],unfolded:[...w.unfolded]}),onCanvasReady:e=>{R.current=e},onQuickFilterChange:f,view:a.views.find(e=>e.id===a.activeView)??null,bottomPanel:w.bottomPanel,onTogglePresentation:(e,t)=>T({type:`presentation.toggled`,flag:e,value:t}),onToggleBottomPanel:()=>T({type:`bottomPanel.toggled`}),onSelectBottomTab:e=>T({type:`bottomPanel.tabSelected`,tab:e}),onApplyFilter:e=>u(e,`editor`,w.nesting),onStageView:p,readOnly:n,paletteReachable:Y.includes(`palette`)}),se?(0,$.jsxs)(`button`,{type:`button`,className:`conversation-reopen`,title:`Show the session panel`,"aria-label":ge,onClick:()=>T({type:`conversation.toggled`}),children:[(0,$.jsx)(`span`,{className:`reopen-chevron`,"aria-hidden":`true`,children:`«`}),w.conversation.unread===0?null:(0,$.jsx)(`span`,{className:`attention-count`,children:w.conversation.unread}),a.choices===null?null:(0,$.jsx)(`span`,{className:`attention-choice`,title:`The agent is waiting on a choice`,children:`?`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(KE,{width:w.conversation.width,viewportWidth:w.viewportWidth,onResize:e=>T({type:`conversation.resized`,width:e})}),(0,$.jsxs)(`aside`,{className:`section-stack`,"aria-label":`Session`,children:[(0,$.jsx)(`div`,{className:`stack-rim`,children:(0,$.jsx)(`button`,{type:`button`,className:`conversation-hide`,title:`Hide the session panel`,"aria-label":`Hide the session panel`,onClick:()=>T({type:`conversation.toggled`}),children:`»`})}),DT(te,{palette:(0,$.jsx)(TT,{id:`palette`,label:`Kind palette`,meta:ie.length===0?void 0:ie.length===1?`1 kind`:`${ie.length} kinds`,open:G(`palette`),onToggle:()=>T({type:`section.toggled`,section:`palette`}),children:ie.length===0?(0,$.jsx)(`p`,{className:`section-empty`,children:`No model yet. The kinds arrive with it.`}):(0,$.jsx)($_,{kinds:ie,patterns:ae,onPick:le})}),properties:(0,$.jsx)(TT,{id:`properties`,label:`Element properties`,meta:w.selectedSubject?.id,open:G(`properties`),onToggle:()=>T({type:`section.toggled`,section:`properties`}),children:w.selectedSubject===null||a.model===null?(0,$.jsx)(`p`,{className:`section-empty`,children:`Nothing selected. Pick a subject on the canvas or in the rail.`}):(0,$.jsx)(VE,{subject:w.selectedSubject,model:a.model,operations:a.pendingChangeset.operations,expanded:w.descriptionExpanded,onToggleDescription:()=>T({type:`description.toggled`}),onClear:()=>T({type:`subject.cleared`}),onConnect:e=>T({type:`connection.started`,from:e}),onDelete:e=>T({type:`deletion.asked`,id:e}),onStageChange:_,readOnly:n})}),questions:(0,$.jsx)(TT,{id:`questions`,label:`Open questions`,meta:re===void 0?void 0:re===0?`nothing open`:`${re} open`,open:G(`questions`),onToggle:()=>T({type:`section.toggled`,section:`questions`}),children:K===void 0?null:(0,$.jsx)(Yw,{overlay:K,selectedId:ne})}),changes:(0,$.jsx)(TT,{id:`changes`,label:`Changes`,meta:W===0?`nothing staged`:`${W} staged`,open:G(`changes`),onToggle:()=>T({type:`section.toggled`,section:`changes`}),children:(0,$.jsx)(VC,{state:a,onDiscardChange:g,onClearChangeset:v,onUndoChangeset:b,onRedoChangeset:x,onCommitChangeset:S})}),chat:(0,$.jsx)(TT,{id:`chat`,label:`Chat`,meta:w.conversation.unread===0?WE(a):(0,$.jsx)(`span`,{className:`attention-count`,children:w.conversation.unread}),open:G(`chat`),onToggle:()=>T({type:`section.toggled`,section:`chat`}),children:(0,$.jsx)(GE,{state:a,disabled:!a.composerEnabled,selectedSubject:w.selectedSubject,onSend:e=>s(wT(e,w.selectedSubject)),onChoice:c,onClearSubject:()=>T({type:`subject.cleared`}),onEnd:C})})},{changes:(0,$.jsx)(ET,{label:`Resize the changes section`,height:w.conversation.changesHeight,viewportHeight:w.viewportHeight,onResize:e=>T({type:`section.resized`,section:`changes`,height:e})}),chat:(0,$.jsx)(ET,{label:`Resize the chat section`,height:w.conversation.chatHeight,viewportHeight:w.viewportHeight,onResize:e=>T({type:`section.resized`,section:`chat`,height:e})})})]})]})]}),w.contextMenu===null?null:(0,$.jsx)(EE,{groups:fe,x:w.contextMenu.x,y:w.contextMenu.y,onChoose:pe,onDismiss:()=>T({type:`menu.dismissed`})}),(0,$.jsx)(TC,{views:a.views,activeViewId:a.activeView,query:a.activeFilter?.query??null,layout:w.layout,direction:w.direction,showLifecycle:w.showLifecycle,showEvidence:w.showEvidence,showOwnership:w.showOwnership,showKindLabels:w.showKindLabels,open:O,folder:M,onClose:()=>k(!1),onStage:p}),A?(0,$.jsx)(cE,{title:`New folder`,label:`Folder`,initialValue:``,confirmLabel:`Continue`,cancelLabel:`Cancel`,onConfirm:e=>{j(!1);let t=e.trim();t!==``&&(N(t),k(!0))},onCancel:()=>j(!1)}):null,he===null?null:(0,$.jsx)(cE,{title:`Rename view`,label:`Title`,initialValue:he.title,confirmLabel:`Rename`,cancelLabel:`Cancel`,onConfirm:e=>{p({op:`write-view`,...CS(he,e)}),T({type:`viewRename.dismissed`})},onCancel:()=>T({type:`viewRename.dismissed`})}),me===null?null:(0,$.jsx)(sE,{title:`Delete view`,message:`Stage the removal of "${me.title}"? The projection document goes when the changeset is committed; no subject is touched.`,confirmLabel:`Delete`,cancelLabel:`Keep`,onConfirm:()=>{p({op:`delete-view`,path:me.path}),T({type:`viewDeletion.dismissed`})},onCancel:()=>T({type:`viewDeletion.dismissed`})})]})},JE=`/api/session`,YE=`/socket`,XE=1e3,ZE=()=>{let e=null;return{open:t=>{let n=!1,r,i=null,a=()=>{let e=new URL(YE,window.location.href);return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.searchParams.set(`after`,String(t.session().lastSequence)),e},o=()=>{if(!n){if(i??=Date.now(),!PT(i,Date.now())){t.frame({kind:`closing`,reason:`browser-timeout`});return}r=setTimeout(s,XE)}},s=()=>{if(n)return;let r=new WebSocket(a());e=r,r.addEventListener(`open`,()=>{i=null,t.connected(!0)}),r.addEventListener(`message`,e=>{if(typeof e.data==`string`)try{t.frame(JSON.parse(e.data))}catch{}}),r.addEventListener(`close`,()=>{t.connected(!1),e=null,!(n||t.session().closed)&&(t.lost(),o())}),r.addEventListener(`error`,()=>r.close())};return(async()=>{let e=await fetch(JE,{credentials:`same-origin`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(`Session request answered ${e.status}`);let r=await e.json();n||(t.frame({kind:`ready`,snapshot:r}),s())})().catch(()=>{n||(t.lost(),o())}),()=>{n=!0,r!==void 0&&clearTimeout(r),e?.close()}},send:t=>{e!==null&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify(t))}}},QE=document.getElementById(`visual-session`);if(QE===null)throw Error(`The visual session page has no mount point`);jv(Av(()=>new v)),(0,_.createRoot)(QE).render((0,$.jsx)(qE,{host:ZE()}));export{l as n,o as t};
|
|
369
|
+
`}var sS=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Fy,{value:Ay});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new tb({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[Fy]:{value:Ay}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=Uy(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){cS(this.contents)&&this.contents.add(e)}addIn(e,t){cS(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=rb(this);e.anchor=!t||n.has(t)?ib(t||`a`,n):t}return new lb(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=ab(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=hb(e,l,p);return o&&Hy(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new Qb(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return cS(this.contents)?this.contents.delete(e):!1}deleteIn(e){return _b(e)?this.contents!=null&&(this.contents=null,!0):cS(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Hy(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return _b(e)?!t&&By(this.contents)?this.contents.value:this.contents:Hy(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Hy(this.contents)?this.contents.has(e):!1}hasIn(e){return _b(e)?this.contents!==void 0:Hy(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=gb(this.schema,[e],t):cS(this.contents)&&this.contents.set(e,t)}setIn(e,t){_b(e)?this.contents=t:this.contents==null?this.contents=gb(this.schema,Array.from(e),t):cS(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new tb({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new tb({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new aS(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=sb(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?ob(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return oS(this,e)}};function cS(e){if(Hy(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var lS=Symbol(`break visit`),uS=Symbol(`skip children`),dS=Symbol(`remove item`);function fS(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),pS(Object.freeze([]),e,t)}fS.BREAK=lS,fS.SKIP=uS,fS.REMOVE=dS,fS.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},fS.parentCollection=(e,t)=>{let n=fS.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function pS(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=pS(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===lS)return lS;else r===dS&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function mS(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return Ly(e)&&!r?e.toString(n):new sS(e,r,n).toString(n)}var hS=e=>mS(e,{version:`1.1`})!==mS(e,{version:`1.2`}),gS=(e,t={})=>{let n=new sS(e);return Jy(n,{Scalar(e,t){typeof t.value==`string`&&hS(t.value)&&(t.type=fb.QUOTE_DOUBLE)}}),n.toString(t)},_S=`.yarramate/projections`,vS=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t.length===0?`view`:/^[a-z]/.test(t)?t:`view-${t}`},yS=(e,t)=>{if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;return`${e}-${n}`},bS=(e,t)=>yS(vS(e),t),xS=e=>`${_S}/${e}.yaml`,SS=e=>e.presentation?.folder??``,CS=(e,t)=>({path:e.path,projection:TS({id:e.id,title:t,description:e.description,query:e.query,presentation:e.presentation})}),wS=(e,t)=>{let n=`${e.title} copy`,r=bS(n,t);return{path:xS(r),projection:TS({id:r,title:n,description:e.description,query:e.query,presentation:e.presentation})}},TS=e=>{let{title:t,description:n,...r}=e.presentation??{};return{format:`yarramate/projection/v1`,id:e.id,version:`1.0`,query:e.query,presentation:{...r,...e.title.trim()===``?{}:{title:e.title},...e.description.trim()===``?{}:{description:e.description}}}},ES=e=>e.subjects!==void 0,DS=(e,t,n)=>{if(!ES(e.query))return OS(e,t,n);let r=e.query.subjects,i=r.includes(t);return(n===`add`?i:!i)?null:{...e,query:{...e.query,subjects:n===`add`?[...r,t]:r.filter(e=>e!==t)}}},OS=(e,t,n)=>{let r=e.query.exclude??[],i=r.includes(t);if(n===`add`?!i:i)return null;let a=n===`add`?r.filter(e=>e!==t):[...r,t],{exclude:o,...s}=e.query;return{...e,query:a.length===0?s:{...s,exclude:a}}},kS=(e,t)=>{if(!ES(e)&&!ES(t)){let n=e.exclude??[],r=t.exclude??[];return[...n.filter(e=>!r.includes(e)).map(e=>`+${e}`),...r.filter(e=>!n.includes(e)).map(e=>`-${e}`)]}return!ES(e)||!ES(t)?[]:[...t.subjects.filter(t=>!e.subjects.includes(t)).map(e=>`+${e}`),...e.subjects.filter(e=>!t.subjects.includes(e)).map(e=>`-${e}`)]},AS=(e,t)=>jS(e)===jS(t),jS=e=>Array.isArray(e)?`[${e.map(jS).join(`,`)}]`:typeof e==`object`&&e?`{${Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:1).map(([e,t])=>`${JSON.stringify(e)}:${jS(t)}`).join(`,`)}}`:JSON.stringify(e)??`null`,MS={subjects:[],documents:[],kinds:[],layers:[],statuses:[],excludeStatuses:[],states:[],owners:[],constraints:[],relationshipKinds:[],kindMatching:``,relationships:``,isolatedConcepts:``},NS=[`planned`,`current`,`retired`],PS=e=>e===null?MS:{subjects:e.subjects??[],documents:e.documents??[],kinds:e.kinds??[],layers:e.layers??[],statuses:e.statuses??[],excludeStatuses:e.excludeStatuses??[],states:e.states??[],owners:e.owners??[],constraints:e.constraints??[],relationshipKinds:e.relationshipKinds??[],kindMatching:e.kindMatching??``,relationships:e.relationships??``,isolatedConcepts:e.isolatedConcepts??``},FS=e=>({...e.subjects.length>0?{subjects:e.subjects}:{},...e.documents.length>0?{documents:e.documents}:{},...e.kinds.length>0?{kinds:e.kinds}:{},...e.layers.length>0?{layers:e.layers}:{},...e.statuses.length>0?{statuses:e.statuses}:{},...e.excludeStatuses.length>0?{excludeStatuses:e.excludeStatuses}:{},...e.states.length>0?{states:e.states}:{},...e.owners.length>0?{owners:e.owners}:{},...e.constraints.length>0?{constraints:e.constraints}:{},...e.relationshipKinds.length>0?{relationshipKinds:e.relationshipKinds}:{},...e.kindMatching===``?{}:{kindMatching:e.kindMatching},...e.relationships===``?{}:{relationships:e.relationships},...e.isolatedConcepts===``?{}:{isolatedConcepts:e.isolatedConcepts}}),IS=({id:e,label:t,values:n,onChange:r})=>{let[i,a]=(0,y.useState)(``),o=()=>{let e=i.trim();a(``),!(e===``||n.includes(e))&&r([...n,e])};return(0,$.jsxs)(`div`,{className:`filter-field`,children:[(0,$.jsx)(`label`,{htmlFor:e,children:t}),(0,$.jsxs)(`div`,{className:`tag-input`,children:[n.map(e=>(0,$.jsxs)(`span`,{className:`tag-chip`,children:[e,(0,$.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>r(n.filter(t=>t!==e)),children:`×`})]},e)),(0,$.jsx)(`input`,{id:e,type:`text`,value:i,placeholder:`Add…`,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`||e.key===`,`?(e.preventDefault(),o()):e.key===`Backspace`&&i===``&&n.length>0&&r(n.slice(0,-1))},onBlur:o})]})]})},LS=({legend:e,values:t,onChange:n})=>(0,$.jsxs)(`fieldset`,{className:`filter-field filter-checkbox-group`,children:[(0,$.jsx)(`legend`,{children:e}),NS.map(e=>(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.includes(e),onChange:r=>n(r.target.checked?[...t,e]:t.filter(t=>t!==e))}),e]},e))]}),RS=({id:e,label:t,value:n,options:r,onChange:i})=>(0,$.jsxs)(`div`,{className:`filter-field`,children:[(0,$.jsx)(`label`,{htmlFor:e,children:t}),(0,$.jsxs)(`select`,{id:e,value:n,onChange:e=>i(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`Any`}),r.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))]})]}),zS=(e,t)=>n=>e(t,n);function BS({fields:e,onChange:t}){return(0,$.jsxs)(`div`,{className:`filter-grid`,children:[(0,$.jsx)(IS,{id:`filter-subjects`,label:`Subjects`,values:e.subjects,onChange:e=>t(`subjects`,e)}),(0,$.jsx)(IS,{id:`filter-documents`,label:`Documents`,values:e.documents,onChange:e=>t(`documents`,e)}),(0,$.jsx)(IS,{id:`filter-kinds`,label:`Kinds`,values:e.kinds,onChange:e=>t(`kinds`,e)}),(0,$.jsx)(IS,{id:`filter-layers`,label:`Layers`,values:e.layers,onChange:e=>t(`layers`,e)}),(0,$.jsx)(IS,{id:`filter-states`,label:`States`,values:e.states,onChange:e=>t(`states`,e)}),(0,$.jsx)(IS,{id:`filter-owners`,label:`Owners`,values:e.owners,onChange:e=>t(`owners`,e)}),(0,$.jsx)(IS,{id:`filter-constraints`,label:`Constraints`,values:e.constraints,onChange:e=>t(`constraints`,e)}),(0,$.jsx)(IS,{id:`filter-relationship-kinds`,label:`Relationship kinds`,values:e.relationshipKinds,onChange:e=>t(`relationshipKinds`,e)}),(0,$.jsx)(LS,{legend:`Statuses`,values:e.statuses,onChange:e=>t(`statuses`,e)}),(0,$.jsx)(LS,{legend:`Exclude statuses`,values:e.excludeStatuses,onChange:e=>t(`excludeStatuses`,e)}),(0,$.jsx)(RS,{id:`filter-kind-matching`,label:`Kind matching`,value:e.kindMatching,options:[`exact`,`descendants`],onChange:e=>t(`kindMatching`,e)}),(0,$.jsx)(RS,{id:`filter-relationships`,label:`Relationships`,value:e.relationships,options:[`between`,`connected`,`none`],onChange:e=>t(`relationships`,e)}),(0,$.jsx)(RS,{id:`filter-isolated-concepts`,label:`Isolated concepts`,value:e.isolatedConcepts,options:[`include`,`exclude`],onChange:e=>t(`isolatedConcepts`,e)})]})}function VS({showLifecycle:e,showEvidence:t,showOwnership:n,showKindLabels:r,showNudges:i,onTogglePresentation:a}){return(0,$.jsxs)(`fieldset`,{className:`filter-field filter-presentation-group`,children:[(0,$.jsx)(`legend`,{children:`Presentation`}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>zS(a,`showLifecycle`)(e.currentTarget.checked)}),`Lifecycle badges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>zS(a,`showEvidence`)(e.currentTarget.checked)}),`Evidence badges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>zS(a,`showOwnership`)(e.currentTarget.checked)}),`Ownership badges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>zS(a,`showKindLabels`)(e.currentTarget.checked)}),`Kind labels`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>zS(a,`showNudges`)(e.currentTarget.checked)}),`Open-question badges`]})]})}var HS=[{id:`view-query`,label:`View query`}],US=e=>JSON.stringify(Object.entries(e??{}).sort(([e],[t])=>e<t?-1:1)),WS=(e,t)=>US(e)===US(t),GS={exclude:`Taken out of this view`,states:`States`,subjects:`Subjects`,instances:`Not inside a named instance`,documents:`Documents`,kinds:`Kinds`,layers:`Layers`,statuses:`Statuses`,excludeStatuses:`Excluded statuses`,owners:`Owners`,constraints:`Constraints`,isolatedConcepts:`Isolated concepts`,unreported:`Not reported`},KS=Object.keys(GS),qS=(e,t,n)=>{if(t===null)return[];let r=new Set(t),i=n===null?null:new Map(n.map(({id:e,facet:t})=>[e,t])),a=new Map;for(let t of e){if(r.has(t.id))continue;let e=i===null?`unreported`:i.get(t.id)??`isolatedConcepts`,n=a.get(e)??[];n.push({id:t.id,title:t.name}),a.set(e,n)}return KS.flatMap(e=>{let t=a.get(e);return t===void 0?[]:[{reason:e,label:GS[e],subjects:t}]})},JS=(e,t)=>{if(t===null)return e.length;let n=new Set(t);return e.filter(e=>n.has(e.id)).length},YS=(e,t)=>{if(e===null||t===null)return 0;let n=new Set(e);return t.filter(({id:e})=>n.has(e)).length},XS=(e,t,n)=>{let r=e.presentation??{},i=e=>r[e]!==void 0||t[e]!==n[e]?{[e]:t[e]}:{};return{...r,...i(`showLifecycle`),...i(`showEvidence`),...i(`showOwnership`),...i(`showKindLabels`)}},ZS=({view:e,query:t,badges:n,opened:r})=>TS({id:e.id,title:e.title,description:e.description,query:t,presentation:XS(e,n,r)}),QS=e=>({op:`write-view`,path:e.view.path,projection:ZS(e)}),$S=e=>{let t=ZS(e),n=TS({id:e.view.id,title:e.view.title,description:e.view.description,query:e.view.query,presentation:e.view.presentation});return US(t.query)!==US(n.query)||US(t.presentation)!==US(n.presentation)};function eC({nodes:e,activeFilter:t,view:n,open:r,tab:i,showLifecycle:a,showEvidence:o,showOwnership:s,showKindLabels:c,showNudges:l,onTogglePresentation:u,onToggleOpen:d,onSelectTab:f,onApply:p,onStage:m,readOnly:h=!1}){let g=(0,y.useRef)(null),[_,v]=(0,y.useState)(()=>PS(n?.query??t?.query??null)),[b,x]=(0,y.useState)(!1),[S]=(0,y.useState)(()=>({showLifecycle:a,showEvidence:o,showOwnership:s,showKindLabels:c})),C=e=>{g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{g.current=null,p(FS(e))},300)},w=(e,t)=>{x(!1),v(n=>{let r={...n,[e]:t};return C(r),r})},T=FS(_),E=t?.matchedIds??null,D=JS(e,E),O=qS(e,E,t?.excluded??null),k=YS(E,t?.excluded??null),A=t===null?Object.keys(T).length===0:WS(T,t.query),j=n===null?null:{view:n,query:T,badges:{showLifecycle:a,showEvidence:o,showOwnership:s,showKindLabels:c},opened:S};return(0,$.jsxs)(`section`,{className:`bottom-panel`,"aria-label":`Canvas panels`,children:[(0,$.jsxs)(`div`,{className:`bottom-panel-tabs`,role:`tablist`,"aria-label":`Canvas panels`,children:[HS.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,id:`bottom-tab-${e.id}`,className:`bottom-panel-tab`,"aria-selected":r&&i===e.id,"aria-controls":`bottom-panel-${e.id}`,onClick:()=>{if(r&&i===e.id){d();return}f(e.id)},children:e.label},e.id)),(0,$.jsxs)(`span`,{className:`bottom-panel-summary`,role:`status`,children:[D,` `,D===1?`subject`:`subjects`,O.length===0?``:` · ${O.reduce((e,t)=>e+t.subjects.length,0)} excluded`]}),(0,$.jsx)(`button`,{type:`button`,className:`bottom-panel-collapse`,"aria-expanded":r,"aria-controls":`bottom-panel-${i}`,"aria-label":r?`Collapse panel`:`Expand panel`,onClick:d,children:r?`▾`:`▴`})]}),r?(0,$.jsx)(`div`,{className:`bottom-panel-body`,id:`bottom-panel-${i}`,role:`tabpanel`,"aria-labelledby":`bottom-tab-${i}`,children:(0,$.jsxs)(`div`,{className:`query-tab`,children:[(0,$.jsxs)(`div`,{className:`query-tab-fields`,children:[(0,$.jsx)(BS,{fields:_,onChange:w}),(0,$.jsx)(VS,{showLifecycle:a,showEvidence:o,showOwnership:s,showKindLabels:c,showNudges:l,onTogglePresentation:u})]}),(0,$.jsxs)(`div`,{className:`query-tab-outcome`,children:[(0,$.jsx)(`h3`,{children:`Matches`}),(0,$.jsxs)(`p`,{className:`query-match-count`,children:[(0,$.jsx)(`strong`,{children:D}),` `,D===1?`subject`:`subjects`,` of `,e.length]}),A?null:(0,$.jsx)(`p`,{className:`query-outcome-stale`,children:`Describing the query on the canvas, not the edit in progress.`}),D===0&&E!==null?(0,$.jsx)(`p`,{className:`query-outcome-empty`,children:`This query selects nothing.`}):null,k===0?null:(0,$.jsxs)(`p`,{className:`query-outcome-note`,children:[k,` a facet dropped `,k===1?`is`:`are`,` drawn anyway: `,(0,$.jsx)(`code`,{children:`relationships: connected`}),` takes the other end of a relationship with it.`]}),(0,$.jsx)(`h3`,{children:`Excluded, and why`}),O.length===0?(0,$.jsx)(`p`,{className:`query-outcome-note`,children:`Nothing is left out of this view.`}):(0,$.jsx)(`ul`,{className:`query-exclusions`,children:O.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{className:`query-exclusion-facet`,children:e.label}),` `,(0,$.jsx)(`span`,{className:`query-exclusion-count`,children:e.subjects.length}),(0,$.jsxs)(`ul`,{children:[e.subjects.slice(0,12).map(e=>(0,$.jsx)(`li`,{title:e.id,children:e.title},e.id)),e.subjects.length>12?(0,$.jsxs)(`li`,{className:`query-exclusion-more`,children:[`and `,e.subjects.length-12,` more`]}):null]})]},e.reason))})]}),(0,$.jsxs)(`div`,{className:`query-tab-document`,children:[(0,$.jsx)(`h3`,{children:`Document`}),j===null?(0,$.jsx)(`p`,{className:`query-outcome-note`,children:h?`No view is active, so this query has no document. Pick one in the tree.`:`No view is active, so this query has no document yet. Pick one in the tree, or save this query as a new view.`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`pre`,{className:`query-document`,children:gS(ZS(j))}),h?null:(0,$.jsxs)(`div`,{className:`query-tab-actions`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:!$S(j),onClick:()=>{m(QS(j)),x(!0)},children:`Stage view change`}),(0,$.jsx)(`span`,{role:`status`,className:`query-stage-status`,children:b?`Staged. It lands when the changeset is committed.`:``})]})]})]})]})}):null]})}function tC({value:e,onChange:t}){return(0,$.jsx)(`input`,{type:`search`,name:`quick-filter`,className:`quick-filter`,value:e,onChange:e=>t(e.currentTarget.value),placeholder:`Filter by name or id…`,"aria-label":`Quick filter`})}var nC=`views`,rC=`model`,iC=e=>`view-folder:${e}`,aC=e=>`model-layer:${e}`,oC=e=>`model-folder:${e}`,sC=`unlayered`,cC=(e,t)=>t===``||e.toLowerCase().includes(t),lC=(e,t)=>cC(e,tv(t)),uC=e=>e.presentation?.folder??``,dC=({views:e,stagedOperations:t,activeViewId:n,activeSubjects:r,filterText:i})=>{let a=tv(i),o=a!==``,s=r===null?null:rv(r,i),c=new Map,l=(e,t)=>{let n=c.get(e);n===void 0?c.set(e,[t]):n.push(t)},u=new Map;for(let e of t)u.set(e.path,e);for(let t of e){let e=u.get(t.path);u.delete(t.path);let r=e?.op===`write-view`?e.projection:null,i=e===void 0?null:r===null?`delete`:`overwrite`,c=r===null?t.title:r.presentation?.title??r.id,d=r===null?uC(t):r.presentation?.folder??``,f=t.id===n;!cC(c,a)&&!cC(d,a)||l(d,{id:t.id,title:c,path:t.path,subjectCount:f&&s!==null?s:o?null:t.subjectCount,active:f,staged:i})}for(let e of u.values()){if(e.op!==`write-view`)continue;let{projection:t}=e,n=t.presentation?.title??t.id,r=t.presentation?.folder??``;!cC(n,a)&&!cC(r,a)||l(r,{id:t.id,title:n,path:e.path,subjectCount:null,active:!1,staged:`new`})}let d=(e,t)=>e.title.localeCompare(t.title),f=[...c.get(``)??[]].sort(d),p=[...c.entries()].filter(([e])=>e!==``).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:iC(e),name:e,views:[...t].sort(d)}));return{folders:p,loose:f,matched:f.length+p.reduce((e,t)=>e+t.views.length,0)}},fC=({nodes:e,inViewIds:t,filterText:n,folded:r,insideCounts:i})=>{let a=tv(n),o=new Map,s=new Map;for(let n of e){let e=n.layer,c=n.folder,l=c??e??`unlayered`;if(!nv(a,n.id,n.name,n.kindLabel)&&!cC(l,a))continue;let u={id:n.id,name:n.name,kindLabel:n.kindLabel,layer:e,folder:c,inView:t===null||t.has(n.id),foldedCount:r?.has(n.id)===!0?i?.get(n.id)??0:null},d=c===null?s:o,f=d.get(l);f===void 0?d.set(l,[u]):f.push(u)}let c=(e,t)=>e.name.localeCompare(t.name),l=[...o.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:oC(e),label:e,grouping:`folder`,subjects:[...t].sort(c)})),u=[...D_,sC];return[...l,...u.flatMap(e=>{let t=s.get(e);return t===void 0||t.length===0?[]:[{key:aC(e),label:e,grouping:`layer`,subjects:[...t].sort(c)}]})]},pC=`All subjects`,mC=`M2 3.5 5 6.5 8 3.5`,hC=`M3.5 2 6.5 5 3.5 8`;function gC({open:e}){return(0,$.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`none`,"aria-hidden":!0,children:(0,$.jsx)(`path`,{d:e?mC:hC,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function _C(){return(0,$.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":!0,children:[(0,$.jsx)(`rect`,{x:`1.5`,y:`2.5`,width:`9`,height:`7`,stroke:`currentColor`,strokeWidth:`1.2`}),(0,$.jsx)(`path`,{d:`M1.5 5h9`,stroke:`currentColor`,strokeWidth:`1.2`})]})}function vC({layer:e}){let t=e===null?null:M_[e];return(0,$.jsx)(`span`,{className:`tree-swatch`,style:t==null?void 0:{background:t.fill,borderColor:t.border},"aria-hidden":!0})}var yC=(e,t)=>n=>{n.preventDefault(),t(e,{x:n.clientX,y:n.clientY})};function bC({row:e,depth:t,onSelect:n,onMenu:r}){let i=e.staged!==`new`;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`tree-row tree-view tree-depth-${t}${e.active?` tree-row-active`:``}${e.staged===null?``:` tree-row-staged`}${e.staged===`delete`?` tree-row-staged-delete`:``}`,title:e.title,"aria-current":e.active?`true`:void 0,onClick:i?()=>n(e.id):void 0,onContextMenu:i?yC({kind:`view`,id:e.id},r):void 0,children:[(0,$.jsx)(_C,{}),(0,$.jsx)(`span`,{className:`tree-label`,children:e.title}),e.staged===null?null:(0,$.jsx)(`span`,{className:`tree-staged`,children:e.staged===`delete`?`staged delete`:`staged`}),e.subjectCount===null?null:(0,$.jsx)(`span`,{className:`tree-count`,children:e.subjectCount})]})})}function xC({label:e,open:t,count:n,depth:r,onToggle:i}){return(0,$.jsxs)(`button`,{type:`button`,className:`tree-row tree-branch tree-depth-${r}`,"aria-expanded":t,onClick:i,children:[(0,$.jsx)(gC,{open:t}),(0,$.jsx)(`span`,{className:`tree-label`,children:e}),n===void 0?null:(0,$.jsx)(`span`,{className:`tree-count`,children:n})]})}function SC({views:e,stagedViewOperations:t,activeViewId:n,nodes:r,inViewIds:i,folded:a,insideCounts:o,filterText:s,collapsed:c,onFilterChange:l,onToggle:u,onSelectView:d,onClearView:f,onNewView:p,onSelectSubject:m,onRowMenu:h,readOnly:g=!1,onHide:_}){let v=dC({views:e,stagedOperations:t,activeViewId:n,activeSubjects:i===null?null:r.filter(e=>i.has(e.id)),filterText:s}),y=fC({nodes:r,inViewIds:i,filterText:s,folded:a,insideCounts:o}),b=!c.has(nC),x=!c.has(rC),S=s.trim()!==``,C=n===``&&i===null,w=lC(pC,s);return(0,$.jsxs)(`aside`,{className:`view-tree`,"aria-label":`Views and model`,children:[(0,$.jsxs)(`div`,{className:`view-tree-head`,children:[(0,$.jsx)(`input`,{type:`search`,name:`view-tree-filter`,className:`view-tree-filter`,placeholder:`Filter tree`,"aria-label":`Filter views and subjects`,value:s,onChange:e=>l(e.currentTarget.value)}),_===void 0?null:(0,$.jsx)(`button`,{type:`button`,className:`rail-hide`,title:`Hide the view tree`,"aria-label":`Hide the view tree`,onClick:_,children:`«`}),g?null:(0,$.jsx)(`button`,{type:`button`,className:`view-tree-new`,title:`New view`,"aria-label":`New view`,onClick:p,children:(0,$.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":!0,children:(0,$.jsx)(`path`,{d:`M7 3v8M3 7h8`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinecap:`round`})})})]}),(0,$.jsxs)(`div`,{className:`view-tree-body`,children:[(0,$.jsx)(xC,{label:`Views`,open:b,depth:0,onToggle:()=>u(nC)}),b?(0,$.jsxs)(`ul`,{className:`tree-list`,children:[w?(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`tree-row tree-view tree-depth-1${C?` tree-row-active`:``}`,"aria-current":C?`true`:void 0,onClick:f,onContextMenu:yC({kind:`view`,id:``},h),children:[(0,$.jsx)(_C,{}),(0,$.jsx)(`span`,{className:`tree-label`,children:pC}),(0,$.jsx)(`span`,{className:`tree-count`,children:rv(r,s)})]})}):null,v.loose.map(e=>(0,$.jsx)(bC,{row:e,depth:1,onSelect:d,onMenu:h},e.id)),v.folders.map(e=>{let t=S||!c.has(e.key);return(0,$.jsxs)(`li`,{children:[(0,$.jsx)(xC,{label:e.name,open:t,count:t?void 0:e.views.length,depth:1,onToggle:()=>u(e.key)}),t?(0,$.jsx)(`ul`,{className:`tree-list`,children:e.views.map(e=>(0,$.jsx)(bC,{row:e,depth:2,onSelect:d,onMenu:h},e.id))}):null]},e.key)}),!S||v.matched!==0||w?null:(0,$.jsx)(`li`,{className:`tree-empty`,children:`No view matches that.`})]}):null,(0,$.jsx)(xC,{label:`Model`,open:x,depth:0,onToggle:()=>u(rC)}),x?(0,$.jsxs)(`ul`,{className:`tree-list`,children:[y.map(e=>{let t=S||!c.has(e.key);return(0,$.jsxs)(`li`,{children:[(0,$.jsx)(xC,{label:e.label,open:t,count:t?void 0:e.subjects.length,depth:1,onToggle:()=>u(e.key)}),t?(0,$.jsx)(`ul`,{className:`tree-list`,children:e.subjects.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`tree-row tree-subject tree-depth-2${e.inView?``:` tree-row-quiet`}`,title:e.foldedCount===null?`${e.name} — ${e.kindLabel}`:`${e.name} — ${e.kindLabel}, folded over ${e.foldedCount} ${e.foldedCount===1?`subject`:`subjects`}`,onClick:()=>m(e.id),onContextMenu:yC({kind:`subject`,id:e.id},h),children:[(0,$.jsx)(vC,{layer:e.layer}),e.foldedCount===null?null:(0,$.jsx)(`span`,{className:`tree-fold`,"aria-hidden":`true`,children:`▸`}),(0,$.jsx)(`span`,{className:`tree-label`,children:e.name}),e.foldedCount===null||e.foldedCount===0?null:(0,$.jsx)(`span`,{className:`tree-count`,children:e.foldedCount}),e.inView?null:(0,$.jsx)(`span`,{className:`tree-count`,children:`not in view`})]})},e.id))}):null]},e.key)}),y.length!==0||!S?null:(0,$.jsx)(`li`,{className:`tree-empty`,children:`No subject matches that.`})]}):null]})]})}var CC=({id:e,taken:t,path:n,declared:r,folder:i,title:a,description:o,query:s,layout:c,direction:l,showLifecycle:u,showEvidence:d,showOwnership:f,showKindLabels:p})=>{let m=e??bS(a,t);return{op:`write-view`,path:n??xS(m),projection:TS({id:m,title:a,description:o,query:s??{},presentation:{...r??{},layout:c,direction:l,...i===void 0||i===``?{}:{folder:i},showLifecycle:u,showEvidence:d,showOwnership:f,showKindLabels:p}})}};function wC({activeView:e,presetFolder:t,onSubmit:n,onCancel:r}){let[i,a]=(0,y.useState)(e?.title??``),[o,s]=(0,y.useState)(e?.description??``),c=i.trim()===``||o.trim()===``,l=t!==void 0;return(0,$.jsx)(`div`,{className:`save-view-panel`,children:(0,$.jsx)(`div`,{id:`save-view-panel-body`,className:`save-view-panel-body`,children:(0,$.jsxs)(`form`,{className:`save-view-form`,onSubmit:t=>{t.preventDefault(),!c&&n(l?void 0:e?.id,i,o)},children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`save-view-title`,children:`Title`}),(0,$.jsx)(`input`,{id:`save-view-title`,type:`text`,value:i,onChange:e=>a(e.currentTarget.value),required:!0})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`save-view-description`,children:`Description`}),(0,$.jsx)(`textarea`,{id:`save-view-description`,value:o,onChange:e=>s(e.currentTarget.value),required:!0})]}),(0,$.jsxs)(`div`,{className:`save-view-actions`,children:[(0,$.jsx)(`button`,{type:`submit`,disabled:e===null||c||l,title:l?`Save overwrites the active view and keeps its own folder — Save As New puts the first view in "${t}".`:void 0,children:`Save`}),(0,$.jsx)(`button`,{type:`button`,disabled:c,onClick:()=>{c||n(void 0,i,o)},children:`Save As New`}),(0,$.jsx)(`button`,{type:`button`,onClick:r,children:`Cancel`})]})]})})})}function TC({views:e,activeViewId:t,query:n,layout:r,direction:i,showLifecycle:a,showEvidence:o,showOwnership:s,showKindLabels:c,open:l,folder:u,onClose:d,onStage:f}){let p=e.find(e=>e.id===t)??null,m=(t,l,d)=>{f(CC({id:t,taken:new Set(e.map(e=>e.id)),path:t===void 0?void 0:p?.path,declared:t===void 0?void 0:p?.presentation,folder:t===void 0?u:p?.presentation?.folder,title:l,description:d,query:n,layout:r,direction:i,showLifecycle:a,showEvidence:o,showOwnership:s,showKindLabels:c}))};return l?(0,$.jsx)(`div`,{className:`save-view-control`,children:(0,$.jsx)(wC,{activeView:p,presetFolder:u,onSubmit:(e,t,n)=>{m(e,t,n),d()},onCancel:d},t)}):null}function EC(e){if((e.relationships===`connected`||e.relationships===`between`)&&e.subjects!==void 0&&e.subjects.length>0){let t=`${e.relationships===`connected`?`connected to`:`between`} ${e.subjects.join(`, `)}`;return e.exclude===void 0||e.exclude.length===0?t:`${t} · except: ${e.exclude.join(`, `)}`}let t=[],n=(e,n)=>{n!==void 0&&n.length>0&&t.push(`${e}: ${n.join(`, `)}`)};return n(`subjects`,e.subjects),n(`documents`,e.documents),n(`layers`,e.layers),n(e.kindMatching===`descendants`?`kinds (and descendants)`:`kinds`,e.kinds),n(`statuses`,e.statuses),n(`excluding statuses`,e.excludeStatuses),n(`states`,e.states),n(`owners`,e.owners),n(`constraints`,e.constraints),n(`relationship kinds`,e.relationshipKinds),n(`except`,e.exclude),e.isolatedConcepts===`exclude`&&t.push(`connected concepts only`),e.isolatedConcepts===`include`&&t.push(`including isolated concepts`),t.length>0?t.join(` · `):`all`}var DC=(e,t)=>{if(!e.nodes.some(({id:e})=>e===t))return[];let n=new Set([t]);for(let r of e.edges)r.from===t?n.add(r.to):r.to===t&&n.add(r.from);return[...n]},OC=(e,t)=>{let n=e.edges.find(({id:e})=>e===t);return n===void 0?[]:[n.from,n.to]},kC=(e,t)=>{let n=new Set(t.nodes.map(e=>e.id));for(let e of t.edges)n.add(e.id);let r=0;for(let t of e)(t.subjects??[]).some(e=>n.has(e))&&(r+=1);return{total:e.length,onCanvas:r,elsewhere:e.length-r}},AC=e=>{let t=new Set;for(let n of e)for(let e of n.subjects??[])t.add(e);return t},jC=(e,t,n)=>{let r=n=>n.document===e&&n.localId===t,i=n?.nodes.find(r);if(i!==void 0)return i.name;let a=n?.edges.find(r);return a?.name!==void 0&&a.name!==null?a.name:t},MC=(e,t,n)=>[...e.operations.map(e=>PC(e,t)),...e.viewOperations.map(e=>NC(e,n))],NC=(e,t)=>{if(e.op===`delete-view`)return{verb:e.op,subjectName:e.path,fields:[],removedFields:[],scope:`view`};let n=t.find(t=>t.path===e.path),r=n===void 0?[]:kS(n.query,e.projection.query);return{verb:e.op,subjectName:e.projection.presentation?.title??e.projection.id,fields:r.length>0?r:[e.path],removedFields:[],scope:`view`}},PC=(e,t)=>{let n=e.op===`update-concept`||e.op===`update-relationship`||e.op===`update-observation`?e.remove??[]:[];if(`observation`in e){let{subject:r,claim:i,key:a,...o}=e.observation,s=jC(e.document,r??i,t);return{verb:e.op,subjectName:a===void 0?s:`${s} (${a})`,fields:Object.keys(o),removedFields:n,scope:`model`}}let r=`concept`in e?e.concept:e.relationship;return{verb:e.op,subjectName:jC(e.document,r.id,t),fields:Object.keys(r).filter(e=>e!==`id`),removedFields:n,scope:`model`}},FC=e=>{let t=[...e.fields,...e.removedFields.map(e=>`remove: ${e}`)];return t.length===0?`${e.verb} · ${e.subjectName}`:`${e.verb} · ${e.subjectName} · ${t.join(`, `)}`},IC=/^\/operations\/(\d+)(\/|$)/,LC=e=>{let t=new Map,n=[];for(let r of e){let e=IC.exec(r.pointer);if(e===null){n.push(r);continue}let i=Number(e[1]),a=t.get(i);a===void 0?t.set(i,[r]):a.push(r)}return{byRow:t,batch:n}},RC=(e,t,n)=>{let r=t[e];if(r===void 0)return null;let i=n?.sourceDigests[e]??n?.projectionDigests[e];return i===void 0||i===r?null:e},zC=({diagnostic:e})=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{className:`code`,children:e.code}),` `,e.message,e.path===``?null:(0,$.jsxs)(`span`,{className:`where`,children:[e.path,`:`,e.line,`:`,e.column]})]}),BC=({index:e,row:t,diagnostics:n,conflict:r,onDiscard:i})=>(0,$.jsxs)(`li`,{className:r===null?`changeset-row`:`changeset-row conflicted`,children:[(0,$.jsxs)(`div`,{className:`changeset-row-line`,children:[(0,$.jsx)(`span`,{className:`changeset-row-label`,children:FC(t)}),(0,$.jsx)(`span`,{className:`changeset-row-scope changeset-scope-${t.scope}`,children:t.scope}),(0,$.jsx)(`button`,{type:`button`,className:`changeset-row-discard`,onClick:i,children:`Discard`})]}),r===null?null:(0,$.jsxs)(`p`,{className:`changeset-row-conflict`,role:`status`,children:[r,` changed after this edit was staged`]}),n.length===0?null:(0,$.jsx)(`ul`,{className:`changeset-row-diagnostics`,children:n.map(e=>(0,$.jsx)(zC,{diagnostic:e},`${e.code}-${e.pointer}`))})]}),VC=({state:e,onDiscardChange:t,onClearChangeset:n,onUndoChangeset:r,onRedoChangeset:i,onCommitChangeset:a})=>{let o=e.model?.graph??null,s=MC(e.pendingChangeset,o,e.views);if(s.length===0&&e.commitNotice===null&&e.commitDiagnostics===null&&e.undoStack.length===0&&e.redoStack.length===0)return null;let{byRow:c,batch:l}=LC(e.commitDiagnostics??[]),u=e.commitStatus===`committing`;return(0,$.jsxs)(`section`,{className:`changeset-tray`,"aria-labelledby":`changeset-heading`,children:[(0,$.jsxs)(`div`,{className:`changeset-heading-row`,children:[(0,$.jsx)(`h2`,{id:`changeset-heading`,children:`Pending changes`}),(0,$.jsxs)(`div`,{className:`changeset-history-controls`,children:[(0,$.jsx)(`button`,{type:`button`,className:`changeset-undo`,disabled:e.undoStack.length===0,onClick:r,children:`Undo`}),(0,$.jsx)(`button`,{type:`button`,className:`changeset-redo`,disabled:e.redoStack.length===0,onClick:i,children:`Redo`}),s.length===0?null:(0,$.jsx)(`button`,{type:`button`,className:`changeset-discard-all`,onClick:n,children:`Discard all`})]})]}),e.commitDiagnostics===null||e.commitDiagnostics.length===0||o===null?null:(0,$.jsx)(`p`,{className:`changeset-fault-summary`,role:`status`,children:(()=>{let t=kC(e.commitDiagnostics,o);return`${t.total} problem${t.total===1?``:`s`}: ${t.onCanvas} marked on the diagram, ${t.elsewhere} not on it.`})()}),l.length===0?null:(0,$.jsx)(`ul`,{className:`changeset-batch-diagnostics`,role:`alert`,children:l.map(e=>(0,$.jsx)(zC,{diagnostic:e},`${e.code}-${e.pointer}`))}),s.length===0?null:(0,$.jsx)(`ol`,{className:`changeset-rows`,children:s.map((n,r)=>(0,$.jsx)(BC,{index:r,row:n,diagnostics:c.get(r)??[],conflict:RC(r<e.pendingChangeset.operations.length?e.pendingChangeset.operations[r].document:e.pendingChangeset.viewOperations[r-e.pendingChangeset.operations.length].path,e.pendingChangeset.sourceDigests,e.model),onDiscard:()=>t(r)},r))}),(0,$.jsx)(`div`,{className:`changeset-actions`,children:(0,$.jsx)(`button`,{type:`button`,className:`changeset-commit`,disabled:s.length===0||u,"aria-busy":u,onClick:a,children:u?`Committing…`:`Commit changes`})}),e.commitNotice===null?null:(0,$.jsxs)(`div`,{className:`changeset-notice`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[`Committed · `,e.commitNotice.length,` `,e.commitNotice.length===1?`file`:`files`]}),(0,$.jsx)(`ul`,{children:e.commitNotice.map(e=>(0,$.jsx)(`li`,{children:e},e))})]})]})},HC=e=>e.slice(e.lastIndexOf(`#`)+1),UC=e=>e.name===void 0||e.name===e.label?e.label:`${e.name} (${e.label})`,WC={a:`access`,c:`composition`,f:`flow`,g:`aggregation`,i:`assignment`,n:`influence`,o:`association`,r:`realization`,s:`specialization`,t:`triggering`,v:`serving`},GC=`applicationCollaboration.applicationComponent.applicationEvent.applicationFunction.applicationInteraction.applicationInterface.applicationProcess.applicationService.artifact.assessment.businessActor.businessCollaboration.businessEvent.businessFunction.businessInteraction.businessInterface.businessObject.businessProcess.businessRole.businessService.capability.communicationNetwork.constraint.contract.courseOfAction.dataObject.deliverable.device.distributionNetwork.driver.equipment.facility.gap.goal.grouping.implementationEvent.andJunction.orJunction.location.material.meaning.node.outcome.path.plateau.principle.product.representation.requirement.resource.stakeholder.systemSoftware.technologyCollaboration.technologyEvent.technologyFunction.technologyInteraction.technologyInterface.technologyProcess.technologyService.value.valueStream.workPackage`.split(`.`),KC={applicationCollaboration:`cfgostv fgortv fiortv fiortv fiortv cfgortv fiortv fiortv ao no fotv fotv fortv fortv fortv fortv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,applicationComponent:`fotv cfgorstv fiortv fiortv fiortv cfgortv fiortv fiortv ao no fotv fotv fortv fortv fortv fortv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,applicationEvent:`fotv fotv cfgostv fotv fotv fotv fotv fotv ao no fotv fotv fortv fotv fotv fotv ao fotv fotv fotv o fotv nor ao o ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no o o`,applicationFunction:`fotv fotv fotv cfgostv cfgotv fotv cfgotv fortv ao no fotv fotv fotv fortv fortv fotv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,applicationInteraction:`fotv fotv fotv cfgotv cfgostv fotv cfgotv fortv ao no fotv fotv fotv fortv fortv fotv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,applicationInterface:`fotv fotv fotv fotv fotv cfgostv fotv fiotv ao no fotv fotv fotv fotv fotv fortv ao fotv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,applicationProcess:`fotv fotv fotv cfgotv cfgotv fotv cfgostv fortv ao no fotv fotv fotv fortv fortv fotv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,applicationService:`fotv fotv fotv fotv fotv fotv fotv cfgostv ao no fotv fotv fotv fotv fotv fotv ao fotv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,artifact:`or or or or or or or or cgors no o o or or or or or or o or or o nor or or or o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o o nor or no or o or or or or or or no or o`,assessment:`o o o o o o o o o cgnos o o o o o o o o o o o o no o o o o o o no o o o no cgnos o acfginorstv acfginorstv o o no o no o o no o o no o no o o o o o o o o no o o`,businessActor:`fotv fotv fotv fotv fotv fotv fotv fotv ao no cfgostv fotv fiotv fiotv fiotv cfgiotv ao fiotv fiotv fiortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv io acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or ino fotv fotv fotv fotv fotv fotv fotv fotv no or io`,businessCollaboration:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fgotv cfgostv fiotv fiotv fiotv cfgiotv ao fiotv fgiotv fiortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv io acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or ino fotv fotv fotv fotv fotv fotv fotv fotv no or io`,businessEvent:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv cfgostv fotv fotv fotv ao fotv fotv fotv o fotv nor ao o ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no o o`,businessFunction:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv fotv cfgostv cfgotv fotv ao cfgotv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,businessInteraction:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv fotv cfgotv cfgostv fotv ao cfgotv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,businessInterface:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv fotv fotv fotv cfgostv ao fotv fotv fiotv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,businessObject:`o o o o o o o o o no o o o o o o cgos o o o or o nor cgos or o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o o nor or no o o o o o o o o no or o`,businessProcess:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv fotv cfgotv cfgotv fotv ao cfgostv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,businessRole:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv fiotv fiotv fiotv cfgotv ao fiotv cfgostv fiortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv io acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or ino fotv fotv fotv fotv fotv fotv fotv fotv no or io`,businessService:`fotv fotv fotv fotv fotv fotv fotv fotv ao no fotv fotv fotv fotv fotv fotv ao fotv fotv cfgostv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv fotv no or o`,capability:`o o o o o o o o o no o o o o o o o o o o cfgostv o nor o fortv o o o o no o o o nor cfgnorstv o acfginorstv acfginorstv o o no o nor o o nor o o nor fotv no o o o o o o o o no fotv o`,communicationNetwork:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fortv fortv fortv fortv fortv fortv ao fortv fortv fortv or cfgostv nor ao or ao o fgortv fotv no fortv fortv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fortv nor fortv o nor fotv ao nor or nor fgiortv fortv fiortv fiortv fiortv fgiortv fiortv fiortv no or o`,constraint:`o o o o o o o o o no o o o o o o o o o o o o cgnos o o o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o o cgnos o no o o o o o o o o no o o`,contract:`o o o o o o o o o no o o o o o o cgos o o o or o nor cgos or o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o o nor or no o o o o o o o o no or o`,courseOfAction:`o o o o o o o o o no o o o o o o o o o o fotv o nor o cfgostv o o o o no o o o nor cfgnorstv o acfginorstv acfginorstv o o no o nor o o nor o o nor fotv no o o o o o o o o no fotv o`,dataObject:`o o o o o o o o o no o o o o o o or o o o or o nor or or cgos o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o o nor or no o o o o o o o o no or o`,deliverable:`or or or or or or or or or no or or or or or or or or or or or or nor or or or cgos or or no or or o nor cgnors o acfginorstv acfginorstv or or no or nor or or nor or or nor or nor or or or or or or or or no or o`,device:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fotv fotv fortv fortv fortv fortv ao fortv fotv fortv or fotv nor ao or ao o cfgostv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no cfgiortv fotv fiortv fiortv fiortv cfgiortv fiortv fiortv no or o`,distributionNetwork:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fiortv fiortv fiortv fiortv fiortv fiortv ao fiortv fiortv fiortv or fotv nor ao or ao o fgiortv cfgostv no fgiortv fgiortv o nor acfginorstv io acfginorstv acfginorstv fotv aio no fgiortv nor fortv o nor fotv ao nor or inor fgiortv fortv fiortv fiortv fiortv fgiortv fiortv fiortv no or io`,driver:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o cgnos o o o no cgnos o acfginorstv acfginorstv o o no o no o o no o o no o no o o o o o o o o no o o`,equipment:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fotv fotv fortv fortv fortv fortv ao fortv fotv fortv or fotv nor ao or ao o cfgortv fotv no cfgorstv fotv o nor acfginorstv o acfginorstv acfginorstv fotv aio no fotv nor fotv o nor fotv ao nor or no cfgiortv fotv fiortv fiortv fiortv cfgiortv fiortv fiortv no or o`,facility:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fiotv fiotv fiortv fiortv fiortv fiortv ao fiortv fiotv fiortv or fotv nor ao or ao o cfgiortv fotv no cfgiortv cfgiostv o nor acfginorstv io acfginorstv acfginorstv fotv aio no cfgiotv nor fotv o nor fotv ao nor or ino cfgiortv fotv fiortv fiortv fiortv cfgiortv fiortv fiortv no or io`,gap:`o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o cgos o cgos o acfginorstv acfginorstv o o o o o o o o o o o o o o o o o o o o o o o o`,goal:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o no o o o cgnos cgnos o acfginorstv acfginorstv o o no o no o o no o o no o no o o o o o o o o no o o`,grouping:`cfgorstv cfgorstv cfgiorstv cfgiorstv cfgiorstv cfgorstv cfgiorstv cfgiorstv acgiors cgnos cfgiorstv cfgiorstv cfgiorstv cfgiorstv cfgiorstv cfgiorstv acgors cfgiorstv cfgiorstv cfgiorstv cfgiorstv cfgorstv cgnors acgors cfgorstv acgors acgors cfgiorstv cfgorstv cgnos cfgiorstv cfgiorstv cgos cgnors acfginorstv cfgiost acfginorstv acfginorstv cfgorstv acgiors cgnos cfgiorstv cgnors cfgorstv cfgorst cgnors cfgorstv acgors cgnors cfgorstv cginors cfgiorstv cfgorstv cfgiorstv cfgiorstv cfgiorstv cfgiorstv cfgiorstv cfgiorstv cgnos cfgiorstv cfgiost`,implementationEvent:`o o o o o o o o o no o o o o o o o o o o o o no o o o ao o o no o o o no acfgnost cfgost acfginorstv acfginorstv o o no o no o fot no o o no o no o o o o o o o o no o fot`,andJunction:`fortv fortv fiortv fiortv fiortv fortv fiortv fiortv aior no fiortv fiortv fiortv fiortv fiortv fiortv aor fiortv fiortv fiortv fiortv fortv nor aor fortv aor aor fiortv fortv no fiortv fiortv o nor afinortv fiot acfginorstv acfginorstv fortv aior no fiortv nor fortv fort nor fortv aor nor fortv inor fiortv fortv fiortv fiortv fiortv fiortv fiortv fiortv no fiortv fiot`,orJunction:`fortv fortv fiortv fiortv fiortv fortv fiortv fiortv aior no fiortv fiortv fiortv fiortv fiortv fiortv aor fiortv fiortv fiortv fiortv fortv nor aor fortv aor aor fiortv fortv no fiortv fiortv o nor afinortv fiot acfginorstv acfginorstv fortv aior no fiortv nor fortv fort nor fortv aor nor fortv inor fiortv fortv fiortv fiortv fiortv fiortv fiortv fiortv no fiortv fiot`,location:`cfgortv cfgortv cfgiortv cfgiortv cfgiortv cfgortv cfgiortv cfgiortv acgio cgno cfgiortv cfgiortv cfgiortv cfgiortv cfgiortv cfgiortv acgo cfgiortv cfgiortv cfgiortv cgor cfgotv cgnor acgo cgor acgo cgo cfgiortv cfgotv cgno cfgiortv cfgiortv cgo cgnor acfginorstv cgio acfginorstv acfginorstv cfgostv acgio cgno cfgiortv cgnor cfgortv cgo cgnor cfgotv acgo cgnor cgor cginor cfgiortv cfgortv cfgiortv cfgiortv cfgiortv cfgiortv cfgiortv cfgiortv cgno cgor cgio`,material:`or or or or or or or or or no o o or or or or or or o or or o nor or or or o or o no or o o nor cgnors o acfginorstv acfginorstv o cgors no o nor o o nor o o nor or no or o or or or or or or no or o`,meaning:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o no o o o no cgnos o acfginorstv acfginorstv o o cgnos o no o o no o o no o no o o o o o o o o no o o`,node:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fiotv fiotv fiortv fiortv fiortv fiortv ao fiortv fiotv fiortv or fotv nor ao or ao o cfgiortv fotv no cfgiortv cfgiotv o nor acfginorstv io acfginorstv acfginorstv fotv aio no cfgiostv nor fotv o nor fotv ao nor or ino cfgiortv fotv fiortv fiortv fiortv cfgiortv fiortv fiortv no or io`,outcome:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o cgnos o o no o o no o no o o o o o o o o no o o`,path:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fiotv fiotv fiortv fiortv fiortv fiortv ao fiortv fiotv fiortv or fotv nor ao or ao o fgiortv fotv no fgiortv fgiotv o nor acfginorstv io acfginorstv acfginorstv fotv aio no fgiotv nor cfgostv o nor fotv ao nor or ino fgiortv fgotv fiortv fiortv fiortv fgiortv fiortv fiortv no or io`,plateau:`cgor cgor cgor cgor cgor cgor cgor cgor cgor no cgor cgor cgor cgor cgor cgor cgor cgor cgor cgor cgor cgor cgnor cgor cgor cgor ao cgor cgor no cgor cgor o cgnor acfginorst fot acfginorstv acfginorstv cgor cgor no cgor cgnor cgor cfgost nor cgor cgor cgnor cgor inor cgor cgor cgor cgor cgor cgor cgor cgor no cgor fot`,principle:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o cgnos o o no o no o o o o o o o o no o o`,product:`fortv fortv fortv fortv fortv fortv fortv cfgortv acgo no fotv fotv fortv fortv fortv fortv acgo fortv fotv cfgortv or fotv nor acgo or acgo o fortv fotv no fortv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv acgo no fotv nor fotv o nor cfgostv acgo nor or no fortv fotv fortv fortv fortv fortv fortv cfgortv no or o`,representation:`o o o o o o o o o no o o o o o o or o o o or o nor or or o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o cgos nor or no o o o o o o o o no or o`,requirement:`o o o o o o o o o no o o o o o o o o o o o o cgnos o o o o o o no o o o nor cgnors o acfginorstv acfginorstv o o no o nor o o nor o o cgnos o no o o o o o o o o no o o`,resource:`o o o o o o o o o no o o o o o o o o o o fiotv o nor o fortv o o o o no o o o nor cfginorstv o acfginorstv acfginorstv o o no o nor o o nor o o nor cfgostv no o o o o o o o o no fiotv o`,stakeholder:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o no o o o no cgnos o acfginorstv acfginorstv o o no o no o o no o o no o cgnos o o o o o o o o no o o`,systemSoftware:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fotv fotv fortv fortv fortv fortv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no cfgiorstv fotv fiortv fiortv fiortv cfgiortv fiortv fiortv no or o`,technologyCollaboration:`fortv fortv fortv fortv fortv fortv fortv fortv aio no fiotv fiotv fiortv fiortv fiortv fiortv ao fiortv fiotv fiortv or fotv nor ao or ao o fgiortv fotv no fgiortv fgiotv o nor acfginorstv io acfginorstv acfginorstv fotv aio no fgiotv nor fotv o nor fotv ao nor or ino fgiortv cfgostv fiortv fiortv fiortv cfgiortv fiortv fiortv no or io`,technologyEvent:`fotv fotv fortv fotv fotv fotv fotv fotv ao no fotv fotv fortv fotv fotv fotv ao fotv fotv fotv o fotv nor ao o ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv cfgostv fotv fotv fotv fotv fotv no o o`,technologyFunction:`fotv fotv fotv fortv fortv fotv fortv fortv ao no fotv fotv fotv fortv fortv fotv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv cfgostv cfgotv fotv cfgotv fortv no or o`,technologyInteraction:`fotv fotv fotv fortv fortv fotv fortv fortv ao no fotv fotv fotv fortv fortv fotv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv cfgotv cfgostv fotv cfgotv fortv no or o`,technologyInterface:`fotv fotv fotv fotv fotv fortv fotv fortv ao no fotv fotv fotv fotv fotv fortv ao fotv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfginorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor or no fotv fotv fotv fotv fotv cfgostv fotv fiotv no or o`,technologyProcess:`fotv fotv fotv fortv fortv fotv fortv fortv ao no fotv fotv fotv fortv fortv fotv ao fortv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv cfgotv cfgotv fotv cfgostv fortv no or o`,technologyService:`fotv fotv fotv fotv fotv fotv fotv fortv ao no fotv fotv fotv fotv fotv fotv ao fotv fotv fortv or fotv nor ao or ao o fotv fotv no fotv fotv o nor acfgnorstv o acfginorstv acfginorstv fotv ao no fotv nor fotv o nor fotv ao nor o no fotv fotv fotv fotv fotv fotv fotv cfgostv no or o`,value:`o o o o o o o o o no o o o o o o o o o o o o no o o o o o o no o o o no cgnos o acfginorstv acfginorstv o o no o no o o no o o no o no o o o o o o o o cgnos o o`,valueStream:`o o o o o o o o o no o o o o o o o o o o fotv o nor o fortv o o o o no o o o nor cfgnorstv o acfginorstv acfginorstv o o no o nor o o nor o o nor fotv no o o o o o o o o no cfgostv o`,workPackage:`or or or or or or or or or no or or or or or or or or or or or or nor or or or aor or or no or or o nor acfgnorst fot acfginorstv acfginorstv or or no or nor or fort nor or or nor or nor or or or or or or or or no or cfgost`},qC=new Map(GC.map((e,t)=>[e,t])),JC=new Map(Object.entries(WC)),YC=new Map;for(let e of GC){let t=KC[e].split(` `);for(let[n,r]of GC.entries()){let i=t[n]??`-`,a=new Set;for(let e of i){let t=JC.get(e);t!==void 0&&a.add(t)}YC.set(`${e}>${r}`,a)}}var XC=new Set,ZC=e=>qC.has(e),QC=(e,t)=>YC.get(`${e}>${t}`)??XC;new Map(k_.map(e=>[e.id,e.aspect])),new Set(GC),new Set(A_);var $C=A_,ew=(e,t,n)=>{let r=e.nodes.find(e=>e.id===t),i=e.nodes.find(e=>e.id===n);if(r===void 0||i===void 0||!ZC(r.coreKindLabel)||!ZC(i.coreKindLabel))return[];let a=[...QC(r.coreKindLabel,i.coreKindLabel)].sort();if(r.portKinds.length===0||i.portKinds.length===0)return a;let o=new Set(i.portKinds),s=a.filter(e=>r.portKinds.includes(e)&&o.has(e));return s.length===0?a:s},tw=(e,t,n,r,i=[])=>{let a=new Set([...e.nodes.map(e=>e.id),...e.edges.map(e=>e.id),...i]),o=`${t}-${n}-${r}`;if(!a.has(o))return o;for(let e=2;;e+=1){let t=`${o}-${e}`;if(!a.has(t))return t}},nw=(e,t,n,r,i=[])=>{if(!ew(e,t,r).includes(n))return null;let a=e.nodes.find(e=>e.id===t);return a===void 0?null:{op:`add-relationship`,document:a.document,relationship:{id:tw(e,t,n,r,i),kind:n,from:t,to:r}}},rw=e=>e.flatMap(e=>{let t=e.op===`rename-concept`||e.op===`rename-relationship`?[e.to]:[];return`relationship`in e?[e.relationship.id,...t]:`concept`in e?[e.concept.id,...t]:t}),iw=(e,t,n,r)=>{let i=new Set(ew(e,t.from,t.to));if(i.size===0)return{options:n,narrowed:!1};let a=new Set($C);return{options:n.filter(e=>i.has(e.coreLabel)||!a.has(e.coreLabel)||e.label===r),narrowed:!0}},aw=[`kind`,`name`,`description`,`status`,`owner`],ow=[`aka`,`constraints`,`references`,`presentIn`,`attestations`,`distinctFrom`,`supersedes`],sw=[`kind`,`from`,`to`,`name`,`description`,`status`,`mode`,`content`],cw=[`references`,`presentIn`],lw=(e,t)=>{if(e===t)return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`)return!1;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>lw(e,t[n]));let n=e,r=t,i=Object.keys(n),a=Object.keys(r);return i.length===a.length&&i.every(e=>lw(n[e],r[e]))},uw=(e,t)=>t===(e??``)?{kind:`none`}:t===``?{kind:`remove`}:{kind:`set`,value:t},dw=(e,t)=>lw(e,t)?{kind:`none`}:t.length>=e.length&&e.every((e,n)=>lw(e,t[n]))?{kind:`append`,added:t.slice(e.length)}:{kind:`replace`,next:t},fw=(e,t,n,r,i)=>r?{op:`update-concept`,document:e,concept:{id:t,[n]:i}}:{op:`update-concept`,document:e,concept:{id:t},remove:[n]},pw=(e,t,n,r)=>r===null?{op:`update-concept`,document:e,concept:{id:t},remove:[n]}:{op:`update-concept`,document:e,concept:{id:t,[n]:r}},mw=(e,t,n,r,i)=>r?{op:`update-relationship`,document:e,relationship:{id:t,[n]:i}}:{op:`update-relationship`,document:e,relationship:{id:t},remove:[n]},hw=(e,t,n,r)=>r===null?{op:`update-relationship`,document:e,relationship:{id:t},remove:[n]}:{op:`update-relationship`,document:e,relationship:{id:t,[n]:r}},gw=(e,t,n,r,i)=>{let a=uw(r,i);return a.kind===`none`?[]:a.kind===`remove`?[fw(e,t,n,!1,``)]:[fw(e,t,n,!0,a.value)]},_w=(e,t,n,r,i)=>{let a=uw(r,i);return a.kind===`none`?[]:a.kind===`remove`?[mw(e,t,n,!1,``)]:[mw(e,t,n,!0,a.value)]},vw=(e,t,n,r,i)=>{let a=dw(r,i);if(a.kind===`none`)return[];if(a.kind===`append`)return a.added.length===0?[]:[pw(e,t,n,a.added)];let o=[pw(e,t,n,null)];return a.next.length>0&&o.push(pw(e,t,n,a.next)),o},yw=(e,t,n,r,i)=>{let a=dw(r,i);if(a.kind===`none`)return[];if(a.kind===`append`)return a.added.length===0?[]:[hw(e,t,n,a.added)];let o=[hw(e,t,n,null)];return a.next.length>0&&o.push(hw(e,t,n,a.next)),o},bw=e=>e.expects===null?{id:e.id,ref:e.ref}:{id:e.id,ref:e.ref,expects:e.expects},xw=(e,t,n,r)=>{let i=dw(n,r);if(i.kind===`none`)return[];if(i.kind===`append`)return i.added.length===0?[]:[pw(e,t,`constraints`,i.added.map(bw))];let a=[pw(e,t,`constraints`,null)];return i.next.length>0&&a.push(pw(e,t,`constraints`,i.next.map(bw))),a},Sw=e=>({topic:e.topic,by:e.by,recordedBy:e.recordedBy??``,on:e.on}),Cw=(e,t,n,r)=>{let i=dw(n,r);if(i.kind===`none`)return[];if(i.kind===`append`)return i.added.length===0?[]:[pw(e,t,`attestations`,i.added.map(Sw))];let a=[pw(e,t,`attestations`,null)];return i.next.length>0&&a.push(pw(e,t,`attestations`,i.next.map(Sw))),a},ww=(e,t)=>{let n={...e},r=t.concept;for(let e of aw)r[e]!==void 0&&(n[e]=r[e]);for(let e of ow){let t=r[e];t!==void 0&&t.length>0&&(n[e]=[...n[e],...t])}for(let e of t.remove??[])n[e]=ow.includes(e)?[]:null;return n},Tw=(e,t)=>{let n=e;for(let r of t)r.op===`update-concept`&&r.document===e.document&&r.concept.id===e.localId&&(n=ww(n,r));return n},Ew=(e,t)=>{let n={...e},r=t.relationship;for(let e of sw)r[e]!==void 0&&(n[e]=r[e]);for(let e of cw){let t=r[e];t!==void 0&&t.length>0&&(n[e]=[...n[e],...t])}for(let e of t.remove??[])n[e]=cw.includes(e)?[]:null;return n},Dw=(e,t)=>{let n=e;for(let r of t)r.op===`update-relationship`&&r.document===e.document&&r.relationship.id===e.localId&&(n=Ew(n,r));return n},Ow=e=>`subject-${e.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}`,kw=({label:e,value:t,options:n,onCommit:r})=>(0,$.jsxs)(`label`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,$.jsx)(`select`,{name:Ow(e),value:t,onChange:e=>r(e.target.value),children:n.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),Aw=({label:e,value:t,onCommit:n})=>{let[r,i]=(0,y.useState)(t);return(0,y.useEffect)(()=>i(t),[t]),(0,$.jsxs)(`label`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,$.jsx)(`input`,{type:`text`,name:Ow(e),value:r,onChange:e=>i(e.target.value),onBlur:()=>n(r)})]})},jw=({label:e,values:t,emptyRow:n,isRowFilled:r,renderRow:i,onCommit:a})=>{let[o,s]=(0,y.useState)(t);(0,y.useEffect)(()=>s(t),[t]);let c=e=>{s(e),a(e.filter(r))};return(0,$.jsxs)(`div`,{className:`subject-form-field subject-form-list`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,$.jsxs)(`div`,{className:`subject-form-list-body`,children:[o.map((e,t)=>(0,$.jsxs)(`div`,{className:`subject-form-row`,children:[i(e,{set:e=>s(o.map((n,r)=>r===t?e:n)),commit:()=>c(o),replace:e=>c(o.map((n,r)=>r===t?e:n))}),(0,$.jsx)(`button`,{type:`button`,className:`subject-form-row-remove`,onClick:()=>c(o.filter((e,n)=>n!==t)),children:`Remove`})]},t)),(0,$.jsxs)(`button`,{type:`button`,className:`subject-form-row-add`,onClick:()=>s([...o,n]),children:[`Add `,e]})]})]})},Mw=({label:e,values:t,onCommit:n})=>(0,$.jsx)(jw,{label:e,values:t,emptyRow:``,isRowFilled:e=>e.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n})=>(0,$.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),onBlur:n})}),Nw={id:``,ref:``},Pw=({label:e,values:t,onCommit:n})=>(0,$.jsx)(jw,{label:e,values:t,emptyRow:Nw,isRowFilled:e=>e.id.trim()!==``&&e.ref.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n})=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`input`,{type:`text`,placeholder:`id`,value:e.id,onChange:n=>t({...e,id:n.target.value}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`ref`,value:e.ref,onChange:n=>t({...e,ref:n.target.value}),onBlur:n})]})}),Fw={id:``,ref:``,expects:null},Iw=({label:e,values:t,onCommit:n})=>(0,$.jsx)(jw,{label:e,values:t,emptyRow:Fw,isRowFilled:e=>e.id.trim()!==``&&e.ref.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n,replace:r})=>(0,$.jsxs)(`div`,{className:`subject-form-row-body`,children:[(0,$.jsx)(`input`,{type:`text`,placeholder:`id`,value:e.id,onChange:n=>t({...e,id:n.target.value}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`ref`,value:e.ref,onChange:n=>t({...e,ref:n.target.value}),onBlur:n}),(0,$.jsxs)(`label`,{className:`subject-form-toggle`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.expects!==null,onChange:t=>r({...e,expects:t.target.checked?{provider:``,key:``,value:``}:null})}),`Expects`]}),e.expects===null?null:(0,$.jsxs)(`div`,{className:`subject-form-row-body`,children:[(0,$.jsx)(`input`,{type:`text`,placeholder:`provider`,value:e.expects.provider,onChange:n=>e.expects!==null&&t({...e,expects:{...e.expects,provider:n.target.value}}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`key`,value:e.expects.key,onChange:n=>e.expects!==null&&t({...e,expects:{...e.expects,key:n.target.value}}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`value`,value:e.expects.value,onChange:n=>e.expects!==null&&t({...e,expects:{...e.expects,value:n.target.value}}),onBlur:n})]})]})}),Lw={topic:``,by:``,on:``,recordedBy:null},Rw=({label:e,values:t,onCommit:n})=>(0,$.jsx)(jw,{label:e,values:t,emptyRow:Lw,isRowFilled:e=>e.topic.trim()!==``&&e.by.trim()!==``&&e.on.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n})=>(0,$.jsxs)(`div`,{className:`subject-form-row-body`,children:[(0,$.jsx)(`input`,{type:`text`,placeholder:`topic`,value:e.topic,onChange:n=>t({...e,topic:n.target.value}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`by`,value:e.by,onChange:n=>t({...e,by:n.target.value}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`on`,value:e.on,onChange:n=>t({...e,on:n.target.value}),onBlur:n}),(0,$.jsx)(`input`,{type:`text`,placeholder:`recorded by`,value:e.recordedBy??``,onChange:n=>t({...e,recordedBy:n.target.value}),onBlur:n})]})}),zw={value:``,label:`— unset —`},Bw=[zw,{value:`planned`,label:`planned`},{value:`current`,label:`current`},{value:`retired`,label:`retired`}],Vw=[zw,{value:`read`,label:`read`},{value:`write`,label:`write`},{value:`read-write`,label:`read-write`},{value:`unspecified`,label:`unspecified`}],Hw=(e,t)=>t.find(t=>t.id===e)?.label??HC(e),Uw=(e,t)=>{let n=t.find(t=>t.id===e);return n===void 0?HC(e):UC(n)},Ww=({node:e,model:t,operations:n,onStageChange:r})=>{let i=Tw(e,n),a=e.document,o=e.localId,s=e=>e.forEach(r),c=t.vocabulary.conceptKinds.map(e=>({value:e.label,label:UC(e)})),l=Hw(i.kind,t.vocabulary.conceptKinds);return(0,$.jsxs)(`div`,{className:`subject-form`,children:[(0,$.jsxs)(`div`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,$.jsx)(`code`,{children:e.id})]}),(0,$.jsx)(kw,{label:`Kind`,value:l,options:c,onCommit:e=>s(gw(a,o,`kind`,l,e))}),(0,$.jsx)(Aw,{label:`Name`,value:i.name,onCommit:e=>s(gw(a,o,`name`,i.name,e))}),(0,$.jsx)(Aw,{label:`Description`,value:i.description??``,onCommit:e=>s(gw(a,o,`description`,i.description,e))}),(0,$.jsx)(kw,{label:`Status`,value:i.status??``,options:Bw,onCommit:e=>s(gw(a,o,`status`,i.status,e))}),(0,$.jsx)(Aw,{label:`Owner`,value:i.owner??``,onCommit:e=>s(gw(a,o,`owner`,i.owner,e))}),(0,$.jsx)(Mw,{label:`Aka`,values:i.aka,onCommit:e=>s(vw(a,o,`aka`,i.aka,e))}),(0,$.jsx)(Mw,{label:`Distinct from`,values:i.distinctFrom,onCommit:e=>s(vw(a,o,`distinctFrom`,i.distinctFrom,e))}),(0,$.jsx)(Mw,{label:`Supersedes`,values:i.supersedes,onCommit:e=>s(vw(a,o,`supersedes`,i.supersedes,e))}),(0,$.jsx)(Mw,{label:`Present in`,values:i.presentIn,onCommit:e=>s(vw(a,o,`presentIn`,i.presentIn,e))}),(0,$.jsx)(Pw,{label:`References`,values:i.references,onCommit:e=>s(vw(a,o,`references`,i.references,e))}),(0,$.jsx)(Iw,{label:`Constraints`,values:i.constraints,onCommit:e=>s(xw(a,o,i.constraints,e))}),(0,$.jsx)(Rw,{label:`Attestations`,values:i.attestations,onCommit:e=>s(Cw(a,o,i.attestations,e))})]})},Gw=({label:e,value:t})=>t===``?null:(0,$.jsxs)(`div`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,$.jsx)(`span`,{className:`subject-fact-value`,children:t})]}),Kw=({node:e,model:t})=>(0,$.jsxs)(`div`,{className:`subject-form subject-facts`,children:[(0,$.jsxs)(`div`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,$.jsx)(`code`,{children:e.id})]}),(0,$.jsx)(Gw,{label:`Kind`,value:Uw(e.kind,t.vocabulary.conceptKinds)}),(0,$.jsx)(Gw,{label:`Name`,value:e.name}),(0,$.jsx)(Gw,{label:`Status`,value:e.status??``}),(0,$.jsx)(Gw,{label:`Owner`,value:e.owner??``}),(0,$.jsx)(Gw,{label:`Aka`,value:e.aka.join(`, `)}),(0,$.jsx)(Gw,{label:`Distinct from`,value:e.distinctFrom.join(`, `)}),(0,$.jsx)(Gw,{label:`Supersedes`,value:e.supersedes.join(`, `)}),(0,$.jsx)(Gw,{label:`Present in`,value:e.presentIn.join(`, `)}),(0,$.jsx)(Gw,{label:`References`,value:e.references.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,$.jsx)(Gw,{label:`Constraints`,value:e.constraints.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,$.jsx)(Gw,{label:`Attestations`,value:e.attestations.map(e=>`${e.topic} by ${e.by} on ${e.on}`).join(`; `)})]}),qw=({edge:e,model:t})=>{let n=e=>t.graph.nodes.find(t=>t.id===e)?.name??e;return(0,$.jsxs)(`div`,{className:`subject-form subject-facts`,children:[(0,$.jsxs)(`div`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,$.jsx)(`code`,{children:e.id})]}),(0,$.jsx)(Gw,{label:`Kind`,value:Uw(e.kind,t.vocabulary.relationshipKinds)}),(0,$.jsx)(Gw,{label:`From`,value:n(e.from)}),(0,$.jsx)(Gw,{label:`To`,value:n(e.to)}),(0,$.jsx)(Gw,{label:`Name`,value:e.name??``}),(0,$.jsx)(Gw,{label:`Mode`,value:e.mode??``}),(0,$.jsx)(Gw,{label:`Content`,value:e.content??``}),(0,$.jsx)(Gw,{label:`Status`,value:e.status??``}),(0,$.jsx)(Gw,{label:`References`,value:e.references.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,$.jsx)(Gw,{label:`Present in`,value:e.presentIn.join(`, `)})]})},Jw=({edge:e,model:t,operations:n,onStageChange:r})=>{let i=Dw(e,n),a=e.document,o=e.localId,s=e=>e.forEach(r),c=Hw(i.kind,t.vocabulary.relationshipKinds),l=iw(t.graph,{from:i.from,to:i.to},t.vocabulary.relationshipKinds,c).options.map(e=>({value:e.label,label:UC(e)})),u=t.graph.nodes.map(e=>({value:e.id,label:e.name}));return(0,$.jsxs)(`div`,{className:`subject-form`,children:[(0,$.jsxs)(`div`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,$.jsx)(`code`,{children:e.id})]}),(0,$.jsx)(kw,{label:`Kind`,value:c,options:l,onCommit:e=>s(_w(a,o,`kind`,c,e))}),(0,$.jsx)(kw,{label:`From`,value:i.from,options:u,onCommit:e=>s(_w(a,o,`from`,i.from,e))}),(0,$.jsx)(kw,{label:`To`,value:i.to,options:u,onCommit:e=>s(_w(a,o,`to`,i.to,e))}),(0,$.jsx)(Aw,{label:`Name`,value:i.name??``,onCommit:e=>s(_w(a,o,`name`,i.name,e))}),(0,$.jsx)(Aw,{label:`Description`,value:i.description??``,onCommit:e=>s(_w(a,o,`description`,i.description,e))}),(0,$.jsx)(kw,{label:`Mode`,value:i.mode??``,options:Vw,onCommit:e=>s(_w(a,o,`mode`,i.mode,e))}),(0,$.jsx)(Aw,{label:`Content`,value:i.content??``,onCommit:e=>s(_w(a,o,`content`,i.content,e))}),(0,$.jsx)(kw,{label:`Status`,value:i.status??``,options:Bw,onCommit:e=>s(_w(a,o,`status`,i.status,e))}),(0,$.jsx)(Pw,{label:`References`,values:i.references,onCommit:e=>s(yw(a,o,`references`,i.references,e))}),(0,$.jsx)(Mw,{label:`Present in`,values:i.presentIn,onCommit:e=>s(yw(a,o,`presentIn`,i.presentIn,e))})]})},Yw={realization:{out:`realizes`,in:`realizes it`},influence:{out:`influences`,in:`influences it`},serving:{out:`serves`,in:`serves it`},assignment:{out:`is assigned to`,in:`is assigned to it`},composition:{out:`composes`,in:`it is part of`},aggregation:{out:`aggregates`,in:`it belongs to`},access:{out:`accesses`,in:`accesses it`},flow:{out:`flows to`,in:`flows to it`},triggering:{out:`triggers`,in:`triggers it`},association:{out:`is associated with`,in:`is associated with it`},specialization:{out:`specializes`,in:`specializes it`}},Xw=(e,t)=>{let n=HC(e),r=Yw[n];return r===void 0?t===`incoming`?`${n} to it`:`${n}`:t===`incoming`?r.in:r.out},Zw=(e,t)=>e.map(e=>Xw(e,t)).join(` or `),Qw=e=>{for(let t of e.trigger??[]){let n=$w(t,e);if(n!==null)return n}return null},$w=(e,t)=>{switch(e.condition){case`missing-relationship`:case`missing-linkage`:{let t=e.direction===`incoming`,n=e.kinds,r=t?`incoming`:`outgoing`;return{kind:`connect`,label:t?`Connect what ${Zw(n,r)}…`:`Connect what it ${Zw(n,r)}…`,kinds:n,direction:r}}case`isolated`:return{kind:`connect`,label:`Connect it to something…`,kinds:[],direction:`outgoing`};case`no-subject-of-kind`:{let t=e.kinds[0];if(t===void 0)return null;let n=HC(t);return{kind:`add`,label:`Add ${eT(n)} ${n}…`,subjectKind:n}}case`missing-claim`:case`missing-reference`:case`missing-constraint`:case`missing-attestation`:case`missing-part`:return t.scope===`workspace`?null:{kind:`describe`,label:`Fill it in under properties…`};default:return null}},eT=e=>/^[aeiou]/i.test(e)?`an`:`a`,tT=(e,t)=>{let n=[`A question from the architecture record, asked by yarramate.`,``,`Question: ${e.question}`];t!==null&&n.push(`About: ${t.name} (${t.id})`),e.materiality!==void 0&&n.push(`Why it matters: ${e.materiality}`),e.resolution!==void 0&&n.push(`What closes it: ${e.resolution}`);let r=nT(e,t);return r!==null&&n.push(``,`Answer as a yarramate/operations/v1 document I can apply. The shape the question implies:`,``,r),n.push(``,`If the question does not apply here, say so in one sentence instead.`),n.join(`
|
|
370
|
+
`)},nT=(e,t)=>{let n=e.trigger?.[0];if(n===void 0)return null;let r=`.yarramate/architecture/<document>.yaml`;switch(n.condition){case`no-subject-of-kind`:{let e=n.kinds[0];return e===void 0?null:[`format: yarramate/operations/v1`,`operations:`,` - op: add-concept`,` document: ${r}`,` concept:`,` id: <local-id>`,` kind: ${HC(e)}`,` name: <name>`,` description: <one sentence>`].join(`
|
|
371
|
+
`)}case`missing-relationship`:case`missing-linkage`:{if(t===null)return null;let e=n.kinds[0],i=n.direction===`incoming`;return[`format: yarramate/operations/v1`,`operations:`,` - op: add-relationship`,` document: ${r}`,` relationship:`,` id: <local-id>`,` kind: ${e===void 0?`<kind>`:HC(e)}`,` from: ${i?`<the other subject>`:t.id}`,` to: ${i?t.id:`<the other subject>`}`].join(`
|
|
372
|
+
`)}case`missing-claim`:case`missing-reference`:case`missing-constraint`:case`missing-attestation`:case`missing-part`:return t===null?null:[`format: yarramate/operations/v1`,`operations:`,` - op: update-concept`,` document: ${r}`,` concept:`,` id: ${t.id}`,` <the field the question names>: <value>`].join(`
|
|
373
|
+
`);default:return null}};function rT({overlay:e,selectedId:t,readOnly:n=!1,onVerb:r,onDelegate:i,delegateLabel:a}){let o=t===null?e.workspace:e.subjects[t]??[],s=t===null?`Whole-model questions. Select a subject to see what names it.`:null;return(0,$.jsxs)(`div`,{className:`open-questions`,children:[s===null?null:(0,$.jsx)(`p`,{className:`open-questions-scope`,children:s}),o.length===0?(0,$.jsx)(`p`,{className:`section-empty`,children:t===null?`Nothing open at the whole-model level.`:`No open questions name this subject.`}):(0,$.jsx)(`ul`,{className:`question-list`,children:o.map(e=>(0,$.jsx)(iT,{entry:e,verb:n||r===void 0?null:Qw(e),onVerb:n=>r?.(e,n,t),delegateLabel:n||i===void 0?null:a??`Answer via agent`,onDelegate:()=>i?.(e,t)},e.questionId))}),(0,$.jsxs)(`p`,{className:`open-questions-catalogue`,children:[`Catalogue `,e.catalogue,` · answers land through the changeset, never here.`]})]})}var iT=({entry:e,verb:t,onVerb:n,delegateLabel:r,onDelegate:i})=>(0,$.jsxs)(`li`,{className:`question-row`,children:[(0,$.jsx)(`span`,{className:`question-text`,title:e.materiality,children:e.question}),(0,$.jsxs)(`span`,{className:`question-meta`,children:[(0,$.jsx)(`span`,{className:`question-authority question-authority-${e.authority}`,children:e.authority}),e.since===void 0?null:(0,$.jsxs)(`span`,{className:`question-since`,children:[`since `,e.since]}),t===null?null:(0,$.jsx)(`button`,{type:`button`,className:`question-verb question-verb-${t.kind}`,onClick:()=>n(t),children:t.label}),r===null?null:(0,$.jsx)(`button`,{type:`button`,className:`question-verb question-verb-delegate`,onClick:i,children:r})]})]}),aT={layered:`Layered`,routed:`Routed`,"served-by":`Served-by`,bands:`Layer bands`},oT=[`top-down`,`left-right`],sT={"top-down":`Top-down`,"left-right":`Left-right`};function cT({layout:e,direction:t,onLayoutChange:n,onDirectionChange:r,stylePreset:i,onStyleChange:a}){return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`select`,{className:`canvas-select`,"aria-label":`Layout`,value:e,onChange:e=>n(e.currentTarget.value),children:Pg.map(e=>(0,$.jsx)(`option`,{value:e,children:aT[e]},e))}),(0,$.jsx)(`select`,{className:`canvas-select`,"aria-label":`Direction`,value:t,onChange:e=>r(e.currentTarget.value),children:oT.map(e=>(0,$.jsx)(`option`,{value:e,children:sT[e]},e))}),(0,$.jsx)(`select`,{className:`canvas-select`,"aria-label":`Style`,value:i,onChange:e=>a(e.currentTarget.value),children:Ug.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.title},e.id))})]})}var lT=[`composition`],uT=`top-down`,dT=e=>{let t=e?.trim()??``;return t===``?null:t},fT=e=>({type:`element`,id:e.id,title:e.name,kind:e.kindLabel,description:dT(e.description)}),pT=(e,t)=>{let n=e.from,r=e.to;return{type:`relationship`,id:e.id,sourceId:n,sourceTitle:t.get(n)??n,targetId:r,targetTitle:t.get(r)??r,label:dT(e.name),description:dT(e.description),kind:e.kindLabel}},mT=e=>new Map(e.nodes.map(e=>[e.id,e.name])),hT=(e,t)=>{let n=e.nodes.find(e=>e.id===t);return n===void 0?null:fT(n)},gT=(e,t)=>{let n=e.edges.find(e=>e.id===t);return n===void 0?null:pT(n,mT(e))},_T=(e,t,n,r)=>({select:n=>{let{graph:r}=e();if(r===null)return!1;let i=hT(r,n)??gT(r,n);return i!==null&&(t({type:`subject.selected`,subject:i}),!0)},openDraft:r=>{let{graph:i,readOnly:a}=e();return a||i===null?!1:(n(r?.kind),t({type:`subject.draft.opened`}),!0)},startConnection:n=>{let{graph:r,readOnly:i}=e();return i||r===null||!r.nodes.some(e=>e.id===n)?!1:(t({type:`connection.started`,from:n}),!0)},stagedPins:()=>e().stagedPins,setDecorations:e=>(r(e),!0)}),vT=[`palette`,`properties`,`questions`,`changes`,`chat`],yT=e=>({min:96,max:Math.max(96,e-160)}),bT=(e,t)=>{let{min:n,max:r}=yT(t);return Math.min(r,Math.max(n,e))},xT=.45,ST=(e,t)=>e.length===t.length&&new Set([...e,...t]).size===new Set(e).size,CT=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),wT=e=>{let t=[];return t.push({type:`layout.set`,layout:e?.layout??`served-by`}),t.push({type:`nesting.set`,nesting:e?.nesting??lT}),t.push({type:`fold.set`,mode:e?.fold??`none`,folded:[],unfolded:[]}),t.push({type:`direction.set`,direction:e?.direction??`top-down`}),e?.showLifecycle!==void 0&&t.push({type:`presentation.toggled`,flag:`showLifecycle`,value:e.showLifecycle}),e?.showEvidence!==void 0&&t.push({type:`presentation.toggled`,flag:`showEvidence`,value:e.showEvidence}),e?.showOwnership!==void 0&&t.push({type:`presentation.toggled`,flag:`showOwnership`,value:e.showOwnership}),e?.showKindLabels!==void 0&&t.push({type:`presentation.toggled`,flag:`showKindLabels`,value:e.showKindLabels}),t},TT=(e,t,n,r)=>!r||e===``||e===n?null:t.find(t=>t.id===e)??null,ET=e=>({min:320,max:Math.max(320,Math.min(640,e*xT))}),DT=(e,t)=>{let{min:n,max:r}=ET(t);return Math.min(r,Math.max(n,e))},OT=480,kT=(e,t)=>{let{min:n,max:r}=ET(t);return Math.min(Math.min(r,OT),Math.max(n,e))},AT=(e,t=0)=>({railHidden:!1,conversation:{width:kT(e*.28,e),hidden:!1,unread:0,collapsed:[],changesHeight:200,chatHeight:300},viewportWidth:e,viewportHeight:t,selectedSubject:null,descriptionExpanded:!1,detailsOpen:!1,bottomPanel:{open:!1,tab:`view-query`},tree:{filterText:``,collapsed:[]},connection:null,draftingSubject:!1,pendingDeletion:null,pendingViewDeletion:null,pendingViewRename:null,contextMenu:null,nesting:lT,foldMode:wg,folded:[],unfolded:[],direction:uT,layout:Fg,showLifecycle:!0,showEvidence:!0,showKindLabels:!0,showOwnership:!1,showNudges:!0,stylePreset:Kg()}),jT=(e,t)=>{switch(t.type){case`section.toggled`:{let n=e.conversation.collapsed.includes(t.section);return{...e,conversation:{...e.conversation,collapsed:n?e.conversation.collapsed.filter(e=>e!==t.section):[...e.conversation.collapsed,t.section],unread:t.section===`chat`&&n?0:e.conversation.unread}}}case`section.resized`:{let n=bT(t.height,e.viewportHeight),r=t.section===`chat`?`chatHeight`:`changesHeight`;return e.conversation[r]===n?e:{...e,conversation:{...e.conversation,[r]:n}}}case`conversation.resized`:{if(e.conversation.hidden)return e;let n=DT(t.width,e.viewportWidth);return n===e.conversation.width?e:{...e,conversation:{...e.conversation,width:n}}}case`rail.toggled`:return{...e,railHidden:!e.railHidden};case`conversation.toggled`:{let t=!e.conversation.hidden;return{...e,conversation:{...e.conversation,hidden:t,unread:!t&&!e.conversation.collapsed.includes(`chat`)?0:e.conversation.unread}}}case`viewport.resized`:{let n=DT(e.conversation.width,t.viewportWidth),r=t.viewportHeight??e.viewportHeight,i=bT(e.conversation.changesHeight,r),a=bT(e.conversation.chatHeight,r);return n===e.conversation.width&&i===e.conversation.changesHeight&&a===e.conversation.chatHeight&&t.viewportWidth===e.viewportWidth&&r===e.viewportHeight?e:{...e,conversation:{...e.conversation,width:n,changesHeight:i,chatHeight:a},viewportWidth:t.viewportWidth,viewportHeight:r}}case`attention.received`:return e.conversation.hidden||e.conversation.collapsed.includes(`chat`)?{...e,conversation:{...e.conversation,unread:e.conversation.unread+1}}:e;case`menu.opened`:return{...e,contextMenu:{target:t.target,x:t.x,y:t.y}};case`menu.dismissed`:return e.contextMenu===null?e:{...e,contextMenu:null};case`connection.started`:return{...e,connection:{from:t.from,to:null,...t.kinds===void 0?{}:{kinds:t.kinds},...t.direction===void 0?{}:{direction:t.direction}},draftingSubject:!1,contextMenu:null};case`connection.targeted`:return e.connection===null?e:t.to===e.connection.from?{...e,connection:null}:{...e,connection:{...e.connection,to:t.to}};case`connection.cancelled`:return e.connection===null?e:{...e,connection:null};case`subject.draft.opened`:return{...e,draftingSubject:!0,connection:null,contextMenu:null};case`subject.draft.closed`:return e.draftingSubject?{...e,draftingSubject:!1}:e;case`deletion.asked`:return{...e,pendingDeletion:t.id,connection:null,draftingSubject:!1,contextMenu:null};case`deletion.dismissed`:return e.pendingDeletion===null?e:{...e,pendingDeletion:null};case`viewDeletion.asked`:return{...e,pendingViewDeletion:t.id,contextMenu:null};case`viewDeletion.dismissed`:return e.pendingViewDeletion===null?e:{...e,pendingViewDeletion:null};case`viewRename.asked`:return{...e,pendingViewRename:t.id,contextMenu:null};case`viewRename.dismissed`:return e.pendingViewRename===null?e:{...e,pendingViewRename:null};case`subject.selected`:return{...e,conversation:{...e.conversation,collapsed:e.conversation.collapsed.filter(e=>e!==`properties`)},selectedSubject:t.subject,descriptionExpanded:!1,contextMenu:null};case`subject.cleared`:return e.selectedSubject===null?e:{...e,selectedSubject:null,descriptionExpanded:!1};case`description.toggled`:return e.selectedSubject===null?e:{...e,descriptionExpanded:!e.descriptionExpanded};case`details.toggled`:return{...e,detailsOpen:!e.detailsOpen};case`bottomPanel.toggled`:return{...e,bottomPanel:{...e.bottomPanel,open:!e.bottomPanel.open}};case`bottomPanel.tabSelected`:return e.bottomPanel.open&&e.bottomPanel.tab===t.tab?e:{...e,bottomPanel:{open:!0,tab:t.tab}};case`tree.filtered`:return e.tree.filterText===t.filterText?e:{...e,tree:{...e.tree,filterText:t.filterText}};case`tree.toggled`:{let n=e.tree.collapsed.includes(t.key);return{...e,tree:{...e.tree,collapsed:n?e.tree.collapsed.filter(e=>e!==t.key):[...e.tree.collapsed,t.key]}}}case`nesting.set`:return CT(e.nesting,t.nesting)?e:{...e,nesting:t.nesting};case`fold.set`:return e.foldMode===t.mode&&ST(e.folded,t.folded)&&ST(e.unfolded,t.unfolded)?e:{...e,foldMode:t.mode,folded:t.folded,unfolded:t.unfolded};case`fold.toggled`:{let n=e.folded.includes(t.id)||e.foldMode===`instances`&&!e.unfolded.includes(t.id);return{...e,folded:n?e.folded.filter(e=>e!==t.id):[...e.folded.filter(e=>e!==t.id),t.id],unfolded:n?[...e.unfolded.filter(e=>e!==t.id),t.id]:e.unfolded.filter(e=>e!==t.id)}}case`fold.all`:return t.folded?{...e,folded:[...t.ids],unfolded:[]}:{...e,folded:[],unfolded:[...t.ids]};case`direction.set`:return e.direction===t.direction?e:{...e,direction:t.direction};case`layout.set`:return e.layout===t.layout?e:{...e,layout:t.layout};case`presentation.toggled`:return{...e,[t.flag]:t.value};case`style.set`:return e.stylePreset===t.preset?e:{...e,stylePreset:t.preset};case`model.replaced`:{let n=e.contextMenu===null?e:{...e,contextMenu:null},r=n.selectedSubject;if(r===null)return n;let i=t.graph,a=i===null?null:r.type===`element`?hT(i,r.id):gT(i,r.id);return a===null?{...n,selectedSubject:null,descriptionExpanded:!1}:{...n,selectedSubject:a}}}},MT=(e,t)=>{let n=e.trim();if(t===null)return n;if(t.type===`element`)return`About element “${t.title}” (${t.id}): ${n}`;let r=`${t.sourceTitle} → ${t.targetTitle}`;return`About relationship “${t.label===null?r:`${r} — ${t.label}`}”: ${n}`};function NT({id:e,label:t,meta:n,open:r,onToggle:i,children:a}){return(0,$.jsxs)(`section`,{className:`stack-section stack-section-${e}`,children:[(0,$.jsxs)(`h2`,{className:`section-head`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`section-toggle`,"aria-expanded":r,"aria-controls":`section-${e}`,onClick:i,children:[(0,$.jsx)(`span`,{className:`section-chevron`,"aria-hidden":`true`,children:r?`▾`:`▸`}),(0,$.jsx)(`span`,{className:`section-label`,children:t})]}),n===void 0?null:(0,$.jsx)(`span`,{className:`section-meta`,children:n})]}),(0,$.jsx)(`div`,{className:`section-body`,id:`section-${e}`,hidden:!r,children:a})]})}function PT({label:e,height:t,viewportHeight:n,onResize:r}){let i=yT(n),a=(0,y.useRef)(null),o=e=>{let t=a.current;t?.pointerId===e.pointerId&&r(t.startHeight+t.startY-e.clientY)},s=e=>{a.current={pointerId:e.pointerId,startY:e.clientY,startHeight:t},e.currentTarget.setPointerCapture(e.pointerId)},c=e=>{a.current?.pointerId===e.pointerId&&(a.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,$.jsx)(`div`,{className:`section-splitter`,role:`separator`,"aria-label":e,"aria-orientation":`horizontal`,"aria-valuenow":Math.round(t),"aria-valuemin":i.min,"aria-valuemax":Math.round(i.max),tabIndex:0,onPointerDown:s,onPointerMove:o,onPointerUp:c,onPointerCancel:c,onKeyDown:e=>{if(e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault();let n=e.shiftKey?32:8;r(t+(e.key===`ArrowUp`?n:-n))}})}var FT=(e,t,n)=>vT.filter(t=>e.includes(t)).flatMap((e,r)=>{let i=r===0?void 0:n[e];return[...i===void 0?[]:[(0,$.jsx)(y.Fragment,{children:i},`splitter-${e}`)],(0,$.jsx)(y.Fragment,{children:t[e]},e)]}),IT={messageBytes:65536,modelBytes:5242880,transcriptBytes:5242880,pendingEvents:32,reconnectMs:3e5,staleSessionMs:864e5}.reconnectMs,LT=`Returning control to the main agent`,RT={operations:[],viewOperations:[],sourceDigests:{}},zT=e=>e.operations.length===0&&e.viewOperations.length===0,BT={lifecycle:`connecting`,authority:`canonical`,title:``,description:``,chatEnabled:!1,model:null,styleNonce:``,activeView:``,transcript:[],views:[],choices:null,agentStatus:null,diagnostics:[],handoff:null,composerEnabled:!1,awaitingAgent:!1,localRecords:0,lastSequence:0,frozen:!1,activeFilter:null,focusReturn:null,quickFilterText:``,closedReason:null,pendingChangeset:RT,undoStack:[],redoStack:[],commitStatus:`idle`,commitDiagnostics:null,commitNotice:null,layoutNotice:null},VT=e=>({authority:e.authority,title:e.title,description:e.description,chatEnabled:e.chatEnabled,model:e.model,transcript:e.transcript,agentTurnOpen:e.agentTurnOpen,choices:e.pendingChoice,styleNonce:e.styleNonce,lastSequence:e.lastSequence,frozen:e.frozen,views:e.views}),HT=(e,t)=>t-e<IT,UT=(e,t,n)=>({id:`local-${e.localRecords}`,speaker:t,text:n}),WT=(e,t)=>e.transcript.some(e=>e.id===t.id)?e.transcript:[...e.transcript,t],GT=e=>e.initialView,KT={awaitingAgent:!1,agentStatus:null},qT=e=>{let t=(e,t)=>Object.keys(e).filter(e=>!t.includes(e)).sort().join(`:`);if(`concept`in e){let n=e.concept;return`${e.op}:${e.document}:concept:${n.id}:${t(n,[`id`])}`}if(`relationship`in e){let n=e.relationship;return`${e.op}:${e.document}:relationship:${n.id}:${t(n,[`id`])}`}let n=e.observation,r=`${n.subject??n.claim}:${n.key??``}`;return`${e.op}:${e.document}:observation:${r}:${t(n,[`subject`,`claim`,`key`])}`},JT=(e,t,n,r)=>{let i={},a=(e,t)=>{if(i[e]!==void 0)return;let r=n[e]??t;r!==void 0&&(i[e]=r)};for(let t of e)a(t.document,r?.sourceDigests[t.document]);for(let e of t)a(e.path,r?.projectionDigests[e.path]);return i},YT=(e,t,n)=>{let r=n.operations??e.operations,i=n.viewOperations??e.viewOperations;return{operations:r,viewOperations:i,sourceDigests:JT(r,i,e.sourceDigests,t)}},XT=(e,t)=>{switch(t.type){case`session.loaded`:return{...e,...t.snapshot,lifecycle:e.lifecycle===`ending`?`ending`:`active`,activeView:GT(t.snapshot.model),transcript:[...t.snapshot.transcript,...e.transcript.filter(e=>e.speaker===`session`)],awaitingAgent:t.snapshot.agentTurnOpen,agentStatus:t.snapshot.agentTurnOpen?e.agentStatus:null,lastSequence:Math.max(e.lastSequence,t.snapshot.lastSequence)};case`model.received`:return{...e,model:t.model,views:t.views,diagnostics:[]};case`diagnostic.received`:return{...e,diagnostics:t.diagnostics,...KT};case`chat.sent`:return{...e,transcript:WT(e,UT(e,`reviewer`,t.text)),localRecords:e.localRecords+1,choices:null,awaitingAgent:!0};case`chat.received`:return{...e,transcript:WT(e,{id:t.id,speaker:`agent`,text:t.text}),...KT};case`status.received`:return{...e,agentStatus:t.status};case`choice.presented`:return{...e,choices:t.choice,...KT};case`choice.sent`:{let n=e.choices?.options.find(e=>e.id===t.optionId);return n===void 0?e:{...e,transcript:WT(e,UT(e,`reviewer`,n.label)),localRecords:e.localRecords+1,choices:null,awaitingAgent:!0}}case`view.navigated`:return e.activeView===t.viewId?e:{...e,activeView:t.viewId,focusReturn:null};case`handoff.received`:return{...e,handoff:t.handoff,transcript:WT(e,{id:t.id,speaker:`agent`,text:t.handoff.summary}),...KT};case`event.acknowledged`:return{...e,lastSequence:Math.max(e.lastSequence,t.sequence)};case`input.refused`:{let n=e=>t.refused===void 0||t.refused===e;return{...e,diagnostics:t.diagnostics,frozen:e.frozen||t.frozen,...n(`changeset.commit`)?{commitStatus:`idle`,commitDiagnostics:t.diagnostics}:{},...n(`chat.message`)||n(`choice.selected`)?KT:{}}}case`end.requested`:return{...e,lifecycle:`ending`,choices:null,transcript:WT(e,UT(e,`session`,LT)),localRecords:e.localRecords+1};case`connection.lost`:return{...e,lifecycle:`disconnected`};case`session.closed`:return{...e,lifecycle:`closed`,closedReason:t.reason};case`filter.applied`:return{...e,focusReturn:t.source===`focus`?e.activeFilter?.source===`focus`?e.focusReturn:{activeView:e.activeView,activeFilter:e.activeFilter}:null,activeFilter:{query:t.query,matchedIds:t.matchedIds,excluded:t.excluded,source:t.source},activeView:t.source===`view`||t.source===`editor`?e.activeView:``};case`filter.cleared`:return e.focusReturn===null?{...e,activeFilter:null,activeView:``,focusReturn:null}:{...e,activeFilter:e.focusReturn.activeFilter,activeView:e.focusReturn.activeView,focusReturn:null};case`quickFilter.changed`:return e.quickFilterText===t.text?e:{...e,quickFilterText:t.text};case`changeset.staged`:{let n=qT(t.operation),r=[...e.pendingChangeset.operations.filter(e=>qT(e)!==n),t.operation];return{...e,pendingChangeset:YT(e.pendingChangeset,e.model,{operations:r}),undoStack:[...e.undoStack,e.pendingChangeset],redoStack:[],commitDiagnostics:null,commitNotice:null}}case`changeset.viewStaged`:{let n=e.pendingChangeset.viewOperations.filter(e=>e.path!==t.operation.path);return{...e,pendingChangeset:YT(e.pendingChangeset,e.model,{viewOperations:[...n,t.operation]}),undoStack:[...e.undoStack,e.pendingChangeset],redoStack:[],commitDiagnostics:null,commitNotice:null}}case`changeset.viewMembership`:{let n=e.views.find(({id:e})=>e===t.viewId);if(n===void 0)return e;let r=e.pendingChangeset.viewOperations.find(e=>e.path===n.path),i=TS({id:n.id,title:n.title,description:n.description,query:n.query,presentation:n.presentation}),a=DS(r?.op===`write-view`?r.projection:i,t.subjectId,t.membership);if(a===null)return e;let o=e.pendingChangeset.viewOperations.filter(e=>e.path!==n.path),s=AS(a,i);return{...e,pendingChangeset:YT(e.pendingChangeset,e.model,{viewOperations:s?o:[...o,{op:`write-view`,path:n.path,projection:a}]}),undoStack:[...e.undoStack,e.pendingChangeset],redoStack:[],commitDiagnostics:null,commitNotice:null}}case`changeset.discarded`:{let{index:n}=t,r=e.pendingChangeset.operations.length,i=r+e.pendingChangeset.viewOperations.length;if(n<0||n>=i)return e;let a=n<r?{operations:e.pendingChangeset.operations.filter((e,t)=>t!==n)}:{viewOperations:e.pendingChangeset.viewOperations.filter((e,t)=>t!==n-r)};return{...e,pendingChangeset:YT(e.pendingChangeset,e.model,a),undoStack:[...e.undoStack,e.pendingChangeset],redoStack:[],commitDiagnostics:null}}case`changeset.cleared`:{let t=zT(e.pendingChangeset);return{...e,pendingChangeset:RT,undoStack:t?e.undoStack:[...e.undoStack,e.pendingChangeset],redoStack:t?e.redoStack:[],commitDiagnostics:null}}case`changeset.undone`:{let t=e.undoStack.at(-1);return t===void 0?e:{...e,pendingChangeset:t,undoStack:e.undoStack.slice(0,-1),redoStack:[...e.redoStack,e.pendingChangeset],commitDiagnostics:null}}case`changeset.redone`:{let t=e.redoStack.at(-1);return t===void 0?e:{...e,pendingChangeset:t,redoStack:e.redoStack.slice(0,-1),undoStack:[...e.undoStack,e.pendingChangeset],commitDiagnostics:null}}case`changeset.commit.sent`:return{...e,commitStatus:`committing`,commitDiagnostics:null};case`changeset.committed`:return{...e,pendingChangeset:RT,undoStack:[],redoStack:[],commitStatus:`idle`,commitDiagnostics:null,commitNotice:t.documents};case`apply.failed`:return{...e,commitStatus:`idle`,commitDiagnostics:t.diagnostics};case`layout.saved`:{let n=t.result.ok?`Layout saved`:t.result.message;return{...e,layoutNotice:n}}}},ZT=e=>e.lifecycle===`active`&&e.chatEnabled&&!e.frozen&&!e.awaitingAgent;function QT(e,t){if(e.lifecycle===`closed`)return e;let n=XT(e,t);return n===e?e:{...n,composerEnabled:ZT(n)}}var $T=(e,t)=>{let n=t.lastSequence;switch(e.kind){case`chat`:return{type:`chat.message`,lastAcknowledgedSequence:n,payload:{text:e.text}};case`choice`:return{type:`choice.selected`,lastAcknowledgedSequence:n,payload:{choiceId:e.choiceId,optionId:e.optionId}};case`navigate`:return{type:`view.navigate`,lastAcknowledgedSequence:n,payload:{viewId:e.viewId,requiresAttention:!1}};case`end`:return{type:`session.end`,lastAcknowledgedSequence:n,payload:{reason:`user-ended`}};case`delegate`:return{type:`question.delegate`,lastAcknowledgedSequence:n,payload:e.payload};case`filter`:return{type:`filter.query`,lastAcknowledgedSequence:n,payload:{query:e.query,...e.nesting===void 0?{}:{nesting:e.nesting}}};case`commit-changeset`:return{type:`changeset.commit`,lastAcknowledgedSequence:n,payload:t.pendingChangeset};case`save-layout`:return{type:`layout.save`,lastAcknowledgedSequence:n,payload:e.payload}}},eE=e=>{if(e.focusReturn===null)return;let t=e.focusReturn.activeView;return e.views.find(({id:e})=>e===t)?.title},tE=e=>{let t=e.views.find(({id:t})=>t===e.activeView);if(t===void 0)return null;let n=e.pendingChangeset.viewOperations.find(e=>e.path===t.path),r=n?.op===`write-view`?n.projection.query:t.query;return ES(r)?{kind:`enumerated`,subjects:r.subjects}:{kind:`faceted`,excluded:r.exclude??[]}},nE=(e,t)=>{if(e.kind!==`model`||t.activeFilter===null)return null;let n=t.activeFilter.source===`view`||t.activeFilter.source===`editor`,r=e.views.find(({id:e})=>e===t.activeView);return{query:n&&r!==void 0?r.query:t.activeFilter.query,source:t.activeFilter.source}},rE=(e,t=`panel`)=>{switch(e.kind){case`ready`:return[{type:`session.loaded`,snapshot:VT(e.snapshot)}];case`accepted`:return[{type:`event.acknowledged`,sequence:e.sequence}];case`rejected`:return[{type:`input.refused`,...e.refused===void 0?{}:{refused:e.refused},diagnostics:e.diagnostics,frozen:e.frozen!==void 0}];case`model`:return[{type:`model.received`,model:e.model,views:e.views}];case`closing`:return[{type:`session.closed`,reason:e.reason}];case`filter-result`:return[{type:`filter.applied`,query:e.result.query,matchedIds:e.result.matchedIds,excluded:e.result.excluded,source:t}];case`response`:switch(e.response.type){case`chat.response`:{let t=[{type:`chat.received`,id:e.response.responseId,text:e.response.payload.text}],n=e.response.payload.appliedQuery;return n&&t.push({type:`filter.applied`,query:n.query,matchedIds:n.matchedIds??[],excluded:null,source:`chat`}),t}case`agent.status`:return[{type:`status.received`,status:e.response.payload}];case`choice.present`:return[{type:`choice.presented`,choice:e.response.payload}];case`operations.propose`:return[{type:`chat.received`,id:e.response.responseId,text:e.response.payload.note},...e.response.payload.operations.map(e=>({type:`changeset.staged`,operation:e}))];case`handoff.complete`:return[{type:`handoff.received`,id:e.response.responseId,handoff:e.response.payload}];case`diagnostic`:return[{type:`diagnostic.received`,diagnostics:e.response.payload.diagnostics}]}case`apply-result`:{let t=[];return e.result.ok?t.push({type:`changeset.committed`,documents:e.result.result.documents}):t.push({type:`apply.failed`,diagnostics:e.result.diagnostics}),t}case`layout-save-result`:return[{type:`layout.saved`,result:e.result}]}},iE=e=>{let[t,n]=(0,y.useReducer)(QT,BT),[r,i]=(0,y.useState)(!1),a=(0,y.useRef)(t);a.current=t;let o=(0,y.useRef)(`panel`),s=(0,y.useRef)(e);s.current=e,(0,y.useEffect)(()=>s.current.open({frame:e=>{for(let t of rE(e,o.current))n(t);let t=nE(e,a.current);t!==null&&(o.current=t.source,s.current.send($T({kind:`filter`,query:t.query},a.current)))},connected:i,lost:()=>n({type:`connection.lost`}),session:()=>({lastSequence:a.current.lastSequence,closed:a.current.lifecycle===`closed`})}),[]);let c=(0,y.useCallback)(e=>{s.current.send($T(e,a.current))},[]),l=(0,y.useCallback)(e=>{n({type:`chat.sent`,text:e}),c({kind:`chat`,text:e})},[c]),u=(0,y.useCallback)(e=>{n({type:`chat.sent`,text:`Answer via your agent: ${e.question}`}),c({kind:`delegate`,payload:e})},[c]),d=(0,y.useCallback)(e=>{let t=a.current.choices?.choiceId;t!==void 0&&(n({type:`choice.sent`,optionId:e}),c({kind:`choice`,choiceId:t,optionId:e}))},[c]),f=(0,y.useCallback)(e=>{n({type:`view.navigated`,viewId:e}),c({kind:`navigate`,viewId:e})},[c]),p=(0,y.useCallback)((e,t=`panel`,n)=>{o.current=t,c({kind:`filter`,query:e,...n===void 0?{}:{nesting:n}})},[c]),m=(0,y.useCallback)(()=>{n({type:`filter.cleared`})},[]),h=(0,y.useCallback)(e=>{n({type:`quickFilter.changed`,text:e})},[]),g=(0,y.useCallback)(e=>{n({type:`changeset.staged`,operation:e})},[]);return{state:t,connected:r,ask:l,choose:d,delegate:u,navigate:f,filter:p,clearFilter:m,setQuickFilterText:h,stageViewChange:(0,y.useCallback)(e=>{n({type:`changeset.viewStaged`,operation:e})},[]),stageViewMembership:(0,y.useCallback)((e,t,r)=>{n({type:`changeset.viewMembership`,viewId:e,subjectId:t,membership:r})},[]),stageChange:g,discardChange:(0,y.useCallback)(e=>{n({type:`changeset.discarded`,index:e})},[]),clearChangeset:(0,y.useCallback)(()=>{n({type:`changeset.cleared`})},[]),undoChangeset:(0,y.useCallback)(()=>{n({type:`changeset.undone`})},[]),redoChangeset:(0,y.useCallback)(()=>{n({type:`changeset.redone`})},[]),commitChangeset:(0,y.useCallback)(()=>{zT(a.current.pendingChangeset)||(n({type:`changeset.commit.sent`}),c({kind:`commit-changeset`}))},[c]),saveLayout:(0,y.useCallback)(e=>{c({kind:`save-layout`,payload:e})},[c]),end:(0,y.useCallback)(()=>{n({type:`end.requested`}),c({kind:`end`})},[c])}},aE=(e,t,n,r=8)=>{let i=n.trim().toLowerCase();if(i===``)return{matches:[],more:0};let a=e.nodes.filter(e=>e.id!==t).filter(e=>e.name.toLowerCase().includes(i)||e.id.toLowerCase().includes(i)).map(e=>({id:e.id,name:e.name})).sort((e,t)=>e.name.localeCompare(t.name)||e.id.localeCompare(t.id));return{matches:a.slice(0,r),more:Math.max(0,a.length-r)}},oE=({graph:e,from:t,onTarget:n})=>{let[r,i]=(0,y.useState)(``),{matches:a,more:o}=aE(e,t,r);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`connection-search-label`,htmlFor:`connection-target-search`,children:`Search targets`}),(0,$.jsx)(`input`,{id:`connection-target-search`,className:`connection-search`,type:`search`,autoComplete:`off`,placeholder:`Target name or id`,value:r,onChange:e=>i(e.currentTarget.value)}),r.trim()===``?null:a.length===0?(0,$.jsx)(`p`,{className:`connection-empty`,children:`No subject matches.`}):(0,$.jsxs)(`ul`,{className:`connection-targets`,children:[a.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),children:[e.name,(0,$.jsxs)(`span`,{className:`connection-target-id`,children:[` `,e.id]})]})},e.id)),o===0?null:(0,$.jsxs)(`li`,{className:`connection-targets-more`,children:[o,` more match`]})]})]})},sE=({draft:e,graph:t,reservedIds:n,onTarget:r,onStage:i,onCancel:a})=>{let o=e=>t.nodes.find(t=>t.id===e)?.name??e;if(e.to===null)return(0,$.jsxs)(`section`,{className:`connection-panel`,"aria-label":`Connect subjects`,children:[(0,$.jsxs)(`p`,{className:`connection-prompt`,children:[`Connecting from `,(0,$.jsx)(`strong`,{children:o(e.from)}),`. Choose a target on the diagram, or search for one.`]}),(0,$.jsx)(oE,{graph:t,from:e.from,onTarget:r}),(0,$.jsx)(`button`,{type:`button`,onClick:a,children:`Cancel`})]});let s=e.to,c=e.direction===`incoming`,l=c?s:e.from,u=c?e.from:s,d=ew(t,l,u),f=new Set((e.kinds??[]).map(HC)),p=d.filter(e=>f.has(e)),m=d.filter(e=>!f.has(e)),h=p.length===0?d:p,g=e=>{let r=nw(t,l,e,u,n);r!==null&&i(r),a()};return(0,$.jsxs)(`section`,{className:`connection-panel`,"aria-label":`Connect subjects`,children:[(0,$.jsxs)(`p`,{className:`connection-prompt`,children:[(0,$.jsx)(`strong`,{children:o(l)}),` to`,` `,(0,$.jsx)(`strong`,{children:o(u)})]}),f.size>0&&p.length===0&&d.length>0?(0,$.jsxs)(`p`,{className:`connection-note`,children:[`The question asked for `,[...f].join(` or `),`, which the table does not permit between these two. What it does permit:`]}):null,h.length===0?(0,$.jsx)(`p`,{className:`connection-empty`,children:`No relationship is defined between these kinds. One of them is outside the ArchiMate vocabulary the table covers.`}):(0,$.jsx)(`ul`,{className:`connection-kinds`,children:h.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(e),children:e})},e))}),p.length>0&&m.length>0?(0,$.jsxs)(`details`,{className:`connection-others`,children:[(0,$.jsx)(`summary`,{children:`Other relationships the table permits`}),(0,$.jsx)(`ul`,{className:`connection-kinds`,children:m.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(e),children:e})},e))})]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:a,children:`Cancel`})]})},cE=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,lE=(e,t,n=[])=>{let r=t.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase();if(r===``||!cE.test(r))return null;let i=new Set([...e.nodes.map(e=>e.id),...e.edges.map(e=>e.id),...n]);if(!i.has(r))return r;for(let e=2;;e+=1){let t=`${r}-${e}`;if(!i.has(t))return t}},uE=(e,t,n,r=[])=>{if(t.document===``||!n.includes(t.kind))return null;let i=t.name.trim();if(i===``)return null;let a=lE(e,i,r);return a===null?null:{op:`add-concept`,document:t.document,concept:{id:a,kind:t.kind,name:i}}},dE=(e,t,n,r=[])=>{if(t.document===``)return null;let i=t.name.trim();if(i===``)return null;let a=new Set(r),o=[],s={};for(let r of t.slots){let i=n.get(r.name)??null;if(i===null){if(r.required)return null;continue}if(i.mode===`existing`){if(i.subject===``)return null;s[r.name]=i.subject;continue}if(!r.admits.includes(i.kind))return null;let c=i.name.trim();if(c===``)return null;let l=lE(e,c,a);if(l===null)return null;a.add(l),o.push({op:`add-concept`,document:t.document,concept:{id:l,kind:i.kind,name:c}}),s[r.name]=l}let c=lE(e,i,a);return c===null?null:[...o,{op:`add-concept`,document:t.document,concept:{id:c,kind:t.kind,name:i,...Object.keys(s).length===0?{}:{parts:s}}}]},fE=(e,t,n,r=[])=>{if(n===null||t.document===``||t.slot===``)return null;if(n.mode===`existing`)return n.subject===``?null:[{op:`update-concept`,document:t.document,concept:{id:t.instance,parts:{[t.slot]:n.subject}}}];if(!t.admits.includes(n.kind))return null;let i=n.name.trim();if(i===``)return null;let a=lE(e,i,r);return a===null?null:[{op:`add-concept`,document:t.document,concept:{id:a,kind:n.kind,name:i}},{op:`update-concept`,document:t.document,concept:{id:t.instance,parts:{[t.slot]:a}}}]},pE=({graph:e,pattern:t,documents:n,defaultDocument:r,reservedIds:i,onStage:a,onCancel:o})=>{let[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(r),[d,f]=(0,y.useState)(new Map),p=(e,t)=>f(n=>{let r=new Map(n);return t===null?r.delete(e):r.set(e,t),r}),m=t=>e.nodes.filter(e=>t.includes(e.kindLabel)),h=dE(e,{name:s,document:l,kind:t.label,slots:t.slots.map(e=>({name:e.name,required:e.required,admits:e.admits}))},d,i);return(0,$.jsxs)(`section`,{className:`subject-draft instance-draft`,"aria-label":`Add an instance`,children:[(0,$.jsx)(`h3`,{children:t.name??t.label}),(0,$.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`instance-draft-name`,children:[(0,$.jsx)(`span`,{children:`Name`}),(0,$.jsx)(`input`,{id:`instance-draft-name`,value:s,onChange:e=>c(e.target.value)})]}),(0,$.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`instance-draft-document`,children:[(0,$.jsx)(`span`,{children:`Document`}),(0,$.jsx)(`select`,{id:`instance-draft-document`,value:l,onChange:e=>u(e.target.value),children:n.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}),(0,$.jsx)(`ul`,{className:`instance-draft-slots`,children:t.slots.map(e=>{let t=d.get(e.name)??null,n=m(e.admits),r=t===null?``:t.mode===`new`?`__new__`:t.subject;return(0,$.jsxs)(`li`,{className:`instance-draft-slot`,children:[(0,$.jsxs)(`label`,{htmlFor:`instance-slot-${e.name}`,children:[(0,$.jsx)(`span`,{className:`instance-draft-slot-name`,children:e.name}),e.required?(0,$.jsx)(`span`,{className:`instance-draft-required`,children:`required`}):null,e.wiring===`context`?(0,$.jsx)(`span`,{className:`instance-draft-context`,children:`context`}):null]}),(0,$.jsxs)(`select`,{id:`instance-slot-${e.name}`,value:r,onChange:t=>{let n=t.target.value;if(n===``)return p(e.name,null);if(n===`__new__`)return p(e.name,{mode:`new`,name:``,kind:e.admits[0]??``});p(e.name,{mode:`existing`,subject:n})},children:[(0,$.jsx)(`option`,{value:``,children:e.required?`Choose one`:`Leave for later`}),n.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)),(0,$.jsx)(`option`,{value:`__new__`,children:`New…`})]}),t?.mode===`new`?(0,$.jsxs)(`div`,{className:`instance-draft-new`,children:[(0,$.jsx)(`input`,{"aria-label":`New ${e.name} name`,value:t.name,onChange:n=>p(e.name,{...t,name:n.target.value})}),e.admits.length<2?null:(0,$.jsx)(`select`,{"aria-label":`New ${e.name} kind`,value:t.kind,onChange:n=>p(e.name,{...t,kind:n.target.value}),children:e.admits.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}):null]},e.name)})}),t.wiring.length===0?null:(0,$.jsxs)(`div`,{className:`instance-draft-wiring`,children:[(0,$.jsx)(`h4`,{children:`The compiler will mint`}),(0,$.jsx)(`ul`,{children:t.wiring.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`code`,{children:`${e.from} ${e.kind} ${e.to}`})},`${e.from}-${e.kind}-${e.to}`))})]}),(0,$.jsx)(`button`,{type:`button`,disabled:h===null,onClick:()=>{if(h!==null){for(let e of h)a(e);o()}},children:`Add instance`}),(0,$.jsx)(`button`,{type:`button`,onClick:o,children:`Cancel`})]})},mE=({graph:e,kinds:t,documents:n,defaultDocument:r,initialKind:i,reservedIds:a,onStage:o,onCancel:s})=>{let[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(i??``),[f,p]=(0,y.useState)(r),m=c.trim()===``?null:lE(e,c,a),h=m===null?null:uE(e,{name:c,kind:u,document:f},t.map(e=>e.label),a);return(0,$.jsxs)(`section`,{className:`subject-draft-panel`,"aria-label":`Add a subject`,children:[(0,$.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`subject-draft-name`,children:[(0,$.jsx)(`span`,{children:`Name`}),(0,$.jsx)(`input`,{id:`subject-draft-name`,type:`text`,value:c,onChange:e=>l(e.target.value)})]}),(0,$.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`subject-draft-kind`,children:[(0,$.jsx)(`span`,{children:`Kind`}),(0,$.jsxs)(`select`,{id:`subject-draft-kind`,value:u,onChange:e=>d(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`Choose a kind`}),t.map(e=>(0,$.jsx)(`option`,{value:e.label,children:UC(e)},e.id))]})]}),(0,$.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`subject-draft-document`,children:[(0,$.jsx)(`span`,{children:`Document`}),(0,$.jsx)(`select`,{id:`subject-draft-document`,value:f,onChange:e=>p(e.target.value),children:n.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}),(0,$.jsx)(`p`,{className:`subject-draft-id`,children:u===``?`Choose a kind.`:c.trim()===``?`Give it a name.`:m===null?`That name makes no id. An id starts with a letter and is made of letters, digits and hyphens.`:(0,$.jsxs)($.Fragment,{children:[`Id: `,(0,$.jsx)(`code`,{children:m})]})}),(0,$.jsx)(`button`,{type:`button`,disabled:h===null,onClick:()=>{h!==null&&(o(h),s())},children:`Add`}),(0,$.jsx)(`button`,{type:`button`,onClick:s,children:`Cancel`})]})};function hE({title:e,message:t,confirmLabel:n,cancelLabel:r,onConfirm:i,onCancel:a}){return(0,$.jsx)(`div`,{className:`confirm-dialog-backdrop`,role:`presentation`,onClick:a,children:(0,$.jsxs)(`div`,{className:`confirm-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`confirm-dialog-title`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(`h2`,{id:`confirm-dialog-title`,children:e}),(0,$.jsx)(`p`,{children:t}),(0,$.jsxs)(`div`,{className:`confirm-dialog-actions`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:a,children:r}),(0,$.jsx)(`button`,{type:`button`,onClick:i,children:n})]})]})})}function gE({title:e,label:t,initialValue:n,confirmLabel:r,cancelLabel:i,onConfirm:a,onCancel:o}){let[s,c]=(0,y.useState)(n),l=s.trim()===``;return(0,$.jsx)(`div`,{className:`confirm-dialog-backdrop`,role:`presentation`,onClick:o,children:(0,$.jsxs)(`div`,{className:`confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-dialog-title`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(`h2`,{id:`prompt-dialog-title`,children:e}),(0,$.jsxs)(`form`,{className:`prompt-dialog-form`,onSubmit:e=>{e.preventDefault(),!l&&a(s.trim())},children:[(0,$.jsx)(`label`,{htmlFor:`prompt-dialog-value`,children:t}),(0,$.jsx)(`input`,{id:`prompt-dialog-value`,type:`text`,value:s,autoFocus:!0,onChange:e=>c(e.currentTarget.value),onKeyDown:e=>{e.key===`Escape`&&o()}}),(0,$.jsxs)(`div`,{className:`confirm-dialog-actions`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:o,children:i}),(0,$.jsx)(`button`,{type:`submit`,disabled:l,children:r})]})]})]})})}var _E=new Set([`subject.inspect`,`relationship.inspect`,`view.open`,`view.clear`,`subject.focus`,`subject.focus-instance`,`relationship.focus`,`subject.fold`,`subject.unfold`,`subject.unfold-all`,`selection.fold`,`selection.unfold`,`canvas.fold-all`,`canvas.unfold-all`,`view.copy-path`,`canvas.export-png`]),vE=(e,t)=>t.membership===null?[]:[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:[(t.membership.kind===`enumerated`?t.membership.subjects.includes(e):!t.membership.excluded.includes(e))?{key:`view.remove-subject`,label:`Remove from view`,intent:{type:`view.remove-subject`,id:e}}:{key:`view.add-subject`,label:`Add to this view`,intent:{type:`view.add-subject`,id:e}}]}],yE={key:`view.new`,label:`New view…`,intent:{type:`view.new`}},bE={key:`view.new-folder`,label:`New folder…`,intent:{type:`view.new-folder`}},xE={key:`view.clear`,label:`Show all subjects`,intent:{type:`view.clear`}},SE=e=>e.focusReturnLabel===void 0?xE:{key:`view.clear`,label:`Back to ${e.focusReturnLabel}`,intent:{type:`view.clear`}},CE=(e,t)=>({key:`delete`,scope:`model`,label:null,destructive:!0,items:[{key:`delete`,label:t,intent:e}]}),wE=(e,t)=>t.instanceIds?.has(e)===!0?[{key:`focus-instance`,label:`Focus on this instance`,intent:{type:`subject.focus-instance`,id:e}}]:[],TE=(e,t,n)=>[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:[{key:`focus`,label:`Focus on this`,intent:e},...e.type===`subject.focus`?wE(e.id,n):[],...t.flatMap(e=>e.items),...n.filtered?[SE(n)]:[]]}],EE=(e,t)=>{if(t.containerIds?.has(e)!==!0)return[];let n=t.selectedIds??[],r=n.length>1&&n.includes(e),i=t.folded?.has(e)===!0;return[{key:`fold`,scope:`view`,label:`Fold`,destructive:!1,items:r?[{key:`selection-fold`,label:`Fold ${n.length} selected`,intent:{type:`selection.fold`,ids:n}},{key:`selection-unfold`,label:`Unfold ${n.length} selected`,intent:{type:`selection.unfold`,ids:n}}]:i?[{key:`unfold`,label:`Unfold`,intent:{type:`subject.unfold`,id:e}},{key:`unfold-all`,label:`Unfold everything inside`,intent:{type:`subject.unfold-all`,id:e}}]:[{key:`fold`,label:`Fold`,intent:{type:`subject.fold`,id:e}}]}]},DE=(e,t)=>{let n=e.split(/(?<=[.?!])\s/)[0]??e;return n.length<=t?n:`${n.slice(0,t-1).trimEnd()}…`},OE=(e,t,n)=>{if(e.length===0)return[];let r=e[0];return[{key:`questions`,scope:`model`,label:`Questions · ${e.length} open`,destructive:!1,items:[...e.map(e=>({key:`question:${e.questionId}`,label:DE(e.question,72),intent:{type:`question.answer`,questionId:e.questionId,subjectId:t,verb:Qw(e)}})),...n.delegateLabel===void 0?[]:[{key:`question-delegate`,label:`${n.delegateLabel}: ${DE(r.question,40)}`,intent:{type:`question.delegate`,questionId:r.questionId,subjectId:t,question:r.question}}]]}]},kE=(e,t)=>t.graph?.nodes.find(t=>t.id===e)===void 0?[]:[...TE({type:`subject.focus`,id:e},vE(e,t),t),...EE(e,t),...OE(t.questions?.subjects[e]??[],e,t),{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`inspect`,label:`Properties`,intent:{type:`subject.inspect`,id:e}},{key:`connect`,label:`Connect from here…`,intent:{type:`subject.connect`,from:e}}]},CE({type:`subject.delete`,id:e},`Delete from model…`)],AE=(e,t)=>{let n=t.graph,r=n?.edges.find(t=>t.id===e);if(n==null||r===void 0)return[];let i=iw(n,{from:r.from,to:r.to},t.relationshipKinds,r.kindLabel),a=[...TE({type:`relationship.focus`,id:e},[],t),{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`inspect`,label:`Properties`,intent:{type:`relationship.inspect`,id:e}}]}];return i.options.length>1&&a.push({key:`kind`,scope:`model`,label:`Change kind`,destructive:!1,items:i.options.map(t=>({key:`kind:${t.label}`,label:t.label,intent:{type:`relationship.retype`,id:e,kind:t.label},...t.label===r.kindLabel?{current:!0}:{}}))}),a.push(CE({type:`relationship.delete`,id:e},`Delete from model…`)),a},jE=e=>e.graph===null?[]:[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:[yE,bE,...e.filtered?[xE]:[],{key:`canvas.export-png`,label:`Export PNG`,intent:{type:`canvas.export-png`}},...e.containerIds!==void 0&&e.containerIds.size>0?[{key:`canvas.fold-all`,label:`Fold every instance`,intent:{type:`canvas.fold-all`}},{key:`canvas.unfold-all`,label:`Unfold everything`,intent:{type:`canvas.unfold-all`}}]:[]]},...OE(e.questions?.workspace??[],null,e),{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`add`,label:`Add subject…`,intent:{type:`canvas.draft-subject`}}]}],ME=(e,t)=>{let n=[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:e===``?[xE,yE,bE]:[{key:`view.open`,label:`Open view`,intent:{type:`view.open`,id:e},...e===t.activeViewId?{current:!0}:{}},{key:`view.rename`,label:`Rename…`,intent:{type:`view.rename`,id:e}},{key:`view.duplicate`,label:`Duplicate`,intent:{type:`view.duplicate`,id:e}},{key:`view.new-in-folder`,label:`New view in this folder…`,intent:{type:`view.new-in-folder`,id:e}},yE,bE,{key:`view.copy-path`,label:`Copy projection path`,intent:{type:`view.copy-path`,id:e}}]}];return e!==``&&n.push({key:`delete`,scope:`view`,label:null,destructive:!0,items:[{key:`delete`,label:`Delete view…`,intent:{type:`view.delete`,id:e}}]}),n},NE=(e,t)=>t.graph?.nodes.find(t=>t.id===e)===void 0?[]:[...vE(e,t),...wE(e,t).length===0?[]:[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:wE(e,t)}],...EE(e,t),...OE(t.questions?.subjects[e]??[],e,t),{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`inspect`,label:`Properties`,intent:{type:`subject.inspect`,id:e}}]},CE({type:`subject.delete`,id:e},`Delete from model…`)],PE=(e,t)=>{let n=(()=>{switch(e.kind){case`subject`:return kE(e.id,t);case`relationship`:return AE(e.id,t);case`canvas`:return jE(t);case`view-row`:return ME(e.id,t);case`model-row`:return NE(e.id,t)}})();return t.readOnly===!0?n.flatMap(e=>{let t=e.items.filter(e=>_E.has(e.intent.type));return t.length===0?[]:[{...e,items:t}]}):n},FE=(e,t,n)=>({left:Math.max(0,e.x+t.width<=n.width?e.x:Math.min(e.x-t.width,n.width-t.width)),top:Math.max(0,e.y+t.height<=n.height?e.y:Math.min(e.y-t.height,n.height-t.height))});function IE({groups:e,x:t,y:n,onChoose:r,onDismiss:i}){let a=(0,y.useRef)(null),[o,s]=(0,y.useState)(null);return(0,y.useLayoutEffect)(()=>{let e=a.current;if(e===null)return;let r=e.getBoundingClientRect();s(FE({x:t,y:n},{width:r.width,height:r.height},{width:window.innerWidth,height:window.innerHeight})),e.focus()},[t,n,e]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()},t=e=>{let t=e.target;a.current!==null&&t instanceof Node&&a.current.contains(t)||i()};return window.addEventListener(`keydown`,e),window.addEventListener(`pointerdown`,t,!0),window.addEventListener(`contextmenu`,t,!0),window.addEventListener(`resize`,i),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`contextmenu`,t,!0),window.removeEventListener(`resize`,i)}},[i]),e.length===0?null:(0,$.jsx)(`div`,{ref:a,className:`context-menu`,role:`dialog`,"aria-label":`Actions`,tabIndex:-1,style:o===null?{left:0,top:0,visibility:`hidden`}:{left:`${o.left}px`,top:`${o.top}px`},children:e.map(e=>(0,$.jsxs)(`div`,{className:`context-menu-group context-menu-${e.scope}${e.destructive?` context-menu-destructive`:``}`,role:e.label===null?void 0:`group`,"aria-label":e.label??void 0,children:[e.label===null?null:(0,$.jsx)(`p`,{className:`context-menu-heading`,children:e.label}),(0,$.jsx)(`ul`,{children:e.items.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`context-menu-item`,"aria-current":e.current===!0?`true`:void 0,onClick:()=>r(e.intent),children:[(0,$.jsx)(`span`,{className:`context-menu-tick`,"aria-hidden":!0,children:e.current===!0?`•`:``}),(0,$.jsx)(`span`,{className:`context-menu-label`,children:e.label})]})},e.key))})]},e.key))})}function LE(e,t=[],n=[],r=[]){let i=t.filter(({instance:t})=>t===e),a=n.filter(({instance:t})=>t===e);if(i.length===0&&a.length===0)return null;let o=new Map;for(let t of r){let n=t.op===`update-concept`||t.op===`add-concept`?t.concept:void 0;if(n===void 0)continue;let r=e.slice(e.lastIndexOf(`#`)+1);if(n.id===r||n.id===e)for(let[e,t]of Object.entries(n.parts??{}))typeof t==`string`&&o.set(e,t)}let s=new Map;for(let e of t){let t=s.get(e.member);t===void 0?s.set(e.member,new Set([e.instance])):t.add(e.instance)}let c=(e,t)=>e.slot.localeCompare(t.slot),l=[...[...i].sort(c).map(e=>({slot:e.slot,member:e.member,wiring:e.wiring,required:!1,sharedWith:(s.get(e.member)?.size??1)-1})),...[...a].sort(c).map(e=>{let t=o.get(e.slot);return t===void 0?{slot:e.slot,member:null,wiring:void 0,required:e.required,sharedWith:0}:{slot:e.slot,member:t,wiring:void 0,required:e.required,sharedWith:0,staged:!0}})],u=l.filter(e=>e.staged===!0).length;return{pattern:i[0]?.pattern??a[0]?.pattern??``,rows:l,boundCount:i.length+u,vacantCount:a.length-u}}function RE(e){if(e.member===null)return e.required?`to decide — required`:`to decide`;let t=[];return e.staged===!0&&t.push(`staged`),e.wiring===`context`&&t.push(`context`),e.sharedWith>0&&t.push(e.sharedWith===1?`shared with 1 other`:`shared with ${e.sharedWith} others`),t.length===0?e.member:`${e.member} (${t.join(`, `)})`}var zE=(e,t)=>{let n=[];for(let r of e.nodes)r.id!==t&&(r.owner===t&&n.push({by:r.id,field:`owner`}),r.distinctFrom.includes(t)&&n.push({by:r.id,field:`distinctFrom`}),r.supersedes.includes(t)&&n.push({by:r.id,field:`supersedes`}),r.constraints.some(e=>e.ref===t)&&n.push({by:r.id,field:`constraint`}),r.references.some(e=>e.ref===t)&&n.push({by:r.id,field:`reference`}));return n},BE=(e,t)=>{let n=e.edges.find(e=>e.id===t);if(n!==void 0)return[{op:`delete-relationship`,document:n.document,relationship:{id:n.id}}];let r=e.nodes.find(e=>e.id===t);return r===void 0?[]:[...e.edges.filter(e=>e.from===t||e.to===t).map(e=>({op:`delete-relationship`,document:e.document,relationship:{id:e.id}})),{op:`delete-concept`,document:r.document,concept:{id:r.id}}]},VE=(e,t)=>{let n=e.edges.find(e=>e.id===t);if(n!==void 0)return`Delete the ${n.kindLabel} relationship from "${e.nodes.find(e=>e.id===n.from)?.name??n.from}" to "${e.nodes.find(e=>e.id===n.to)?.name??n.to}"?`;let r=e.nodes.find(e=>e.id===t);if(r===void 0)return null;let i=e.edges.filter(e=>e.from===t||e.to===t).length,a=zE(e,t),o=i===0?`Delete "${r.name}"?`:`Delete "${r.name}" and the ${i} ${i===1?`relationship that names`:`relationships that name`} it?`;if(a.length===0)return o;let s=[...new Set(a.map(t=>e.nodes.find(e=>e.id===t.by)?.name??t.by))],c=s.slice(0,3),l=s.length>c.length?` and others`:``;return`${o} It is still named by ${c.join(`, `)}${l}, so this may be refused.`},HE={reviewer:`You`,agent:`Agent`,session:`Session`},UE={thinking:`Agent is thinking`,compiling:`Agent is compiling the model`,waiting:`Agent is waiting`,idle:`Agent is idle`},WE=(e,t)=>{switch(e.lifecycle){case`connecting`:return`Opening`;case`active`:return t?`Live`:`Reconnecting`;case`ending`:return`Ending`;case`disconnected`:return`Reconnecting`;case`closed`:return`Closed`}},GE=e=>e.lifecycle===`closed`?`Visual conversation ended. Continue in the main agent.`:e.lifecycle===`ending`?e.handoff===null?`Ending conversation — preparing a handoff for the main agent.`:`Handoff ready — returning control to the main agent.`:``,KE=({state:e,connection:t})=>(0,$.jsxs)(`header`,{className:`command-strip`,children:[(0,$.jsxs)(`div`,{className:`command-identity`,children:[(0,$.jsx)(`h1`,{children:e.title===``?`Opening the session`:e.title}),(0,$.jsx)(`span`,{className:`beta-badge`,children:`Beta`}),(0,$.jsx)(`span`,{className:`authority`,children:`Checked YarraMate model`}),(0,$.jsx)(`span`,{className:`connection-state`,role:`status`,children:t})]}),e.description===``?null:(0,$.jsx)(`p`,{className:`session-description`,title:e.description,children:e.description})]}),qE=({choices:e,disabled:t,onChoice:n})=>(0,$.jsxs)(`div`,{className:`choices`,children:[(0,$.jsx)(`p`,{className:`question`,children:e.question}),(0,$.jsx)(`ul`,{children:e.options.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),disabled:t,children:[(0,$.jsx)(`span`,{className:`label`,children:e.label}),e.description===void 0?null:(0,$.jsx)(`span`,{className:`detail`,children:e.description})]})},e.id))})]}),JE=({diagnostics:e})=>e.length===0?null:(0,$.jsxs)(`div`,{className:`faults`,role:`alert`,children:[(0,$.jsx)(`p`,{className:`faults-title`,children:`The workspace did not compile. The diagram still shows the model that did.`}),(0,$.jsx)(`ul`,{children:e.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`span`,{className:`code`,children:e.code}),` `,e.message,(0,$.jsxs)(`span`,{className:`where`,children:[e.path,`:`,e.line]})]},`${e.code}-${e.pointer}`))})]}),YE=({state:e,selectedId:t,waiting:n,layout:r,nesting:i,folded:a,memberships:o,direction:s,onLayoutChange:c,onDirectionChange:l,stylePreset:u,onStyleChange:d,showLifecycle:f,showEvidence:p,showOwnership:m,showKindLabels:h,showNudges:g,openQuestionCounts:_,decorations:v,connection:b,onConnectTarget:x,onConnectCancel:S,onConnectStage:C,onDraftStage:w,draftingSubject:T,draftInitialKind:E,draftPattern:D,onKindDrop:O,onDraftSubject:k,onDraftSubjectClose:A,pendingDeletion:j,onDeletionDismiss:M,onSelect:N,onCanvasMenu:P,onClearFilter:F,onSaveLayout:I,onCanvasReady:L,onQuickFilterChange:R,view:z,bottomPanel:B,onTogglePresentation:V,onToggleBottomPanel:H,onSelectBottomTab:U,onApplyFilter:W,onStageView:G,readOnly:K,paletteReachable:q})=>{let J=(0,y.useMemo)(()=>new Map((e.model?.graph.nodes??[]).map(e=>[e.id,e.name])),[e.model]),ee=e.model?.graph.nodes??[],Y=eE(e),te=e.activeFilter?.matchedIds??null,ne=ee.length>0&&(e.activeFilter!==null||e.quickFilterText.trim()!==``)&&py(ee,te,e.quickFilterText)===0,re=e.activeFilter!==null&&py(ee,te,``)===0;return(0,$.jsxs)(`section`,{className:`diagram-workspace`,"aria-label":`Architecture diagram`,children:[e.activeFilter!==null&&e.activeFilter.source!==`view`&&e.activeFilter.source!==`editor`?(0,$.jsxs)(`div`,{className:`filter-pill`,role:`status`,children:[(0,$.jsxs)(`span`,{children:[`Filtered by `,e.activeFilter.source,`:`,` `,(0,$.jsx)(`code`,{children:EC(e.activeFilter.query)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:F,children:Y===void 0?`Show all`:`Back to ${Y}`})]}):null,(0,$.jsxs)(`div`,{className:`canvas`,children:[e.model===null?null:(0,$.jsxs)(`div`,{className:`canvas-controls`,children:[(0,$.jsx)(tC,{value:e.quickFilterText,onChange:R}),(0,$.jsx)(cT,{layout:r,direction:s,onLayoutChange:c,onDirectionChange:l,stylePreset:u,onStyleChange:d}),K||q?null:(0,$.jsx)(`button`,{type:`button`,className:`subject-draft-open`,onClick:k,children:`Add subject`})]}),!T||e.model===null||D===void 0?null:(0,$.jsx)(pE,{graph:e.model.graph,pattern:D,documents:e.model.documents,reservedIds:rw(e.pendingChangeset.operations),defaultDocument:(t===null?void 0:e.model.graph.nodes.find(e=>e.id===t)?.document)??e.model.documents[0]??``,onStage:w,onCancel:A},`pattern:${D.kind}`),!T||e.model===null||D!==void 0?null:(0,$.jsx)(mE,{initialKind:E,graph:e.model.graph,kinds:e.model.vocabulary.conceptKinds,documents:e.model.documents,reservedIds:rw(e.pendingChangeset.operations),defaultDocument:(t===null?void 0:e.model.graph.nodes.find(e=>e.id===t)?.document)??e.model.documents[0]??``,onStage:w,onCancel:A},E??``),j===null||e.model===null?null:(0,$.jsx)(hE,{title:`Delete`,message:VE(e.model.graph,j)??`That subject is no longer on the diagram.`,confirmLabel:`Delete`,cancelLabel:`Keep`,onConfirm:()=>{for(let t of BE(e.model.graph,j))C(t);M()},onCancel:M}),b===null||e.model===null?null:(0,$.jsx)(sE,{draft:b,graph:e.model.graph,reservedIds:rw(e.pendingChangeset.operations),onTarget:x,onStage:C,onCancel:S}),e.model===null?null:(0,$.jsx)(Oy,{graph:e.model.graph,selectedId:t,onSelect:(t,n)=>{let r=e.model.graph;if(n===`node`){if(b!==null){x(t);return}let e=r.nodes.find(e=>e.id===t);e!==void 0&&N(fT(e))}else{let e=r.edges.find(e=>e.id===t);e!==void 0&&N(pT(e,J))}},onContextMenu:P,matchedIds:e.activeFilter?.matchedIds??null,quickFilterText:e.quickFilterText,nesting:i,folded:a,memberships:o,faultedIds:AC(e.commitDiagnostics??[]),decorations:v,showLifecycle:f,showEvidence:p,showOwnership:m,showNudges:g,openQuestionCounts:_,activeViewId:e.activeView,direction:s,layout:r,showKindLabels:h,stylePreset:u,savedPositions:e.model.layouts[e.activeView],savedRoutes:e.model.routes?.[e.activeView],onSaveLayout:K?()=>void 0:I,onKindDrop:K?void 0:O,onCanvasReady:L}),ne?(0,$.jsx)(`div`,{className:`filter-empty-pill`,role:`status`,children:re&&e.activeFilter!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{children:[`Nothing matches this filter:`,` `,(0,$.jsx)(`code`,{children:EC(e.activeFilter.query)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:F,children:`Show all`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{children:[`Nothing matches “`,e.quickFilterText.trim(),`”`]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>R(``),children:`Clear filter`})]})}):null,e.layoutNotice===null?null:(0,$.jsx)(`div`,{className:`layout-notice-pill`,role:`status`,children:(0,$.jsx)(`span`,{children:e.layoutNotice})}),n===null?null:(0,$.jsx)(`p`,{className:`waiting`,children:n})]}),(0,$.jsx)(eC,{nodes:e.model?.graph.nodes??[],activeFilter:e.activeFilter,view:z,open:B.open,tab:B.tab,showLifecycle:f,showEvidence:p,showOwnership:m,showKindLabels:h,showNudges:g,onTogglePresentation:V,onToggleOpen:H,onSelectTab:U,onApply:W,onStage:G,readOnly:K},e.activeView),(0,$.jsx)(JE,{diagnostics:e.diagnostics})]})},XE=({text:e,expanded:t,onToggle:n})=>{let r=e??`No description declared in this model`,i=(0,y.useRef)(null),[a,o]=(0,y.useState)(!1);return(0,y.useLayoutEffect)(()=>{let e=i.current;if(e===null||t)return;let n=()=>o(e.scrollHeight>e.clientHeight+1);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[r,t]),(0,$.jsxs)(`div`,{className:`subject-description`,children:[(0,$.jsx)(`p`,{ref:i,className:t?`description-expanded`:`description-clamped`,children:r}),a||t?(0,$.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:n,children:t?`Show less`:`Show more`}):null]})},ZE=({subject:e,model:t,operations:n,expanded:r,onToggleDescription:i,onClear:a,onConnect:o,onDelete:s,onStageChange:c,readOnly:l})=>{let u=e.type===`element`?t.graph.nodes.find(t=>t.id===e.id):void 0,d=e.type===`relationship`?t.graph.edges.find(t=>t.id===e.id):void 0;return(0,$.jsxs)(`section`,{className:`subject-inspector`,"aria-labelledby":`subject-heading`,children:[(0,$.jsxs)(`div`,{className:`subject-heading-row`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`subject-type`,children:e.type===`element`?`Selected element`:`Selected relationship`}),(0,$.jsx)(`h2`,{id:`subject-heading`,children:e.type===`element`?e.title:`${e.sourceTitle} → ${e.targetTitle}`})]}),e.type===`element`&&!l?(0,$.jsx)(`button`,{type:`button`,className:`subject-connect`,onClick:()=>o(e.id),children:`Connect`}):null,l?null:(0,$.jsx)(`button`,{type:`button`,className:`subject-delete`,onClick:()=>s(e.id),children:`Delete`}),(0,$.jsx)(`button`,{type:`button`,className:`subject-clear`,onClick:a,children:`Clear`})]}),u===void 0?null:l?(0,$.jsx)(Kw,{node:u,model:t}):(0,$.jsx)(Ww,{node:u,model:t,operations:n,onStageChange:c}),d===void 0?null:l?(0,$.jsx)(qw,{edge:d,model:t}):(0,$.jsx)(Jw,{edge:d,model:t,operations:n,onStageChange:c}),u===void 0?null:(0,$.jsx)($E,{id:u.id,model:t,operations:n,reservedIds:rw(n),onStage:c,readOnly:l}),(0,$.jsx)(XE,{text:e.description,expanded:r,onToggle:i})]})},QE=({graph:e,instance:t,slot:n,document:r,admits:i,reservedIds:a,onStage:o,fallback:s})=>{let[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(``),f=e.nodes.filter(e=>i.includes(e.kindLabel));if(i.length===0)return(0,$.jsx)($.Fragment,{children:s});let p=s=>{let c=fE(e,{instance:t,slot:n,document:r,admits:i},s,a);if(c!==null){for(let e of c)o(e);l(!1),d(``)}};return(0,$.jsxs)(`span`,{className:`subject-slot-filler`,children:[(0,$.jsxs)(`select`,{"aria-label":`Fill ${n}`,value:``,onChange:e=>{let t=e.target.value;if(t!==``){if(t===`__new__`)return l(!0);p({mode:`existing`,subject:t})}},children:[(0,$.jsx)(`option`,{value:``,children:`to decide`}),f.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.name},e.id)),(0,$.jsx)(`option`,{value:`__new__`,children:`New…`})]}),c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`input`,{"aria-label":`New ${n} name`,value:u,onChange:e=>d(e.target.value)}),(0,$.jsx)(`button`,{type:`button`,disabled:u.trim()===``,onClick:()=>p({mode:`new`,name:u,kind:i[0]??``}),children:`Add`})]}):null]})},$E=({id:e,model:t,operations:n,reservedIds:r,onStage:i,readOnly:a})=>{let o=LE(e,t.memberships,t.vacancies,n);if(o===null)return null;let s=t.graph.nodes.find(t=>t.id===e),c=(t.vocabulary.patterns??[]).find(e=>e.kind===s?.kind);return(0,$.jsxs)(`section`,{className:`subject-slots`,"aria-labelledby":`slots-heading`,children:[(0,$.jsxs)(`h3`,{id:`slots-heading`,className:`subject-slots-heading`,children:[`Slots`,(0,$.jsx)(`span`,{className:`tree-count`,children:o.vacantCount===0?`${o.boundCount}`:`${o.boundCount} of ${o.boundCount+o.vacantCount}`})]}),(0,$.jsx)(`dl`,{className:`subject-slots-list`,children:o.rows.map(n=>(0,$.jsxs)(`div`,{className:`subject-slot-row`,children:[(0,$.jsx)(`dt`,{className:`subject-slot-name`,children:n.slot}),(0,$.jsx)(`dd`,{className:n.member===null?`subject-slot-value subject-slot-vacant`:`subject-slot-value`,children:n.member!==null||a||c===void 0||s===void 0?RE(n):(0,$.jsx)(QE,{graph:t.graph,instance:e,slot:n.slot,document:s.document,admits:c.slots.find(e=>e.name===n.slot)?.admits??[],reservedIds:r,onStage:i,fallback:RE(n)})})]},n.slot))})]})},eD=e=>e.lifecycle===`active`?e.awaitingAgent?UE[e.agentStatus?.state??`thinking`]??`working`:`agent idle`:`closed`,tD=({state:e,disabled:t,selectedSubject:n,onSend:r,onChoice:i,onClearSubject:a,onEnd:o})=>{let[s,c]=(0,y.useState)(``),l=e.lifecycle===`active`&&e.awaitingAgent,u=e.lifecycle===`active`?e.agentStatus:null;return(0,$.jsxs)(`div`,{className:`talk`,children:[(0,$.jsxs)(`div`,{className:`conversation-scroll`,children:[(0,$.jsx)(`ol`,{className:`ledger`,role:`log`,"aria-live":`polite`,children:e.transcript.length===0?(0,$.jsx)(`li`,{className:`empty`,children:(0,$.jsx)(`p`,{children:`Nothing asked yet. Question anything on the diagram.`})}):e.transcript.map(e=>(0,$.jsxs)(`li`,{className:`said said-${e.speaker}`,children:[(0,$.jsx)(`p`,{className:`who`,children:HE[e.speaker]}),(0,$.jsx)(`p`,{className:`words`,children:e.text})]},e.id))}),e.choices===null?null:(0,$.jsx)(qE,{choices:e.choices,disabled:t,onChoice:i})]}),(0,$.jsxs)(`form`,{className:`composer`,onSubmit:e=>{e.preventDefault();let n=s.trim();n===``||t||(r(n),c(``))},children:[n===null?null:(0,$.jsxs)(`div`,{className:`subject-chip`,children:[(0,$.jsx)(`span`,{children:n.type===`element`?n.title:`${n.sourceTitle} → ${n.targetTitle}`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Remove selected diagram context`,onClick:a,children:`Remove`})]}),(0,$.jsx)(`label`,{className:`offscreen`,htmlFor:`composer-text`,children:`Ask about this design`}),(0,$.jsx)(`textarea`,{id:`composer-text`,name:`question`,rows:3,value:s,disabled:t,placeholder:e.chatEnabled?n?.type===`element`?`Ask about this element`:n?.type===`relationship`?`Ask about this relationship`:`Ask about this design`:`This session is read-only`,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||(e.preventDefault(),e.currentTarget.form?.requestSubmit())}}),(0,$.jsxs)(`div`,{className:`composer-foot`,children:[(0,$.jsxs)(`p`,{className:`agent-status`,role:`status`,"aria-live":`polite`,"aria-busy":l,children:[l?(0,$.jsx)(`span`,{className:`agent-spinner`,"aria-hidden":`true`}):null,(0,$.jsx)(`span`,{children:u===null?l?`Awaiting agent response`:`\xA0`:UE[u.state]??`\xA0`})]}),(0,$.jsx)(`button`,{type:`submit`,disabled:t||s.trim()===``,children:`Send`})]}),(0,$.jsxs)(`div`,{className:`session-foot`,children:[(0,$.jsx)(`span`,{className:`end-transition-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:GE(e)}),(0,$.jsx)(`button`,{type:`button`,className:`end-session`,onClick:o,disabled:e.lifecycle!==`active`,children:e.lifecycle===`ending`||e.lifecycle===`closed`?`Returning…`:`Return to agent`})]})]})]})},nD=({width:e,viewportWidth:t,onResize:n})=>{let r=ET(t),i=(0,y.useRef)(null),a=e=>{let t=i.current;t?.pointerId===e.pointerId&&n(t.startWidth+t.startX-e.clientX)},o=t=>{i.current={pointerId:t.pointerId,startX:t.clientX,startWidth:e},t.currentTarget.setPointerCapture(t.pointerId)},s=e=>{i.current?.pointerId===e.pointerId&&(i.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,$.jsx)(`div`,{className:`conversation-separator`,role:`separator`,"aria-label":`Resize conversation`,"aria-orientation":`vertical`,"aria-valuemin":r.min,"aria-valuemax":r.max,"aria-valuenow":Math.round(e),tabIndex:0,onPointerDown:o,onPointerMove:a,onPointerUp:s,onPointerCancel:s,onKeyDown:t=>{if(t.key!==`ArrowLeft`&&t.key!==`ArrowRight`)return;t.preventDefault();let r=t.shiftKey?32:8;n(e+(t.key===`ArrowLeft`?r:-r))}})},rD=({host:e,sections:t=vT,readOnly:n=!1,decorations:r,onDelegateQuestion:i,onReady:a})=>{let{state:o,connected:s,ask:c,choose:l,delegate:u,navigate:d,filter:f,clearFilter:p,setQuickFilterText:m,stageViewChange:h,stageViewMembership:g,saveLayout:_,discardChange:v,stageChange:b,clearChangeset:x,undoChangeset:S,redoChangeset:C,commitChangeset:w,end:T}=iE(e),[E,D]=(0,y.useReducer)(jT,{width:window.innerWidth,height:window.innerHeight},({width:e,height:t})=>AT(e,t)),[O,k]=(0,y.useState)(null),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(void 0),[I,L]=(0,y.useState)(void 0),[R,z]=(0,y.useState)(r??{}),B=(0,y.useRef)(null),V=(0,y.useRef)({graph:null,readOnly:n,stagedPins:{}});V.current={graph:o.model?.graph??null,readOnly:n,stagedPins:o.pendingChangeset.sourceDigests},(0,y.useEffect)(()=>{a?.(_T(()=>V.current,D,L,z))},[a]),(0,y.useEffect)(()=>{let e=()=>D({type:`viewport.resized`,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight});return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let H=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(o.activeView===``){H.current=null;return}let e=TT(o.activeView,o.views,H.current,s);if(e!==null){H.current=e.id,f(e.query,`view`,e.presentation?.nesting);for(let t of wT(e.presentation))D(t)}},[o.activeView,o.views,s,f]);let U=(0,y.useRef)({transcriptLength:o.transcript.length,choices:o.choices,diagnostics:o.diagnostics});(0,y.useEffect)(()=>{let e=U.current,t=!1;for(let n=e.transcriptLength;n<o.transcript.length;n+=1)if(o.transcript[n]?.speaker===`agent`){t=!0;break}let n=t||o.choices!==null&&o.choices!==e.choices||o.diagnostics.length>0&&o.diagnostics!==e.diagnostics;U.current={transcriptLength:o.transcript.length,choices:o.choices,diagnostics:o.diagnostics},n&&D({type:`attention.received`})},[o.transcript.length,o.choices,o.diagnostics]);let W=(0,y.useRef)(o.model);(0,y.useEffect)(()=>{o.model!==W.current&&(W.current=o.model,D({type:`model.replaced`,graph:o.model?.graph??null}))},[o.model]);let G=o.model===null?o.lifecycle===`connecting`?`Reading the session`:`No model to draw`:O,K=o.pendingChangeset.operations.length+o.pendingChangeset.viewOperations.length,q=e=>!E.conversation.collapsed.includes(e),J=o.model?.interrogation,ee=(0,y.useMemo)(()=>new Map(Object.entries(J?.subjects??{}).map(([e,t])=>[e,t.length])),[J]),Y=(0,y.useMemo)(()=>{let e=o.model?.graph;if(e===void 0)return{folded:new Set,insideCounts:new Map,insideIds:new Map};let t=Ag({nodes:e.nodes.map(e=>({id:e.id,kind:e.kind,coreKind:e.coreKindLabel})),edges:e.edges,memberships:o.model?.memberships??[],nesting:E.nesting}),n=new Map,r=new Map;for(let e of t.parentOf.keys()){let i=t.parentOf.get(e),a=new Set([e]);for(;i!==void 0&&!a.has(i);){a.add(i),n.set(i,(n.get(i)??0)+1);let o=r.get(i);o===void 0?r.set(i,[e]):o.push(e),i=t.parentOf.get(i)}}let i=new Set;for(let e of n.keys()){let t=E.folded.includes(e),n=E.unfolded.includes(e);(t||E.foldMode===`instances`&&!n)&&i.add(e)}return{folded:i,insideCounts:n,insideIds:r}},[o.model,E.nesting,E.foldMode,E.folded,E.unfolded]),te=Y.folded,ne=n?t.filter(e=>e!==`palette`&&e!==`changes`):t,re=J===void 0?ne.filter(e=>e!==`questions`):ne,ie=E.selectedSubject?.type===`element`?E.selectedSubject.id:null,ae=J===void 0?void 0:ie===null?J.workspace.length:ee.get(ie)??0,oe=o.model?.vocabulary.conceptKinds??[],se=o.model?.vocabulary.patterns,ce=(0,y.useMemo)(()=>new Set(E.tree.collapsed),[E.tree.collapsed]),le=E.conversation.hidden,ue={"--conversation-width":le?`0px`:`${E.conversation.width}px`,"--changes-height":q(`changes`)?`${E.conversation.changesHeight}px`:`auto`,"--chat-height":q(`chat`)?`${E.conversation.chatHeight}px`:`auto`},de=e=>{L(e),D({type:`subject.draft.opened`})},fe=(e,t)=>D({type:`menu.opened`,target:e,x:t.x,y:t.y}),pe=o.views.find(({id:e})=>e===o.activeView)?.title,me=o.chatEnabled?`Answer via agent`:i===void 0?`Copy for my assistant`:`Answer via assistant`,he=E.contextMenu===null?[]:PE(E.contextMenu.target,{graph:o.model?.graph??null,relationshipKinds:o.model?.vocabulary.relationshipKinds??[],activeViewId:o.activeView,filtered:o.activeFilter!==null,membership:tE(o),folded:te,containerIds:new Set(Y.insideCounts.keys()),instanceIds:new Set((o.model?.memberships??[]).map(({instance:e})=>e)),selectedIds:E.selectedSubject===null?[]:[E.selectedSubject.id],...eE(o)===void 0?{}:{focusReturnLabel:eE(o)},readOnly:n,...J===void 0?{}:{questions:J},delegateLabel:me}),ge=(e,t)=>{if(e?.kind===`connect`&&t!==null){D({type:`connection.started`,from:t,kinds:e.kinds,direction:e.direction});return}if(e?.kind===`add`){L(e.subjectKind),D({type:`subject.draft.opened`});return}if(t!==null){let e=o.model?.graph.nodes.find(e=>e.id===t);e!==void 0&&D({type:`subject.selected`,subject:fT(e)})}q(`properties`)||D({type:`section.toggled`,section:`properties`})},_e=(e,t)=>{if(o.chatEnabled){u(e);return}if(i!==void 0){i(e);return}let n=(e.subjectId===null?J?.workspace:J?.subjects[e.subjectId])?.find(t=>t.questionId===e.questionId),r=e.subjectId===null?null:{id:e.subjectId,name:t??e.subjectId};navigator.clipboard?.writeText(tT(n??{questionId:e.questionId,question:e.question,authority:`human`},r))},ve=e=>{let t=o.model?.graph??null;switch(e.type){case`question.answer`:ge(e.verb,e.subjectId);return;case`question.delegate`:{let n=t?.nodes.find(t=>t.id===e.subjectId);_e({questionId:e.questionId,subjectId:e.subjectId,question:e.question},n?.name??null);return}case`subject.inspect`:{let n=t?.nodes.find(t=>t.id===e.id);if(n===void 0)return;D({type:`subject.selected`,subject:fT(n)});return}case`relationship.inspect`:{let n=t?.edges.find(t=>t.id===e.id);if(n===void 0||t===null)return;D({type:`subject.selected`,subject:pT(n,new Map(t.nodes.map(e=>[e.id,e.name])))});return}case`subject.connect`:D({type:`connection.started`,from:e.from});return;case`subject.delete`:case`relationship.delete`:D({type:`deletion.asked`,id:e.id});return;case`relationship.retype`:{let n=t?.edges.find(t=>t.id===e.id);if(n===void 0)return;for(let t of _w(n.document,n.localId,`kind`,n.kindLabel,e.kind))b(t);D({type:`menu.dismissed`});return}case`canvas.draft-subject`:L(void 0),D({type:`subject.draft.opened`});return;case`view.add-subject`:case`view.remove-subject`:g(o.activeView,e.id,e.type===`view.add-subject`?`add`:`remove`),D({type:`menu.dismissed`});return;case`view.open`:d(e.id),D({type:`menu.dismissed`});return;case`view.clear`:p(),D({type:`menu.dismissed`});return;case`subject.fold`:case`subject.unfold`:D({type:`fold.toggled`,id:e.id}),D({type:`menu.dismissed`});return;case`subject.unfold-all`:{let t=Y.insideIds.get(e.id)??[];D({type:`fold.all`,folded:!1,ids:[e.id,...t]}),D({type:`menu.dismissed`});return}case`selection.fold`:case`selection.unfold`:for(let t of e.ids)te.has(t)!==(e.type===`selection.fold`)&&D({type:`fold.toggled`,id:t});D({type:`menu.dismissed`});return;case`canvas.fold-all`:case`canvas.unfold-all`:D({type:`fold.all`,folded:e.type===`canvas.fold-all`,ids:[...Y.insideCounts.keys()]}),D({type:`menu.dismissed`});return;case`subject.focus-instance`:f({instances:[e.id],relationships:`between`},`focus`,E.nesting),D({type:`menu.dismissed`});return;case`subject.focus`:case`relationship.focus`:{let t=o.model?.graph??null;if(t===null){D({type:`menu.dismissed`});return}let n=e.type===`subject.focus`?DC(t,e.id):OC(t,e.id);if(n.length===0){D({type:`menu.dismissed`});return}f({subjects:[...n],relationships:`between`},`focus`,E.nesting),D({type:`menu.dismissed`});return}case`view.new`:F(void 0),j(!0),D({type:`menu.dismissed`});return;case`view.delete`:D({type:`viewDeletion.asked`,id:e.id});return;case`view.rename`:D({type:`viewRename.asked`,id:e.id});return;case`view.new-folder`:N(!0),D({type:`menu.dismissed`});return;case`view.duplicate`:{let t=o.views.find(t=>t.id===e.id);if(t===void 0)return;let n=wS(t,new Set(o.views.map(e=>e.id)));h({op:`write-view`,...n}),D({type:`menu.dismissed`});return}case`view.new-in-folder`:{let t=o.views.find(t=>t.id===e.id);if(t===void 0)return;F(SS(t)),j(!0),D({type:`menu.dismissed`});return}case`view.copy-path`:{let t=o.views.find(t=>t.id===e.id);if(t===void 0)return;navigator.clipboard?.writeText(t.path),D({type:`menu.dismissed`});return}case`canvas.export-png`:{let e=B.current;if(e===null)return;let t=document.createElement(`a`);t.href=e(),t.download=`${o.activeView===``?`all-subjects`:o.activeView}.png`,t.click(),D({type:`menu.dismissed`});return}}},ye=E.pendingViewDeletion===null?null:o.views.find(e=>e.id===E.pendingViewDeletion)??null,be=E.pendingViewRename===null?null:o.views.find(e=>e.id===E.pendingViewRename)??null,xe=[`Show the session panel`,...E.conversation.unread===0?[]:[`${E.conversation.unread} unread`],...o.choices===null?[]:[`the agent is waiting on a choice`]].join(`, `);return(0,$.jsxs)(`main`,{className:`visual-shell`,style:ue,children:[(0,$.jsx)(KE,{state:o,connection:WE(o,s)}),(0,$.jsxs)(`div`,{className:`workspace`,"data-rail":E.railHidden?`hidden`:void 0,children:[E.railHidden?(0,$.jsx)(`button`,{type:`button`,className:`rail-reopen`,title:`Show the view tree`,"aria-label":pe===void 0?`Show the view tree`:`Show the view tree, showing ${pe}`,onClick:()=>D({type:`rail.toggled`}),children:(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`»`})}):(0,$.jsx)(SC,{views:o.views,stagedViewOperations:o.pendingChangeset.viewOperations,activeViewId:o.activeView,nodes:o.model?.graph.nodes??[],folded:te,insideCounts:Y.insideCounts,inViewIds:o.activeFilter===null?null:new Set(o.activeFilter.matchedIds),filterText:E.tree.filterText,collapsed:ce,onFilterChange:e=>D({type:`tree.filtered`,filterText:e}),onToggle:e=>D({type:`tree.toggled`,key:e}),onSelectView:e=>d(e),onClearView:p,onNewView:()=>{F(void 0),j(!0)},onSelectSubject:e=>{let t=o.model?.graph.nodes.find(t=>t.id===e);t!==void 0&&D({type:`subject.selected`,subject:fT(t)})},onRowMenu:(e,t)=>fe(e.kind===`view`?{kind:`view-row`,id:e.id}:{kind:`model-row`,id:e.id},t),readOnly:n,onHide:()=>D({type:`rail.toggled`})}),(0,$.jsx)(YE,{state:o,selectedId:E.selectedSubject?.id??null,waiting:G,layout:E.layout,nesting:E.nesting,folded:te,memberships:o.model?.memberships,direction:E.direction,onLayoutChange:e=>D({type:`layout.set`,layout:e}),onDirectionChange:e=>D({type:`direction.set`,direction:e}),stylePreset:E.stylePreset,onStyleChange:e=>{qg(e),D({type:`style.set`,preset:e})},decorations:R,connection:E.connection,onConnectTarget:e=>D({type:`connection.targeted`,to:e}),onConnectCancel:()=>D({type:`connection.cancelled`}),onConnectStage:b,onDraftStage:e=>{b(e),e.op===`add-concept`&&g(o.activeView,e.concept.id,`add`)},draftingSubject:E.draftingSubject,draftInitialKind:I,draftPattern:(o.model?.vocabulary.patterns??[]).find(e=>e.label===I),onKindDrop:e=>de(e),onDraftSubject:()=>{L(void 0),D({type:`subject.draft.opened`})},onDraftSubjectClose:()=>D({type:`subject.draft.closed`}),pendingDeletion:E.pendingDeletion,onDeletionDismiss:()=>D({type:`deletion.dismissed`}),showLifecycle:E.showLifecycle,showEvidence:E.showEvidence,showOwnership:E.showOwnership,showKindLabels:E.showKindLabels,showNudges:E.showNudges,openQuestionCounts:ee,onSelect:e=>D({type:`subject.selected`,subject:e}),onCanvasMenu:(e,t)=>fe(e.type===`node`?{kind:`subject`,id:e.id??``}:e.type===`edge`?{kind:`relationship`,id:e.id??``}:{kind:`canvas`},t),onClearFilter:p,onSaveLayout:e=>_({...e,folded:[...E.folded],unfolded:[...E.unfolded]}),onCanvasReady:e=>{B.current=e},onQuickFilterChange:m,view:o.views.find(e=>e.id===o.activeView)??null,bottomPanel:E.bottomPanel,onTogglePresentation:(e,t)=>D({type:`presentation.toggled`,flag:e,value:t}),onToggleBottomPanel:()=>D({type:`bottomPanel.toggled`}),onSelectBottomTab:e=>D({type:`bottomPanel.tabSelected`,tab:e}),onApplyFilter:e=>f(e,`editor`,E.nesting),onStageView:h,readOnly:n,paletteReachable:ne.includes(`palette`)}),le?(0,$.jsxs)(`button`,{type:`button`,className:`conversation-reopen`,title:`Show the session panel`,"aria-label":xe,onClick:()=>D({type:`conversation.toggled`}),children:[(0,$.jsx)(`span`,{className:`reopen-chevron`,"aria-hidden":`true`,children:`«`}),E.conversation.unread===0?null:(0,$.jsx)(`span`,{className:`attention-count`,children:E.conversation.unread}),o.choices===null?null:(0,$.jsx)(`span`,{className:`attention-choice`,title:`The agent is waiting on a choice`,children:`?`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(nD,{width:E.conversation.width,viewportWidth:E.viewportWidth,onResize:e=>D({type:`conversation.resized`,width:e})}),(0,$.jsxs)(`aside`,{className:`section-stack`,"aria-label":`Session`,children:[(0,$.jsx)(`div`,{className:`stack-rim`,children:(0,$.jsx)(`button`,{type:`button`,className:`conversation-hide`,title:`Hide the session panel`,"aria-label":`Hide the session panel`,onClick:()=>D({type:`conversation.toggled`}),children:`»`})}),FT(re,{palette:(0,$.jsx)(NT,{id:`palette`,label:`Kind palette`,meta:oe.length===0?void 0:oe.length===1?`1 kind`:`${oe.length} kinds`,open:q(`palette`),onToggle:()=>D({type:`section.toggled`,section:`palette`}),children:oe.length===0?(0,$.jsx)(`p`,{className:`section-empty`,children:`No model yet. The kinds arrive with it.`}):(0,$.jsx)($_,{kinds:oe,patterns:se,onPick:de})}),properties:(0,$.jsx)(NT,{id:`properties`,label:`Element properties`,meta:E.selectedSubject?.id,open:q(`properties`),onToggle:()=>D({type:`section.toggled`,section:`properties`}),children:E.selectedSubject===null||o.model===null?(0,$.jsx)(`p`,{className:`section-empty`,children:`Nothing selected. Pick a subject on the canvas or in the rail.`}):(0,$.jsx)(ZE,{subject:E.selectedSubject,model:o.model,operations:o.pendingChangeset.operations,expanded:E.descriptionExpanded,onToggleDescription:()=>D({type:`description.toggled`}),onClear:()=>D({type:`subject.cleared`}),onConnect:e=>D({type:`connection.started`,from:e}),onDelete:e=>D({type:`deletion.asked`,id:e}),onStageChange:b,readOnly:n})}),questions:(0,$.jsx)(NT,{id:`questions`,label:`Open questions`,meta:ae===void 0?void 0:ae===0?`nothing open`:`${ae} open`,open:q(`questions`),onToggle:()=>D({type:`section.toggled`,section:`questions`}),children:J===void 0?null:(0,$.jsx)(rT,{overlay:J,selectedId:ie,readOnly:n,onVerb:(e,t,n)=>ge(t,n),delegateLabel:me,onDelegate:(e,t)=>_e({questionId:e.questionId,subjectId:t,question:e.question},E.selectedSubject?.type===`element`?E.selectedSubject.title:null)})}),changes:(0,$.jsx)(NT,{id:`changes`,label:`Changes`,meta:K===0?`nothing staged`:`${K} staged`,open:q(`changes`),onToggle:()=>D({type:`section.toggled`,section:`changes`}),children:(0,$.jsx)(VC,{state:o,onDiscardChange:v,onClearChangeset:x,onUndoChangeset:S,onRedoChangeset:C,onCommitChangeset:w})}),chat:(0,$.jsx)(NT,{id:`chat`,label:`Chat`,meta:E.conversation.unread===0?eD(o):(0,$.jsx)(`span`,{className:`attention-count`,children:E.conversation.unread}),open:q(`chat`),onToggle:()=>D({type:`section.toggled`,section:`chat`}),children:(0,$.jsx)(tD,{state:o,disabled:!o.composerEnabled,selectedSubject:E.selectedSubject,onSend:e=>c(MT(e,E.selectedSubject)),onChoice:l,onClearSubject:()=>D({type:`subject.cleared`}),onEnd:T})})},{changes:(0,$.jsx)(PT,{label:`Resize the changes section`,height:E.conversation.changesHeight,viewportHeight:E.viewportHeight,onResize:e=>D({type:`section.resized`,section:`changes`,height:e})}),chat:(0,$.jsx)(PT,{label:`Resize the chat section`,height:E.conversation.chatHeight,viewportHeight:E.viewportHeight,onResize:e=>D({type:`section.resized`,section:`chat`,height:e})})})]})]})]}),E.contextMenu===null?null:(0,$.jsx)(IE,{groups:he,x:E.contextMenu.x,y:E.contextMenu.y,onChoose:ve,onDismiss:()=>D({type:`menu.dismissed`})}),(0,$.jsx)(TC,{views:o.views,activeViewId:o.activeView,query:o.activeFilter?.query??null,layout:E.layout,direction:E.direction,showLifecycle:E.showLifecycle,showEvidence:E.showEvidence,showOwnership:E.showOwnership,showKindLabels:E.showKindLabels,open:A,folder:P,onClose:()=>j(!1),onStage:h}),M?(0,$.jsx)(gE,{title:`New folder`,label:`Folder`,initialValue:``,confirmLabel:`Continue`,cancelLabel:`Cancel`,onConfirm:e=>{N(!1);let t=e.trim();t!==``&&(F(t),j(!0))},onCancel:()=>N(!1)}):null,be===null?null:(0,$.jsx)(gE,{title:`Rename view`,label:`Title`,initialValue:be.title,confirmLabel:`Rename`,cancelLabel:`Cancel`,onConfirm:e=>{h({op:`write-view`,...CS(be,e)}),D({type:`viewRename.dismissed`})},onCancel:()=>D({type:`viewRename.dismissed`})}),ye===null?null:(0,$.jsx)(hE,{title:`Delete view`,message:`Stage the removal of "${ye.title}"? The projection document goes when the changeset is committed; no subject is touched.`,confirmLabel:`Delete`,cancelLabel:`Keep`,onConfirm:()=>{h({op:`delete-view`,path:ye.path}),D({type:`viewDeletion.dismissed`})},onCancel:()=>D({type:`viewDeletion.dismissed`})})]})},iD=`/api/session`,aD=`/socket`,oD=1e3,sD=()=>{let e=null;return{open:t=>{let n=!1,r,i=null,a=()=>{let e=new URL(aD,window.location.href);return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.searchParams.set(`after`,String(t.session().lastSequence)),e},o=()=>{if(!n){if(i??=Date.now(),!HT(i,Date.now())){t.frame({kind:`closing`,reason:`browser-timeout`});return}r=setTimeout(s,oD)}},s=()=>{if(n)return;let r=new WebSocket(a());e=r,r.addEventListener(`open`,()=>{i=null,t.connected(!0)}),r.addEventListener(`message`,e=>{if(typeof e.data==`string`)try{t.frame(JSON.parse(e.data))}catch{}}),r.addEventListener(`close`,()=>{t.connected(!1),e=null,!(n||t.session().closed)&&(t.lost(),o())}),r.addEventListener(`error`,()=>r.close())};return(async()=>{let e=await fetch(iD,{credentials:`same-origin`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(`Session request answered ${e.status}`);let r=await e.json();n||(t.frame({kind:`ready`,snapshot:r}),s())})().catch(()=>{n||(t.lost(),o())}),()=>{n=!0,r!==void 0&&clearTimeout(r),e?.close()}},send:t=>{e!==null&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify(t))}}},cD=document.getElementById(`visual-session`);if(cD===null)throw Error(`The visual session page has no mount point`);jv(Av(()=>new v)),(0,_.createRoot)(cD).render((0,$.jsx)(rD,{host:sD()}));export{l as n,o as t};
|