yarramate 1.40.0 → 1.41.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/dist/adapters/visual-graph-entry.d.ts +1 -0
- package/dist/adapters/visual-graph-entry.js +6 -0
- package/dist/canvas-scene.d.ts +116 -0
- package/dist/canvas-scene.js +175 -0
- package/dist/visual-app/assets/{elk.bundled-CaECCSYs.js → elk.bundled-sPNnidPe.js} +1 -1
- package/dist/visual-app/assets/{index-BOTpBM0s.js → index-B2_ANkAG.js} +28 -28
- package/dist/visual-app/index.html +1 -1
- package/dist/visual-app-lib/editor.js +23906 -23845
- package/dist/visual-app-lib/types/canvas-scene.d.ts +116 -0
- package/package.json +1 -1
|
@@ -326,48 +326,48 @@ 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 ve(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 Qr(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=Et(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 Me(t&&t.style&&t.style.backgroundColor||`white`)}function Ah(e,t){var n=e._private.rscratch;return gn(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`?Qr(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`?Qr(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`?ei():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=ni(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 Na(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`};fe()&&(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]||nn(`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=pr(),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(Cl(e.pstyle(`text-halign`).value)){case`left`:n.x=-t.w-(t.leftPad||0);break;case`right`:n.x=-(t.rightPad||0)}switch(wl(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){Z(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){an("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(Vu.prototype[t])return i(t);Vu.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)}};Z(o,{createEmitter:function(){return this._private.emitter=new lu(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}}),Pc.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(){nn("Renderer does not implement `renderer."+e+"()` on its prototype")}}),r=_}else if(e===`__proto__`||e===`constructor`||e===`prototype`)return nn(e+` is an illegal type to be registered, possibly lead to prototype pollutions`);return Pe({map:cg,keys:[e,t],value:r})}function dg(e,t){return Fe({map:cg,keys:[e,t]})}function fg(e,t,n,r,i){return Pe({map:lg,keys:[e,t,n,r],value:i})}function pg(e,t,n,r){return Fe({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);nn(`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[he(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.3`,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 rn(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,t){let n=e>9?`9+`:String(e),r=n.length>1?6.5:8;return m_((t?`<circle cx="6" cy="6" r="5.5" fill="none" stroke="${s_}" stroke-width="1"/>`:``)+`<circle cx="6" cy="6" r="${t?4.5:5}" fill="${u_}"/><text x="6" y="7.5" font-size="${r}" font-weight="bold" fill="#ffffff" text-anchor="middle" dominant-baseline="middle">${n}</text>`)}function C_(e,t=!1){return p_(S_(e,t))}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={"yarramate/policy@0.2#responsible":`is responsible for`,"yarramate/policy@0.2#consulted":`is consulted on`,"yarramate/policy@0.2#informed":`is informed of`},sv={serving:`served by`,realization:`realized by`,specialization:`specialized by`},cv=e=>e.slice(e.indexOf(`#`)+1).replaceAll(/([a-z0-9])([A-Z])/g,`$1 $2`).replaceAll(`-`,` `).toLowerCase(),lv=(e,t=!1)=>(t?sv[e]:void 0)??ov[e]??av[e]??cv(e),uv=(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=e.readingKind,o=e.reading!==void 0&&e.reading!==``?e.reading:a!==void 0&&a!==r?lv(a):i!==r&&i!==``?cv(i):lv(r,Lg(t)&&zg.has(r)),s=typeof e.liftedCount==`number`?e.liftedCount:0;return s>1?`${o} ×${s}`:o},dv=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),fv=function(e,t){return new URL(e,t).href},pv={},mv=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=fv(t,n),t=s(t),t in pv)return;pv[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`:dv,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}`)))})}).filter(e=>e!==void 0))}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)})},hv=2.5,gv={"top-down":`DOWN`,"left-right":`RIGHT`},_v={"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]`},vv=e=>Ig(e)?{..._v,"elk.spacing.edgeEdge":`60`}:{..._v},yv=(e,t)=>({"elk.algorithm":`layered`,"elk.direction":gv[e],"elk.layered.nodePlacement.strategy":`NETWORK_SIMPLEX`,"elk.aspectRatio":String(hv),...vv(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`}:{}}),bv=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 xv(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=vv(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=uv(e.data(),r,i);t!==``&&(c.labels=[{text:t,...bv(t)}])}p.push(c)}),{graph:{id:`root`,layoutOptions:yv(n,r),children:c.map(d),edges:p},reversed:f}}var Sv=(e,t)=>[e.startPoint,...e.bendPoints??[],e.endPoint].map(e=>({x:e.x+t.x,y:e.y+t.y})),Cv=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},wv=(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 Tv(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=Sv(o,i),c=null,l=r.labels?.[0];if(l!==void 0&&l.x!==void 0&&l.y!==void 0&&(c=wv(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=Cv(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 Ev=e=>e.default??e,Dv=Ev(iv.default),Ov,kv=()=>Ov??=mv(()=>import(`./elk.bundled-CaECCSYs.js`).then(e=>c(e.default,1)).then(e=>new(Ev(e))),[],import.meta.url),Av;function jv(e){let t=new Dv({workerFactory:()=>e()});return{layout:e=>t.layout(e),terminate:()=>t.terminateWorker?.()}}function Mv(e){Av=e}var Nv=async e=>(Av??await kv()).layout(e),Pv=[`curve-style`,`edge-distances`,`source-endpoint`,`target-endpoint`,`segment-weights`,`segment-distances`,`source-text-offset`],Fv=e=>`${Math.round(e*10)/10}px`;function Iv(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":`${Fv(i.x-t.x)} ${Fv(i.y-t.y)}`,"target-endpoint":`${Fv(a.x-n.x)} ${Fv(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 Lv=1e-6;function Rv(e,t){if(e.isParent()){let n=e.descendants().filter(e=>!e.isParent());return n.length>0&&n.every(e=>Rv(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)<Lv&&Math.abs(r.y-n.y)<Lv}function zv(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(Iv(a.points,t.source().position(),t.target().position(),a.labelAt)),t.scratch(Vv,a),t.addClass(`routed`),r+=1)}}finally{e.endBatch()}return r}function Bv(e){e.removeClass(`routed`),e.removeStyle(Pv.join(` `)),e.removeScratch(Vv)}var Vv=`_route`;function Hv(e){let t={};return e.forEach(e=>{if(!e.hasClass(`routed`))return;let n=e.scratch(Vv);n!==void 0&&(t[e.id()]={points:n.points.map(e=>({x:e.x,y:e.y})),labelAt:n.labelAt})}),t}function Uv(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 zv(e,r,e=>!e.hasClass(`routed`)&&Rv(e.source(),r)&&Rv(e.target(),r))}function Wv(e){let t=e=>{let t=e.target;Bv(t.union(t.ancestors()).union(t.descendants()).connectedEdges(`.routed`))};return e.on(`dragfree`,`node`,t),()=>{e.off(`dragfree`,`node`,t)}}var Gv=`#F0F0F0`,Kv=`#999999`,qv=170,Jv=50,Yv=150,Xv=``;function Zv(e){return e.replace(/([/._-])/g,`$1${Xv}`)}var Qv=20,$v=1.25,ey=.02,ty=10;function ny(e,t){let n=t===1?e*$v:e/$v;return Math.min(ty,Math.max(ey,n))}var ry=12;function iy(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:ry}),n&&e.data(`hasAttestations`)===!0&&o.push({image:__,positionX:`0%`,positionY:`100%`,size:ry});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:ry});let f=e.data(`openQuestions`);return i&&typeof f==`number`&&f>0&&o.push({image:C_(f,e.data(`nextQuestion`)===!0),positionX:d?`84%`:`96%`,positionY:d?`100%`:`88%`,size:ry}),o}var ay=[`added`,`removed`,`changed`],oy=e=>`deco-${e}`,sy=ay.map(oy).join(` `),cy={added:`#416F65`,removed:`#677074`,changed:`#8C4D18`};function ly(e,t){e.elements().removeClass(sy);for(let[n,r]of Object.entries(t)){let t=e.getElementById(n);t.nonempty()&&t.addClass(oy(r))}}function uy(e,t,n,r,i=!0,a=Fg,o=Wg){let s=Jg(o).glyph,c=e=>Zv(uv(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=iy(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":Gv,"border-color":Kv,"border-width":2,shape:`roundrectangle`,width:qv,height:Jv,padding:`8px`,label:`data(wrapLabel)`,"font-size":12,"text-wrap":`wrap`,"text-max-width":`${Yv}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`]=[Kv,Gv],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":cy.added,"border-width":3,"line-color":cy.added,"target-arrow-color":cy.added}},{selector:`node.deco-removed, edge.deco-removed`,style:{"border-color":cy.removed,"border-width":3,"border-style":`dashed`,"line-color":cy.removed,"target-arrow-color":cy.removed,"line-style":`dashed`}},{selector:`node.deco-changed, edge.deco-changed`,style:{"border-color":cy.changed,"border-width":3,"line-color":cy.changed,"target-arrow-color":cy.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 dy(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=>`${fy(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 fy=e=>e.split(`#`)[1]??e,py=(e,t)=>t>1?`${e} \u00d7${t}`:e;function my(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});dy(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),a=o.get(e.id)??[],c=s.has(e.id);return{data:{id:e.id,label:e.name,wrapLabel:Zv(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:c?[e.id,...a].reduce((e,t)=>e+(n.get(t)??0),0):n.get(e.id)??0,nextQuestion:r?.nextQuestionSubjectId!==void 0&&r.nextQuestionSubjectId!==null&&(c?[e.id,...a].includes(r.nextQuestionSubjectId):e.id===r.nextQuestionSubjectId),insideCount:a.length,insideIds:a,...t===void 0?{}:{parent:t,compositionParent:t}},group:`nodes`,...c?{classes:`folded`}:{}}}),l=e.edges.filter(e=>!a.has(e.id)&&(r?.showResponsibility===!0||(e.responsibility??null)===null)),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:Zv(e.name??e.kindLabel),coreKindLabel:e.coreKindLabel,...e.readingKind===void 0?{}:{readingKind:e.readingKind},...e.responsibility===void 0?{}:{responsibility:e.responsibility},...e.reading===void 0?{}:{reading:e.reading}},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:py(fy(e.kind),e.count),wrapLabel:Zv(fy(e.kind)),name:null,kindLabel:fy(e.kind),coreKindLabel:fy(e.kind),lifted:!0,liftedCount:e.count,relationshipIds:e.relationshipIds},group:`edges`,classes:`lifted`}));return[...c,...f,...p]}function hy(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 gy(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)}e.scratch(_y,t===null?null:vy(t,s));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(Ty(e.elements()).map(e=>e.id())),u=new Set(a);for(let t of e.edges())u.delete(t.id());let d=t===null?null:new Set(t),f=e=>{if(d===null)return!0;let t=e.data(`relationshipIds`);return Array.isArray(t)?t.some(e=>d.has(e)):d.has(e.id())};for(let t of e.edges()){let e=t.data(`source`),n=t.data(`target`);a.has(e)&&a.has(n)&&f(t)&&u.add(t.id())}for(let t of e.edges(`.lifted`)){let e=t.data(`relationshipIds`);if(!Array.isArray(e))continue;let n=e,r=d===null?n.length:n.filter(e=>d.has(e)).length;t.data(`liftedCount`)!==r&&t.data({liftedCount:r,label:py(String(t.data(`kindLabel`)??``),r)})}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 _y=`_viewNodeIds`;function vy(e,t){let n=new Set(e);for(let r of e){let e=t(r);for(;e!==void 0&&!n.has(e);)n.add(e),e=t(e)}return n}function yy(e){return e.scratch(_y)??null}var by=`_layoutGeneration`,xy=`_reservedTop`;function Sy(e,t,n,r,i,a){let o=e.x2-e.x1,s=e.y2-e.y1;if(!(o>0)||!(s>0))return null;let c=Math.max(0,Math.min(i,n)),l=n-c,u=Math.min((t-2*r)/o,(l-2*r)/s),d=Math.max(a.minZoom,Math.min(a.maxZoom,u));return{zoom:d,pan:{x:(t-d*(e.x1+e.x2))/2,y:c+(l-d*(e.y1+e.y2))/2}}}function Cy(e,t,n){let r=e.scratch(xy)??0,i=Sy(t.boundingBox(),e.width(),e.height(),n,r,{minZoom:e.minZoom(),maxZoom:e.maxZoom()});if(i===null){e.fit(t,n);return}e.viewport(i)}async function wy(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=Ty(o),c=s.empty()?o:o.difference(s);Bv(a.edges());let l=(a.scratch(by)??0)+1;a.scratch(by,l);let{graph:u,reversed:d}=xv(c,{direction:t,mode:n,showKindLabels:r}),f=await Nv(u);if(a.destroyed()||a.scratch(by)!==l)return;let p=Tv(f,d);c.layout({name:`preset`,positions:e=>p.nodes.get(e.id())??null,fit:!1,animate:!1}).run(),Cy(a,c,Qv),Ig(n)&&(a.nodes().updateCompoundBounds(!0),zv(a,p,e=>Rv(e.source(),p)&&Rv(e.target(),p)),i?.routes!==void 0&&Uv(a,i.routes,i.positions??{}))}var Ty=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 Ey(e,t,n=Fg,r=!0,i){return wy(e.elements(`:visible`),t,n,r,i)}async function Dy(e,t,n,r,i,a){let o=i===null?null:e.getElementById(i),s=o!==null&&o.nonempty()?{...o.position()}:null;if(await Ey(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?(Cy(e,c,40),!0):!1}function Oy(e){let t=e.elements(`:visible`);return!t.empty()&&(Cy(e,t,Qv),!0)}function ky(e,t=null){let n={};return e.forEach(e=>{if(t!==null&&!t.has(e.id()))return;let{x:r,y:i}=e.position();n[e.id()]={x:r,y:i}}),n}function Ay(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 jy(e,t,n){return n.has(t)?void 0:e}function My(e,t,n){return n.has(t)?void 0:e}function Ny(e,t,n){return e!==void 0&&(n??t).some(t=>e[t]!==void 0)}function Py(e,t,n){return{x:(e.x-t.x)/n,y:(e.y-t.y)/n}}function Fy(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=Hv(e.edges());n({projectionId:i,positions:ky(e.nodes(),yy(e)),...Object.keys(a).length===0?{}:{routes:a}})},500)};return e.on(`dragfree`,`node`,a),{cancelPending:i,dispose:()=>{e.off(`dragfree`,`node`,a),i()}}}function Iy({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,showResponsibility:C,showNudges:w,openQuestionCounts:T,nextQuestionSubjectId:E=null,reservedTop:D=0,folded:O,memberships:k}){let A=(0,y.useRef)(null),j=(0,y.useRef)(null),[M,N]=(0,y.useState)(()=>new Set),P=jy(m,l,M),F=My(h,l,M),I=(0,y.useRef)(n),L=(0,y.useRef)(v);L.current=v;let R=(0,y.useRef)(_);R.current=_;let z=(0,y.useRef)(r),B=(0,y.useRef)(!0),V=(0,y.useRef)(!0),H=(0,y.useRef)(l),U=(0,y.useRef)(u),W=(0,y.useRef)(d),G=(0,y.useRef)(!1),K=(0,y.useRef)(i),q=(0,y.useRef)(a),J=(0,y.useRef)(g),ee=(0,y.useRef)(P),Y=(0,y.useRef)(F),X=(0,y.useRef)(null),te=(0,y.useRef)(null);(0,y.useEffect)(()=>{I.current=n},[n]),(0,y.useEffect)(()=>{z.current=r},[r]),(0,y.useEffect)(()=>{J.current=g},[g]),(0,y.useEffect)(()=>{ee.current=P},[P]),(0,y.useEffect)(()=>{Y.current=F},[F]),(0,y.useEffect)(()=>{X.current?.cancelPending()},[l]),(0,y.useEffect)(()=>{j.current?.scratch(xy,D)},[D]),(0,y.useEffect)(()=>{if(!A.current)return;let t=vg({container:A.current,elements:my(e,o,T,{nextQuestionSubjectId:E,folded:O??new Set,memberships:k,showResponsibility:C}),selectionType:`additive`,boxSelectionEnabled:!0,style:uy(b,x,S,w,f,d,p),wheelSensitivity:.1,layout:{name:`null`}});t.scratch(xy,D),j.current=t,L.current?.(()=>t.png({full:!0,scale:2,bg:`#ffffff`})),t.on(`tap`,`node`,e=>{let t=e.target.id();I.current(t,`node`)}),t.on(`tap`,`edge`,e=>{let t=e.target.id();I.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=>{z.current({type:`node`,id:e.target.id()},n(e))}),t.on(`cxttap`,`edge`,e=>{z.current({type:`edge`,id:e.target.id()},n(e))}),t.on(`cxttap`,e=>{e.target===t&&z.current({type:`canvas`,id:null},n(e))}),X.current=Fy(t,()=>H.current,e=>{N(t=>{if(!t.has(e.projectionId))return t;let n=new Set(t);return n.delete(e.projectionId),n}),J.current(e)});let r=Wv(t),i=()=>{te.current={zoom:t.zoom(),pan:{...t.pan()}}};t.on(`layoutstop`,()=>{Ay(t,ee.current),i()});let a=A.current,s=0,c=new ResizeObserver(()=>{cancelAnimationFrame(s),s=requestAnimationFrame(()=>{t.resize();let e=te.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()||(Cy(t,r,Qv),i())})});return c.observe(a),()=>{cancelAnimationFrame(s),c.disconnect(),r(),X.current?.dispose(),L.current?.(null),t.destroy(),j.current=null}},[]),(0,y.useEffect)(()=>{if(j.current){if(V.current){V.current=!1;return}j.current.style(uy(b,x,S,w,f,d,p))}},[b,x,S,w,f,d,p]),(0,y.useEffect)(()=>{if(j.current){if(B.current)B.current=!1;else{let t=my(e,o,T,{nextQuestionSubjectId:E,folded:O??new Set,memberships:k,showResponsibility:C});j.current.elements().remove(),j.current.add(t)}gy(j.current,K.current,q.current),wy(j.current.elements(`:visible`),u,d,f,{positions:ee.current,routes:Y.current})}},[e,T,E,o,k,C]);let ne=(0,y.useRef)(null);(0,y.useEffect)(()=>{let t=j.current;if(t===null)return;let n=ne.current;if(ne.current=O??new Set,n===null)return;let r=O??new Set,s=[...[...r].filter(e=>!n.has(e)),...[...n].filter(e=>!r.has(e))];s.length!==0&&(t.elements().remove(),t.add(my(e,o,T,{nextQuestionSubjectId:E,folded:r,memberships:k,showResponsibility:C})),gy(t,i,a),Dy(t,u,d,f,s.length===1?s[0]:null,{positions:ee.current,routes:Y.current}))},[O]),(0,y.useEffect)(()=>{if(j.current){j.current.elements().removeClass(`faulted`);for(let e of s){let t=j.current.getElementById(e);t.nonempty()&&t.addClass(`faulted`)}}},[s,e]),(0,y.useEffect)(()=>{j.current&&ly(j.current,c)},[c,e]),(0,y.useEffect)(()=>{if(j.current&&(j.current.elements().removeClass(`selected`),t)){let e=j.current.getElementById(t);e.nonempty()&&e.addClass(`selected`)}},[t,e]),(0,y.useEffect)(()=>{(l!==H.current||u!==U.current||d!==W.current)&&(H.current=l,U.current=u,W.current=d,G.current=!0)},[l,u,d]),(0,y.useEffect)(()=>{if(!j.current)return;gy(j.current,i,a);let e=i!==K.current;K.current=i;let t=a!==q.current;q.current=a,G.current||e?(G.current=!1,Ey(j.current,u,d,f,{positions:ee.current,routes:Y.current})):t&&Oy(j.current)&&(te.current={zoom:j.current.zoom(),pan:{...j.current.pan()}})},[i,a,e,u,d]);let re=()=>{N(e=>new Set(e).add(l)),ee.current=void 0,Y.current=void 0,X.current?.cancelPending(),j.current!==null&&Ey(j.current,u,d,f)},ie=e=>{let t=j.current;t!==null&&t.zoom({level:ny(t.zoom(),e),renderedPosition:{x:t.width()/2,y:t.height()/2}})},ae=()=>{let e=j.current;e!==null&&Oy(e)&&(te.current={zoom:e.zoom(),pan:{...e.pan()}})},oe=Ny(P,e.nodes.map(e=>e.id),i);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{ref:A,style:{position:`relative`,width:`100%`,height:`100%`,...Jg(p).canvas===void 0?{}:{background:Jg(p).canvas}},onContextMenu:e=>e.preventDefault(),onDragOver:e=>{R.current!==void 0&&e.dataTransfer.types.includes(`application/x-yarramate-kind`)&&e.preventDefault()},onDrop:e=>{let t=e.dataTransfer.getData(G_);if(t===``||R.current===void 0)return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect(),r=j.current;R.current(t,Py({x:e.clientX-n.left,y:e.clientY-n.top},r?.pan()??{x:0,y:0},r?.zoom()??1))}}),oe?(0,$.jsxs)(`div`,{className:`saved-layout-pill`,role:`status`,children:[(0,$.jsx)(`span`,{children:`Saved layout in force`}),(0,$.jsx)(`button`,{type:`button`,onClick:re,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:()=>ie(1),children:`+`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Zoom out`,onClick:()=>ie(-1),children:`−`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Fit diagram`,onClick:ae,children:`Fit`})]})]})}var Ly=`YarraMate`,Ry=`yarramate`,zy=`Powered by yarramate`,By=/^[A-Za-z0-9][A-Za-z0-9-]*$/,Vy={productName:Ly,shortName:Ly,vendorLine:null,toolPrefix:Ry,branded:!1},Hy=e=>{if(e===void 0)return Vy;let t=e.productName.trim();if(t===``)throw TypeError(`branding.productName must not be blank`);let n=e.toolPrefix??`yarramate`;if(!By.test(n))throw TypeError(`branding.toolPrefix "${n}" must be letters, digits and hyphens, starting with a letter or digit`);let r=e.shortName===null?null:e.shortName?.trim(),i=e.vendorLine===void 0?zy:e.vendorLine===null||e.vendorLine.trim()===``?null:e.vendorLine.trim();return{productName:t,shortName:r===null?null:r===void 0||r===``?t:r,...e.logo===void 0?{}:{logo:e.logo},...e.accent===void 0?{}:{accent:e.accent},...e.docsUrl===void 0?{}:{docsUrl:e.docsUrl},vendorLine:i,toolPrefix:n,branded:!0}},Uy=Symbol.for(`yaml.alias`),Wy=Symbol.for(`yaml.document`),Gy=Symbol.for(`yaml.map`),Ky=Symbol.for(`yaml.pair`),qy=Symbol.for(`yaml.scalar`),Jy=Symbol.for(`yaml.seq`),Yy=Symbol.for(`yaml.node.type`),Xy=e=>!!e&&typeof e==`object`&&e[Yy]===Uy,Zy=e=>!!e&&typeof e==`object`&&e[Yy]===Wy,Qy=e=>!!e&&typeof e==`object`&&e[Yy]===Gy,$y=e=>!!e&&typeof e==`object`&&e[Yy]===Ky,eb=e=>!!e&&typeof e==`object`&&e[Yy]===qy,tb=e=>!!e&&typeof e==`object`&&e[Yy]===Jy;function nb(e){if(e&&typeof e==`object`)switch(e[Yy]){case Gy:case Jy:return!0}return!1}function rb(e){if(e&&typeof e==`object`)switch(e[Yy]){case Uy:case Gy:case qy:case Jy:return!0}return!1}var ib=e=>(eb(e)||nb(e))&&!!e.anchor,ab=Symbol(`break visit`),ob=Symbol(`skip children`),sb=Symbol(`remove node`);function cb(e,t){let n=ub(t);Zy(e)?lb(null,e.contents,n,Object.freeze([e]))===sb&&(e.contents=null):lb(null,e,n,Object.freeze([]))}cb.BREAK=ab,cb.SKIP=ob,cb.REMOVE=sb;function lb(e,t,n,r){let i=db(e,t,n,r);if(rb(i)||$y(i))return fb(e,r,i),lb(e,i,n,r);if(typeof i!=`symbol`){if(nb(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=lb(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===ab)return ab;else i===sb&&(t.items.splice(e,1),--e)}}else if($y(t)){r=Object.freeze(r.concat(t));let e=lb(`key`,t.key,n,r);if(e===ab)return ab;e===sb&&(t.key=null);let i=lb(`value`,t.value,n,r);if(i===ab)return ab;i===sb&&(t.value=null)}}return i}function ub(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 db(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(Qy(t))return n.Map?.(e,t,r);if(tb(t))return n.Seq?.(e,t,r);if($y(t))return n.Pair?.(e,t,r);if(eb(t))return n.Scalar?.(e,t,r);if(Xy(t))return n.Alias?.(e,t,r)}function fb(e,t,n){let r=t[t.length-1];if(nb(r))r.items[e]=n;else if($y(r))e===`key`?r.key=n:r.value=n;else if(Zy(r))r.contents=n;else{let e=Xy(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var pb={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},mb=e=>e.replace(/[!,[\]{}]/g,e=>pb[e]),hb=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+mb(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&&rb(e.contents)){let t={};cb(e.contents,(e,n)=>{rb(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
|
-
`)}};
|
|
331
|
-
`)?
|
|
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 ve(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 Qr(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=Et(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 Me(t&&t.style&&t.style.backgroundColor||`white`)}function Ah(e,t){var n=e._private.rscratch;return gn(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`?Qr(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`?Qr(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`?ei():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=ni(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 Na(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`};fe()&&(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]||nn(`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=pr(),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(Cl(e.pstyle(`text-halign`).value)){case`left`:n.x=-t.w-(t.leftPad||0);break;case`right`:n.x=-(t.rightPad||0)}switch(wl(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){Z(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){an("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(Vu.prototype[t])return i(t);Vu.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)}};Z(o,{createEmitter:function(){return this._private.emitter=new lu(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}}),Pc.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(){nn("Renderer does not implement `renderer."+e+"()` on its prototype")}}),r=_}else if(e===`__proto__`||e===`constructor`||e===`prototype`)return nn(e+` is an illegal type to be registered, possibly lead to prototype pollutions`);return Pe({map:cg,keys:[e,t],value:r})}function dg(e,t){return Fe({map:cg,keys:[e,t]})}function fg(e,t,n,r,i){return Pe({map:lg,keys:[e,t,n,r],value:i})}function pg(e,t,n,r){return Fe({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);nn(`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[he(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.3`,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 rn(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=e=>e.trim().toLowerCase();function Fg(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 Ig=(e,t)=>{let n=Pg(t);return e.filter(e=>Fg(n,e.id,e.name,e.kindLabel)).length};function Lg(e,t,n){return e.edges.filter(e=>!t.consumedEdgeIds.has(e.id)&&(n||(e.responsibility??null)===null))}function Rg(e,t,n={}){let r=Ag({nodes:e.nodes.map(e=>({id:e.id,kind:e.kind,coreKind:e.coreKindLabel})),edges:e.edges,memberships:n.memberships??[],nesting:t}),i=new Map;for(let e of r.parentOf.keys()){let t=r.parentOf.get(e),n=new Set([e]);for(;t!==void 0&&!n.has(t);){n.add(t);let a=i.get(t);a===void 0?i.set(t,[e]):a.push(e),t=r.parentOf.get(t)}}let a=n.folded??new Set,o=e.nodes.map(e=>{let t=r.parentOf.get(e.id);return{id:e.id,name:e.name,kindLabel:e.kindLabel,...t===void 0?{}:{parent:t},folded:a.has(e.id),insideIds:i.get(e.id)??[]}}),s=Lg(e,r,n.showResponsibility===!0),c=a.size===0?[]:Ng({nodes:e.nodes,edges:s},r,a).edges.flatMap(e=>`count`in e?[{id:e.id,from:e.from,to:e.to,relationshipIds:e.relationshipIds,liftedKind:e.kind}]:[]);return{nodes:o,edges:[...s.map(e=>({id:e.id,from:e.from,to:e.to})),...c],tree:r}}function zg(e,t,n){let r=new Map(e.nodes.map(e=>[e.id,e])),i=e=>r.get(e)?.parent,a=n.trim().toLowerCase(),o=t===null?e.nodes.map(e=>e.id):t.filter(e=>r.has(e)),s=new Set(o.filter(e=>{let t=r.get(e);return Fg(a,e,t.name,t.kindLabel)})),c=new Set(s);for(let e of s){let t=new Set([e]),n=i(e);for(;n!==void 0&&!t.has(n);)t.add(n),c.add(n),n=i(n)}for(let e of[...c]){let t=new Set([e]),n=i(e);for(;n!==void 0&&!t.has(n);){if(t.add(n),r.get(n)?.folded===!0){c.delete(e);break}n=i(n)}}let l=new Map;for(let t of e.nodes)t.parent!==void 0&&c.has(t.id)&&c.has(t.parent)&&l.set(t.id,t.parent);let u=new Map;for(let t of e.nodes)t.folded&&u.set(t.id,t.insideIds.filter(e=>r.has(e)&&s.has(e)).length);let d=t===null?null:new Set(t),f=new Map;for(let t of e.edges)t.relationshipIds!==void 0&&f.set(t.id,d===null?t.relationshipIds.length:t.relationshipIds.filter(e=>d.has(e)).length);let p=e=>d===null||(e.relationshipIds===void 0?d.has(e.id):e.relationshipIds.some(e=>d.has(e))),m=new Set(e.edges.filter(e=>yg(e.from,e.to,l)).map(e=>e.id)),h=new Set(e.edges.filter(e=>c.has(e.from)&&c.has(e.to)&&p(e)&&!m.has(e.id)).map(e=>e.id)),g=null;if(t!==null){g=new Set(o);for(let e of o){let t=i(e);for(;t!==void 0&&!g.has(t);)g.add(t),t=i(t)}}return{visibleNodeIds:c,contextNodeIds:new Set([...c].filter(e=>!s.has(e))),parentOf:l,insideCount:u,visibleEdgeIds:h,liftedCount:f,impliedEdgeIds:m,viewNodeIds:g}}var Bg=[`layered`,`routed`,`served-by`,`bands`],Vg=`served-by`,Hg=e=>e!==`layered`,Ug=e=>e===`served-by`||e===`bands`,Wg=e=>e===`bands`,Gg=new Set([`serving`,`realization`,`specialization`]),Kg={motivation:0,strategy:1,business:2,application:3,technology:4,physical:5,implementation:6},qg=e=>e==null?void 0:Kg[e],Jg=[`current`,`drafting`,`ink`,`tinted`,`dark`],Yg=[{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`}],Xg=`current`,Zg=`yarramate-visual.style`,Qg=()=>{try{let e=globalThis.localStorage?.getItem(Zg);return t_(e)?e:Xg}catch{return Xg}},$g=e=>{try{globalThis.localStorage?.setItem(Zg,e)}catch{}},e_=e=>Yg.find(t=>t.id===e)??Yg[0],t_=e=>typeof e==`string`&&Jg.includes(e),n_=`'Avenir Next', Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif`,r_=`ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace`,i_={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`}},a_={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`}},o_={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`}},s_={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`}},c_=(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]}}))],l_=e=>[...c_(e.palette),{selector:`node`,style:{"border-width":e.nodeBorder,"corner-radius":`${e.corner}px`,"font-family":n_,"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}}],u_={current:()=>[],drafting:()=>l_({palette:i_,ink:`#182228`,quiet:`#7d868c`,ground:`#e8eef0`,nodeBorder:1,corner:4,edge:`#6b7680`,edgeWidth:1.25,edgeLabelFace:r_,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:r_,size:10,weight:`500`,color:`#4a555e`,upper:!0},select:`#2457a6`}),ink:()=>l_({palette:a_,ink:`#182228`,quiet:`#6b7680`,ground:`#ffffff`,nodeBorder:1.5,corner:4,edge:`#182228`,edgeWidth:1.2,edgeLabelFace:n_,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:n_,size:11,weight:`600`,color:`#182228`,upper:!0},select:`#2457a6`}),tinted:()=>l_({palette:o_,ink:`#0f172a`,quiet:`#94a3b8`,ground:`#e8eef0`,nodeBorder:1,corner:8,edge:`#64748b`,edgeWidth:1.5,edgeLabelFace:n_,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:n_,size:11,weight:`600`,color:`#334155`,upper:!1},select:`#2563eb`}),dark:()=>l_({palette:s_,ink:`#e5e9ed`,quiet:`#97a3ae`,ground:`#12161b`,nodeBorder:1,corner:6,edge:`#7f8b96`,edgeWidth:1.25,edgeLabelFace:n_,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:n_,size:11,weight:`600`,color:`#97a3ae`,upper:!1},select:`#7ea6ec`})},d_=e=>u_[e]();function f_(e){return e===`planned`||e===`current`||e===`retired`}var p_=`#182228`,m_=`#416f65`,h_=`#a3403a`,g_=`#5f686d`,__=[m_,`#8c4d18`,`#2457a6`,p_],v_=12;function y_(e){return`data:image/svg+xml;utf8,${encodeURIComponent(e)}`}function b_(e){return`<svg xmlns="http://www.w3.org/2000/svg" width="${v_}" height="${v_}" viewBox="0 0 12 12">${e}</svg>`}var x_={planned:b_(`<circle cx="6" cy="6" r="4" fill="none" stroke="${g_}" stroke-width="2"/>`),current:b_(`<circle cx="6" cy="6" r="5" fill="${m_}"/>`),retired:b_(`<circle cx="6" cy="6" r="5" fill="${h_}"/>`)},S_={planned:y_(x_.planned),current:y_(x_.current),retired:y_(x_.retired)},C_=y_(b_(`<circle cx="6" cy="6" r="5" fill="${p_}"/><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 w_(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return t}function T_(e){if(e===null)return null;let t=w_(e);return __[Math.abs(t)%__.length]}function E_(e,t){return b_(`<circle cx="6" cy="6" r="5" fill="${T_(e)}"/><text x="6" y="7.5" font-size="8" font-weight="bold" fill="#ffffff" text-anchor="middle" dominant-baseline="middle">${t}</text>`)}function D_(e,t){return y_(E_(e,t))}function O_(e,t){let n=e>9?`9+`:String(e),r=n.length>1?6.5:8;return b_((t?`<circle cx="6" cy="6" r="5.5" fill="none" stroke="${p_}" stroke-width="1"/>`:``)+`<circle cx="6" cy="6" r="${t?4.5:5}" fill="${g_}"/><text x="6" y="7.5" font-size="${r}" font-weight="bold" fill="#ffffff" text-anchor="middle" dominant-baseline="middle">${n}</text>`)}function k_(e,t=!1){return y_(O_(e,t))}function A_(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="${p_}"/><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 j_(e){return y_(A_(e))}function M_(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 N_=[`motivation`,`strategy`,`business`,`application`,`technology`,`physical`,`implementation`,`composite`],P_=(e,t,n)=>n.map(([n,r,i])=>({id:n,name:r,layer:e,aspect:t,...i===void 0?{}:{rigidity:i},inspiredBy:`archimate:${r}`})),F_=[...P_(`motivation`,`motivation`,[[`stakeholder`,`Stakeholder`,`anti-rigid`],[`driver`,`Driver`],[`assessment`,`Assessment`],[`goal`,`Goal`],[`outcome`,`Outcome`],[`principle`,`Principle`],[`requirement`,`Requirement`],[`constraint`,`Constraint`],[`meaning`,`Meaning`],[`value`,`Value`]]),...P_(`strategy`,`active-structure`,[[`resource`,`Resource`]]),...P_(`strategy`,`behavior`,[[`capability`,`Capability`],[`valueStream`,`Value stream`],[`courseOfAction`,`Course of action`]]),...P_(`business`,`active-structure`,[[`businessActor`,`Business actor`],[`businessRole`,`Business role`,`anti-rigid`],[`businessCollaboration`,`Business collaboration`,`anti-rigid`],[`businessInterface`,`Business interface`]]),...P_(`business`,`behavior`,[[`businessProcess`,`Business process`],[`businessFunction`,`Business function`],[`businessInteraction`,`Business interaction`],[`businessEvent`,`Business event`],[`businessService`,`Business service`]]),...P_(`business`,`passive-structure`,[[`businessObject`,`Business object`],[`contract`,`Contract`],[`representation`,`Representation`]]),...P_(`business`,`composite`,[[`product`,`Product`]]),...P_(`application`,`active-structure`,[[`applicationComponent`,`Application component`],[`applicationCollaboration`,`Application collaboration`,`anti-rigid`],[`applicationInterface`,`Application interface`]]),...P_(`application`,`behavior`,[[`applicationFunction`,`Application function`],[`applicationInteraction`,`Application interaction`],[`applicationProcess`,`Application process`],[`applicationEvent`,`Application event`],[`applicationService`,`Application service`]]),...P_(`application`,`passive-structure`,[[`dataObject`,`Data object`]]),...P_(`technology`,`active-structure`,[[`node`,`Node`],[`device`,`Device`],[`systemSoftware`,`System software`],[`technologyCollaboration`,`Technology collaboration`,`anti-rigid`],[`technologyInterface`,`Technology interface`],[`path`,`Path`],[`communicationNetwork`,`Communication network`]]),...P_(`technology`,`behavior`,[[`technologyFunction`,`Technology function`],[`technologyProcess`,`Technology process`],[`technologyInteraction`,`Technology interaction`],[`technologyEvent`,`Technology event`],[`technologyService`,`Technology service`]]),...P_(`technology`,`passive-structure`,[[`artifact`,`Artifact`]]),...P_(`physical`,`active-structure`,[[`equipment`,`Equipment`],[`facility`,`Facility`],[`distributionNetwork`,`Distribution network`]]),...P_(`physical`,`passive-structure`,[[`material`,`Material`]]),...P_(`implementation`,`behavior`,[[`workPackage`,`Work package`],[`implementationEvent`,`Implementation event`]]),...P_(`implementation`,`passive-structure`,[[`deliverable`,`Deliverable`]]),...P_(`implementation`,`composite`,[[`plateau`,`Plateau`],[`gap`,`Gap`]]),...P_(`composite`,`composite`,[[`grouping`,`Grouping`],[`location`,`Location`],[`andJunction`,`AND junction`],[`orJunction`,`OR junction`]])],I_=[`composition`,`aggregation`,`assignment`,`realization`,`serving`,`access`,`influence`,`association`,`triggering`,`flow`,`specialization`],L_=`#182228`,R_={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`}},z_={motivation:{shape:`octagon`},"active-structure":{shape:`rectangle`},behavior:{shape:`round-rectangle`},"passive-structure":{shape:`rectangle`,accent:`top-band`},composite:{shape:`rectangle`}},B_={grouping:{borderStyle:`dashed`}};function V_(e,t=L_){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 H_(e){return`data:image/svg+xml;utf8,${encodeURIComponent(e)}`}var U_={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"/>`},W_=F_.map(e=>({id:e.id,notation:e.name,layer:e.layer,aspect:e.aspect,...z_[e.aspect],...B_[e.id],glyph:U_[e.id]??null,colors:R_[e.layer]})),G_=Object.fromEntries(W_.map(e=>[e.id,e]));function K_(e,t=L_){let n=G_[e]?.glyph;return n==null?null:H_(V_(n,t))}var q_={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`}}},J_=I_.map(e=>({id:e,...q_[e]}));Object.fromEntries(J_.map(e=>[e.id,e]));function Y_(e,t){return K_(e,t)}var X_=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=X_()}))(),Z_=`application/x-yarramate-kind`,Q_=`unlayered`,$_=`constraint`,ev=(e,t)=>{let n=e===1?`slot`:`slots`;return t===0?`${e} ${n}`:`${e} ${n}, ${t} required`},tv=e=>e.slice(e.lastIndexOf(`/`)+1).replace(/\.ya?ml$/,``),nv=new Map(F_.map(e=>[e.id,e.layer])),rv=(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}))},iv=(e,t=[])=>{let n=new Set(t.flatMap(e=>e.slots.flatMap(e=>[...e.admits]))),r=e=>e.coreLabel===$_&&n.has(e.label),i=new Map,a=new Map;for(let t of e){let e=nv.get(t.coreLabel)??Q_,n=r(t)?a:i,o=n.get(e);o===void 0?n.set(e,[t]):o.push(t)}return[...N_,Q_].flatMap(e=>{let t=i.get(e),n=a.get(e);return t===void 0&&n===void 0?[]:[{layer:e,kinds:t??[],boundThroughSlot:n??[]}]})},av=({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:[rv(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 ${tv(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(Z_,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:ev(e.slots.length,t)})]})},e.kind)})})]},`pattern:${e.document}`)}),iv(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=Y_(e.label)??Y_(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(Z_,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)(ov,{layer:e.layer,kinds:e.boundThroughSlot,onPick:n})]},e.layer)})]})},ov=({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(Z_,e.label),t.dataTransfer.effectAllowed=`copy`},onClick:()=>n(e.label),children:(0,$.jsx)(`span`,{children:e.label})})},e.id))}):null]})},sv=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),cv={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`},lv={"yarramate/policy@0.2#responsible":`is responsible for`,"yarramate/policy@0.2#consulted":`is consulted on`,"yarramate/policy@0.2#informed":`is informed of`},uv={serving:`served by`,realization:`realized by`,specialization:`specialized by`},dv=e=>e.slice(e.indexOf(`#`)+1).replaceAll(/([a-z0-9])([A-Z])/g,`$1 $2`).replaceAll(`-`,` `).toLowerCase(),fv=(e,t=!1)=>(t?uv[e]:void 0)??lv[e]??cv[e]??dv(e),pv=(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=e.readingKind,o=e.reading!==void 0&&e.reading!==``?e.reading:a!==void 0&&a!==r?fv(a):i!==r&&i!==``?dv(i):fv(r,Ug(t)&&Gg.has(r)),s=typeof e.liftedCount==`number`?e.liftedCount:0;return s>1?`${o} ×${s}`:o},mv=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),hv=function(e,t){return new URL(e,t).href},gv={},_v=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=hv(t,n),t=s(t),t in gv)return;gv[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`:mv,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}`)))})}).filter(e=>e!==void 0))}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)})},vv=2.5,yv={"top-down":`DOWN`,"left-right":`RIGHT`},bv={"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]`},xv=e=>Hg(e)?{...bv,"elk.spacing.edgeEdge":`60`}:{...bv},Sv=(e,t)=>({"elk.algorithm":`layered`,"elk.direction":yv[e],"elk.layered.nodePlacement.strategy":`NETWORK_SIMPLEX`,"elk.aspectRatio":String(vv),...xv(t),...Hg(t)?{"elk.hierarchyHandling":`INCLUDE_CHILDREN`,"elk.edgeRouting":`ORTHOGONAL`,"elk.edgeLabels.inline":`true`,"elk.layered.considerModelOrder.strategy":`NODES_AND_EDGES`}:{},...Wg(t)?{"elk.partitioning.activate":`true`}:{}}),Cv=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 wv(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 qg(e.data(`layer`));let n=t.map(l).filter(e=>e!==void 0);return n.length===0?void 0:Math.min(...n)},u=xv(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(Wg(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=Ug(r)&&Gg.has(a);s&&f.add(e.id());let c={id:e.id(),sources:[s?n:t],targets:[s?t:n]};if(Hg(r)){let t=pv(e.data(),r,i);t!==``&&(c.labels=[{text:t,...Cv(t)}])}p.push(c)}),{graph:{id:`root`,layoutOptions:Sv(n,r),children:c.map(d),edges:p},reversed:f}}var Tv=(e,t)=>[e.startPoint,...e.bendPoints??[],e.endPoint].map(e=>({x:e.x+t.x,y:e.y+t.y})),Ev=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},Dv=(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 Ov(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=Tv(o,i),c=null,l=r.labels?.[0];if(l!==void 0&&l.x!==void 0&&l.y!==void 0&&(c=Dv(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=Ev(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 kv=e=>e.default??e,Av=kv(sv.default),jv,Mv=()=>jv??=_v(()=>import(`./elk.bundled-sPNnidPe.js`).then(e=>c(e.default,1)).then(e=>new(kv(e))),[],import.meta.url),Nv;function Pv(e){let t=new Av({workerFactory:()=>e()});return{layout:e=>t.layout(e),terminate:()=>t.terminateWorker?.()}}function Fv(e){Nv=e}var Iv=async e=>(Nv??await Mv()).layout(e),Lv=[`curve-style`,`edge-distances`,`source-endpoint`,`target-endpoint`,`segment-weights`,`segment-distances`,`source-text-offset`],Rv=e=>`${Math.round(e*10)/10}px`;function zv(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":`${Rv(i.x-t.x)} ${Rv(i.y-t.y)}`,"target-endpoint":`${Rv(a.x-n.x)} ${Rv(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 Bv=1e-6;function Vv(e,t){if(e.isParent()){let n=e.descendants().filter(e=>!e.isParent());return n.length>0&&n.every(e=>Vv(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)<Bv&&Math.abs(r.y-n.y)<Bv}function Hv(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(zv(a.points,t.source().position(),t.target().position(),a.labelAt)),t.scratch(Wv,a),t.addClass(`routed`),r+=1)}}finally{e.endBatch()}return r}function Uv(e){e.removeClass(`routed`),e.removeStyle(Lv.join(` `)),e.removeScratch(Wv)}var Wv=`_route`;function Gv(e){let t={};return e.forEach(e=>{if(!e.hasClass(`routed`))return;let n=e.scratch(Wv);n!==void 0&&(t[e.id()]={points:n.points.map(e=>({x:e.x,y:e.y})),labelAt:n.labelAt})}),t}function Kv(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 Hv(e,r,e=>!e.hasClass(`routed`)&&Vv(e.source(),r)&&Vv(e.target(),r))}function qv(e){let t=e=>{let t=e.target;Uv(t.union(t.ancestors()).union(t.descendants()).connectedEdges(`.routed`))};return e.on(`dragfree`,`node`,t),()=>{e.off(`dragfree`,`node`,t)}}var Jv=`#F0F0F0`,Yv=`#999999`,Xv=170,Zv=50,Qv=150,$v=``;function ey(e){return e.replace(/([/._-])/g,`$1${$v}`)}var ty=20,ny=1.25,ry=.02,iy=10;function ay(e,t){let n=t===1?e*ny:e/ny;return Math.min(iy,Math.max(ry,n))}var oy=12;function sy(e,t,n,r,i,a){let o=[],s=Y_(String(e.data(`kindLabel`)),a)??Y_(String(e.data(`coreKindLabel`)),a);s!==null&&o.push({image:s,positionX:`0%`,positionY:`0%`,size:14});let c=e.data(`status`);t&&f_(c)&&o.push({image:S_[c],positionX:`100%`,positionY:`0%`,size:oy}),n&&e.data(`hasAttestations`)===!0&&o.push({image:C_,positionX:`0%`,positionY:`100%`,size:oy});let l=e.data(`owner`),u=e.data(`ownerInitials`),d=r&&l!==null&&u!==null;d&&o.push({image:D_(l,u),positionX:`100%`,positionY:`100%`,size:oy});let f=e.data(`openQuestions`);return i&&typeof f==`number`&&f>0&&o.push({image:k_(f,e.data(`nextQuestion`)===!0),positionX:d?`84%`:`96%`,positionY:d?`100%`:`88%`,size:oy}),o}var cy=[`added`,`removed`,`changed`],ly=e=>`deco-${e}`,uy=cy.map(ly).join(` `),dy={added:`#416F65`,removed:`#677074`,changed:`#8C4D18`};function fy(e,t){e.elements().removeClass(uy);for(let[n,r]of Object.entries(t)){let t=e.getElementById(n);t.nonempty()&&t.addClass(ly(r))}}function py(e,t,n,r,i=!0,a=Vg,o=Xg){let s=e_(o).glyph,c=e=>ey(pv(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=sy(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":Jv,"border-color":Yv,"border-width":2,shape:`roundrectangle`,width:Xv,height:Zv,padding:`8px`,label:`data(wrapLabel)`,"font-size":12,"text-wrap":`wrap`,"text-max-width":`${Qv}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(R_).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=>j_(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(z_).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`]=[Yv,Jv],n[`background-gradient-stop-positions`]=[`0%`,`20%`]),t.borderStyle===`dashed`&&(n[`border-style`]=`dashed`),{selector:`node[aspect = "${e}"]:childless`,style:n}}),p=J_.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":dy.added,"border-width":3,"line-color":dy.added,"target-arrow-color":dy.added}},{selector:`node.deco-removed, edge.deco-removed`,style:{"border-color":dy.removed,"border-width":3,"border-style":`dashed`,"line-color":dy.removed,"target-arrow-color":dy.removed,"line-style":`dashed`}},{selector:`node.deco-changed, edge.deco-changed`,style:{"border-color":dy.changed,"border-width":3,"line-color":dy.changed,"target-arrow-color":dy.changed}},{selector:`node.faulted, edge.faulted`,style:{"border-color":`#A3403A`,"border-width":4,"line-color":`#A3403A`,"target-arrow-color":`#A3403A`}}];return[...d,...f,...p,...d_(o),...m]}function my(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=>`${hy(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 hy=e=>e.split(`#`)[1]??e,gy=(e,t)=>t>1?`${e} \u00d7${t}`:e;function _y(e,t,n,r){let i=Rg(e,t,{...r?.folded===void 0?{}:{folded:r.folded},...r?.memberships===void 0?{}:{memberships:r.memberships},...r?.showResponsibility===void 0?{}:{showResponsibility:r.showResponsibility}});my(i.tree);let a=new Map(i.nodes.map(e=>[e.id,e])),o=e.nodes.map(e=>{let t=a.get(e.id),i=t.parent,o=t.insideIds,s=t.folded;return{data:{id:e.id,label:e.name,wrapLabel:ey(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:M_(e.owner),openQuestions:s?[e.id,...o].reduce((e,t)=>e+(n.get(t)??0),0):n.get(e.id)??0,nextQuestion:r?.nextQuestionSubjectId!==void 0&&r.nextQuestionSubjectId!==null&&(s?[e.id,...o].includes(r.nextQuestionSubjectId):e.id===r.nextQuestionSubjectId),insideCount:o.length,insideIds:o,...i===void 0?{}:{parent:i,compositionParent:i}},group:`nodes`,...s?{classes:`folded`}:{}}}),s=Lg(e,i.tree,r?.showResponsibility===!0),c=new Map,l=e=>e.from<e.to?`${e.from}\u0000${e.to}`:`${e.to}\u0000${e.from}`;for(let e of s){let t=l(e);c.set(t,(c.get(t)??0)+1)}let u=s.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:ey(e.name??e.kindLabel),coreKindLabel:e.coreKindLabel,...e.readingKind===void 0?{}:{readingKind:e.readingKind},...e.responsibility===void 0?{}:{responsibility:e.responsibility},...e.reading===void 0?{}:{reading:e.reading}},group:`edges`,...c.get(l(e))>1?{classes:`parallel`}:{}})),d=i.edges.filter(e=>e.relationshipIds!==void 0).map(e=>{let t=hy(e.liftedKind??``),n=e.relationshipIds.length;return{data:{id:e.id,source:e.from,target:e.to,label:gy(t,n),wrapLabel:ey(t),name:null,kindLabel:t,coreKindLabel:t,lifted:!0,liftedCount:n,relationshipIds:e.relationshipIds},group:`edges`,classes:`lifted`}});return[...o,...u,...d]}function vy(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))&&Fg(r,e.id,e.name,e.kindLabel)).length}function yy(e,t,n){let r=zg({nodes:e.nodes().map(e=>{let t=e.data(`compositionParent`),n=e.data(`insideIds`);return{id:e.id(),name:e.data(`label`),kindLabel:e.data(`kindLabel`),...typeof t==`string`?{parent:t}:{},folded:e.hasClass(`folded`),insideIds:Array.isArray(n)?n:[]}}),edges:e.edges().map(e=>{let t=e.data(`relationshipIds`);return{id:e.id(),from:e.data(`source`),to:e.data(`target`),...Array.isArray(t)?{relationshipIds:t}:{}}})},t,n);e.scratch(by,r.viewNodeIds);let i=[];for(let t of e.nodes()){if(typeof t.data(`compositionParent`)!=`string`)continue;let e=r.parentOf.get(t.id())??null;(t.parent().nonempty()?t.parent().first().id():null)!==e&&i.push({node:t.id(),parent:e})}for(let{node:t,parent:n}of i)e.getElementById(t).move({parent:n});for(let[t,n]of r.insideCount)e.getElementById(t).data(`insideCount`,n);for(let[t,n]of r.liftedCount){let r=e.getElementById(t);r.data(`liftedCount`)!==n&&r.data({liftedCount:n,label:gy(String(r.data(`kindLabel`)??``),n)})}e.elements().style(`display`,`none`),e.elements().filter(e=>e.isNode()?r.visibleNodeIds.has(e.id()):r.visibleEdgeIds.has(e.id())).style(`display`,`element`)}var by=`_viewNodeIds`;function xy(e){return e.scratch(by)??null}var Sy=`_layoutGeneration`,Cy=`_reservedTop`;function wy(e,t,n,r,i,a){let o=e.x2-e.x1,s=e.y2-e.y1;if(!(o>0)||!(s>0))return null;let c=Math.max(0,Math.min(i,n)),l=n-c,u=Math.min((t-2*r)/o,(l-2*r)/s),d=Math.max(a.minZoom,Math.min(a.maxZoom,u));return{zoom:d,pan:{x:(t-d*(e.x1+e.x2))/2,y:c+(l-d*(e.y1+e.y2))/2}}}function Ty(e,t,n){let r=e.scratch(Cy)??0,i=wy(t.boundingBox(),e.width(),e.height(),n,r,{minZoom:e.minZoom(),maxZoom:e.maxZoom()});if(i===null){e.fit(t,n);return}e.viewport(i)}async function Ey(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=Dy(o),c=s.empty()?o:o.difference(s);Uv(a.edges());let l=(a.scratch(Sy)??0)+1;a.scratch(Sy,l);let{graph:u,reversed:d}=wv(c,{direction:t,mode:n,showKindLabels:r}),f=await Iv(u);if(a.destroyed()||a.scratch(Sy)!==l)return;let p=Ov(f,d);c.layout({name:`preset`,positions:e=>p.nodes.get(e.id())??null,fit:!1,animate:!1}).run(),Ty(a,c,ty),Hg(n)&&(a.nodes().updateCompoundBounds(!0),Hv(a,p,e=>Vv(e.source(),p)&&Vv(e.target(),p)),i?.routes!==void 0&&Kv(a,i.routes,i.positions??{}))}var Dy=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 Oy(e,t,n=Vg,r=!0,i){return Ey(e.elements(`:visible`),t,n,r,i)}async function ky(e,t,n,r,i,a){let o=i===null?null:e.getElementById(i),s=o!==null&&o.nonempty()?{...o.position()}:null;if(await Oy(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?(Ty(e,c,40),!0):!1}function Ay(e){let t=e.elements(`:visible`);return!t.empty()&&(Ty(e,t,ty),!0)}function jy(e,t=null){let n={};return e.forEach(e=>{if(t!==null&&!t.has(e.id()))return;let{x:r,y:i}=e.position();n[e.id()]={x:r,y:i}}),n}function My(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 Ny(e,t,n){return n.has(t)?void 0:e}function Py(e,t,n){return n.has(t)?void 0:e}function Fy(e,t,n){return e!==void 0&&(n??t).some(t=>e[t]!==void 0)}function Iy(e,t,n){return{x:(e.x-t.x)/n,y:(e.y-t.y)/n}}function Ly(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=Gv(e.edges());n({projectionId:i,positions:jy(e.nodes(),xy(e)),...Object.keys(a).length===0?{}:{routes:a}})},500)};return e.on(`dragfree`,`node`,a),{cancelPending:i,dispose:()=>{e.off(`dragfree`,`node`,a),i()}}}function Ry({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,showResponsibility:C,showNudges:w,openQuestionCounts:T,nextQuestionSubjectId:E=null,reservedTop:D=0,folded:O,memberships:k}){let A=(0,y.useRef)(null),j=(0,y.useRef)(null),[M,N]=(0,y.useState)(()=>new Set),P=Ny(m,l,M),F=Py(h,l,M),I=(0,y.useRef)(n),L=(0,y.useRef)(v);L.current=v;let R=(0,y.useRef)(_);R.current=_;let z=(0,y.useRef)(r),B=(0,y.useRef)(!0),V=(0,y.useRef)(!0),H=(0,y.useRef)(l),U=(0,y.useRef)(u),W=(0,y.useRef)(d),G=(0,y.useRef)(!1),K=(0,y.useRef)(i),q=(0,y.useRef)(a),J=(0,y.useRef)(g),ee=(0,y.useRef)(P),Y=(0,y.useRef)(F),X=(0,y.useRef)(null),te=(0,y.useRef)(null);(0,y.useEffect)(()=>{I.current=n},[n]),(0,y.useEffect)(()=>{z.current=r},[r]),(0,y.useEffect)(()=>{J.current=g},[g]),(0,y.useEffect)(()=>{ee.current=P},[P]),(0,y.useEffect)(()=>{Y.current=F},[F]),(0,y.useEffect)(()=>{X.current?.cancelPending()},[l]),(0,y.useEffect)(()=>{j.current?.scratch(Cy,D)},[D]),(0,y.useEffect)(()=>{if(!A.current)return;let t=vg({container:A.current,elements:_y(e,o,T,{nextQuestionSubjectId:E,folded:O??new Set,memberships:k,showResponsibility:C}),selectionType:`additive`,boxSelectionEnabled:!0,style:py(b,x,S,w,f,d,p),wheelSensitivity:.1,layout:{name:`null`}});t.scratch(Cy,D),j.current=t,L.current?.(()=>t.png({full:!0,scale:2,bg:`#ffffff`})),t.on(`tap`,`node`,e=>{let t=e.target.id();I.current(t,`node`)}),t.on(`tap`,`edge`,e=>{let t=e.target.id();I.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=>{z.current({type:`node`,id:e.target.id()},n(e))}),t.on(`cxttap`,`edge`,e=>{z.current({type:`edge`,id:e.target.id()},n(e))}),t.on(`cxttap`,e=>{e.target===t&&z.current({type:`canvas`,id:null},n(e))}),X.current=Ly(t,()=>H.current,e=>{N(t=>{if(!t.has(e.projectionId))return t;let n=new Set(t);return n.delete(e.projectionId),n}),J.current(e)});let r=qv(t),i=()=>{te.current={zoom:t.zoom(),pan:{...t.pan()}}};t.on(`layoutstop`,()=>{My(t,ee.current),i()});let a=A.current,s=0,c=new ResizeObserver(()=>{cancelAnimationFrame(s),s=requestAnimationFrame(()=>{t.resize();let e=te.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()||(Ty(t,r,ty),i())})});return c.observe(a),()=>{cancelAnimationFrame(s),c.disconnect(),r(),X.current?.dispose(),L.current?.(null),t.destroy(),j.current=null}},[]),(0,y.useEffect)(()=>{if(j.current){if(V.current){V.current=!1;return}j.current.style(py(b,x,S,w,f,d,p))}},[b,x,S,w,f,d,p]),(0,y.useEffect)(()=>{if(j.current){if(B.current)B.current=!1;else{let t=_y(e,o,T,{nextQuestionSubjectId:E,folded:O??new Set,memberships:k,showResponsibility:C});j.current.elements().remove(),j.current.add(t)}yy(j.current,K.current,q.current),Ey(j.current.elements(`:visible`),u,d,f,{positions:ee.current,routes:Y.current})}},[e,T,E,o,k,C]);let ne=(0,y.useRef)(null);(0,y.useEffect)(()=>{let t=j.current;if(t===null)return;let n=ne.current;if(ne.current=O??new Set,n===null)return;let r=O??new Set,s=[...[...r].filter(e=>!n.has(e)),...[...n].filter(e=>!r.has(e))];s.length!==0&&(t.elements().remove(),t.add(_y(e,o,T,{nextQuestionSubjectId:E,folded:r,memberships:k,showResponsibility:C})),yy(t,i,a),ky(t,u,d,f,s.length===1?s[0]:null,{positions:ee.current,routes:Y.current}))},[O]),(0,y.useEffect)(()=>{if(j.current){j.current.elements().removeClass(`faulted`);for(let e of s){let t=j.current.getElementById(e);t.nonempty()&&t.addClass(`faulted`)}}},[s,e]),(0,y.useEffect)(()=>{j.current&&fy(j.current,c)},[c,e]),(0,y.useEffect)(()=>{if(j.current&&(j.current.elements().removeClass(`selected`),t)){let e=j.current.getElementById(t);e.nonempty()&&e.addClass(`selected`)}},[t,e]),(0,y.useEffect)(()=>{(l!==H.current||u!==U.current||d!==W.current)&&(H.current=l,U.current=u,W.current=d,G.current=!0)},[l,u,d]),(0,y.useEffect)(()=>{if(!j.current)return;yy(j.current,i,a);let e=i!==K.current;K.current=i;let t=a!==q.current;q.current=a,G.current||e?(G.current=!1,Oy(j.current,u,d,f,{positions:ee.current,routes:Y.current})):t&&Ay(j.current)&&(te.current={zoom:j.current.zoom(),pan:{...j.current.pan()}})},[i,a,e,u,d]);let re=()=>{N(e=>new Set(e).add(l)),ee.current=void 0,Y.current=void 0,X.current?.cancelPending(),j.current!==null&&Oy(j.current,u,d,f)},ie=e=>{let t=j.current;t!==null&&t.zoom({level:ay(t.zoom(),e),renderedPosition:{x:t.width()/2,y:t.height()/2}})},ae=()=>{let e=j.current;e!==null&&Ay(e)&&(te.current={zoom:e.zoom(),pan:{...e.pan()}})},oe=Fy(P,e.nodes.map(e=>e.id),i);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{ref:A,style:{position:`relative`,width:`100%`,height:`100%`,...e_(p).canvas===void 0?{}:{background:e_(p).canvas}},onContextMenu:e=>e.preventDefault(),onDragOver:e=>{R.current!==void 0&&e.dataTransfer.types.includes(`application/x-yarramate-kind`)&&e.preventDefault()},onDrop:e=>{let t=e.dataTransfer.getData(Z_);if(t===``||R.current===void 0)return;e.preventDefault();let n=e.currentTarget.getBoundingClientRect(),r=j.current;R.current(t,Iy({x:e.clientX-n.left,y:e.clientY-n.top},r?.pan()??{x:0,y:0},r?.zoom()??1))}}),oe?(0,$.jsxs)(`div`,{className:`saved-layout-pill`,role:`status`,children:[(0,$.jsx)(`span`,{children:`Saved layout in force`}),(0,$.jsx)(`button`,{type:`button`,onClick:re,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:()=>ie(1),children:`+`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Zoom out`,onClick:()=>ie(-1),children:`−`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Fit diagram`,onClick:ae,children:`Fit`})]})]})}var zy=`YarraMate`,By=`yarramate`,Vy=`Powered by yarramate`,Hy=/^[A-Za-z0-9][A-Za-z0-9-]*$/,Uy={productName:zy,shortName:zy,vendorLine:null,toolPrefix:By,branded:!1},Wy=e=>{if(e===void 0)return Uy;let t=e.productName.trim();if(t===``)throw TypeError(`branding.productName must not be blank`);let n=e.toolPrefix??`yarramate`;if(!Hy.test(n))throw TypeError(`branding.toolPrefix "${n}" must be letters, digits and hyphens, starting with a letter or digit`);let r=e.shortName===null?null:e.shortName?.trim(),i=e.vendorLine===void 0?Vy:e.vendorLine===null||e.vendorLine.trim()===``?null:e.vendorLine.trim();return{productName:t,shortName:r===null?null:r===void 0||r===``?t:r,...e.logo===void 0?{}:{logo:e.logo},...e.accent===void 0?{}:{accent:e.accent},...e.docsUrl===void 0?{}:{docsUrl:e.docsUrl},vendorLine:i,toolPrefix:n,branded:!0}},Gy=Symbol.for(`yaml.alias`),Ky=Symbol.for(`yaml.document`),qy=Symbol.for(`yaml.map`),Jy=Symbol.for(`yaml.pair`),Yy=Symbol.for(`yaml.scalar`),Xy=Symbol.for(`yaml.seq`),Zy=Symbol.for(`yaml.node.type`),Qy=e=>!!e&&typeof e==`object`&&e[Zy]===Gy,$y=e=>!!e&&typeof e==`object`&&e[Zy]===Ky,eb=e=>!!e&&typeof e==`object`&&e[Zy]===qy,tb=e=>!!e&&typeof e==`object`&&e[Zy]===Jy,nb=e=>!!e&&typeof e==`object`&&e[Zy]===Yy,rb=e=>!!e&&typeof e==`object`&&e[Zy]===Xy;function ib(e){if(e&&typeof e==`object`)switch(e[Zy]){case qy:case Xy:return!0}return!1}function ab(e){if(e&&typeof e==`object`)switch(e[Zy]){case Gy:case qy:case Yy:case Xy:return!0}return!1}var ob=e=>(nb(e)||ib(e))&&!!e.anchor,sb=Symbol(`break visit`),cb=Symbol(`skip children`),lb=Symbol(`remove node`);function ub(e,t){let n=fb(t);$y(e)?db(null,e.contents,n,Object.freeze([e]))===lb&&(e.contents=null):db(null,e,n,Object.freeze([]))}ub.BREAK=sb,ub.SKIP=cb,ub.REMOVE=lb;function db(e,t,n,r){let i=pb(e,t,n,r);if(ab(i)||tb(i))return mb(e,r,i),db(e,i,n,r);if(typeof i!=`symbol`){if(ib(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=db(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===sb)return sb;else i===lb&&(t.items.splice(e,1),--e)}}else if(tb(t)){r=Object.freeze(r.concat(t));let e=db(`key`,t.key,n,r);if(e===sb)return sb;e===lb&&(t.key=null);let i=db(`value`,t.value,n,r);if(i===sb)return sb;i===lb&&(t.value=null)}}return i}function fb(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 pb(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(eb(t))return n.Map?.(e,t,r);if(rb(t))return n.Seq?.(e,t,r);if(tb(t))return n.Pair?.(e,t,r);if(nb(t))return n.Scalar?.(e,t,r);if(Qy(t))return n.Alias?.(e,t,r)}function mb(e,t,n){let r=t[t.length-1];if(ib(r))r.items[e]=n;else if(tb(r))e===`key`?r.key=n:r.value=n;else if($y(r))r.contents=n;else{let e=Qy(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var hb={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},gb=e=>e.replace(/[!,[\]{}]/g,e=>hb[e]),_b=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+gb(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&&ab(e.contents)){let t={};ub(e.contents,(e,n)=>{ab(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
|
+
`)}};_b.defaultYaml={explicit:!1,version:`1.2`},_b.defaultTags={"!!":`tag:yaml.org,2002:`};function vb(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 yb(e){let t=new Set;return ub(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function bb(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function xb(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=yb(e);let a=bb(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(nb(t.node)||ib(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 Sb(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=Sb(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=Sb(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=Sb(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=Sb(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function Cb(e,t,n){if(Array.isArray(e))return e.map((e,t)=>Cb(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!ob(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 wb=class{constructor(e){Object.defineProperty(this,Zy,{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(!$y(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=Cb(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?Sb(i,{"":o},``,o):o}},Tb=class extends wb{constructor(e){super(Gy),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=[],ub(e,{Node:(e,t)=>{(Qy(t)||ob(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)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(Cb(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Eb(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(vb(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 Eb(e,t,n){if(Qy(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(ib(t)){let r=0;for(let i of t.items){let t=Eb(e,i,n);t>r&&(r=t)}return r}if(tb(t)){let r=Eb(e,t.key,n),i=Eb(e,t.value,n);return Math.max(r,i)}return 1}var Db=e=>!e||typeof e!=`function`&&typeof e!=`object`,Ob=class extends wb{constructor(e){super(Yy),this.value=e}toJSON(e,t){return t?.keep?this.value:Cb(this.value,e,t)}toString(){return String(this.value)}};Ob.BLOCK_FOLDED=`BLOCK_FOLDED`,Ob.BLOCK_LITERAL=`BLOCK_LITERAL`,Ob.PLAIN=`PLAIN`,Ob.QUOTE_DOUBLE=`QUOTE_DOUBLE`,Ob.QUOTE_SINGLE=`QUOTE_SINGLE`;var kb=`tag:yaml.org,2002:`;function Ab(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 jb(e,t,n){if($y(e)&&(e=e.contents),ab(e))return e;if(tb(e)){let t=n.schema[qy].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 Tb(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=kb+t.slice(2));let l=Ab(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new Ob(e);return c&&(c.node=t),t}l=e instanceof Map?o[qy]:Symbol.iterator in Object(e)?o[Xy]:o[qy]}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 Ob(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function Mb(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 jb(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var Nb=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,Pb=class extends wb{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=>ab(t)||tb(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Nb(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(ib(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Mb(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(ib(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&&nb(i)?i.value:i:ib(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!tb(t))return!1;let n=t.value;return n==null||e&&nb(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 ib(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(ib(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,Mb(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},Fb=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function Ib(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Lb=(e,t,n)=>e.endsWith(`
|
|
331
|
+
`)?Ib(n,t):n.includes(`
|
|
332
332
|
`)?`
|
|
333
|
-
`+
|
|
334
|
-
`)n===`block`&&(h=
|
|
333
|
+
`+Ib(n,t):(e.endsWith(` `)?``:` `)+n,Rb=`flow`,zb=`block`,Bb=`quoted`;function Vb(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=Hb(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
|
|
334
|
+
`)n===`block`&&(h=Hb(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
|
|
335
335
|
`&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
|
|
336
|
-
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function
|
|
337
|
-
`);r=t,i=t+1,a=e[i]}return r}var
|
|
338
|
-
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function
|
|
336
|
+
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function Hb(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
337
|
+
`);r=t,i=t+1,a=e[i]}return r}var Ub=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Wb=e=>/^(%|---|\.\.\.)/m.test(e);function Gb(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
|
|
338
|
+
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function Kb(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(Wb(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
|
|
339
339
|
|
|
340
340
|
`;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
|
|
341
|
-
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:
|
|
342
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return
|
|
341
|
+
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:Vb(o,a,Bb,Ub(t,!1))}function qb(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
342
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return Kb(e,t);let n=t.indent||(Wb(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:Vb(r,n,Rb,Ub(t,!1))}function Jb(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=Kb;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?qb:i&&!t?Kb:n?qb:Kb}return r(e,t)}var Yb;try{Yb=RegExp(`(^|(?<!
|
|
343
343
|
))
|
|
344
344
|
+(?!
|
|
345
|
-
|$)`,`g`)}catch{
|
|
345
|
+
|$)`,`g`)}catch{Yb=/\n+(?!\n|$)/g}function Xb({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return Jb(n,r);let l=r.indent||(r.forceBlockIndent||Wb(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===Ob.BLOCK_FOLDED?!1:t===Ob.BLOCK_LITERAL||!Gb(n,c,l.length);if(!n)return u?`|
|
|
346
346
|
`:`>
|
|
347
347
|
`;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
|
|
348
348
|
`&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
|
|
349
349
|
`);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
|
|
350
|
-
`&&(p=p.slice(0,-1)),p.replace(
|
|
350
|
+
`&&(p=p.slice(0,-1)),p.replace(Yb,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
|
|
351
351
|
`)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
|
|
352
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=
|
|
353
|
-
`)||u&&/[[\]{},]/.test(a))return
|
|
354
|
-
`)?
|
|
355
|
-
`))return
|
|
356
|
-
`:``,v){let e=l(v);S+=`\n${
|
|
352
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=Ub(r,!0);o!==`folded`&&t!==Ob.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=Vb(`${v}${e}${p}`,l,zb,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function Zb(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
|
|
353
|
+
`)||u&&/[[\]{},]/.test(a))return Jb(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
|
|
354
|
+
`)?Jb(a,t):Xb(e,t,n,r);if(!s&&!u&&i!==Ob.PLAIN&&a.includes(`
|
|
355
|
+
`))return Xb(e,t,n,r);if(Wb(a)){if(c===``)return t.forceBlockIndent=!0,Xb(e,t,n,r);if(s&&c===l)return Jb(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return Jb(a,t)}return s?d:Vb(d,c,Rb,Ub(t,!1))}function Qb(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==Ob.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=Ob.QUOTE_DOUBLE);let c=e=>{switch(e){case Ob.BLOCK_FOLDED:case Ob.BLOCK_LITERAL:return i||a?Jb(o.value,t):Xb(o,t,n,r);case Ob.QUOTE_DOUBLE:return Kb(o.value,t);case Ob.QUOTE_SINGLE:return qb(o.value,t);case Ob.PLAIN:return Zb(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function $b(e,t){let n=Object.assign({blockQuote:!0,commentString:Fb,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function ex(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(nb(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function tx(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(nb(e)||ib(e))&&e.anchor;a&&vb(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function nx(e,t,n,r){if(tb(e))return e.toString(t,n,r);if(Qy(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=ab(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=ex(t.doc.schema.tags,a);let o=tx(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):nb(a)?Qb(a,t,n,r):a.toString(t,n,r);return o?nb(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function rx({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=ab(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(ib(e)||!ab(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||ib(e)||(nb(e)?e.type===Ob.BLOCK_FOLDED||e.type===Ob.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=nx(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=Lb(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=Lb(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=Lb(g,n.indent,l(f))));let _,v,y;ab(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&nb(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&rb(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=nx(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
|
|
356
|
+
`:``,v){let e=l(v);S+=`\n${Ib(e,n.indent)}`}x===``&&!n.inFlow?S===`
|
|
357
357
|
`&&y&&(S=`
|
|
358
358
|
|
|
359
|
-
`):S+=`\n${n.indent}`}else if(!p&&
|
|
359
|
+
`):S+=`\n${n.indent}`}else if(!p&&ib(t)){let e=x[0],r=x.indexOf(`
|
|
360
360
|
`),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(S=`\n${n.indent}`)}}else(x===``||x[0]===`
|
|
361
|
-
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=
|
|
361
|
+
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=Lb(g,n.indent,l(y)):h&&i&&i(),g}function ix(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var ax=`<<`,ox={identify:e=>e===ax||typeof e==`symbol`&&e.description===ax,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new Ob(Symbol(ax)),{addToJSMap:cx}),stringify:()=>ax},sx=(e,t)=>(ox.identify(t)||nb(t)&&(!t.type||t.type===Ob.PLAIN)&&ox.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===ox.tag&&e.default);function cx(e,t,n){let r=ux(e,n);if(rb(r))for(let n of r.items)lx(e,t,n);else if(Array.isArray(r))for(let n of r)lx(e,t,n);else lx(e,t,r)}function lx(e,t,n){let r=ux(e,n);if(!eb(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function ux(e,t){return e&&Qy(t)?t.resolve(e.doc,e):t}function dx(e,t,{key:n,value:r}){if(ab(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(sx(e,n))cx(e,t,r);else{let i=Cb(n,``,e);if(t instanceof Map)t.set(i,Cb(r,i,e));else if(t instanceof Set)t.add(i);else{let a=fx(n,i,e),o=Cb(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function fx(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(ab(e)&&n?.doc){let t=$b(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),ix(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function px(e,t,n){return new mx(jb(e,void 0,n),jb(t,void 0,n))}var mx=class e{constructor(e,t=null){Object.defineProperty(this,Zy,{value:Jy}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return ab(n)&&(n=n.clone(t)),ab(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return dx(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?rx(this,e,t,n):JSON.stringify(this)}};function hx(e,t,n){return(t.inFlow??e.flow?_x:gx)(e,t,n)}function gx({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(ab(i))!d&&i.spaceBefore&&f.push(``),vx(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(tb(i)){let e=ab(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),vx(n,f,e.commentBefore,d))}d=!1;let s=nx(i,u,()=>o=null,()=>d=!0);o&&(s+=Lb(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
|
|
362
362
|
`}}return e?(p+=`
|
|
363
|
-
`+
|
|
364
|
-
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=
|
|
365
|
-
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function
|
|
366
|
-
`:` `)}return
|
|
367
|
-
`)?(n.push(`...`),n.push(
|
|
363
|
+
`+Ib(l(e),c),s&&s()):d&&o&&o(),p}function _x({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(ab(i))i.spaceBefore&&d.push(``),vx(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(tb(i)){let e=ab(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),vx(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=ab(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=nx(i,c,()=>a=null);l||=d.length>u||o.includes(`
|
|
364
|
+
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=Lb(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
|
|
365
|
+
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function vx({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=Ib(t(r),e);n.push(i.trimStart())}}function yx(e,t){let n=nb(t)?t.value:t;for(let r of e)if(tb(r)&&(r.key===t||r.key===n||nb(r.key)&&r.key.value===n))return r}var bx=class extends Pb{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(qy,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(px(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=tb(e)?e:!e||typeof e!=`object`||!(`key`in e)?new mx(e,e?.value):new mx(e.key,e.value);let r=yx(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);nb(r.value)&&Db(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=yx(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=yx(this.items,e)?.value;return(!t&&nb(n)?n.value:n)??void 0}has(e){return!!yx(this.items,e)}set(e,t){this.add(new mx(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)dx(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!tb(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),hx(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},xx={collection:`map`,default:!0,nodeClass:bx,tag:`tag:yaml.org,2002:map`,resolve(e,t){return eb(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>bx.from(e,t,n)},Sx=class extends Pb{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(Xy,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Cx(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=Cx(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&nb(r)?r.value:r}has(e){let t=Cx(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=Cx(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];nb(r)&&Db(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(Cb(e,String(r++),t));return n}toString(e,t,n){return e?hx(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(jb(a,void 0,n))}}return i}};function Cx(e){let t=nb(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var wx={collection:`seq`,default:!0,nodeClass:Sx,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return rb(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>Sx.from(e,t,n)},Tx={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),Qb(e,t,n,r)}},Ex={identify:e=>e==null,createNode:()=>new Ob(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Ob(null),stringify:({source:e},t)=>typeof e==`string`&&Ex.test.test(e)?e:t.options.nullStr},Dx={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Ob(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&Dx.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function Ox({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var kx={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:Ox},Ax={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),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Ox(e)}},jx={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 Ob(parseFloat(e)),n=e.indexOf(`.`);return n!==-1&&e[e.length-1]===`0`&&(t.minFractionDigits=e.length-n-1),t},stringify:Ox},Mx=e=>typeof e==`bigint`||Number.isInteger(e),Nx=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function Px(e,t,n){let{value:r}=e;return Mx(r)&&r>=0?n+r.toString(t):Ox(e)}var Fx={identify:e=>Mx(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>Nx(e,2,8,n),stringify:e=>Px(e,8,`0o`)},Ix={identify:Mx,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>Nx(e,0,10,n),stringify:Ox},Lx={identify:e=>Mx(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>Nx(e,2,16,n),stringify:e=>Px(e,16,`0x`)},Rx=[xx,wx,Tx,Ex,Dx,Fx,Ix,Lx,kx,Ax,jx];function zx(e){return typeof e==`bigint`||Number.isInteger(e)}var Bx=({value:e})=>JSON.stringify(e),Vx=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:Bx},{identify:e=>e==null,createNode:()=>new Ob(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:Bx},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:Bx},{identify:zx,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>zx(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Bx}],Hx=[xx,wx].concat(Vx,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}}),Ux={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,t){if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return t(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:t,value:n},r,i,a){if(!n)return``;let o=n,s;if(typeof btoa==`function`){let e=``;for(let t=0;t<o.length;++t)e+=String.fromCharCode(o[t]);s=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(t??=Ob.BLOCK_LITERAL,t!==Ob.QUOTE_DOUBLE){let e=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),n=Math.ceil(s.length/e),i=Array(n);for(let t=0,r=0;t<n;++t,r+=e)i[t]=s.substr(r,e);s=i.join(t===Ob.BLOCK_LITERAL?`
|
|
366
|
+
`:` `)}return Qb({comment:e,type:t,value:s},r,i,a)}};function Wx(e,t){if(rb(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!tb(r)){if(eb(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new mx(new Ob(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]=tb(r)?r:new mx(r)}}else t(`Expected a sequence for this tag`);return e}function Gx(e,t,n){let{replacer:r}=n,i=new Sx(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(px(o,s,n))}return i}var Kx={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:Wx,createNode:Gx},qx=class e extends Sx{constructor(){super(),this.add=bx.prototype.add.bind(this),this.delete=bx.prototype.delete.bind(this),this.get=bx.prototype.get.bind(this),this.has=bx.prototype.has.bind(this),this.set=bx.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(tb(e)?(r=Cb(e.key,``,t),i=Cb(e.value,r,t)):r=Cb(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=Gx(e,t,n),i=new this;return i.items=r.items,i}};qx.tag=`tag:yaml.org,2002:omap`;var Jx={collection:`seq`,identify:e=>e instanceof Map,nodeClass:qx,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=Wx(e,t),r=[];for(let{key:e}of n.items)nb(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new qx,n)},createNode:(e,t,n)=>qx.from(e,t,n)};function Yx({value:e,source:t},n){return t&&(e?Xx:Zx).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var Xx={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 Ob(!0),stringify:Yx},Zx={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 Ob(!1),stringify:Yx},Qx={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:Ox},$x={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():Ox(e)}},eS={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 Ob(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:Ox},tS=e=>typeof e==`bigint`||Number.isInteger(e);function nS(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 rS(e,t,n){let{value:r}=e;if(tS(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return Ox(e)}var iS={identify:tS,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>nS(e,2,2,n),stringify:e=>rS(e,2,`0b`)},aS={identify:tS,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>nS(e,1,8,n),stringify:e=>rS(e,8,`0`)},oS={identify:tS,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>nS(e,0,10,n),stringify:Ox},sS={identify:tS,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>nS(e,2,16,n),stringify:e=>rS(e,16,`0x`)},cS=class e extends bx{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=tb(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new mx(e.key,null):new mx(e,null),yx(this.items,t.key)||this.items.push(t)}get(e,t){let n=yx(this.items,e);return!t&&tb(n)?nb(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=yx(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new mx(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(px(e,null,n));return i}};cS.tag=`tag:yaml.org,2002:set`;var lS={collection:`map`,identify:e=>e instanceof Set,nodeClass:cS,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>cS.from(e,t,n),resolve(e,t){if(eb(e)){if(e.hasAllNullValues(!0))return Object.assign(new cS,e);t(`Set items must all have null values`)}else t(`Expected a mapping for this tag`);return e}};function uS(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 dS(e){let{value:t}=e,n=e=>e;if(typeof t==`bigint`)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return Ox(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 fS={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})=>uS(e,n),stringify:dS},pS={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=>uS(e,!1),stringify:dS},mS={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(mS.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=uS(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$/,``)??``},hS=[xx,wx,Tx,Ex,Xx,Zx,iS,aS,oS,sS,Qx,$x,eS,Ux,ox,Jx,Kx,lS,fS,pS,mS],gS=new Map([[`core`,Rx],[`failsafe`,[xx,wx,Tx]],[`json`,Hx],[`yaml11`,hS],[`yaml-1.1`,hS]]),_S={binary:Ux,bool:Dx,float:jx,floatExp:Ax,floatNaN:kx,floatTime:pS,int:Ix,intHex:Lx,intOct:Fx,intTime:fS,map:xx,merge:ox,null:Ex,omap:Jx,pairs:Kx,seq:wx,set:lS,timestamp:mS},vS={"tag:yaml.org,2002:binary":Ux,"tag:yaml.org,2002:merge":ox,"tag:yaml.org,2002:omap":Jx,"tag:yaml.org,2002:pairs":Kx,"tag:yaml.org,2002:set":lS,"tag:yaml.org,2002:timestamp":mS};function yS(e,t,n){let r=gS.get(t);if(r&&!e)return n&&!r.includes(ox)?r.concat(ox):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(gS.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(ox)),i.reduce((e,t)=>{let n=typeof t==`string`?_S[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(_S).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 bS=(e,t)=>e.key<t.key?-1:+(e.key>t.key),xS=class e{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?yS(e,`compat`):e?yS(null,e):null,this.name=typeof i==`string`&&i||`core`,this.knownTags=r?vS:{},this.tags=yS(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,qy,{value:xx}),Object.defineProperty(this,Yy,{value:Tx}),Object.defineProperty(this,Xy,{value:wx}),this.sortMapEntries=typeof a==`function`?a:a===!0?bS:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function SS(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=$b(e,t),{commentString:a}=i.options;if(e.commentBefore){n.length!==1&&n.unshift(``);let t=a(e.commentBefore);n.unshift(Ib(t,``))}let o=!1,s=null;if(e.contents){if(ab(e.contents)){if(e.contents.spaceBefore&&r&&n.push(``),e.contents.commentBefore){let t=a(e.contents.commentBefore);n.push(Ib(t,``))}i.forceBlockIndent=!!e.comment,s=e.contents.comment}let t=s?void 0:()=>o=!0,c=nx(e.contents,i,()=>s=null,t);s&&(c+=Lb(c,``,a(s))),(c[0]===`|`||c[0]===`>`)&&n[n.length-1]===`---`?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(nx(e.contents,i));if(e.directives?.docEnd){if(e.comment){let t=a(e.comment);t.includes(`
|
|
367
|
+
`)?(n.push(`...`),n.push(Ib(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(Ib(a(t),``)))}return n.join(`
|
|
368
368
|
`)+`
|
|
369
|
-
`}var
|
|
370
|
-
`)},
|
|
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>`:
|
|
369
|
+
`}var CS=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Zy,{value:Ky});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 _b({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[Zy]:{value:Ky}});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=ab(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){wS(this.contents)&&this.contents.add(e)}addIn(e,t){wS(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=yb(this);e.anchor=!t||n.has(t)?bb(t||`a`,n):t}return new Tb(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}=xb(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=jb(e,l,p);return o&&ib(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new mx(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return wS(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Nb(e)?this.contents!=null&&(this.contents=null,!0):wS(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return ib(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Nb(e)?!t&&nb(this.contents)?this.contents.value:this.contents:ib(this.contents)?this.contents.getIn(e,t):void 0}has(e){return ib(this.contents)?this.contents.has(e):!1}hasIn(e){return Nb(e)?this.contents!==void 0:ib(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Mb(this.schema,[e],t):wS(this.contents)&&this.contents.set(e,t)}setIn(e,t){Nb(e)?this.contents=t:this.contents==null?this.contents=Mb(this.schema,Array.from(e),t):wS(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 _b({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 _b({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 xS(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=Cb(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`?Sb(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 SS(this,e)}};function wS(e){if(ib(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var TS=Symbol(`break visit`),ES=Symbol(`skip children`),DS=Symbol(`remove item`);function OS(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),kS(Object.freeze([]),e,t)}OS.BREAK=TS,OS.SKIP=ES,OS.REMOVE=DS,OS.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},OS.parentCollection=(e,t)=>{let n=OS.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 kS(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=kS(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===TS)return TS;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 AS(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 $y(e)&&!r?e.toString(n):new CS(e,r,n).toString(n)}var jS=e=>AS(e,{version:`1.1`})!==AS(e,{version:`1.2`}),MS=(e,t={})=>{let n=new CS(e);return ub(n,{Scalar(e,t){typeof t.value==`string`&&jS(t.value)&&(t.type=Ob.QUOTE_DOUBLE)}}),n.toString(t)},NS=`.yarramate/projections`,PS=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t.length===0?`view`:/^[a-z]/.test(t)?t:`view-${t}`},FS=(e,t)=>{if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;return`${e}-${n}`},IS=(e,t)=>FS(PS(e),t),LS=e=>`${NS}/${e}.yaml`,RS=e=>e.presentation?.folder??``,zS=(e,t)=>({path:e.path,projection:VS({id:e.id,title:t,description:e.description,query:e.query,presentation:e.presentation})}),BS=(e,t)=>{let n=`${e.title} copy`,r=IS(n,t);return{path:LS(r),projection:VS({id:r,title:n,description:e.description,query:e.query,presentation:e.presentation})}},VS=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}}}},HS=e=>e.subjects!==void 0,US=(e,t,n)=>{if(!HS(e.query))return WS(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)}}},WS=(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}}},GS=(e,t)=>{if(!HS(e)&&!HS(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!HS(e)||!HS(t)?[]:[...t.subjects.filter(t=>!e.subjects.includes(t)).map(e=>`+${e}`),...e.subjects.filter(e=>!t.subjects.includes(e)).map(e=>`-${e}`)]},KS=(e,t)=>qS(e)===qS(t),qS=e=>Array.isArray(e)?`[${e.map(qS).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)}:${qS(t)}`).join(`,`)}}`:JSON.stringify(e)??`null`,JS=e=>e.slice(e.lastIndexOf(`#`)+1),YS=e=>e.name===void 0||e.name===e.label?e.label:`${e.name} (${e.label})`,XS={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`}},ZS=(e,t)=>{let n=JS(e),r=XS[n];return r===void 0?t===`incoming`?`${n} to it`:`${n}`:t===`incoming`?r.in:r.out},QS=(e,t)=>e.map(e=>ZS(e,t)).join(` or `),$S=e=>{for(let t of e.trigger??[]){let n=eC(t,e);if(n!==null)return n}return null},eC=(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 ${QS(n,r)}…`:`Connect what it ${QS(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=JS(t);return{kind:`add`,label:`Add ${tC(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}},tC=e=>/^[aeiou]/i.test(e)?`an`:`a`,nC=(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=rC(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
|
+
`)},rC=(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: ${JS(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>`:JS(e)}`,` from: ${i?`<the other subject>`:t.id}`,` to: ${i?t.id:`<the other subject>`}`].join(`
|
|
372
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}},nC={subjects:[],documents:[],kinds:[],layers:[],statuses:[],excludeStatuses:[],states:[],owners:[],constraints:[],relationshipKinds:[],kindMatching:``,relationships:``,isolatedConcepts:``},rC=[`planned`,`current`,`retired`],iC=e=>e===null?nC:{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??``},aC=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}}),oC=({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})]})]})},sC=({legend:e,values:t,onChange:n})=>(0,$.jsxs)(`fieldset`,{className:`filter-field filter-checkbox-group`,children:[(0,$.jsx)(`legend`,{children:e}),rC.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))]}),cC=({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))]})]}),lC=(e,t)=>n=>e(t,n);function uC({fields:e,onChange:t}){return(0,$.jsxs)(`div`,{className:`filter-grid`,children:[(0,$.jsx)(oC,{id:`filter-subjects`,label:`Subjects`,values:e.subjects,onChange:e=>t(`subjects`,e)}),(0,$.jsx)(oC,{id:`filter-documents`,label:`Documents`,values:e.documents,onChange:e=>t(`documents`,e)}),(0,$.jsx)(oC,{id:`filter-kinds`,label:`Kinds`,values:e.kinds,onChange:e=>t(`kinds`,e)}),(0,$.jsx)(oC,{id:`filter-layers`,label:`Layers`,values:e.layers,onChange:e=>t(`layers`,e)}),(0,$.jsx)(oC,{id:`filter-states`,label:`States`,values:e.states,onChange:e=>t(`states`,e)}),(0,$.jsx)(oC,{id:`filter-owners`,label:`Owners`,values:e.owners,onChange:e=>t(`owners`,e)}),(0,$.jsx)(oC,{id:`filter-constraints`,label:`Constraints`,values:e.constraints,onChange:e=>t(`constraints`,e)}),(0,$.jsx)(oC,{id:`filter-relationship-kinds`,label:`Relationship kinds`,values:e.relationshipKinds,onChange:e=>t(`relationshipKinds`,e)}),(0,$.jsx)(sC,{legend:`Statuses`,values:e.statuses,onChange:e=>t(`statuses`,e)}),(0,$.jsx)(sC,{legend:`Exclude statuses`,values:e.excludeStatuses,onChange:e=>t(`excludeStatuses`,e)}),(0,$.jsx)(cC,{id:`filter-kind-matching`,label:`Kind matching`,value:e.kindMatching,options:[`exact`,`descendants`],onChange:e=>t(`kindMatching`,e)}),(0,$.jsx)(cC,{id:`filter-relationships`,label:`Relationships`,value:e.relationships,options:[`between`,`connected`,`none`],onChange:e=>t(`relationships`,e)}),(0,$.jsx)(cC,{id:`filter-isolated-concepts`,label:`Isolated concepts`,value:e.isolatedConcepts,options:[`include`,`exclude`],onChange:e=>t(`isolatedConcepts`,e)})]})}function dC({showLifecycle:e,showEvidence:t,showOwnership:n,showResponsibility:r,showKindLabels:i,showNudges:a,onTogglePresentation:o}){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=>lC(o,`showLifecycle`)(e.currentTarget.checked)}),`Lifecycle badges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>lC(o,`showEvidence`)(e.currentTarget.checked)}),`Evidence badges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>lC(o,`showOwnership`)(e.currentTarget.checked)}),`Ownership badges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>lC(o,`showResponsibility`)(e.currentTarget.checked)}),`Responsibility edges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>lC(o,`showKindLabels`)(e.currentTarget.checked)}),`Kind labels`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>lC(o,`showNudges`)(e.currentTarget.checked)}),`Open-question badges`]})]})}var fC=[{id:`next-question`,label:`Next question`},{id:`view-query`,label:`View query`}],pC=e=>JSON.stringify(Object.entries(e??{}).sort(([e],[t])=>e<t?-1:1)),mC=(e,t)=>pC(e)===pC(t),hC={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`},gC=Object.keys(hC),_C=(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 gC.flatMap(e=>{let t=a.get(e);return t===void 0?[]:[{reason:e,label:hC[e],subjects:t}]})},vC=(e,t)=>{if(t===null)return e.length;let n=new Set(t);return e.filter(e=>n.has(e.id)).length},yC=(e,t)=>{if(e===null||t===null)return 0;let n=new Set(e);return t.filter(({id:e})=>n.has(e)).length},bC=(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(`showResponsibility`),...i(`showKindLabels`)}},xC=({view:e,query:t,badges:n,opened:r})=>zS({id:e.id,title:e.title,description:e.description,query:t,presentation:bC(e,n,r)}),SC=e=>({op:`write-view`,path:e.view.path,projection:xC(e)}),CC=e=>{let t=xC(e),n=zS({id:e.view.id,title:e.view.title,description:e.view.description,query:e.view.query,presentation:e.view.presentation});return pC(t.query)!==pC(n.query)||pC(t.presentation)!==pC(n.presentation)},wC=({next:e,readOnly:t,delegateLabel:n,onVerb:r,onDelegate:i,onGo:a})=>{let o=t||r===void 0?null:ZS(e),s=e.subjectId===void 0?null:e.subjectName??e.subjectId;return(0,$.jsxs)(`div`,{className:`next-question-tab`,children:[(0,$.jsxs)(`p`,{className:`next-question-eyebrow`,children:[`Next question · `,e.wave,` ·`,` `,s===null?`the whole record`:`about ${s}`]}),(0,$.jsx)(`h3`,{className:`next-question-text`,children:e.question}),e.materiality===void 0?null:(0,$.jsx)(`p`,{className:`next-question-why`,children:e.materiality}),e.resolution===void 0?null:(0,$.jsx)(`p`,{className:`next-question-how`,children:e.resolution}),(0,$.jsxs)(`div`,{className:`next-question-actions`,children:[a===void 0?null:(0,$.jsx)(`button`,{type:`button`,className:`question-verb question-verb-go`,onClick:()=>a(e),children:s===null?`Open the questions`:`Go to ${s}`}),o===null?null:(0,$.jsx)(`button`,{type:`button`,className:`question-verb question-verb-${o.kind}`,onClick:()=>r?.(o,e.subjectId??null),children:o.label}),t||i===void 0?null:(0,$.jsx)(`button`,{type:`button`,className:`question-verb question-verb-delegate`,onClick:()=>i(e),children:n??`Answer via agent`})]})]})};function TC({nodes:e,activeFilter:t,view:n,open:r,tab:i,showLifecycle:a,showEvidence:o,showOwnership:s,showResponsibility:c,showKindLabels:l,showNudges:u,onTogglePresentation:d,onToggleOpen:f,onSelectTab:p,onApply:m,onStage:h,readOnly:g=!1,next:_,delegateLabel:v,onNextVerb:b,onNextDelegate:x,onNextGo:S}){let C=i===`next-question`&&_===void 0?`view-query`:i,w=fC.filter(e=>e.id!==`next-question`||_!==void 0),T=(0,y.useRef)(null),[E,D]=(0,y.useState)(()=>iC(n?.query??t?.query??null)),[O,k]=(0,y.useState)(!1),[A]=(0,y.useState)(()=>({showLifecycle:a,showEvidence:o,showOwnership:s,showResponsibility:c,showKindLabels:l})),j=e=>{T.current!==null&&window.clearTimeout(T.current),T.current=window.setTimeout(()=>{T.current=null,m(aC(e))},300)},M=(e,t)=>{k(!1),D(n=>{let r={...n,[e]:t};return j(r),r})},N=aC(E),P=t?.matchedIds??null,F=vC(e,P),I=_C(e,P,t?.excluded??null),L=yC(P,t?.excluded??null),R=t===null?Object.keys(N).length===0:mC(N,t.query),z=n===null?null:{view:n,query:N,badges:{showLifecycle:a,showEvidence:o,showOwnership:s,showResponsibility:c,showKindLabels:l},opened:A};return(0,$.jsxs)(`section`,{className:`bottom-panel`,"aria-label":`Canvas panels`,children:[(0,$.jsxs)(`div`,{className:`bottom-panel-tabs`,children:[(0,$.jsx)(`div`,{className:`bottom-panel-tablist`,role:`tablist`,"aria-label":`Canvas panels`,children:w.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,id:`bottom-tab-${e.id}`,className:`bottom-panel-tab`,"aria-selected":r&&C===e.id,"aria-controls":`bottom-panel-${e.id}`,onClick:()=>{if(r&&C===e.id){f();return}p(e.id)},children:e.label},e.id))}),C===`next-question`&&_!==void 0?(0,$.jsx)(`span`,{className:`bottom-panel-summary bottom-panel-summary-next`,role:`status`,title:_.materiality,children:_.question}):(0,$.jsxs)(`span`,{className:`bottom-panel-summary`,role:`status`,children:[F,` `,F===1?`subject`:`subjects`,I.length===0?``:` · ${I.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-${C}`,"aria-label":r?`Collapse panel`:`Expand panel`,onClick:f,children:r?`▾`:`▴`})]}),r?C===`next-question`&&_!==void 0?(0,$.jsx)(`div`,{className:`bottom-panel-body`,id:`bottom-panel-next-question`,role:`tabpanel`,"aria-labelledby":`bottom-tab-next-question`,children:(0,$.jsx)(wC,{next:_,readOnly:g,delegateLabel:v,onVerb:b,onDelegate:x,onGo:S})}):(0,$.jsx)(`div`,{className:`bottom-panel-body`,id:`bottom-panel-${C}`,role:`tabpanel`,"aria-labelledby":`bottom-tab-${C}`,children:(0,$.jsxs)(`div`,{className:`query-tab`,children:[(0,$.jsxs)(`div`,{className:`query-tab-fields`,children:[(0,$.jsx)(uC,{fields:E,onChange:M}),(0,$.jsx)(dC,{showLifecycle:a,showEvidence:o,showOwnership:s,showResponsibility:c,showKindLabels:l,showNudges:u,onTogglePresentation:d})]}),(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:F}),` `,F===1?`subject`:`subjects`,` of `,e.length]}),R?null:(0,$.jsx)(`p`,{className:`query-outcome-stale`,children:`Describing the query on the canvas, not the edit in progress.`}),F===0&&P!==null?(0,$.jsx)(`p`,{className:`query-outcome-empty`,children:`This query selects nothing.`}):null,L===0?null:(0,$.jsxs)(`p`,{className:`query-outcome-note`,children:[L,` a facet dropped `,L===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`}),I.length===0?(0,$.jsx)(`p`,{className:`query-outcome-note`,children:`Nothing is left out of this view.`}):(0,$.jsx)(`ul`,{className:`query-exclusions`,children:I.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`}),z===null?(0,$.jsx)(`p`,{className:`query-outcome-note`,children:g?`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:AS(xC(z))}),g?null:(0,$.jsxs)(`div`,{className:`query-tab-actions`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:!CC(z),onClick:()=>{h(SC(z)),k(!0)},children:`Stage view change`}),(0,$.jsx)(`span`,{role:`status`,className:`query-stage-status`,children:O?`Staged. It lands when the changeset is committed.`:``})]})]})]})]})}):null]})}function EC({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 DC=`views`,OC=`model`,kC=e=>`view-folder:${e}`,AC=e=>`model-layer:${e}`,jC=e=>`model-folder:${e}`,MC=`unlayered`,NC=(e,t)=>t===``||e.toLowerCase().includes(t),PC=(e,t)=>NC(e,tv(t)),FC=e=>e.presentation?.folder??``,IC=({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?FC(t):r.presentation?.folder??``,f=t.id===n;(NC(c,a)||NC(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??``;(NC(n,a)||NC(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:kC(e),name:e,views:[...t].sort(d)}));return{folders:p,loose:f,matched:f.length+p.reduce((e,t)=>e+t.views.length,0)}},LC=({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)&&!NC(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:jC(e),label:e,grouping:`folder`,subjects:[...t].sort(c)})),u=[...D_,MC];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)}]})]},RC=`All subjects`,zC=`M2 3.5 5 6.5 8 3.5`,BC=`M3.5 2 6.5 5 3.5 8`;function VC({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?zC:BC,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function HC(){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 UC({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 WC=(e,t)=>n=>{n.preventDefault(),t(e,{x:n.clientX,y:n.clientY})};function GC({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?WC({kind:`view`,id:e.id},r):void 0,children:[(0,$.jsx)(HC,{}),(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 KC({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)(VC,{open:t}),(0,$.jsx)(`span`,{className:`tree-label`,children:e}),n===void 0?null:(0,$.jsx)(`span`,{className:`tree-count`,children:n})]})}function qC({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=IC({views:e,stagedOperations:t,activeViewId:n,activeSubjects:i===null?null:r.filter(e=>i.has(e.id)),filterText:s}),y=LC({nodes:r,inViewIds:i,filterText:s,folded:a,insideCounts:o}),b=!c.has(DC),x=!c.has(OC),S=s.trim()!==``,C=n===``&&i===null,w=PC(RC,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)(KC,{label:`Views`,open:b,depth:0,onToggle:()=>u(DC)}),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:WC({kind:`view`,id:``},h),children:[(0,$.jsx)(HC,{}),(0,$.jsx)(`span`,{className:`tree-label`,children:RC}),(0,$.jsx)(`span`,{className:`tree-count`,children:rv(r,s)})]})}):null,v.loose.map(e=>(0,$.jsx)(GC,{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)(KC,{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)(GC,{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)(KC,{label:`Model`,open:x,depth:0,onToggle:()=>u(OC)}),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)(KC,{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:WC({kind:`subject`,id:e.id},h),children:[(0,$.jsx)(UC,{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 JC=({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??PS(a,t);return{op:`write-view`,path:n??FS(m),projection:zS({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 YC({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 XC({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(JC({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)(YC,{activeView:p,presetFolder:u,onSubmit:(e,t,n)=>{m(e,t,n),d()},onCancel:d},t)}):null}function ZC(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 QC=(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]},$C=(e,t)=>{let n=e.edges.find(({id:e})=>e===t);return n===void 0?[]:[n.from,n.to]},ew=(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}},tw=e=>{let t=new Set;for(let n of e)for(let e of n.subjects??[])t.add(e);return t},nw=(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},rw=(e,t,n)=>[...e.operations.map(e=>aw(e,t)),...e.viewOperations.map(e=>iw(e,n))],iw=(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?[]:US(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`}},aw=(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=nw(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:nw(e.document,r.id,t),fields:Object.keys(r).filter(e=>e!==`id`),removedFields:n,scope:`model`}},ow=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(`, `)}`},sw=/^\/operations\/(\d+)(\/|$)/,cw=e=>{let t=new Map,n=[];for(let r of e){let e=sw.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}},lw=(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},uw=({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]})]}),dw=({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:ow(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)(uw,{diagnostic:e},`${e.code}-${e.pointer}`))})]}),fw=({state:e,onDiscardChange:t,onClearChangeset:n,onUndoChangeset:r,onRedoChangeset:i,onCommitChangeset:a})=>{let o=e.model?.graph??null,s=rw(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}=cw(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=ew(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)(uw,{diagnostic:e},`${e.code}-${e.pointer}`))}),s.length===0?null:(0,$.jsx)(`ol`,{className:`changeset-rows`,children:s.map((n,r)=>(0,$.jsx)(dw,{index:r,row:n,diagnostics:c.get(r)??[],conflict:lw(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))})]})]})},pw={a:`access`,c:`composition`,f:`flow`,g:`aggregation`,i:`assignment`,n:`influence`,o:`association`,r:`realization`,s:`specialization`,t:`triggering`,v:`serving`},mw=`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(`.`),hw={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`},gw=new Map(mw.map((e,t)=>[e,t])),_w=new Map(Object.entries(pw)),vw=new Map;for(let e of mw){let t=hw[e].split(` `);for(let[n,r]of mw.entries()){let i=t[n]??`-`,a=new Set;for(let e of i){let t=_w.get(e);t!==void 0&&a.add(t)}vw.set(`${e}>${r}`,a)}}var yw=new Set,bw=e=>gw.has(e),xw=(e,t)=>vw.get(`${e}>${t}`)??yw;new Map(k_.map(e=>[e.id,e.aspect])),new Set(mw),new Set(A_);var Sw=A_,Cw=(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||!bw(r.coreKindLabel)||!bw(i.coreKindLabel))return[];let a=[...xw(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},ww=(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}},Tw=(e,t,n,r,i=[])=>{if(!Cw(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:ww(e,t,n,r,i),kind:n,from:t,to:r}}},Ew=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}),Dw=new Map(k_.map(e=>[e.id,{layer:e.layer,aspect:e.aspect}])),Ow=new Set([`businessService`,`applicationService`,`technologyService`]),kw=new Set([`businessInterface`,`applicationInterface`,`technologyInterface`]),Aw=e=>Ow.has(e),jw=e=>kw.has(e),Mw=e=>Dw.get(e)?.aspect===`behavior`&&!Aw(e),Nw=[{name:`behaviour-uses-data`,because:`behaviour reads, writes or creates the passive structure it touches`,kind:`access`,when:(e,t,n,r)=>r.aspect===`passive-structure`&&(Mw(e)||Aw(e))&&t!==`artifact`},{name:`interface-exposes-service`,because:`an interface is assigned to the service it exposes, not to the behaviour that uses it`,kind:`assignment`,when:(e,t,n,r)=>jw(e)&&Aw(t)&&n.layer===r.layer},{name:`service-is-offered-outward`,because:`a service is made available to whoever uses it`,kind:`serving`,when:(e,t,n,r)=>(Aw(e)||jw(e))&&(r.aspect===`active-structure`||r.aspect===`behavior`)},{name:`grouping-collects-members`,because:`a grouping aggregates what it collects; the members exist without it`,kind:`aggregation`,when:e=>e===`grouping`},{name:`artifact-realizes-what-it-implements`,because:`an artifact is the concrete file or deployable that fulfils the thing it stands for`,kind:`realization`,when:(e,t,n,r)=>e===`artifact`&&(r.aspect===`active-structure`||r.aspect===`passive-structure`)&&t!==`artifact`},{name:`active-structure-performs-behaviour`,because:`an active structure element is assigned to the internal behaviour it performs`,kind:`assignment`,when:(e,t,n,r)=>n.aspect===`active-structure`&&Mw(t)&&n.layer===r.layer},{name:`internal-realizes-service`,because:`the internal element is the concrete thing that fulfils the service its layer offers`,kind:`realization`,when:(e,t,n,r)=>Aw(t)&&n.layer===r.layer&&(n.aspect===`active-structure`||Mw(e))&&!jw(e)},{name:`technology-serves-application`,because:`a technology element is not part of the application it runs; it serves it`,kind:`serving`,when:(e,t,n,r)=>n.layer===`technology`&&r.layer===`application`&&(r.aspect===`active-structure`||r.aspect===`behavior`)}],Pw=new Map,Fw=(e,t)=>{let n=`${e}>${t}`,r=Pw.get(n);if(r!==void 0)return r;let i=Iw(e,t);return Pw.set(n,i),i},Iw=(e,t)=>{if(!bw(e)||!bw(t))return null;let n=Dw.get(e),r=Dw.get(t);if(n===void 0||r===void 0)return null;for(let i of Nw)if(i.when(e,t,n,r))return xw(e,t).has(i.kind)?{kind:i.kind,rule:i.name,because:i.because}:null;return null};Nw.map(({name:e,kind:t,because:n})=>({name:e,kind:t,because:n}));var Lw=(e,t,n,r)=>{let i=new Set(Cw(e,t.from,t.to)),a=Fw(e.nodes.find(e=>e.id===t.from)?.coreKindLabel??``,e.nodes.find(e=>e.id===t.to)?.coreKindLabel??``);if(i.size===0)return{options:n,narrowed:!1,conventional:a};let o=new Set(Sw);return{options:n.filter(e=>i.has(e.coreLabel)||!o.has(e.coreLabel)||e.label===r),narrowed:!0,conventional:a}},Rw=[`kind`,`name`,`description`,`status`,`owner`],zw=[`aka`,`constraints`,`references`,`presentIn`,`attestations`,`distinctFrom`,`supersedes`],Bw=[`kind`,`from`,`to`,`name`,`description`,`status`,`mode`,`content`],Vw=[`references`,`presentIn`],Hw=(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)=>Hw(e,t[n]));let n=e,r=t,i=Object.keys(n),a=Object.keys(r);return i.length===a.length&&i.every(e=>Hw(n[e],r[e]))},Uw=(e,t)=>t===(e??``)?{kind:`none`}:t===``?{kind:`remove`}:{kind:`set`,value:t},Ww=(e,t)=>Hw(e,t)?{kind:`none`}:t.length>=e.length&&e.every((e,n)=>Hw(e,t[n]))?{kind:`append`,added:t.slice(e.length)}:{kind:`replace`,next:t},Gw=(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]},Kw=(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}},qw=(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]},Jw=(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}},Yw=(e,t,n,r,i)=>{let a=Uw(r,i);return a.kind===`none`?[]:a.kind===`remove`?[Gw(e,t,n,!1,``)]:[Gw(e,t,n,!0,a.value)]},Xw=(e,t,n,r,i)=>{let a=Uw(r,i);return a.kind===`none`?[]:a.kind===`remove`?[qw(e,t,n,!1,``)]:[qw(e,t,n,!0,a.value)]},Zw=(e,t,n,r,i)=>{let a=Ww(r,i);if(a.kind===`none`)return[];if(a.kind===`append`)return a.added.length===0?[]:[Kw(e,t,n,a.added)];let o=[Kw(e,t,n,null)];return a.next.length>0&&o.push(Kw(e,t,n,a.next)),o},Qw=(e,t,n,r,i)=>{let a=Ww(r,i);if(a.kind===`none`)return[];if(a.kind===`append`)return a.added.length===0?[]:[Jw(e,t,n,a.added)];let o=[Jw(e,t,n,null)];return a.next.length>0&&o.push(Jw(e,t,n,a.next)),o},$w=e=>e.expects===null?{id:e.id,ref:e.ref}:{id:e.id,ref:e.ref,expects:e.expects},eT=(e,t,n,r)=>{let i=Ww(n,r);if(i.kind===`none`)return[];if(i.kind===`append`)return i.added.length===0?[]:[Kw(e,t,`constraints`,i.added.map($w))];let a=[Kw(e,t,`constraints`,null)];return i.next.length>0&&a.push(Kw(e,t,`constraints`,i.next.map($w))),a},tT=e=>({topic:e.topic,by:e.by,recordedBy:e.recordedBy??``,on:e.on}),nT=(e,t,n,r)=>{let i=Ww(n,r);if(i.kind===`none`)return[];if(i.kind===`append`)return i.added.length===0?[]:[Kw(e,t,`attestations`,i.added.map(tT))];let a=[Kw(e,t,`attestations`,null)];return i.next.length>0&&a.push(Kw(e,t,`attestations`,i.next.map(tT))),a},rT=(e,t)=>{let n={...e},r=t.concept;for(let e of Rw)r[e]!==void 0&&(n[e]=r[e]);for(let e of zw){let t=r[e];t!==void 0&&t.length>0&&(n[e]=[...n[e],...t])}for(let e of t.remove??[])n[e]=zw.includes(e)?[]:null;return n},iT=(e,t)=>{let n=e;for(let r of t)r.op===`update-concept`&&r.document===e.document&&r.concept.id===e.localId&&(n=rT(n,r));return n},aT=(e,t)=>{let n={...e},r=t.relationship;for(let e of Bw)r[e]!==void 0&&(n[e]=r[e]);for(let e of Vw){let t=r[e];t!==void 0&&t.length>0&&(n[e]=[...n[e],...t])}for(let e of t.remove??[])n[e]=Vw.includes(e)?[]:null;return n},oT=(e,t)=>{let n=e;for(let r of t)r.op===`update-relationship`&&r.document===e.document&&r.relationship.id===e.localId&&(n=aT(n,r));return n},sT=e=>`subject-${e.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}`,cT=({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:sT(e),value:t,onChange:e=>r(e.target.value),children:n.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),lT=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:#[a-z][a-z0-9]*(?:-[a-z0-9]+)*)?$/,uT=`An id, like finance-it or main#finance-it: lowercase letters, digits and single hyphens.`,dT=({label:e,value:t,onCommit:n,shape:r})=>{let[i,a]=(0,y.useState)(t);(0,y.useEffect)(()=>a(t),[t]);let o=r!==void 0&&i!==``&&!r.pattern.test(i),s=`${sT(e)}-hint`;return(0,$.jsxs)(`label`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,$.jsx)(`input`,{type:`text`,name:sT(e),value:i,onChange:e=>a(e.target.value),onBlur:()=>n(i),...r===void 0?{}:{"aria-describedby":s,"aria-invalid":o}}),r===void 0?null:(0,$.jsx)(`span`,{id:s,className:o?`subject-form-hint subject-form-hint-invalid`:`subject-form-hint`,children:r.hint})]})},fT=({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]})]})]})},pT=({label:e,values:t,onCommit:n})=>(0,$.jsx)(fT,{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})}),mT={id:``,ref:``},hT=({label:e,values:t,onCommit:n})=>(0,$.jsx)(fT,{label:e,values:t,emptyRow:mT,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})]})}),gT={id:``,ref:``,expects:null},_T=({label:e,values:t,onCommit:n})=>(0,$.jsx)(fT,{label:e,values:t,emptyRow:gT,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})]})]})}),vT={topic:``,by:``,on:``,recordedBy:null},yT=({label:e,values:t,onCommit:n})=>(0,$.jsx)(fT,{label:e,values:t,emptyRow:vT,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})]})}),bT={value:``,label:`— unset —`},xT=[bT,{value:`planned`,label:`planned`},{value:`current`,label:`current`},{value:`retired`,label:`retired`}],ST=[bT,{value:`read`,label:`read`},{value:`write`,label:`write`},{value:`read-write`,label:`read-write`},{value:`unspecified`,label:`unspecified`}],CT=(e,t)=>t.find(t=>t.id===e)?.label??KS(e),wT=(e,t)=>{let n=t.find(t=>t.id===e);return n===void 0?KS(e):qS(n)},TT={R:[`Responsible`,`for`],C:[`Consulted`,`on`],I:[`Informed`,`of`]},ET=(e,t)=>{let n=new Map(t.graph.nodes.map(e=>[e.id,e.name])),r={R:[],C:[],I:[]},i={R:[],C:[],I:[]};for(let a of t.graph.edges){let t=a.responsibility??null;t!==null&&(a.to===e.id&&r[t].push(n.get(a.from)??a.from),a.from===e.id&&i[t].push(n.get(a.to)??a.to))}return[`R`,`C`,`I`].flatMap(e=>[{key:`${e}-carried`,label:TT[e][0],value:r[e].join(`, `)},{key:`${e}-held`,label:TT[e][0],value:i[e].length===0?``:`${TT[e][1]} ${i[e].join(`, `)}`}])},DT=({node:e,model:t,operations:n,onStageChange:r})=>{let i=iT(e,n),a=e.document,o=e.localId,s=e=>e.forEach(r),c=t.vocabulary.conceptKinds.map(e=>({value:e.label,label:qS(e)})),l=CT(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)(cT,{label:`Kind`,value:l,options:c,onCommit:e=>s(Yw(a,o,`kind`,l,e))}),(0,$.jsx)(dT,{label:`Name`,value:i.name,onCommit:e=>s(Yw(a,o,`name`,i.name,e))}),(0,$.jsx)(dT,{label:`Description`,value:i.description??``,onCommit:e=>s(Yw(a,o,`description`,i.description,e))}),(0,$.jsx)(cT,{label:`Status`,value:i.status??``,options:xT,onCommit:e=>s(Yw(a,o,`status`,i.status,e))}),(0,$.jsx)(dT,{label:`Owner`,value:i.owner??``,shape:{pattern:lT,hint:uT},onCommit:e=>s(Yw(a,o,`owner`,i.owner,e))}),ET(e,t).map(e=>(0,$.jsx)(OT,{label:e.label,value:e.value},e.key)),(0,$.jsx)(pT,{label:`Aka`,values:i.aka,onCommit:e=>s(Zw(a,o,`aka`,i.aka,e))}),(0,$.jsx)(pT,{label:`Distinct from`,values:i.distinctFrom,onCommit:e=>s(Zw(a,o,`distinctFrom`,i.distinctFrom,e))}),(0,$.jsx)(pT,{label:`Supersedes`,values:i.supersedes,onCommit:e=>s(Zw(a,o,`supersedes`,i.supersedes,e))}),(0,$.jsx)(pT,{label:`Present in`,values:i.presentIn,onCommit:e=>s(Zw(a,o,`presentIn`,i.presentIn,e))}),(0,$.jsx)(hT,{label:`References`,values:i.references,onCommit:e=>s(Zw(a,o,`references`,i.references,e))}),(0,$.jsx)(_T,{label:`Constraints`,values:i.constraints,onCommit:e=>s(eT(a,o,i.constraints,e))}),(0,$.jsx)(yT,{label:`Attestations`,values:i.attestations,onCommit:e=>s(nT(a,o,i.attestations,e))})]})},OT=({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})]}),kT=({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)(OT,{label:`Kind`,value:wT(e.kind,t.vocabulary.conceptKinds)}),(0,$.jsx)(OT,{label:`Name`,value:e.name}),(0,$.jsx)(OT,{label:`Status`,value:e.status??``}),(0,$.jsx)(OT,{label:`Owner`,value:e.owner??``}),ET(e,t).map(e=>(0,$.jsx)(OT,{label:e.label,value:e.value},e.key)),(0,$.jsx)(OT,{label:`Aka`,value:e.aka.join(`, `)}),(0,$.jsx)(OT,{label:`Distinct from`,value:e.distinctFrom.join(`, `)}),(0,$.jsx)(OT,{label:`Supersedes`,value:e.supersedes.join(`, `)}),(0,$.jsx)(OT,{label:`Present in`,value:e.presentIn.join(`, `)}),(0,$.jsx)(OT,{label:`References`,value:e.references.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,$.jsx)(OT,{label:`Constraints`,value:e.constraints.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,$.jsx)(OT,{label:`Attestations`,value:e.attestations.map(e=>`${e.topic} by ${e.by} on ${e.on}`).join(`; `)})]}),AT=({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)(OT,{label:`Kind`,value:wT(e.kind,t.vocabulary.relationshipKinds)}),(0,$.jsx)(OT,{label:`From`,value:n(e.from)}),(0,$.jsx)(OT,{label:`To`,value:n(e.to)}),(0,$.jsx)(OT,{label:`Name`,value:e.name??``}),(0,$.jsx)(OT,{label:`Mode`,value:e.mode??``}),(0,$.jsx)(OT,{label:`Content`,value:e.content??``}),(0,$.jsx)(OT,{label:`Status`,value:e.status??``}),(0,$.jsx)(OT,{label:`References`,value:e.references.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,$.jsx)(OT,{label:`Present in`,value:e.presentIn.join(`, `)})]})},jT=({edge:e,model:t,operations:n,onStageChange:r})=>{let i=oT(e,n),a=e.document,o=e.localId,s=e=>e.forEach(r),c=CT(i.kind,t.vocabulary.relationshipKinds),l=Lw(t.graph,{from:i.from,to:i.to},t.vocabulary.relationshipKinds,c).options.map(e=>({value:e.label,label:qS(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)(cT,{label:`Kind`,value:c,options:l,onCommit:e=>s(Xw(a,o,`kind`,c,e))}),(0,$.jsx)(cT,{label:`From`,value:i.from,options:u,onCommit:e=>s(Xw(a,o,`from`,i.from,e))}),(0,$.jsx)(cT,{label:`To`,value:i.to,options:u,onCommit:e=>s(Xw(a,o,`to`,i.to,e))}),(0,$.jsx)(dT,{label:`Name`,value:i.name??``,onCommit:e=>s(Xw(a,o,`name`,i.name,e))}),(0,$.jsx)(dT,{label:`Description`,value:i.description??``,onCommit:e=>s(Xw(a,o,`description`,i.description,e))}),(0,$.jsx)(cT,{label:`Mode`,value:i.mode??``,options:ST,onCommit:e=>s(Xw(a,o,`mode`,i.mode,e))}),(0,$.jsx)(dT,{label:`Content`,value:i.content??``,onCommit:e=>s(Xw(a,o,`content`,i.content,e))}),(0,$.jsx)(cT,{label:`Status`,value:i.status??``,options:xT,onCommit:e=>s(Xw(a,o,`status`,i.status,e))}),(0,$.jsx)(hT,{label:`References`,values:i.references,onCommit:e=>s(Qw(a,o,`references`,i.references,e))}),(0,$.jsx)(pT,{label:`Present in`,values:i.presentIn,onCommit:e=>s(Qw(a,o,`presentIn`,i.presentIn,e))})]})};function MT({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,c=n=>e.next!==void 0&&e.next.questionId===n.questionId&&(t===null?e.next.subjectId===void 0:e.next.subjectId===t);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)(NT,{entry:e,next:c(e),verb:n||r===void 0?null:ZS(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:[e.catalogues===void 0||e.catalogues.length<2?`Catalogue ${e.catalogue}`:`Catalogues ${e.catalogues.join(`, `)}`,` `,`· answers land through the changeset, never here.`]})]})}var NT=({entry:e,next:t,verb:n,onVerb:r,delegateLabel:i,onDelegate:a})=>(0,$.jsxs)(`li`,{className:t?`question-row question-row-next`:`question-row`,children:[(0,$.jsx)(`span`,{className:`question-text`,title:e.materiality,children:e.question}),(0,$.jsxs)(`span`,{className:`question-meta`,children:[t?(0,$.jsx)(`span`,{className:`question-next`,children:`next`}):null,(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]}),n===null?null:(0,$.jsx)(`button`,{type:`button`,className:`question-verb question-verb-${n.kind}`,onClick:()=>r(n),children:n.label}),i===null?null:(0,$.jsx)(`button`,{type:`button`,className:`question-verb question-verb-delegate`,onClick:a,children:i})]})]}),PT={layered:`Layered`,routed:`Routed`,"served-by":`Served-by`,bands:`Layer bands`},FT=[`top-down`,`left-right`],IT={"top-down":`Top-down`,"left-right":`Left-right`};function LT({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:PT[e]},e))}),(0,$.jsx)(`select`,{className:`canvas-select`,"aria-label":`Direction`,value:t,onChange:e=>r(e.currentTarget.value),children:FT.map(e=>(0,$.jsx)(`option`,{value:e,children:IT[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 RT=[`composition`],zT=`top-down`,BT=e=>{let t=e?.trim()??``;return t===``?null:t},VT=e=>({type:`element`,id:e.id,title:e.name,kind:e.kindLabel,description:BT(e.description)}),HT=(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:BT(e.name),description:BT(e.description),kind:e.kindLabel}},UT=e=>new Map(e.nodes.map(e=>[e.id,e.name])),WT=(e,t)=>{let n=e.nodes.find(e=>e.id===t);return n===void 0?null:VT(n)},GT=(e,t)=>{let n=e.edges.find(e=>e.id===t);return n===void 0?null:HT(n,UT(e))},KT=(e,t,n,r,i)=>({showView:t=>{let{views:n}=e();return n.some(e=>e.id===t)?(i(t),!0):!1},select:n=>{let{graph:r}=e();if(r===null)return!1;let i=WT(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)}),qT=[`palette`,`properties`,`questions`,`changes`,`chat`],JT=e=>({min:96,max:Math.max(96,e-160)}),YT=(e,t)=>{let{min:n,max:r}=JT(t);return Math.min(r,Math.max(n,e))},XT=.45,ZT=(e,t)=>e.length===t.length&&new Set([...e,...t]).size===new Set(e).size,QT=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),$T=e=>{let t=[];return t.push({type:`layout.set`,layout:e?.layout??`served-by`}),t.push({type:`nesting.set`,nesting:e?.nesting??RT}),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?.showResponsibility!==void 0&&t.push({type:`presentation.toggled`,flag:`showResponsibility`,value:e.showResponsibility}),e?.showKindLabels!==void 0&&t.push({type:`presentation.toggled`,flag:`showKindLabels`,value:e.showKindLabels}),t},eE=(e,t,n,r)=>!r||e===``||e===n?null:t.find(t=>t.id===e)??null,tE=e=>({min:320,max:Math.max(320,Math.min(640,e*XT))}),nE=(e,t)=>{let{min:n,max:r}=tE(t);return Math.min(r,Math.max(n,e))},rE=480,iE=(e,t)=>{let{min:n,max:r}=tE(t);return Math.min(Math.min(r,rE),Math.max(n,e))},aE=(e,t=0)=>({railHidden:!1,conversation:{width:iE(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:`next-question`},tree:{filterText:``,collapsed:[]},connection:null,draftingSubject:!1,pendingDeletion:null,pendingViewDeletion:null,pendingViewRename:null,contextMenu:null,nesting:RT,foldMode:wg,folded:[],unfolded:[],direction:zT,layout:Fg,showLifecycle:!0,showEvidence:!0,showKindLabels:!0,showOwnership:!1,showResponsibility:!1,showNudges:!0,stylePreset:Kg()}),oE=(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=YT(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=nE(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=nE(e.conversation.width,t.viewportWidth),r=t.viewportHeight??e.viewportHeight,i=YT(e.conversation.changesHeight,r),a=YT(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 QT(e.nesting,t.nesting)?e:{...e,nesting:t.nesting};case`fold.set`:return e.foldMode===t.mode&&ZT(e.folded,t.folded)&&ZT(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`?WT(i,r.id):GT(i,r.id);return a===null?{...n,selectedSubject:null,descriptionExpanded:!1}:{...n,selectedSubject:a}}}},sE=(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 cE({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 lE({label:e,height:t,viewportHeight:n,onResize:r}){let i=JT(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 uE=(e,t,n)=>qT.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)]}),dE={messageBytes:65536,modelBytes:5242880,transcriptBytes:5242880,pendingEvents:32,reconnectMs:3e5,staleSessionMs:864e5}.reconnectMs,fE=`Returning control to the main agent`,pE={operations:[],viewOperations:[],sourceDigests:{}},mE=e=>e.operations.length===0&&e.viewOperations.length===0,hE={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,closedMessage:null,pendingChangeset:pE,undoStack:[],redoStack:[],commitStatus:`idle`,commitDiagnostics:null,commitNotice:null,layoutNotice:null},gE=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}),_E=(e,t)=>t-e<dE,vE=(e,t,n)=>({id:`local-${e.localRecords}`,speaker:t,text:n}),yE=(e,t)=>e.transcript.some(e=>e.id===t.id)?e.transcript:[...e.transcript,t],bE=e=>e.initialView,xE={awaitingAgent:!1,agentStatus:null},SE=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`])}`},CE=(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},wE=(e,t,n)=>{let r=n.operations??e.operations,i=n.viewOperations??e.viewOperations;return{operations:r,viewOperations:i,sourceDigests:CE(r,i,e.sourceDigests,t)}},TE=(e,t)=>{switch(t.type){case`session.loaded`:return{...e,...t.snapshot,lifecycle:e.lifecycle===`ending`?`ending`:`active`,activeView:bE(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,...xE};case`chat.sent`:return{...e,transcript:yE(e,vE(e,`reviewer`,t.text)),localRecords:e.localRecords+1,choices:null,awaitingAgent:!0};case`chat.received`:return{...e,transcript:yE(e,{id:t.id,speaker:`agent`,text:t.text}),...xE};case`status.received`:return{...e,agentStatus:t.status};case`choice.presented`:return{...e,choices:t.choice,...xE};case`choice.sent`:{let n=e.choices?.options.find(e=>e.id===t.optionId);return n===void 0?e:{...e,transcript:yE(e,vE(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:yE(e,{id:t.id,speaker:`agent`,text:t.handoff.summary}),...xE};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`)?xE:{}}}case`end.requested`:return{...e,lifecycle:`ending`,choices:null,transcript:yE(e,vE(e,`session`,fE)),localRecords:e.localRecords+1};case`connection.lost`:return{...e,lifecycle:`disconnected`};case`session.closed`:return{...e,lifecycle:`closed`,closedReason:t.reason,closedMessage:t.message??null};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=SE(t.operation),r=[...e.pendingChangeset.operations.filter(e=>SE(e)!==n),t.operation];return{...e,pendingChangeset:wE(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:wE(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=zS({id:n.id,title:n.title,description:n.description,query:n.query,presentation:n.presentation}),a=VS(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=WS(a,i);return{...e,pendingChangeset:wE(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:wE(e.pendingChangeset,e.model,a),undoStack:[...e.undoStack,e.pendingChangeset],redoStack:[],commitDiagnostics:null}}case`changeset.cleared`:{let t=mE(e.pendingChangeset);return{...e,pendingChangeset:pE,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:pE,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}}}},EE=e=>e.lifecycle===`active`&&e.chatEnabled&&!e.frozen&&!e.awaitingAgent;function DE(e,t){if(e.lifecycle===`closed`)return e;let n=TE(e,t);return n===e?e:{...n,composerEnabled:EE(n)}}var OE=(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},...e.showResponsibility===void 0?{}:{showResponsibility:e.showResponsibility}}};case`commit-changeset`:return{type:`changeset.commit`,lastAcknowledgedSequence:n,payload:t.pendingChangeset};case`save-layout`:return{type:`layout.save`,lastAcknowledgedSequence:n,payload:e.payload}}},kE=e=>{if(e.focusReturn===null)return;let t=e.focusReturn.activeView;return e.views.find(({id:e})=>e===t)?.title},AE=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 BS(r)?{kind:`enumerated`,subjects:r.subjects}:{kind:`faceted`,excluded:r.exclude??[]}},jE=(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}},ME=(e,t=`panel`)=>{switch(e.kind){case`ready`:return[{type:`session.loaded`,snapshot:gE(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,...e.message===void 0?{}:{message:e.message}}];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}]}},NE=e=>{let[t,n]=(0,y.useReducer)(DE,hE),[r,i]=(0,y.useState)(!1),a=(0,y.useRef)(t);a.current=t;let o=(0,y.useRef)(`panel`),s=(0,y.useRef)({}),c=(0,y.useRef)(e);c.current=e,(0,y.useEffect)(()=>c.current.open({frame:e=>{for(let t of ME(e,o.current))n(t);let t=jE(e,a.current);t!==null&&(o.current=t.source,c.current.send(OE({kind:`filter`,query:t.query,...s.current},a.current)))},connected:i,lost:()=>n({type:`connection.lost`}),session:()=>({lastSequence:a.current.lastSequence,closed:a.current.lifecycle===`closed`})}),[]);let l=(0,y.useCallback)(e=>{c.current.send(OE(e,a.current))},[]),u=(0,y.useCallback)(e=>{n({type:`chat.sent`,text:e}),l({kind:`chat`,text:e})},[l]),d=(0,y.useCallback)(e=>{n({type:`chat.sent`,text:`Answer via your agent: ${e.question}`}),l({kind:`delegate`,payload:e})},[l]),f=(0,y.useCallback)(e=>{let t=a.current.choices?.choiceId;t!==void 0&&(n({type:`choice.sent`,optionId:e}),l({kind:`choice`,choiceId:t,optionId:e}))},[l]),p=(0,y.useCallback)(e=>{n({type:`view.navigated`,viewId:e}),l({kind:`navigate`,viewId:e})},[l]),m=(0,y.useCallback)((e,t=`panel`,n,r)=>{o.current=t,s.current={...n===void 0?{}:{nesting:n},...r===void 0?{}:{showResponsibility:r}},l({kind:`filter`,query:e,...s.current})},[l]),h=(0,y.useCallback)(()=>{n({type:`filter.cleared`})},[]),g=(0,y.useCallback)(e=>{n({type:`quickFilter.changed`,text:e})},[]),_=(0,y.useCallback)(e=>{n({type:`changeset.staged`,operation:e})},[]);return{state:t,connected:r,ask:u,choose:f,delegate:d,navigate:p,filter:m,clearFilter:h,setQuickFilterText:g,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:_,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)(()=>{mE(a.current.pendingChangeset)||(n({type:`changeset.commit.sent`}),l({kind:`commit-changeset`}))},[l]),saveLayout:(0,y.useCallback)(e=>{l({kind:`save-layout`,payload:e})},[l]),end:(0,y.useCallback)(()=>{n({type:`end.requested`}),l({kind:`end`})},[l])}},PE=(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)}},FE=({graph:e,from:t,onTarget:n})=>{let[r,i]=(0,y.useState)(``),{matches:a,more:o}=PE(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`]})]})]})},IE=({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)(FE,{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=Cw(t,l,u),f=new Set((e.kinds??[]).map(KS)),p=Fw(t.nodes.find(e=>e.id===l)?.coreKindLabel??``,t.nodes.find(e=>e.id===u)?.coreKindLabel??``),m=e=>p===null||!e.includes(p.kind)?[...e]:[p.kind,...e.filter(e=>e!==p.kind)],h=m(d.filter(e=>f.has(e))),g=m(d.filter(e=>!f.has(e))),_=h.length===0?m(d):h,v=e=>{let r=Tw(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&&h.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,_.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:_.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>v(e),children:e}),p!==null&&e===p.kind?(0,$.jsx)(`span`,{className:`connection-usual`,title:p.because,children:`usually`}):null]},e))}),h.length>0&&g.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:g.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>v(e),children:e})},e))})]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:a,children:`Cancel`})]})},LE=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,RE=(e,t,n=[])=>{let r=t.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase();if(r===``||!LE.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}},zE=(e,t,n,r=[])=>{if(t.document===``||!n.includes(t.kind))return null;let i=t.name.trim();if(i===``)return null;let a=RE(e,i,r);return a===null?null:{op:`add-concept`,document:t.document,concept:{id:a,kind:t.kind,name:i}}},BE=(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=RE(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=RE(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}}}]},VE=(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=RE(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}}}]},HE=({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=BE(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`})]})},UE=({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:RE(e,c,a),h=m===null?null:zE(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:qS(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 WE({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 KE=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`]),qE=(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}}]}],JE={key:`view.new`,label:`New view…`,intent:{type:`view.new`}},YE={key:`view.new-folder`,label:`New folder…`,intent:{type:`view.new-folder`}},XE={key:`view.clear`,label:`Show all subjects`,intent:{type:`view.clear`}},ZE=e=>e.focusReturnLabel===void 0?XE:{key:`view.clear`,label:`Back to ${e.focusReturnLabel}`,intent:{type:`view.clear`}},QE=(e,t)=>({key:`delete`,scope:`model`,label:null,destructive:!0,items:[{key:`delete`,label:t,intent:e}]}),$E=(e,t)=>t.instanceIds?.has(e)===!0?[{key:`focus-instance`,label:`Focus on this instance`,intent:{type:`subject.focus-instance`,id:e}}]:[],eD=(e,t,n)=>[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:[{key:`focus`,label:`Focus on this`,intent:e},...e.type===`subject.focus`?$E(e.id,n):[],...t.flatMap(e=>e.items),...n.filtered?[ZE(n)]:[]]}],tD=(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}}]}]},nD=(e,t)=>{let n=e.split(/(?<=[.?!])\s/)[0]??e;return n.length<=t?n:`${n.slice(0,t-1).trimEnd()}…`},rD=(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:nD(e.question,72),intent:{type:`question.answer`,questionId:e.questionId,subjectId:t,verb:ZS(e)}})),...n.delegateLabel===void 0?[]:[{key:`question-delegate`,label:`${n.delegateLabel}: ${nD(r.question,40)}`,intent:{type:`question.delegate`,questionId:r.questionId,subjectId:t,question:r.question}}]]}]},iD=(e,t)=>t.graph?.nodes.find(t=>t.id===e)===void 0?[]:[...eD({type:`subject.focus`,id:e},qE(e,t),t),...tD(e,t),...rD(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}}]},QE({type:`subject.delete`,id:e},`Delete from model…`)],aD=(e,t)=>{let n=t.graph,r=n?.edges.find(t=>t.id===e);if(n==null||r===void 0)return[];let i=Lw(n,{from:r.from,to:r.to},t.relationshipKinds,r.kindLabel),a=[...eD({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(QE({type:`relationship.delete`,id:e},`Delete from model…`)),a},oD=e=>e.graph===null?[]:[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:[JE,YE,...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`}}]:[]]},...rD(e.questions?.workspace??[],null,e),{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`add`,label:`Add subject…`,intent:{type:`canvas.draft-subject`}}]}],sD=(e,t)=>{let n=[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:e===``?[XE,JE,YE]:[{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}},JE,YE,{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},cD=(e,t)=>t.graph?.nodes.find(t=>t.id===e)===void 0?[]:[...qE(e,t),...$E(e,t).length===0?[]:[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:$E(e,t)}],...tD(e,t),...rD(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}}]},QE({type:`subject.delete`,id:e},`Delete from model…`)],lD=(e,t)=>{let n=(()=>{switch(e.kind){case`subject`:return iD(e.id,t);case`relationship`:return aD(e.id,t);case`canvas`:return oD(t);case`view-row`:return sD(e.id,t);case`model-row`:return cD(e.id,t)}})();return t.readOnly===!0?n.flatMap(e=>{let t=e.items.filter(e=>KE.has(e.intent.type));return t.length===0?[]:[{...e,items:t}]}):n},uD=(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 dD({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(uD({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 fD(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 pD(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 mD=(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},hD=(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}}]},gD=(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=mD(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.`},_D={reviewer:`You`,agent:`Agent`,session:`Session`},vD={thinking:`Agent is thinking`,compiling:`Agent is compiling the model`,waiting:`Agent is waiting`,idle:`Agent is idle`},yD=(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`}},bD=e=>e.lifecycle===`closed`?e.closedMessage??`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.`:``,xD=({brand:e})=>{if(e.logo===void 0&&e.shortName===null)return null;let t=e.logo===void 0?null:`url`in e.logo?(0,$.jsx)(`img`,{className:`brand-logo`,src:e.logo.url,alt:``}):(0,$.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,dangerouslySetInnerHTML:{__html:e.logo.svg}}),n=(0,$.jsxs)($.Fragment,{children:[t,e.shortName===null?null:(0,$.jsx)(`span`,{className:`brand-name`,children:e.shortName})]});return e.docsUrl===void 0?(0,$.jsx)(`span`,{className:`brand`,"aria-label":e.productName,children:n}):(0,$.jsx)(`a`,{className:`brand`,href:e.docsUrl,target:`_blank`,rel:`noreferrer`,"aria-label":e.productName,children:n})},SD=({state:e,connection:t,brand:n})=>(0,$.jsxs)(`header`,{className:`command-strip`,children:[(0,$.jsxs)(`div`,{className:`command-identity`,children:[n.branded?(0,$.jsx)(xD,{brand:n}):null,(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 ${n.shortName??n.productName} 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}),n.vendorLine===null?null:(0,$.jsx)(`span`,{className:`vendor-line`,children:n.vendorLine})]}),CD=({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))})]}),wD=({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}`))})]}),TD=({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,showResponsibility:h,showKindLabels:g,showNudges:_,openQuestionCounts:v,nextQuestionSubjectId:b,nextQuestion:x,delegateLabel:S,onNextVerb:C,onNextDelegate:w,onNextGo:T,decorations:E,connection:D,onConnectTarget:O,onConnectCancel:k,onConnectStage:A,onDraftStage:j,draftingSubject:M,draftInitialKind:N,draftPattern:P,onKindDrop:F,onDraftSubject:I,onDraftSubjectClose:L,pendingDeletion:R,onDeletionDismiss:z,onSelect:B,onCanvasMenu:V,onClearFilter:H,onSaveLayout:U,onCanvasReady:W,onQuickFilterChange:G,view:K,bottomPanel:q,onTogglePresentation:J,onToggleBottomPanel:ee,onSelectBottomTab:Y,onApplyFilter:X,onStageView:te,readOnly:ne,paletteReachable:re})=>{let ie=(0,y.useRef)(null),[ae,oe]=(0,y.useState)(0),se=e.model!==null;(0,y.useEffect)(()=>{let e=ie.current;if(e===null)return;let t=()=>{let t=e.parentElement,n=t===null?e.getBoundingClientRect().bottom:e.getBoundingClientRect().bottom-t.getBoundingClientRect().top;oe(Math.max(0,Math.round(n+8)))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[se]);let ce=(0,y.useMemo)(()=>new Map((e.model?.graph.nodes??[]).map(e=>[e.id,e.name])),[e.model]),le=e.model?.graph.nodes??[],ue=kE(e),de=e.activeFilter?.matchedIds??null,fe=le.length>0&&(e.activeFilter!==null||e.quickFilterText.trim()!==``)&&hy(le,de,e.quickFilterText)===0,pe=e.activeFilter!==null&&hy(le,de,``)===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:ZC(e.activeFilter.query)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:H,children:ue===void 0?`Show all`:`Back to ${ue}`})]}):null,(0,$.jsxs)(`div`,{className:`canvas`,children:[e.model===null?null:(0,$.jsxs)(`div`,{className:`canvas-controls`,ref:ie,children:[(0,$.jsx)(EC,{value:e.quickFilterText,onChange:G}),(0,$.jsx)(LT,{layout:r,direction:s,onLayoutChange:c,onDirectionChange:l,stylePreset:u,onStyleChange:d}),ne||re?null:(0,$.jsx)(`button`,{type:`button`,className:`subject-draft-open`,onClick:I,children:`Add subject`})]}),!M||e.model===null||P===void 0?null:(0,$.jsx)(HE,{graph:e.model.graph,pattern:P,documents:e.model.documents,reservedIds:Ew(e.pendingChangeset.operations),defaultDocument:(t===null?void 0:e.model.graph.nodes.find(e=>e.id===t)?.document)??e.model.documents[0]??``,onStage:j,onCancel:L},`pattern:${P.kind}`),!M||e.model===null||P!==void 0?null:(0,$.jsx)(UE,{initialKind:N,graph:e.model.graph,kinds:e.model.vocabulary.conceptKinds,documents:e.model.documents,reservedIds:Ew(e.pendingChangeset.operations),defaultDocument:(t===null?void 0:e.model.graph.nodes.find(e=>e.id===t)?.document)??e.model.documents[0]??``,onStage:j,onCancel:L},N??``),R===null||e.model===null?null:(0,$.jsx)(WE,{title:`Delete`,message:gD(e.model.graph,R)??`That subject is no longer on the diagram.`,confirmLabel:`Delete`,cancelLabel:`Keep`,onConfirm:()=>{for(let t of hD(e.model.graph,R))A(t);z()},onCancel:z}),D===null||e.model===null?null:(0,$.jsx)(IE,{draft:D,graph:e.model.graph,reservedIds:Ew(e.pendingChangeset.operations),onTarget:O,onStage:A,onCancel:k}),e.model===null?null:(0,$.jsx)(Iy,{graph:e.model.graph,selectedId:t,onSelect:(t,n)=>{let r=e.model.graph;if(n===`node`){if(D!==null){O(t);return}let e=r.nodes.find(e=>e.id===t);e!==void 0&&B(VT(e))}else{let e=r.edges.find(e=>e.id===t);e!==void 0&&B(HT(e,ce))}},onContextMenu:V,matchedIds:e.activeFilter?.matchedIds??null,quickFilterText:e.quickFilterText,nesting:i,folded:a,memberships:o,faultedIds:tw(e.commitDiagnostics??[]),decorations:E,showLifecycle:f,showEvidence:p,showOwnership:m,showResponsibility:h,showNudges:_,openQuestionCounts:v,nextQuestionSubjectId:b,reservedTop:ae,activeViewId:e.activeView,direction:s,layout:r,showKindLabels:g,stylePreset:u,savedPositions:e.model.layouts[e.activeView],savedRoutes:e.model.routes?.[e.activeView],onSaveLayout:ne?()=>void 0:U,onKindDrop:ne?void 0:F,onCanvasReady:W}),fe?(0,$.jsx)(`div`,{className:`filter-empty-pill`,role:`status`,children:pe&&e.activeFilter!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{children:[`Nothing matches this filter:`,` `,(0,$.jsx)(`code`,{children:ZC(e.activeFilter.query)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:H,children:`Show all`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{children:[`Nothing matches “`,e.quickFilterText.trim(),`”`]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>G(``),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)(TC,{nodes:e.model?.graph.nodes??[],activeFilter:e.activeFilter,view:K,open:q.open,tab:q.tab,showLifecycle:f,showEvidence:p,showOwnership:m,showResponsibility:h,showKindLabels:g,showNudges:_,onTogglePresentation:J,onToggleOpen:ee,onSelectTab:Y,next:x,delegateLabel:S,onNextVerb:C,onNextDelegate:w,onNextGo:T,onApply:X,onStage:te,readOnly:ne},e.activeView),(0,$.jsx)(wD,{diagnostics:e.diagnostics})]})},ED=({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]})},DD=({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)(kT,{node:u,model:t}):(0,$.jsx)(DT,{node:u,model:t,operations:n,onStageChange:c}),d===void 0?null:l?(0,$.jsx)(AT,{edge:d,model:t}):(0,$.jsx)(jT,{edge:d,model:t,operations:n,onStageChange:c}),u===void 0?null:(0,$.jsx)(kD,{id:u.id,model:t,operations:n,reservedIds:Ew(n),onStage:c,readOnly:l}),(0,$.jsx)(ED,{text:e.description,expanded:r,onToggle:i})]})},OD=({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=VE(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]})},kD=({id:e,model:t,operations:n,reservedIds:r,onStage:i,readOnly:a})=>{let o=fD(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?pD(n):(0,$.jsx)(OD,{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:pD(n)})})]},n.slot))})]})},AD=e=>e.lifecycle===`active`?e.awaitingAgent?vD[e.agentStatus?.state??`thinking`]??`working`:`agent idle`:`closed`,jD=({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:_D[e.speaker]}),(0,$.jsx)(`p`,{className:`words`,children:e.text})]},e.id))}),e.choices===null?null:(0,$.jsx)(CD,{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`:vD[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:bD(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`})]})]})]})},MD=({width:e,viewportWidth:t,onResize:n})=>{let r=tE(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))}})},ND=({host:e,sections:t=qT,readOnly:n=!1,decorations:r,onDelegateQuestion:i,onReady:a,initialView:o,onFirstModel:s,branding:c})=>{let{state:l,connected:u,ask:d,choose:f,delegate:p,navigate:m,filter:h,clearFilter:g,setQuickFilterText:_,stageViewChange:v,stageViewMembership:b,saveLayout:x,discardChange:S,stageChange:C,clearChangeset:w,undoChangeset:T,redoChangeset:E,commitChangeset:D,end:O}=NE(e),k=(0,y.useMemo)(()=>Hy(c),[c]),[A,j]=(0,y.useReducer)(oE,{width:window.innerWidth,height:window.innerHeight},({width:e,height:t})=>aE(e,t)),[M,N]=(0,y.useState)(null),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(void 0),[B,V]=(0,y.useState)(void 0),[H,U]=(0,y.useState)(r??{}),W=(0,y.useRef)(null),G=(0,y.useRef)({graph:null,readOnly:n,stagedPins:{},views:[]});G.current={graph:l.model?.graph??null,readOnly:n,stagedPins:l.pendingChangeset.sourceDigests,views:l.views},(0,y.useEffect)(()=>{a?.(KT(()=>G.current,j,V,U,m))},[a,m]);let K=(0,y.useRef)(!1);(0,y.useEffect)(()=>{K.current||l.model===null||(K.current=!0,s?.())},[l.model,s]);let q=(0,y.useRef)(!1);(0,y.useEffect)(()=>{q.current||o===void 0||l.model!==null&&(q.current=!0,l.views.some(e=>e.id===o)&&m(o))},[o,l.model,l.views,m]),(0,y.useEffect)(()=>{let e=()=>j({type:`viewport.resized`,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight});return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let J=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(l.activeView===``){J.current=null;return}let e=eE(l.activeView,l.views,J.current,u);if(e!==null){J.current=e.id,h(e.query,`view`,e.presentation?.nesting,e.presentation?.showResponsibility);for(let t of $T(e.presentation))j(t)}},[l.activeView,l.views,u,h]);let ee=(0,y.useRef)({transcriptLength:l.transcript.length,choices:l.choices,diagnostics:l.diagnostics});(0,y.useEffect)(()=>{let e=ee.current,t=!1;for(let n=e.transcriptLength;n<l.transcript.length;n+=1)if(l.transcript[n]?.speaker===`agent`){t=!0;break}let n=t||l.choices!==null&&l.choices!==e.choices||l.diagnostics.length>0&&l.diagnostics!==e.diagnostics;ee.current={transcriptLength:l.transcript.length,choices:l.choices,diagnostics:l.diagnostics},n&&j({type:`attention.received`})},[l.transcript.length,l.choices,l.diagnostics]);let Y=(0,y.useRef)(l.model);(0,y.useEffect)(()=>{l.model!==Y.current&&(Y.current=l.model,j({type:`model.replaced`,graph:l.model?.graph??null}))},[l.model]);let X=l.model===null?l.lifecycle===`connecting`?`Reading the session`:`No model to draw`:M,te=l.pendingChangeset.operations.length+l.pendingChangeset.viewOperations.length,ne=e=>!A.conversation.collapsed.includes(e),re=l.model?.interrogation,ie=(0,y.useMemo)(()=>new Map(Object.entries(re?.subjects??{}).map(([e,t])=>[e,t.length])),[re]),ae=re?.next?.subjectId??null,oe=(0,y.useMemo)(()=>{let e=l.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:l.model?.memberships??[],nesting:A.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=A.folded.includes(e),n=A.unfolded.includes(e);(t||A.foldMode===`instances`&&!n)&&i.add(e)}return{folded:i,insideCounts:n,insideIds:r}},[l.model,A.nesting,A.foldMode,A.folded,A.unfolded]),se=oe.folded,ce=n?t.filter(e=>e!==`palette`&&e!==`changes`):t,le=re===void 0?ce.filter(e=>e!==`questions`):ce,ue=A.selectedSubject?.type===`element`?A.selectedSubject.id:null,de=re===void 0?void 0:ue===null?re.workspace.length:ie.get(ue)??0,fe=l.model?.vocabulary.conceptKinds??[],pe=l.model?.vocabulary.patterns,me=(0,y.useMemo)(()=>new Set(A.tree.collapsed),[A.tree.collapsed]),he=A.conversation.hidden,ge={"--conversation-width":he?`0px`:`${A.conversation.width}px`,"--changes-height":ne(`changes`)?`${A.conversation.changesHeight}px`:`auto`,"--chat-height":ne(`chat`)?`${A.conversation.chatHeight}px`:`auto`,...k.accent===void 0?{}:{"--accent":k.accent}},_e=e=>{V(e),j({type:`subject.draft.opened`})},ve=(e,t)=>j({type:`menu.opened`,target:e,x:t.x,y:t.y}),ye=l.views.find(({id:e})=>e===l.activeView)?.title,be=l.chatEnabled?`Answer via agent`:i===void 0?`Copy for my assistant`:`Answer via assistant`,xe=A.contextMenu===null?[]:lD(A.contextMenu.target,{graph:l.model?.graph??null,relationshipKinds:l.model?.vocabulary.relationshipKinds??[],activeViewId:l.activeView,filtered:l.activeFilter!==null,membership:AE(l),folded:se,containerIds:new Set(oe.insideCounts.keys()),instanceIds:new Set((l.model?.memberships??[]).map(({instance:e})=>e)),selectedIds:A.selectedSubject===null?[]:[A.selectedSubject.id],...kE(l)===void 0?{}:{focusReturnLabel:kE(l)},readOnly:n,...re===void 0?{}:{questions:re},delegateLabel:be}),Se=(e,t)=>{if(e?.kind===`connect`&&t!==null){j({type:`connection.started`,from:t,kinds:e.kinds,direction:e.direction});return}if(e?.kind===`add`){V(e.subjectKind),j({type:`subject.draft.opened`});return}if(t!==null){let e=l.model?.graph.nodes.find(e=>e.id===t);e!==void 0&&j({type:`subject.selected`,subject:VT(e)})}ne(`properties`)||j({type:`section.toggled`,section:`properties`})},Ce=e=>{if(e.subjectId===void 0)j({type:`subject.cleared`});else{let t=l.model?.graph.nodes.find(t=>t.id===e.subjectId);t!==void 0&&j({type:`subject.selected`,subject:VT(t)})}ne(`questions`)||j({type:`section.toggled`,section:`questions`})},we=(e,t)=>{if(l.chatEnabled){p(e);return}if(i!==void 0){i(e);return}let n=(e.subjectId===null?re?.workspace:re?.subjects[e.subjectId])?.find(t=>t.questionId===e.questionId),r=e.subjectId===null?null:{id:e.subjectId,name:t??e.subjectId};navigator.clipboard?.writeText(eC(n??{questionId:e.questionId,question:e.question,authority:`human`},r))},Te=e=>{let t=l.model?.graph??null;switch(e.type){case`question.answer`:Se(e.verb,e.subjectId);return;case`question.delegate`:{let n=t?.nodes.find(t=>t.id===e.subjectId);we({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;j({type:`subject.selected`,subject:VT(n)});return}case`relationship.inspect`:{let n=t?.edges.find(t=>t.id===e.id);if(n===void 0||t===null)return;j({type:`subject.selected`,subject:HT(n,new Map(t.nodes.map(e=>[e.id,e.name])))});return}case`subject.connect`:j({type:`connection.started`,from:e.from});return;case`subject.delete`:case`relationship.delete`:j({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 Xw(n.document,n.localId,`kind`,n.kindLabel,e.kind))C(t);j({type:`menu.dismissed`});return}case`canvas.draft-subject`:V(void 0),j({type:`subject.draft.opened`});return;case`view.add-subject`:case`view.remove-subject`:b(l.activeView,e.id,e.type===`view.add-subject`?`add`:`remove`),j({type:`menu.dismissed`});return;case`view.open`:m(e.id),j({type:`menu.dismissed`});return;case`view.clear`:g(),j({type:`menu.dismissed`});return;case`subject.fold`:case`subject.unfold`:j({type:`fold.toggled`,id:e.id}),j({type:`menu.dismissed`});return;case`subject.unfold-all`:{let t=oe.insideIds.get(e.id)??[];j({type:`fold.all`,folded:!1,ids:[e.id,...t]}),j({type:`menu.dismissed`});return}case`selection.fold`:case`selection.unfold`:for(let t of e.ids)se.has(t)!==(e.type===`selection.fold`)&&j({type:`fold.toggled`,id:t});j({type:`menu.dismissed`});return;case`canvas.fold-all`:case`canvas.unfold-all`:j({type:`fold.all`,folded:e.type===`canvas.fold-all`,ids:[...oe.insideCounts.keys()]}),j({type:`menu.dismissed`});return;case`subject.focus-instance`:h({instances:[e.id],relationships:`between`},`focus`,A.nesting,A.showResponsibility),j({type:`menu.dismissed`});return;case`subject.focus`:case`relationship.focus`:{let t=l.model?.graph??null;if(t===null){j({type:`menu.dismissed`});return}let n=e.type===`subject.focus`?QC(t,e.id):$C(t,e.id);if(n.length===0){j({type:`menu.dismissed`});return}h({subjects:[...n],relationships:`between`},`focus`,A.nesting,A.showResponsibility),j({type:`menu.dismissed`});return}case`view.new`:z(void 0),F(!0),j({type:`menu.dismissed`});return;case`view.delete`:j({type:`viewDeletion.asked`,id:e.id});return;case`view.rename`:j({type:`viewRename.asked`,id:e.id});return;case`view.new-folder`:L(!0),j({type:`menu.dismissed`});return;case`view.duplicate`:{let t=l.views.find(t=>t.id===e.id);if(t===void 0)return;let n=RS(t,new Set(l.views.map(e=>e.id)));v({op:`write-view`,...n}),j({type:`menu.dismissed`});return}case`view.new-in-folder`:{let t=l.views.find(t=>t.id===e.id);if(t===void 0)return;z(IS(t)),F(!0),j({type:`menu.dismissed`});return}case`view.copy-path`:{let t=l.views.find(t=>t.id===e.id);if(t===void 0)return;navigator.clipboard?.writeText(t.path),j({type:`menu.dismissed`});return}case`canvas.export-png`:{let e=W.current;if(e===null)return;let t=document.createElement(`a`);t.href=e(),t.download=`${l.activeView===``?`all-subjects`:l.activeView}.png`,t.click(),j({type:`menu.dismissed`});return}}},Ee=A.pendingViewDeletion===null?null:l.views.find(e=>e.id===A.pendingViewDeletion)??null,De=A.pendingViewRename===null?null:l.views.find(e=>e.id===A.pendingViewRename)??null,Z=[`Show the session panel`,...A.conversation.unread===0?[]:[`${A.conversation.unread} unread`],...l.choices===null?[]:[`the agent is waiting on a choice`]].join(`, `);return(0,$.jsxs)(`main`,{className:`visual-shell`,style:ge,children:[(0,$.jsx)(SD,{state:l,connection:yD(l,u),brand:k}),(0,$.jsxs)(`div`,{className:`workspace`,"data-rail":A.railHidden?`hidden`:void 0,children:[A.railHidden?(0,$.jsx)(`button`,{type:`button`,className:`rail-reopen`,title:`Show the view tree`,"aria-label":ye===void 0?`Show the view tree`:`Show the view tree, showing ${ye}`,onClick:()=>j({type:`rail.toggled`}),children:(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`»`})}):(0,$.jsx)(qC,{views:l.views,stagedViewOperations:l.pendingChangeset.viewOperations,activeViewId:l.activeView,nodes:l.model?.graph.nodes??[],folded:se,insideCounts:oe.insideCounts,inViewIds:l.activeFilter===null?null:new Set(l.activeFilter.matchedIds),filterText:A.tree.filterText,collapsed:me,onFilterChange:e=>j({type:`tree.filtered`,filterText:e}),onToggle:e=>j({type:`tree.toggled`,key:e}),onSelectView:e=>m(e),onClearView:g,onNewView:()=>{z(void 0),F(!0)},onSelectSubject:e=>{let t=l.model?.graph.nodes.find(t=>t.id===e);t!==void 0&&j({type:`subject.selected`,subject:VT(t)})},onRowMenu:(e,t)=>ve(e.kind===`view`?{kind:`view-row`,id:e.id}:{kind:`model-row`,id:e.id},t),readOnly:n,onHide:()=>j({type:`rail.toggled`})}),(0,$.jsx)(TD,{state:l,selectedId:A.selectedSubject?.id??null,waiting:X,layout:A.layout,nesting:A.nesting,folded:se,memberships:l.model?.memberships,direction:A.direction,onLayoutChange:e=>j({type:`layout.set`,layout:e}),onDirectionChange:e=>j({type:`direction.set`,direction:e}),stylePreset:A.stylePreset,onStyleChange:e=>{qg(e),j({type:`style.set`,preset:e})},decorations:H,connection:A.connection,onConnectTarget:e=>j({type:`connection.targeted`,to:e}),onConnectCancel:()=>j({type:`connection.cancelled`}),onConnectStage:C,onDraftStage:e=>{C(e),e.op===`add-concept`&&b(l.activeView,e.concept.id,`add`)},draftingSubject:A.draftingSubject,draftInitialKind:B,draftPattern:(l.model?.vocabulary.patterns??[]).find(e=>e.label===B),onKindDrop:e=>_e(e),onDraftSubject:()=>{V(void 0),j({type:`subject.draft.opened`})},onDraftSubjectClose:()=>j({type:`subject.draft.closed`}),pendingDeletion:A.pendingDeletion,onDeletionDismiss:()=>j({type:`deletion.dismissed`}),showLifecycle:A.showLifecycle,showEvidence:A.showEvidence,showOwnership:A.showOwnership,showResponsibility:A.showResponsibility,showKindLabels:A.showKindLabels,showNudges:A.showNudges,openQuestionCounts:ie,onSelect:e=>j({type:`subject.selected`,subject:e}),onCanvasMenu:(e,t)=>ve(e.type===`node`?{kind:`subject`,id:e.id??``}:e.type===`edge`?{kind:`relationship`,id:e.id??``}:{kind:`canvas`},t),onClearFilter:g,onSaveLayout:e=>x({...e,folded:[...A.folded],unfolded:[...A.unfolded]}),onCanvasReady:e=>{W.current=e},onQuickFilterChange:_,view:l.views.find(e=>e.id===l.activeView)??null,nextQuestionSubjectId:ae,nextQuestion:re?.next,delegateLabel:be,onNextVerb:(e,t)=>Se(e,t),onNextDelegate:e=>we({questionId:e.questionId,subjectId:e.subjectId??null,question:e.question},e.subjectName??null),onNextGo:Ce,bottomPanel:A.bottomPanel,onTogglePresentation:(e,t)=>{j({type:`presentation.toggled`,flag:e,value:t}),e===`showResponsibility`&&l.activeFilter!==null&&h(l.activeFilter.query,l.activeFilter.source,A.nesting,t)},onToggleBottomPanel:()=>j({type:`bottomPanel.toggled`}),onSelectBottomTab:e=>j({type:`bottomPanel.tabSelected`,tab:e}),onApplyFilter:e=>h(e,`editor`,A.nesting,A.showResponsibility),onStageView:v,readOnly:n,paletteReachable:ce.includes(`palette`)}),he?(0,$.jsxs)(`button`,{type:`button`,className:`conversation-reopen`,title:`Show the session panel`,"aria-label":Z,onClick:()=>j({type:`conversation.toggled`}),children:[(0,$.jsx)(`span`,{className:`reopen-chevron`,"aria-hidden":`true`,children:`«`}),A.conversation.unread===0?null:(0,$.jsx)(`span`,{className:`attention-count`,children:A.conversation.unread}),l.choices===null?null:(0,$.jsx)(`span`,{className:`attention-choice`,title:`The agent is waiting on a choice`,children:`?`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(MD,{width:A.conversation.width,viewportWidth:A.viewportWidth,onResize:e=>j({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:()=>j({type:`conversation.toggled`}),children:`»`})}),uE(le,{palette:(0,$.jsx)(cE,{id:`palette`,label:`Kind palette`,meta:fe.length===0?void 0:fe.length===1?`1 kind`:`${fe.length} kinds`,open:ne(`palette`),onToggle:()=>j({type:`section.toggled`,section:`palette`}),children:fe.length===0?(0,$.jsx)(`p`,{className:`section-empty`,children:`No model yet. The kinds arrive with it.`}):(0,$.jsx)($_,{kinds:fe,patterns:pe,onPick:_e})}),properties:(0,$.jsx)(cE,{id:`properties`,label:`Element properties`,meta:A.selectedSubject?.id,open:ne(`properties`),onToggle:()=>j({type:`section.toggled`,section:`properties`}),children:A.selectedSubject===null||l.model===null?(0,$.jsx)(`p`,{className:`section-empty`,children:`Nothing selected. Pick a subject on the canvas or in the rail.`}):(0,$.jsx)(DD,{subject:A.selectedSubject,model:l.model,operations:l.pendingChangeset.operations,expanded:A.descriptionExpanded,onToggleDescription:()=>j({type:`description.toggled`}),onClear:()=>j({type:`subject.cleared`}),onConnect:e=>j({type:`connection.started`,from:e}),onDelete:e=>j({type:`deletion.asked`,id:e}),onStageChange:C,readOnly:n})}),questions:(0,$.jsx)(cE,{id:`questions`,label:`Open questions`,meta:de===void 0?void 0:de===0?`nothing open`:`${de} open`,open:ne(`questions`),onToggle:()=>j({type:`section.toggled`,section:`questions`}),children:re===void 0?null:(0,$.jsx)(MT,{overlay:re,selectedId:ue,readOnly:n,onVerb:(e,t,n)=>Se(t,n),delegateLabel:be,onDelegate:(e,t)=>we({questionId:e.questionId,subjectId:t,question:e.question},A.selectedSubject?.type===`element`?A.selectedSubject.title:null)})}),changes:(0,$.jsx)(cE,{id:`changes`,label:`Changes`,meta:te===0?`nothing staged`:`${te} staged`,open:ne(`changes`),onToggle:()=>j({type:`section.toggled`,section:`changes`}),children:(0,$.jsx)(fw,{state:l,onDiscardChange:S,onClearChangeset:w,onUndoChangeset:T,onRedoChangeset:E,onCommitChangeset:D})}),chat:(0,$.jsx)(cE,{id:`chat`,label:`Chat`,meta:A.conversation.unread===0?AD(l):(0,$.jsx)(`span`,{className:`attention-count`,children:A.conversation.unread}),open:ne(`chat`),onToggle:()=>j({type:`section.toggled`,section:`chat`}),children:(0,$.jsx)(jD,{state:l,disabled:!l.composerEnabled,selectedSubject:A.selectedSubject,onSend:e=>d(sE(e,A.selectedSubject)),onChoice:f,onClearSubject:()=>j({type:`subject.cleared`}),onEnd:O})})},{changes:(0,$.jsx)(lE,{label:`Resize the changes section`,height:A.conversation.changesHeight,viewportHeight:A.viewportHeight,onResize:e=>j({type:`section.resized`,section:`changes`,height:e})}),chat:(0,$.jsx)(lE,{label:`Resize the chat section`,height:A.conversation.chatHeight,viewportHeight:A.viewportHeight,onResize:e=>j({type:`section.resized`,section:`chat`,height:e})})})]})]})]}),A.contextMenu===null?null:(0,$.jsx)(dD,{groups:xe,x:A.contextMenu.x,y:A.contextMenu.y,onChoose:Te,onDismiss:()=>j({type:`menu.dismissed`})}),(0,$.jsx)(XC,{views:l.views,activeViewId:l.activeView,query:l.activeFilter?.query??null,layout:A.layout,direction:A.direction,showLifecycle:A.showLifecycle,showEvidence:A.showEvidence,showOwnership:A.showOwnership,showKindLabels:A.showKindLabels,open:P,folder:R,onClose:()=>F(!1),onStage:v}),I?(0,$.jsx)(GE,{title:`New folder`,label:`Folder`,initialValue:``,confirmLabel:`Continue`,cancelLabel:`Cancel`,onConfirm:e=>{L(!1);let t=e.trim();t!==``&&(z(t),F(!0))},onCancel:()=>L(!1)}):null,De===null?null:(0,$.jsx)(GE,{title:`Rename view`,label:`Title`,initialValue:De.title,confirmLabel:`Rename`,cancelLabel:`Cancel`,onConfirm:e=>{v({op:`write-view`,...LS(De,e)}),j({type:`viewRename.dismissed`})},onCancel:()=>j({type:`viewRename.dismissed`})}),Ee===null?null:(0,$.jsx)(WE,{title:`Delete view`,message:`Stage the removal of "${Ee.title}"? The projection document goes when the changeset is committed; no subject is touched.`,confirmLabel:`Delete`,cancelLabel:`Keep`,onConfirm:()=>{v({op:`delete-view`,path:Ee.path}),j({type:`viewDeletion.dismissed`})},onCancel:()=>j({type:`viewDeletion.dismissed`})})]})},PD=`/api/session`,FD=`/socket`,ID=1e3,LD=(e={})=>{let t=null,n=e.retryMs??ID,r=(t,n)=>e.reconnectWindowMs===void 0?_E(t,n):n-t<e.reconnectWindowMs;return{open:i=>{let a=!1,o,s=null,c=()=>{let t=i.session().lastSequence;if(typeof e.socket==`function`)return new URL(String(e.socket(t)),window.location.href);let n=new URL(e.socket??FD,window.location.href);return n.protocol=n.protocol===`https:`?`wss:`:n.protocol===`http:`?`ws:`:n.protocol,n.searchParams.set(`after`,String(t)),n},l=()=>{if(!a){if(s??=Date.now(),!r(s,Date.now())){i.frame({kind:`closing`,reason:`browser-timeout`});return}o=setTimeout(u,n)}},u=()=>{if(a)return;let e=new WebSocket(c());t=e,e.addEventListener(`open`,()=>{s=null,i.connected(!0)}),e.addEventListener(`message`,e=>{if(typeof e.data==`string`)try{i.frame(JSON.parse(e.data))}catch{}}),e.addEventListener(`close`,e=>{if(i.connected(!1),t=null,!(a||i.session().closed)){if(e.code>=4e3&&e.code<=4999){i.frame({kind:`closing`,reason:`host-ended`,...e.reason===``?{}:{message:e.reason}});return}i.lost(),l()}}),e.addEventListener(`error`,()=>e.close())};return(async()=>{let t=await fetch(new URL(e.session??PD,window.location.href),{credentials:`same-origin`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(`Session request answered ${t.status}`);let n=await t.json();a||(i.frame({kind:`ready`,snapshot:n}),u())})().catch(()=>{a||(i.lost(),l())}),()=>{a=!0,o!==void 0&&clearTimeout(o),t?.close()}},send:e=>{t!==null&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))}}},RD=document.getElementById(`visual-session`);if(RD===null)throw Error(`The visual session page has no mount point`);Mv(jv(()=>new v)),(0,_.createRoot)(RD).render((0,$.jsx)(ND,{host:LD()}));export{l as n,o as t};
|
|
373
|
+
`);default:return null}},iC={subjects:[],documents:[],kinds:[],layers:[],statuses:[],excludeStatuses:[],states:[],owners:[],constraints:[],relationshipKinds:[],kindMatching:``,relationships:``,isolatedConcepts:``},aC=[`planned`,`current`,`retired`],oC=e=>e===null?iC:{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??``},sC=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}}),cC=({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})]})]})},lC=({legend:e,values:t,onChange:n})=>(0,$.jsxs)(`fieldset`,{className:`filter-field filter-checkbox-group`,children:[(0,$.jsx)(`legend`,{children:e}),aC.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))]}),uC=({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))]})]}),dC=(e,t)=>n=>e(t,n);function fC({fields:e,onChange:t}){return(0,$.jsxs)(`div`,{className:`filter-grid`,children:[(0,$.jsx)(cC,{id:`filter-subjects`,label:`Subjects`,values:e.subjects,onChange:e=>t(`subjects`,e)}),(0,$.jsx)(cC,{id:`filter-documents`,label:`Documents`,values:e.documents,onChange:e=>t(`documents`,e)}),(0,$.jsx)(cC,{id:`filter-kinds`,label:`Kinds`,values:e.kinds,onChange:e=>t(`kinds`,e)}),(0,$.jsx)(cC,{id:`filter-layers`,label:`Layers`,values:e.layers,onChange:e=>t(`layers`,e)}),(0,$.jsx)(cC,{id:`filter-states`,label:`States`,values:e.states,onChange:e=>t(`states`,e)}),(0,$.jsx)(cC,{id:`filter-owners`,label:`Owners`,values:e.owners,onChange:e=>t(`owners`,e)}),(0,$.jsx)(cC,{id:`filter-constraints`,label:`Constraints`,values:e.constraints,onChange:e=>t(`constraints`,e)}),(0,$.jsx)(cC,{id:`filter-relationship-kinds`,label:`Relationship kinds`,values:e.relationshipKinds,onChange:e=>t(`relationshipKinds`,e)}),(0,$.jsx)(lC,{legend:`Statuses`,values:e.statuses,onChange:e=>t(`statuses`,e)}),(0,$.jsx)(lC,{legend:`Exclude statuses`,values:e.excludeStatuses,onChange:e=>t(`excludeStatuses`,e)}),(0,$.jsx)(uC,{id:`filter-kind-matching`,label:`Kind matching`,value:e.kindMatching,options:[`exact`,`descendants`],onChange:e=>t(`kindMatching`,e)}),(0,$.jsx)(uC,{id:`filter-relationships`,label:`Relationships`,value:e.relationships,options:[`between`,`connected`,`none`],onChange:e=>t(`relationships`,e)}),(0,$.jsx)(uC,{id:`filter-isolated-concepts`,label:`Isolated concepts`,value:e.isolatedConcepts,options:[`include`,`exclude`],onChange:e=>t(`isolatedConcepts`,e)})]})}function pC({showLifecycle:e,showEvidence:t,showOwnership:n,showResponsibility:r,showKindLabels:i,showNudges:a,onTogglePresentation:o}){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=>dC(o,`showLifecycle`)(e.currentTarget.checked)}),`Lifecycle badges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>dC(o,`showEvidence`)(e.currentTarget.checked)}),`Evidence badges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>dC(o,`showOwnership`)(e.currentTarget.checked)}),`Ownership badges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>dC(o,`showResponsibility`)(e.currentTarget.checked)}),`Responsibility edges`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>dC(o,`showKindLabels`)(e.currentTarget.checked)}),`Kind labels`]}),(0,$.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>dC(o,`showNudges`)(e.currentTarget.checked)}),`Open-question badges`]})]})}var mC=[{id:`next-question`,label:`Next question`},{id:`view-query`,label:`View query`}],hC=e=>JSON.stringify(Object.entries(e??{}).sort(([e],[t])=>e<t?-1:1)),gC=(e,t)=>hC(e)===hC(t),_C={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`},vC=Object.keys(_C),yC=(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 vC.flatMap(e=>{let t=a.get(e);return t===void 0?[]:[{reason:e,label:_C[e],subjects:t}]})},bC=(e,t)=>{if(t===null)return e.length;let n=new Set(t);return e.filter(e=>n.has(e.id)).length},xC=(e,t)=>{if(e===null||t===null)return 0;let n=new Set(e);return t.filter(({id:e})=>n.has(e)).length},SC=(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(`showResponsibility`),...i(`showKindLabels`)}},CC=({view:e,query:t,badges:n,opened:r})=>VS({id:e.id,title:e.title,description:e.description,query:t,presentation:SC(e,n,r)}),wC=e=>({op:`write-view`,path:e.view.path,projection:CC(e)}),TC=e=>{let t=CC(e),n=VS({id:e.view.id,title:e.view.title,description:e.view.description,query:e.view.query,presentation:e.view.presentation});return hC(t.query)!==hC(n.query)||hC(t.presentation)!==hC(n.presentation)},EC=({next:e,readOnly:t,delegateLabel:n,onVerb:r,onDelegate:i,onGo:a})=>{let o=t||r===void 0?null:$S(e),s=e.subjectId===void 0?null:e.subjectName??e.subjectId;return(0,$.jsxs)(`div`,{className:`next-question-tab`,children:[(0,$.jsxs)(`p`,{className:`next-question-eyebrow`,children:[`Next question · `,e.wave,` ·`,` `,s===null?`the whole record`:`about ${s}`]}),(0,$.jsx)(`h3`,{className:`next-question-text`,children:e.question}),e.materiality===void 0?null:(0,$.jsx)(`p`,{className:`next-question-why`,children:e.materiality}),e.resolution===void 0?null:(0,$.jsx)(`p`,{className:`next-question-how`,children:e.resolution}),(0,$.jsxs)(`div`,{className:`next-question-actions`,children:[a===void 0?null:(0,$.jsx)(`button`,{type:`button`,className:`question-verb question-verb-go`,onClick:()=>a(e),children:s===null?`Open the questions`:`Go to ${s}`}),o===null?null:(0,$.jsx)(`button`,{type:`button`,className:`question-verb question-verb-${o.kind}`,onClick:()=>r?.(o,e.subjectId??null),children:o.label}),t||i===void 0?null:(0,$.jsx)(`button`,{type:`button`,className:`question-verb question-verb-delegate`,onClick:()=>i(e),children:n??`Answer via agent`})]})]})};function DC({nodes:e,activeFilter:t,view:n,open:r,tab:i,showLifecycle:a,showEvidence:o,showOwnership:s,showResponsibility:c,showKindLabels:l,showNudges:u,onTogglePresentation:d,onToggleOpen:f,onSelectTab:p,onApply:m,onStage:h,readOnly:g=!1,next:_,delegateLabel:v,onNextVerb:b,onNextDelegate:x,onNextGo:S}){let C=i===`next-question`&&_===void 0?`view-query`:i,w=mC.filter(e=>e.id!==`next-question`||_!==void 0),T=(0,y.useRef)(null),[E,D]=(0,y.useState)(()=>oC(n?.query??t?.query??null)),[O,k]=(0,y.useState)(!1),[A]=(0,y.useState)(()=>({showLifecycle:a,showEvidence:o,showOwnership:s,showResponsibility:c,showKindLabels:l})),j=e=>{T.current!==null&&window.clearTimeout(T.current),T.current=window.setTimeout(()=>{T.current=null,m(sC(e))},300)},M=(e,t)=>{k(!1),D(n=>{let r={...n,[e]:t};return j(r),r})},N=sC(E),P=t?.matchedIds??null,F=bC(e,P),I=yC(e,P,t?.excluded??null),L=xC(P,t?.excluded??null),R=t===null?Object.keys(N).length===0:gC(N,t.query),z=n===null?null:{view:n,query:N,badges:{showLifecycle:a,showEvidence:o,showOwnership:s,showResponsibility:c,showKindLabels:l},opened:A};return(0,$.jsxs)(`section`,{className:`bottom-panel`,"aria-label":`Canvas panels`,children:[(0,$.jsxs)(`div`,{className:`bottom-panel-tabs`,children:[(0,$.jsx)(`div`,{className:`bottom-panel-tablist`,role:`tablist`,"aria-label":`Canvas panels`,children:w.map(e=>(0,$.jsx)(`button`,{type:`button`,role:`tab`,id:`bottom-tab-${e.id}`,className:`bottom-panel-tab`,"aria-selected":r&&C===e.id,"aria-controls":`bottom-panel-${e.id}`,onClick:()=>{if(r&&C===e.id){f();return}p(e.id)},children:e.label},e.id))}),C===`next-question`&&_!==void 0?(0,$.jsx)(`span`,{className:`bottom-panel-summary bottom-panel-summary-next`,role:`status`,title:_.materiality,children:_.question}):(0,$.jsxs)(`span`,{className:`bottom-panel-summary`,role:`status`,children:[F,` `,F===1?`subject`:`subjects`,I.length===0?``:` · ${I.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-${C}`,"aria-label":r?`Collapse panel`:`Expand panel`,onClick:f,children:r?`▾`:`▴`})]}),r?C===`next-question`&&_!==void 0?(0,$.jsx)(`div`,{className:`bottom-panel-body`,id:`bottom-panel-next-question`,role:`tabpanel`,"aria-labelledby":`bottom-tab-next-question`,children:(0,$.jsx)(EC,{next:_,readOnly:g,delegateLabel:v,onVerb:b,onDelegate:x,onGo:S})}):(0,$.jsx)(`div`,{className:`bottom-panel-body`,id:`bottom-panel-${C}`,role:`tabpanel`,"aria-labelledby":`bottom-tab-${C}`,children:(0,$.jsxs)(`div`,{className:`query-tab`,children:[(0,$.jsxs)(`div`,{className:`query-tab-fields`,children:[(0,$.jsx)(fC,{fields:E,onChange:M}),(0,$.jsx)(pC,{showLifecycle:a,showEvidence:o,showOwnership:s,showResponsibility:c,showKindLabels:l,showNudges:u,onTogglePresentation:d})]}),(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:F}),` `,F===1?`subject`:`subjects`,` of `,e.length]}),R?null:(0,$.jsx)(`p`,{className:`query-outcome-stale`,children:`Describing the query on the canvas, not the edit in progress.`}),F===0&&P!==null?(0,$.jsx)(`p`,{className:`query-outcome-empty`,children:`This query selects nothing.`}):null,L===0?null:(0,$.jsxs)(`p`,{className:`query-outcome-note`,children:[L,` a facet dropped `,L===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`}),I.length===0?(0,$.jsx)(`p`,{className:`query-outcome-note`,children:`Nothing is left out of this view.`}):(0,$.jsx)(`ul`,{className:`query-exclusions`,children:I.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`}),z===null?(0,$.jsx)(`p`,{className:`query-outcome-note`,children:g?`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:MS(CC(z))}),g?null:(0,$.jsxs)(`div`,{className:`query-tab-actions`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:!TC(z),onClick:()=>{h(wC(z)),k(!0)},children:`Stage view change`}),(0,$.jsx)(`span`,{role:`status`,className:`query-stage-status`,children:O?`Staged. It lands when the changeset is committed.`:``})]})]})]})]})}):null]})}function OC({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 kC=`views`,AC=`model`,jC=e=>`view-folder:${e}`,MC=e=>`model-layer:${e}`,NC=e=>`model-folder:${e}`,PC=`unlayered`,FC=(e,t)=>t===``||e.toLowerCase().includes(t),IC=(e,t)=>FC(e,Pg(t)),LC=e=>e.presentation?.folder??``,RC=({views:e,stagedOperations:t,activeViewId:n,activeSubjects:r,filterText:i})=>{let a=Pg(i),o=a!==``,s=r===null?null:Ig(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?LC(t):r.presentation?.folder??``,f=t.id===n;(FC(c,a)||FC(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??``;(FC(n,a)||FC(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:jC(e),name:e,views:[...t].sort(d)}));return{folders:p,loose:f,matched:f.length+p.reduce((e,t)=>e+t.views.length,0)}},zC=({nodes:e,inViewIds:t,filterText:n,folded:r,insideCounts:i})=>{let a=Pg(n),o=new Map,s=new Map;for(let n of e){let e=n.layer,c=n.folder,l=c??e??`unlayered`;if(!Fg(a,n.id,n.name,n.kindLabel)&&!FC(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:NC(e),label:e,grouping:`folder`,subjects:[...t].sort(c)})),u=[...N_,PC];return[...l,...u.flatMap(e=>{let t=s.get(e);return t===void 0||t.length===0?[]:[{key:MC(e),label:e,grouping:`layer`,subjects:[...t].sort(c)}]})]},BC=`All subjects`,VC=`M2 3.5 5 6.5 8 3.5`,HC=`M3.5 2 6.5 5 3.5 8`;function UC({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?VC:HC,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function WC(){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 GC({layer:e}){let t=e===null?null:R_[e];return(0,$.jsx)(`span`,{className:`tree-swatch`,style:t==null?void 0:{background:t.fill,borderColor:t.border},"aria-hidden":!0})}var KC=(e,t)=>n=>{n.preventDefault(),t(e,{x:n.clientX,y:n.clientY})};function qC({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?KC({kind:`view`,id:e.id},r):void 0,children:[(0,$.jsx)(WC,{}),(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 JC({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)(UC,{open:t}),(0,$.jsx)(`span`,{className:`tree-label`,children:e}),n===void 0?null:(0,$.jsx)(`span`,{className:`tree-count`,children:n})]})}function YC({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=RC({views:e,stagedOperations:t,activeViewId:n,activeSubjects:i===null?null:r.filter(e=>i.has(e.id)),filterText:s}),y=zC({nodes:r,inViewIds:i,filterText:s,folded:a,insideCounts:o}),b=!c.has(kC),x=!c.has(AC),S=s.trim()!==``,C=n===``&&i===null,w=IC(BC,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)(JC,{label:`Views`,open:b,depth:0,onToggle:()=>u(kC)}),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:KC({kind:`view`,id:``},h),children:[(0,$.jsx)(WC,{}),(0,$.jsx)(`span`,{className:`tree-label`,children:BC}),(0,$.jsx)(`span`,{className:`tree-count`,children:Ig(r,s)})]})}):null,v.loose.map(e=>(0,$.jsx)(qC,{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)(JC,{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)(qC,{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)(JC,{label:`Model`,open:x,depth:0,onToggle:()=>u(AC)}),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)(JC,{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:KC({kind:`subject`,id:e.id},h),children:[(0,$.jsx)(GC,{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 XC=({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??IS(a,t);return{op:`write-view`,path:n??LS(m),projection:VS({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 ZC({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 QC({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(XC({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)(ZC,{activeView:p,presetFolder:u,onSubmit:(e,t,n)=>{m(e,t,n),d()},onCancel:d},t)}):null}function $C(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 ew=(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]},tw=(e,t)=>{let n=e.edges.find(({id:e})=>e===t);return n===void 0?[]:[n.from,n.to]},nw=(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}},rw=e=>{let t=new Set;for(let n of e)for(let e of n.subjects??[])t.add(e);return t},iw=(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},aw=(e,t,n)=>[...e.operations.map(e=>sw(e,t)),...e.viewOperations.map(e=>ow(e,n))],ow=(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?[]:GS(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`}},sw=(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=iw(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:iw(e.document,r.id,t),fields:Object.keys(r).filter(e=>e!==`id`),removedFields:n,scope:`model`}},cw=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(`, `)}`},lw=/^\/operations\/(\d+)(\/|$)/,uw=e=>{let t=new Map,n=[];for(let r of e){let e=lw.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}},dw=(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},fw=({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]})]}),pw=({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:cw(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)(fw,{diagnostic:e},`${e.code}-${e.pointer}`))})]}),mw=({state:e,onDiscardChange:t,onClearChangeset:n,onUndoChangeset:r,onRedoChangeset:i,onCommitChangeset:a})=>{let o=e.model?.graph??null,s=aw(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}=uw(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=nw(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)(fw,{diagnostic:e},`${e.code}-${e.pointer}`))}),s.length===0?null:(0,$.jsx)(`ol`,{className:`changeset-rows`,children:s.map((n,r)=>(0,$.jsx)(pw,{index:r,row:n,diagnostics:c.get(r)??[],conflict:dw(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))})]})]})},hw={a:`access`,c:`composition`,f:`flow`,g:`aggregation`,i:`assignment`,n:`influence`,o:`association`,r:`realization`,s:`specialization`,t:`triggering`,v:`serving`},gw=`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(`.`),_w={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`},vw=new Map(gw.map((e,t)=>[e,t])),yw=new Map(Object.entries(hw)),bw=new Map;for(let e of gw){let t=_w[e].split(` `);for(let[n,r]of gw.entries()){let i=t[n]??`-`,a=new Set;for(let e of i){let t=yw.get(e);t!==void 0&&a.add(t)}bw.set(`${e}>${r}`,a)}}var xw=new Set,Sw=e=>vw.has(e),Cw=(e,t)=>bw.get(`${e}>${t}`)??xw;new Map(F_.map(e=>[e.id,e.aspect])),new Set(gw),new Set(I_);var ww=I_,Tw=(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||!Sw(r.coreKindLabel)||!Sw(i.coreKindLabel))return[];let a=[...Cw(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},Ew=(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}},Dw=(e,t,n,r,i=[])=>{if(!Tw(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:Ew(e,t,n,r,i),kind:n,from:t,to:r}}},Ow=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}),kw=new Map(F_.map(e=>[e.id,{layer:e.layer,aspect:e.aspect}])),Aw=new Set([`businessService`,`applicationService`,`technologyService`]),jw=new Set([`businessInterface`,`applicationInterface`,`technologyInterface`]),Mw=e=>Aw.has(e),Nw=e=>jw.has(e),Pw=e=>kw.get(e)?.aspect===`behavior`&&!Mw(e),Fw=[{name:`behaviour-uses-data`,because:`behaviour reads, writes or creates the passive structure it touches`,kind:`access`,when:(e,t,n,r)=>r.aspect===`passive-structure`&&(Pw(e)||Mw(e))&&t!==`artifact`},{name:`interface-exposes-service`,because:`an interface is assigned to the service it exposes, not to the behaviour that uses it`,kind:`assignment`,when:(e,t,n,r)=>Nw(e)&&Mw(t)&&n.layer===r.layer},{name:`service-is-offered-outward`,because:`a service is made available to whoever uses it`,kind:`serving`,when:(e,t,n,r)=>(Mw(e)||Nw(e))&&(r.aspect===`active-structure`||r.aspect===`behavior`)},{name:`grouping-collects-members`,because:`a grouping aggregates what it collects; the members exist without it`,kind:`aggregation`,when:e=>e===`grouping`},{name:`artifact-realizes-what-it-implements`,because:`an artifact is the concrete file or deployable that fulfils the thing it stands for`,kind:`realization`,when:(e,t,n,r)=>e===`artifact`&&(r.aspect===`active-structure`||r.aspect===`passive-structure`)&&t!==`artifact`},{name:`active-structure-performs-behaviour`,because:`an active structure element is assigned to the internal behaviour it performs`,kind:`assignment`,when:(e,t,n,r)=>n.aspect===`active-structure`&&Pw(t)&&n.layer===r.layer},{name:`internal-realizes-service`,because:`the internal element is the concrete thing that fulfils the service its layer offers`,kind:`realization`,when:(e,t,n,r)=>Mw(t)&&n.layer===r.layer&&(n.aspect===`active-structure`||Pw(e))&&!Nw(e)},{name:`technology-serves-application`,because:`a technology element is not part of the application it runs; it serves it`,kind:`serving`,when:(e,t,n,r)=>n.layer===`technology`&&r.layer===`application`&&(r.aspect===`active-structure`||r.aspect===`behavior`)}],Iw=new Map,Lw=(e,t)=>{let n=`${e}>${t}`,r=Iw.get(n);if(r!==void 0)return r;let i=Rw(e,t);return Iw.set(n,i),i},Rw=(e,t)=>{if(!Sw(e)||!Sw(t))return null;let n=kw.get(e),r=kw.get(t);if(n===void 0||r===void 0)return null;for(let i of Fw)if(i.when(e,t,n,r))return Cw(e,t).has(i.kind)?{kind:i.kind,rule:i.name,because:i.because}:null;return null};Fw.map(({name:e,kind:t,because:n})=>({name:e,kind:t,because:n}));var zw=(e,t,n,r)=>{let i=new Set(Tw(e,t.from,t.to)),a=Lw(e.nodes.find(e=>e.id===t.from)?.coreKindLabel??``,e.nodes.find(e=>e.id===t.to)?.coreKindLabel??``);if(i.size===0)return{options:n,narrowed:!1,conventional:a};let o=new Set(ww);return{options:n.filter(e=>i.has(e.coreLabel)||!o.has(e.coreLabel)||e.label===r),narrowed:!0,conventional:a}},Bw=[`kind`,`name`,`description`,`status`,`owner`],Vw=[`aka`,`constraints`,`references`,`presentIn`,`attestations`,`distinctFrom`,`supersedes`],Hw=[`kind`,`from`,`to`,`name`,`description`,`status`,`mode`,`content`],Uw=[`references`,`presentIn`],Ww=(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)=>Ww(e,t[n]));let n=e,r=t,i=Object.keys(n),a=Object.keys(r);return i.length===a.length&&i.every(e=>Ww(n[e],r[e]))},Gw=(e,t)=>t===(e??``)?{kind:`none`}:t===``?{kind:`remove`}:{kind:`set`,value:t},Kw=(e,t)=>Ww(e,t)?{kind:`none`}:t.length>=e.length&&e.every((e,n)=>Ww(e,t[n]))?{kind:`append`,added:t.slice(e.length)}:{kind:`replace`,next:t},qw=(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]},Jw=(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}},Yw=(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]},Xw=(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}},Zw=(e,t,n,r,i)=>{let a=Gw(r,i);return a.kind===`none`?[]:a.kind===`remove`?[qw(e,t,n,!1,``)]:[qw(e,t,n,!0,a.value)]},Qw=(e,t,n,r,i)=>{let a=Gw(r,i);return a.kind===`none`?[]:a.kind===`remove`?[Yw(e,t,n,!1,``)]:[Yw(e,t,n,!0,a.value)]},$w=(e,t,n,r,i)=>{let a=Kw(r,i);if(a.kind===`none`)return[];if(a.kind===`append`)return a.added.length===0?[]:[Jw(e,t,n,a.added)];let o=[Jw(e,t,n,null)];return a.next.length>0&&o.push(Jw(e,t,n,a.next)),o},eT=(e,t,n,r,i)=>{let a=Kw(r,i);if(a.kind===`none`)return[];if(a.kind===`append`)return a.added.length===0?[]:[Xw(e,t,n,a.added)];let o=[Xw(e,t,n,null)];return a.next.length>0&&o.push(Xw(e,t,n,a.next)),o},tT=e=>e.expects===null?{id:e.id,ref:e.ref}:{id:e.id,ref:e.ref,expects:e.expects},nT=(e,t,n,r)=>{let i=Kw(n,r);if(i.kind===`none`)return[];if(i.kind===`append`)return i.added.length===0?[]:[Jw(e,t,`constraints`,i.added.map(tT))];let a=[Jw(e,t,`constraints`,null)];return i.next.length>0&&a.push(Jw(e,t,`constraints`,i.next.map(tT))),a},rT=e=>({topic:e.topic,by:e.by,recordedBy:e.recordedBy??``,on:e.on}),iT=(e,t,n,r)=>{let i=Kw(n,r);if(i.kind===`none`)return[];if(i.kind===`append`)return i.added.length===0?[]:[Jw(e,t,`attestations`,i.added.map(rT))];let a=[Jw(e,t,`attestations`,null)];return i.next.length>0&&a.push(Jw(e,t,`attestations`,i.next.map(rT))),a},aT=(e,t)=>{let n={...e},r=t.concept;for(let e of Bw)r[e]!==void 0&&(n[e]=r[e]);for(let e of Vw){let t=r[e];t!==void 0&&t.length>0&&(n[e]=[...n[e],...t])}for(let e of t.remove??[])n[e]=Vw.includes(e)?[]:null;return n},oT=(e,t)=>{let n=e;for(let r of t)r.op===`update-concept`&&r.document===e.document&&r.concept.id===e.localId&&(n=aT(n,r));return n},sT=(e,t)=>{let n={...e},r=t.relationship;for(let e of Hw)r[e]!==void 0&&(n[e]=r[e]);for(let e of Uw){let t=r[e];t!==void 0&&t.length>0&&(n[e]=[...n[e],...t])}for(let e of t.remove??[])n[e]=Uw.includes(e)?[]:null;return n},cT=(e,t)=>{let n=e;for(let r of t)r.op===`update-relationship`&&r.document===e.document&&r.relationship.id===e.localId&&(n=sT(n,r));return n},lT=e=>`subject-${e.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}`,uT=({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:lT(e),value:t,onChange:e=>r(e.target.value),children:n.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),dT=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:#[a-z][a-z0-9]*(?:-[a-z0-9]+)*)?$/,fT=`An id, like finance-it or main#finance-it: lowercase letters, digits and single hyphens.`,pT=({label:e,value:t,onCommit:n,shape:r})=>{let[i,a]=(0,y.useState)(t);(0,y.useEffect)(()=>a(t),[t]);let o=r!==void 0&&i!==``&&!r.pattern.test(i),s=`${lT(e)}-hint`;return(0,$.jsxs)(`label`,{className:`subject-form-field`,children:[(0,$.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,$.jsx)(`input`,{type:`text`,name:lT(e),value:i,onChange:e=>a(e.target.value),onBlur:()=>n(i),...r===void 0?{}:{"aria-describedby":s,"aria-invalid":o}}),r===void 0?null:(0,$.jsx)(`span`,{id:s,className:o?`subject-form-hint subject-form-hint-invalid`:`subject-form-hint`,children:r.hint})]})},mT=({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]})]})]})},hT=({label:e,values:t,onCommit:n})=>(0,$.jsx)(mT,{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})}),gT={id:``,ref:``},_T=({label:e,values:t,onCommit:n})=>(0,$.jsx)(mT,{label:e,values:t,emptyRow:gT,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})]})}),vT={id:``,ref:``,expects:null},yT=({label:e,values:t,onCommit:n})=>(0,$.jsx)(mT,{label:e,values:t,emptyRow:vT,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})]})]})}),bT={topic:``,by:``,on:``,recordedBy:null},xT=({label:e,values:t,onCommit:n})=>(0,$.jsx)(mT,{label:e,values:t,emptyRow:bT,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})]})}),ST={value:``,label:`— unset —`},CT=[ST,{value:`planned`,label:`planned`},{value:`current`,label:`current`},{value:`retired`,label:`retired`}],wT=[ST,{value:`read`,label:`read`},{value:`write`,label:`write`},{value:`read-write`,label:`read-write`},{value:`unspecified`,label:`unspecified`}],TT=(e,t)=>t.find(t=>t.id===e)?.label??JS(e),ET=(e,t)=>{let n=t.find(t=>t.id===e);return n===void 0?JS(e):YS(n)},DT={R:[`Responsible`,`for`],C:[`Consulted`,`on`],I:[`Informed`,`of`]},OT=(e,t)=>{let n=new Map(t.graph.nodes.map(e=>[e.id,e.name])),r={R:[],C:[],I:[]},i={R:[],C:[],I:[]};for(let a of t.graph.edges){let t=a.responsibility??null;t!==null&&(a.to===e.id&&r[t].push(n.get(a.from)??a.from),a.from===e.id&&i[t].push(n.get(a.to)??a.to))}return[`R`,`C`,`I`].flatMap(e=>[{key:`${e}-carried`,label:DT[e][0],value:r[e].join(`, `)},{key:`${e}-held`,label:DT[e][0],value:i[e].length===0?``:`${DT[e][1]} ${i[e].join(`, `)}`}])},kT=({node:e,model:t,operations:n,onStageChange:r})=>{let i=oT(e,n),a=e.document,o=e.localId,s=e=>e.forEach(r),c=t.vocabulary.conceptKinds.map(e=>({value:e.label,label:YS(e)})),l=TT(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)(uT,{label:`Kind`,value:l,options:c,onCommit:e=>s(Zw(a,o,`kind`,l,e))}),(0,$.jsx)(pT,{label:`Name`,value:i.name,onCommit:e=>s(Zw(a,o,`name`,i.name,e))}),(0,$.jsx)(pT,{label:`Description`,value:i.description??``,onCommit:e=>s(Zw(a,o,`description`,i.description,e))}),(0,$.jsx)(uT,{label:`Status`,value:i.status??``,options:CT,onCommit:e=>s(Zw(a,o,`status`,i.status,e))}),(0,$.jsx)(pT,{label:`Owner`,value:i.owner??``,shape:{pattern:dT,hint:fT},onCommit:e=>s(Zw(a,o,`owner`,i.owner,e))}),OT(e,t).map(e=>(0,$.jsx)(AT,{label:e.label,value:e.value},e.key)),(0,$.jsx)(hT,{label:`Aka`,values:i.aka,onCommit:e=>s($w(a,o,`aka`,i.aka,e))}),(0,$.jsx)(hT,{label:`Distinct from`,values:i.distinctFrom,onCommit:e=>s($w(a,o,`distinctFrom`,i.distinctFrom,e))}),(0,$.jsx)(hT,{label:`Supersedes`,values:i.supersedes,onCommit:e=>s($w(a,o,`supersedes`,i.supersedes,e))}),(0,$.jsx)(hT,{label:`Present in`,values:i.presentIn,onCommit:e=>s($w(a,o,`presentIn`,i.presentIn,e))}),(0,$.jsx)(_T,{label:`References`,values:i.references,onCommit:e=>s($w(a,o,`references`,i.references,e))}),(0,$.jsx)(yT,{label:`Constraints`,values:i.constraints,onCommit:e=>s(nT(a,o,i.constraints,e))}),(0,$.jsx)(xT,{label:`Attestations`,values:i.attestations,onCommit:e=>s(iT(a,o,i.attestations,e))})]})},AT=({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})]}),jT=({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)(AT,{label:`Kind`,value:ET(e.kind,t.vocabulary.conceptKinds)}),(0,$.jsx)(AT,{label:`Name`,value:e.name}),(0,$.jsx)(AT,{label:`Status`,value:e.status??``}),(0,$.jsx)(AT,{label:`Owner`,value:e.owner??``}),OT(e,t).map(e=>(0,$.jsx)(AT,{label:e.label,value:e.value},e.key)),(0,$.jsx)(AT,{label:`Aka`,value:e.aka.join(`, `)}),(0,$.jsx)(AT,{label:`Distinct from`,value:e.distinctFrom.join(`, `)}),(0,$.jsx)(AT,{label:`Supersedes`,value:e.supersedes.join(`, `)}),(0,$.jsx)(AT,{label:`Present in`,value:e.presentIn.join(`, `)}),(0,$.jsx)(AT,{label:`References`,value:e.references.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,$.jsx)(AT,{label:`Constraints`,value:e.constraints.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,$.jsx)(AT,{label:`Attestations`,value:e.attestations.map(e=>`${e.topic} by ${e.by} on ${e.on}`).join(`; `)})]}),MT=({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)(AT,{label:`Kind`,value:ET(e.kind,t.vocabulary.relationshipKinds)}),(0,$.jsx)(AT,{label:`From`,value:n(e.from)}),(0,$.jsx)(AT,{label:`To`,value:n(e.to)}),(0,$.jsx)(AT,{label:`Name`,value:e.name??``}),(0,$.jsx)(AT,{label:`Mode`,value:e.mode??``}),(0,$.jsx)(AT,{label:`Content`,value:e.content??``}),(0,$.jsx)(AT,{label:`Status`,value:e.status??``}),(0,$.jsx)(AT,{label:`References`,value:e.references.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,$.jsx)(AT,{label:`Present in`,value:e.presentIn.join(`, `)})]})},NT=({edge:e,model:t,operations:n,onStageChange:r})=>{let i=cT(e,n),a=e.document,o=e.localId,s=e=>e.forEach(r),c=TT(i.kind,t.vocabulary.relationshipKinds),l=zw(t.graph,{from:i.from,to:i.to},t.vocabulary.relationshipKinds,c).options.map(e=>({value:e.label,label:YS(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)(uT,{label:`Kind`,value:c,options:l,onCommit:e=>s(Qw(a,o,`kind`,c,e))}),(0,$.jsx)(uT,{label:`From`,value:i.from,options:u,onCommit:e=>s(Qw(a,o,`from`,i.from,e))}),(0,$.jsx)(uT,{label:`To`,value:i.to,options:u,onCommit:e=>s(Qw(a,o,`to`,i.to,e))}),(0,$.jsx)(pT,{label:`Name`,value:i.name??``,onCommit:e=>s(Qw(a,o,`name`,i.name,e))}),(0,$.jsx)(pT,{label:`Description`,value:i.description??``,onCommit:e=>s(Qw(a,o,`description`,i.description,e))}),(0,$.jsx)(uT,{label:`Mode`,value:i.mode??``,options:wT,onCommit:e=>s(Qw(a,o,`mode`,i.mode,e))}),(0,$.jsx)(pT,{label:`Content`,value:i.content??``,onCommit:e=>s(Qw(a,o,`content`,i.content,e))}),(0,$.jsx)(uT,{label:`Status`,value:i.status??``,options:CT,onCommit:e=>s(Qw(a,o,`status`,i.status,e))}),(0,$.jsx)(_T,{label:`References`,values:i.references,onCommit:e=>s(eT(a,o,`references`,i.references,e))}),(0,$.jsx)(hT,{label:`Present in`,values:i.presentIn,onCommit:e=>s(eT(a,o,`presentIn`,i.presentIn,e))})]})};function PT({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,c=n=>e.next!==void 0&&e.next.questionId===n.questionId&&(t===null?e.next.subjectId===void 0:e.next.subjectId===t);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)(FT,{entry:e,next:c(e),verb:n||r===void 0?null:$S(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:[e.catalogues===void 0||e.catalogues.length<2?`Catalogue ${e.catalogue}`:`Catalogues ${e.catalogues.join(`, `)}`,` `,`· answers land through the changeset, never here.`]})]})}var FT=({entry:e,next:t,verb:n,onVerb:r,delegateLabel:i,onDelegate:a})=>(0,$.jsxs)(`li`,{className:t?`question-row question-row-next`:`question-row`,children:[(0,$.jsx)(`span`,{className:`question-text`,title:e.materiality,children:e.question}),(0,$.jsxs)(`span`,{className:`question-meta`,children:[t?(0,$.jsx)(`span`,{className:`question-next`,children:`next`}):null,(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]}),n===null?null:(0,$.jsx)(`button`,{type:`button`,className:`question-verb question-verb-${n.kind}`,onClick:()=>r(n),children:n.label}),i===null?null:(0,$.jsx)(`button`,{type:`button`,className:`question-verb question-verb-delegate`,onClick:a,children:i})]})]}),IT={layered:`Layered`,routed:`Routed`,"served-by":`Served-by`,bands:`Layer bands`},LT=[`top-down`,`left-right`],RT={"top-down":`Top-down`,"left-right":`Left-right`};function zT({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:Bg.map(e=>(0,$.jsx)(`option`,{value:e,children:IT[e]},e))}),(0,$.jsx)(`select`,{className:`canvas-select`,"aria-label":`Direction`,value:t,onChange:e=>r(e.currentTarget.value),children:LT.map(e=>(0,$.jsx)(`option`,{value:e,children:RT[e]},e))}),(0,$.jsx)(`select`,{className:`canvas-select`,"aria-label":`Style`,value:i,onChange:e=>a(e.currentTarget.value),children:Yg.map(e=>(0,$.jsx)(`option`,{value:e.id,children:e.title},e.id))})]})}var BT=[`composition`],VT=`top-down`,HT=e=>{let t=e?.trim()??``;return t===``?null:t},UT=e=>({type:`element`,id:e.id,title:e.name,kind:e.kindLabel,description:HT(e.description)}),WT=(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:HT(e.name),description:HT(e.description),kind:e.kindLabel}},GT=e=>new Map(e.nodes.map(e=>[e.id,e.name])),KT=(e,t)=>{let n=e.nodes.find(e=>e.id===t);return n===void 0?null:UT(n)},qT=(e,t)=>{let n=e.edges.find(e=>e.id===t);return n===void 0?null:WT(n,GT(e))},JT=(e,t,n,r,i)=>({showView:t=>{let{views:n}=e();return n.some(e=>e.id===t)?(i(t),!0):!1},select:n=>{let{graph:r}=e();if(r===null)return!1;let i=KT(r,n)??qT(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)}),YT=[`palette`,`properties`,`questions`,`changes`,`chat`],XT=e=>({min:96,max:Math.max(96,e-160)}),ZT=(e,t)=>{let{min:n,max:r}=XT(t);return Math.min(r,Math.max(n,e))},QT=.45,$T=(e,t)=>e.length===t.length&&new Set([...e,...t]).size===new Set(e).size,eE=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),tE=e=>{let t=[];return t.push({type:`layout.set`,layout:e?.layout??`served-by`}),t.push({type:`nesting.set`,nesting:e?.nesting??BT}),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?.showResponsibility!==void 0&&t.push({type:`presentation.toggled`,flag:`showResponsibility`,value:e.showResponsibility}),e?.showKindLabels!==void 0&&t.push({type:`presentation.toggled`,flag:`showKindLabels`,value:e.showKindLabels}),t},nE=(e,t,n,r)=>!r||e===``||e===n?null:t.find(t=>t.id===e)??null,rE=e=>({min:320,max:Math.max(320,Math.min(640,e*QT))}),iE=(e,t)=>{let{min:n,max:r}=rE(t);return Math.min(r,Math.max(n,e))},aE=480,oE=(e,t)=>{let{min:n,max:r}=rE(t);return Math.min(Math.min(r,aE),Math.max(n,e))},sE=(e,t=0)=>({railHidden:!1,conversation:{width:oE(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:`next-question`},tree:{filterText:``,collapsed:[]},connection:null,draftingSubject:!1,pendingDeletion:null,pendingViewDeletion:null,pendingViewRename:null,contextMenu:null,nesting:BT,foldMode:wg,folded:[],unfolded:[],direction:VT,layout:Vg,showLifecycle:!0,showEvidence:!0,showKindLabels:!0,showOwnership:!1,showResponsibility:!1,showNudges:!0,stylePreset:Qg()}),cE=(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=ZT(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=iE(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=iE(e.conversation.width,t.viewportWidth),r=t.viewportHeight??e.viewportHeight,i=ZT(e.conversation.changesHeight,r),a=ZT(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 eE(e.nesting,t.nesting)?e:{...e,nesting:t.nesting};case`fold.set`:return e.foldMode===t.mode&&$T(e.folded,t.folded)&&$T(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`?KT(i,r.id):qT(i,r.id);return a===null?{...n,selectedSubject:null,descriptionExpanded:!1}:{...n,selectedSubject:a}}}},lE=(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 uE({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 dE({label:e,height:t,viewportHeight:n,onResize:r}){let i=XT(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 fE=(e,t,n)=>YT.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)]}),pE={messageBytes:65536,modelBytes:5242880,transcriptBytes:5242880,pendingEvents:32,reconnectMs:3e5,staleSessionMs:864e5}.reconnectMs,mE=`Returning control to the main agent`,hE={operations:[],viewOperations:[],sourceDigests:{}},gE=e=>e.operations.length===0&&e.viewOperations.length===0,_E={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,closedMessage:null,pendingChangeset:hE,undoStack:[],redoStack:[],commitStatus:`idle`,commitDiagnostics:null,commitNotice:null,layoutNotice:null},vE=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}),yE=(e,t)=>t-e<pE,bE=(e,t,n)=>({id:`local-${e.localRecords}`,speaker:t,text:n}),xE=(e,t)=>e.transcript.some(e=>e.id===t.id)?e.transcript:[...e.transcript,t],SE=e=>e.initialView,CE={awaitingAgent:!1,agentStatus:null},wE=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`])}`},TE=(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},EE=(e,t,n)=>{let r=n.operations??e.operations,i=n.viewOperations??e.viewOperations;return{operations:r,viewOperations:i,sourceDigests:TE(r,i,e.sourceDigests,t)}},DE=(e,t)=>{switch(t.type){case`session.loaded`:return{...e,...t.snapshot,lifecycle:e.lifecycle===`ending`?`ending`:`active`,activeView:SE(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,...CE};case`chat.sent`:return{...e,transcript:xE(e,bE(e,`reviewer`,t.text)),localRecords:e.localRecords+1,choices:null,awaitingAgent:!0};case`chat.received`:return{...e,transcript:xE(e,{id:t.id,speaker:`agent`,text:t.text}),...CE};case`status.received`:return{...e,agentStatus:t.status};case`choice.presented`:return{...e,choices:t.choice,...CE};case`choice.sent`:{let n=e.choices?.options.find(e=>e.id===t.optionId);return n===void 0?e:{...e,transcript:xE(e,bE(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:xE(e,{id:t.id,speaker:`agent`,text:t.handoff.summary}),...CE};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`)?CE:{}}}case`end.requested`:return{...e,lifecycle:`ending`,choices:null,transcript:xE(e,bE(e,`session`,mE)),localRecords:e.localRecords+1};case`connection.lost`:return{...e,lifecycle:`disconnected`};case`session.closed`:return{...e,lifecycle:`closed`,closedReason:t.reason,closedMessage:t.message??null};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=wE(t.operation),r=[...e.pendingChangeset.operations.filter(e=>wE(e)!==n),t.operation];return{...e,pendingChangeset:EE(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:EE(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=VS({id:n.id,title:n.title,description:n.description,query:n.query,presentation:n.presentation}),a=US(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=KS(a,i);return{...e,pendingChangeset:EE(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:EE(e.pendingChangeset,e.model,a),undoStack:[...e.undoStack,e.pendingChangeset],redoStack:[],commitDiagnostics:null}}case`changeset.cleared`:{let t=gE(e.pendingChangeset);return{...e,pendingChangeset:hE,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:hE,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}}}},OE=e=>e.lifecycle===`active`&&e.chatEnabled&&!e.frozen&&!e.awaitingAgent;function kE(e,t){if(e.lifecycle===`closed`)return e;let n=DE(e,t);return n===e?e:{...n,composerEnabled:OE(n)}}var AE=(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},...e.showResponsibility===void 0?{}:{showResponsibility:e.showResponsibility}}};case`commit-changeset`:return{type:`changeset.commit`,lastAcknowledgedSequence:n,payload:t.pendingChangeset};case`save-layout`:return{type:`layout.save`,lastAcknowledgedSequence:n,payload:e.payload}}},jE=e=>{if(e.focusReturn===null)return;let t=e.focusReturn.activeView;return e.views.find(({id:e})=>e===t)?.title},ME=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 HS(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}},PE=(e,t=`panel`)=>{switch(e.kind){case`ready`:return[{type:`session.loaded`,snapshot:vE(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,...e.message===void 0?{}:{message:e.message}}];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}]}},FE=e=>{let[t,n]=(0,y.useReducer)(kE,_E),[r,i]=(0,y.useState)(!1),a=(0,y.useRef)(t);a.current=t;let o=(0,y.useRef)(`panel`),s=(0,y.useRef)({}),c=(0,y.useRef)(e);c.current=e,(0,y.useEffect)(()=>c.current.open({frame:e=>{for(let t of PE(e,o.current))n(t);let t=NE(e,a.current);t!==null&&(o.current=t.source,c.current.send(AE({kind:`filter`,query:t.query,...s.current},a.current)))},connected:i,lost:()=>n({type:`connection.lost`}),session:()=>({lastSequence:a.current.lastSequence,closed:a.current.lifecycle===`closed`})}),[]);let l=(0,y.useCallback)(e=>{c.current.send(AE(e,a.current))},[]),u=(0,y.useCallback)(e=>{n({type:`chat.sent`,text:e}),l({kind:`chat`,text:e})},[l]),d=(0,y.useCallback)(e=>{n({type:`chat.sent`,text:`Answer via your agent: ${e.question}`}),l({kind:`delegate`,payload:e})},[l]),f=(0,y.useCallback)(e=>{let t=a.current.choices?.choiceId;t!==void 0&&(n({type:`choice.sent`,optionId:e}),l({kind:`choice`,choiceId:t,optionId:e}))},[l]),p=(0,y.useCallback)(e=>{n({type:`view.navigated`,viewId:e}),l({kind:`navigate`,viewId:e})},[l]),m=(0,y.useCallback)((e,t=`panel`,n,r)=>{o.current=t,s.current={...n===void 0?{}:{nesting:n},...r===void 0?{}:{showResponsibility:r}},l({kind:`filter`,query:e,...s.current})},[l]),h=(0,y.useCallback)(()=>{n({type:`filter.cleared`})},[]),g=(0,y.useCallback)(e=>{n({type:`quickFilter.changed`,text:e})},[]),_=(0,y.useCallback)(e=>{n({type:`changeset.staged`,operation:e})},[]);return{state:t,connected:r,ask:u,choose:f,delegate:d,navigate:p,filter:m,clearFilter:h,setQuickFilterText:g,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:_,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)(()=>{gE(a.current.pendingChangeset)||(n({type:`changeset.commit.sent`}),l({kind:`commit-changeset`}))},[l]),saveLayout:(0,y.useCallback)(e=>{l({kind:`save-layout`,payload:e})},[l]),end:(0,y.useCallback)(()=>{n({type:`end.requested`}),l({kind:`end`})},[l])}},IE=(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)}},LE=({graph:e,from:t,onTarget:n})=>{let[r,i]=(0,y.useState)(``),{matches:a,more:o}=IE(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`]})]})]})},RE=({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)(LE,{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=Tw(t,l,u),f=new Set((e.kinds??[]).map(JS)),p=Lw(t.nodes.find(e=>e.id===l)?.coreKindLabel??``,t.nodes.find(e=>e.id===u)?.coreKindLabel??``),m=e=>p===null||!e.includes(p.kind)?[...e]:[p.kind,...e.filter(e=>e!==p.kind)],h=m(d.filter(e=>f.has(e))),g=m(d.filter(e=>!f.has(e))),_=h.length===0?m(d):h,v=e=>{let r=Dw(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&&h.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,_.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:_.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>v(e),children:e}),p!==null&&e===p.kind?(0,$.jsx)(`span`,{className:`connection-usual`,title:p.because,children:`usually`}):null]},e))}),h.length>0&&g.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:g.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>v(e),children:e})},e))})]}):null,(0,$.jsx)(`button`,{type:`button`,onClick:a,children:`Cancel`})]})},zE=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,BE=(e,t,n=[])=>{let r=t.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase();if(r===``||!zE.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}},VE=(e,t,n,r=[])=>{if(t.document===``||!n.includes(t.kind))return null;let i=t.name.trim();if(i===``)return null;let a=BE(e,i,r);return a===null?null:{op:`add-concept`,document:t.document,concept:{id:a,kind:t.kind,name:i}}},HE=(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=BE(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=BE(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}}}]},UE=(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=BE(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}}}]},WE=({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=HE(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`})]})},GE=({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:BE(e,c,a),h=m===null?null:VE(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:YS(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 KE({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 qE({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 JE=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`]),YE=(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}}]}],XE={key:`view.new`,label:`New view…`,intent:{type:`view.new`}},ZE={key:`view.new-folder`,label:`New folder…`,intent:{type:`view.new-folder`}},QE={key:`view.clear`,label:`Show all subjects`,intent:{type:`view.clear`}},$E=e=>e.focusReturnLabel===void 0?QE:{key:`view.clear`,label:`Back to ${e.focusReturnLabel}`,intent:{type:`view.clear`}},eD=(e,t)=>({key:`delete`,scope:`model`,label:null,destructive:!0,items:[{key:`delete`,label:t,intent:e}]}),tD=(e,t)=>t.instanceIds?.has(e)===!0?[{key:`focus-instance`,label:`Focus on this instance`,intent:{type:`subject.focus-instance`,id:e}}]:[],nD=(e,t,n)=>[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:[{key:`focus`,label:`Focus on this`,intent:e},...e.type===`subject.focus`?tD(e.id,n):[],...t.flatMap(e=>e.items),...n.filtered?[$E(n)]:[]]}],rD=(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}}]}]},iD=(e,t)=>{let n=e.split(/(?<=[.?!])\s/)[0]??e;return n.length<=t?n:`${n.slice(0,t-1).trimEnd()}…`},aD=(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:iD(e.question,72),intent:{type:`question.answer`,questionId:e.questionId,subjectId:t,verb:$S(e)}})),...n.delegateLabel===void 0?[]:[{key:`question-delegate`,label:`${n.delegateLabel}: ${iD(r.question,40)}`,intent:{type:`question.delegate`,questionId:r.questionId,subjectId:t,question:r.question}}]]}]},oD=(e,t)=>t.graph?.nodes.find(t=>t.id===e)===void 0?[]:[...nD({type:`subject.focus`,id:e},YE(e,t),t),...rD(e,t),...aD(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}}]},eD({type:`subject.delete`,id:e},`Delete from model…`)],sD=(e,t)=>{let n=t.graph,r=n?.edges.find(t=>t.id===e);if(n==null||r===void 0)return[];let i=zw(n,{from:r.from,to:r.to},t.relationshipKinds,r.kindLabel),a=[...nD({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(eD({type:`relationship.delete`,id:e},`Delete from model…`)),a},cD=e=>e.graph===null?[]:[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:[XE,ZE,...e.filtered?[QE]:[],{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`}}]:[]]},...aD(e.questions?.workspace??[],null,e),{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`add`,label:`Add subject…`,intent:{type:`canvas.draft-subject`}}]}],lD=(e,t)=>{let n=[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:e===``?[QE,XE,ZE]:[{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}},XE,ZE,{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},uD=(e,t)=>t.graph?.nodes.find(t=>t.id===e)===void 0?[]:[...YE(e,t),...tD(e,t).length===0?[]:[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:tD(e,t)}],...rD(e,t),...aD(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}}]},eD({type:`subject.delete`,id:e},`Delete from model…`)],dD=(e,t)=>{let n=(()=>{switch(e.kind){case`subject`:return oD(e.id,t);case`relationship`:return sD(e.id,t);case`canvas`:return cD(t);case`view-row`:return lD(e.id,t);case`model-row`:return uD(e.id,t)}})();return t.readOnly===!0?n.flatMap(e=>{let t=e.items.filter(e=>JE.has(e.intent.type));return t.length===0?[]:[{...e,items:t}]}):n},fD=(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 pD({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(fD({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 mD(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 hD(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 gD=(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},_D=(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}}]},vD=(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=gD(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.`},yD={reviewer:`You`,agent:`Agent`,session:`Session`},bD={thinking:`Agent is thinking`,compiling:`Agent is compiling the model`,waiting:`Agent is waiting`,idle:`Agent is idle`},xD=(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`}},SD=e=>e.lifecycle===`closed`?e.closedMessage??`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.`:``,CD=({brand:e})=>{if(e.logo===void 0&&e.shortName===null)return null;let t=e.logo===void 0?null:`url`in e.logo?(0,$.jsx)(`img`,{className:`brand-logo`,src:e.logo.url,alt:``}):(0,$.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,dangerouslySetInnerHTML:{__html:e.logo.svg}}),n=(0,$.jsxs)($.Fragment,{children:[t,e.shortName===null?null:(0,$.jsx)(`span`,{className:`brand-name`,children:e.shortName})]});return e.docsUrl===void 0?(0,$.jsx)(`span`,{className:`brand`,"aria-label":e.productName,children:n}):(0,$.jsx)(`a`,{className:`brand`,href:e.docsUrl,target:`_blank`,rel:`noreferrer`,"aria-label":e.productName,children:n})},wD=({state:e,connection:t,brand:n})=>(0,$.jsxs)(`header`,{className:`command-strip`,children:[(0,$.jsxs)(`div`,{className:`command-identity`,children:[n.branded?(0,$.jsx)(CD,{brand:n}):null,(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 ${n.shortName??n.productName} 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}),n.vendorLine===null?null:(0,$.jsx)(`span`,{className:`vendor-line`,children:n.vendorLine})]}),TD=({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))})]}),ED=({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}`))})]}),DD=({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,showResponsibility:h,showKindLabels:g,showNudges:_,openQuestionCounts:v,nextQuestionSubjectId:b,nextQuestion:x,delegateLabel:S,onNextVerb:C,onNextDelegate:w,onNextGo:T,decorations:E,connection:D,onConnectTarget:O,onConnectCancel:k,onConnectStage:A,onDraftStage:j,draftingSubject:M,draftInitialKind:N,draftPattern:P,onKindDrop:F,onDraftSubject:I,onDraftSubjectClose:L,pendingDeletion:R,onDeletionDismiss:z,onSelect:B,onCanvasMenu:V,onClearFilter:H,onSaveLayout:U,onCanvasReady:W,onQuickFilterChange:G,view:K,bottomPanel:q,onTogglePresentation:J,onToggleBottomPanel:ee,onSelectBottomTab:Y,onApplyFilter:X,onStageView:te,readOnly:ne,paletteReachable:re})=>{let ie=(0,y.useRef)(null),[ae,oe]=(0,y.useState)(0),se=e.model!==null;(0,y.useEffect)(()=>{let e=ie.current;if(e===null)return;let t=()=>{let t=e.parentElement,n=t===null?e.getBoundingClientRect().bottom:e.getBoundingClientRect().bottom-t.getBoundingClientRect().top;oe(Math.max(0,Math.round(n+8)))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[se]);let ce=(0,y.useMemo)(()=>new Map((e.model?.graph.nodes??[]).map(e=>[e.id,e.name])),[e.model]),le=e.model?.graph.nodes??[],ue=jE(e),de=e.activeFilter?.matchedIds??null,fe=le.length>0&&(e.activeFilter!==null||e.quickFilterText.trim()!==``)&&vy(le,de,e.quickFilterText)===0,pe=e.activeFilter!==null&&vy(le,de,``)===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:$C(e.activeFilter.query)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:H,children:ue===void 0?`Show all`:`Back to ${ue}`})]}):null,(0,$.jsxs)(`div`,{className:`canvas`,children:[e.model===null?null:(0,$.jsxs)(`div`,{className:`canvas-controls`,ref:ie,children:[(0,$.jsx)(OC,{value:e.quickFilterText,onChange:G}),(0,$.jsx)(zT,{layout:r,direction:s,onLayoutChange:c,onDirectionChange:l,stylePreset:u,onStyleChange:d}),ne||re?null:(0,$.jsx)(`button`,{type:`button`,className:`subject-draft-open`,onClick:I,children:`Add subject`})]}),!M||e.model===null||P===void 0?null:(0,$.jsx)(WE,{graph:e.model.graph,pattern:P,documents:e.model.documents,reservedIds:Ow(e.pendingChangeset.operations),defaultDocument:(t===null?void 0:e.model.graph.nodes.find(e=>e.id===t)?.document)??e.model.documents[0]??``,onStage:j,onCancel:L},`pattern:${P.kind}`),!M||e.model===null||P!==void 0?null:(0,$.jsx)(GE,{initialKind:N,graph:e.model.graph,kinds:e.model.vocabulary.conceptKinds,documents:e.model.documents,reservedIds:Ow(e.pendingChangeset.operations),defaultDocument:(t===null?void 0:e.model.graph.nodes.find(e=>e.id===t)?.document)??e.model.documents[0]??``,onStage:j,onCancel:L},N??``),R===null||e.model===null?null:(0,$.jsx)(KE,{title:`Delete`,message:vD(e.model.graph,R)??`That subject is no longer on the diagram.`,confirmLabel:`Delete`,cancelLabel:`Keep`,onConfirm:()=>{for(let t of _D(e.model.graph,R))A(t);z()},onCancel:z}),D===null||e.model===null?null:(0,$.jsx)(RE,{draft:D,graph:e.model.graph,reservedIds:Ow(e.pendingChangeset.operations),onTarget:O,onStage:A,onCancel:k}),e.model===null?null:(0,$.jsx)(Ry,{graph:e.model.graph,selectedId:t,onSelect:(t,n)=>{let r=e.model.graph;if(n===`node`){if(D!==null){O(t);return}let e=r.nodes.find(e=>e.id===t);e!==void 0&&B(UT(e))}else{let e=r.edges.find(e=>e.id===t);e!==void 0&&B(WT(e,ce))}},onContextMenu:V,matchedIds:e.activeFilter?.matchedIds??null,quickFilterText:e.quickFilterText,nesting:i,folded:a,memberships:o,faultedIds:rw(e.commitDiagnostics??[]),decorations:E,showLifecycle:f,showEvidence:p,showOwnership:m,showResponsibility:h,showNudges:_,openQuestionCounts:v,nextQuestionSubjectId:b,reservedTop:ae,activeViewId:e.activeView,direction:s,layout:r,showKindLabels:g,stylePreset:u,savedPositions:e.model.layouts[e.activeView],savedRoutes:e.model.routes?.[e.activeView],onSaveLayout:ne?()=>void 0:U,onKindDrop:ne?void 0:F,onCanvasReady:W}),fe?(0,$.jsx)(`div`,{className:`filter-empty-pill`,role:`status`,children:pe&&e.activeFilter!==null?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{children:[`Nothing matches this filter:`,` `,(0,$.jsx)(`code`,{children:$C(e.activeFilter.query)})]}),(0,$.jsx)(`button`,{type:`button`,onClick:H,children:`Show all`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{children:[`Nothing matches “`,e.quickFilterText.trim(),`”`]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>G(``),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)(DC,{nodes:e.model?.graph.nodes??[],activeFilter:e.activeFilter,view:K,open:q.open,tab:q.tab,showLifecycle:f,showEvidence:p,showOwnership:m,showResponsibility:h,showKindLabels:g,showNudges:_,onTogglePresentation:J,onToggleOpen:ee,onSelectTab:Y,next:x,delegateLabel:S,onNextVerb:C,onNextDelegate:w,onNextGo:T,onApply:X,onStage:te,readOnly:ne},e.activeView),(0,$.jsx)(ED,{diagnostics:e.diagnostics})]})},OD=({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]})},kD=({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)(jT,{node:u,model:t}):(0,$.jsx)(kT,{node:u,model:t,operations:n,onStageChange:c}),d===void 0?null:l?(0,$.jsx)(MT,{edge:d,model:t}):(0,$.jsx)(NT,{edge:d,model:t,operations:n,onStageChange:c}),u===void 0?null:(0,$.jsx)(jD,{id:u.id,model:t,operations:n,reservedIds:Ow(n),onStage:c,readOnly:l}),(0,$.jsx)(OD,{text:e.description,expanded:r,onToggle:i})]})},AD=({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=UE(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]})},jD=({id:e,model:t,operations:n,reservedIds:r,onStage:i,readOnly:a})=>{let o=mD(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?hD(n):(0,$.jsx)(AD,{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:hD(n)})})]},n.slot))})]})},MD=e=>e.lifecycle===`active`?e.awaitingAgent?bD[e.agentStatus?.state??`thinking`]??`working`:`agent idle`:`closed`,ND=({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:yD[e.speaker]}),(0,$.jsx)(`p`,{className:`words`,children:e.text})]},e.id))}),e.choices===null?null:(0,$.jsx)(TD,{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`:bD[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:SD(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`})]})]})]})},PD=({width:e,viewportWidth:t,onResize:n})=>{let r=rE(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))}})},FD=({host:e,sections:t=YT,readOnly:n=!1,decorations:r,onDelegateQuestion:i,onReady:a,initialView:o,onFirstModel:s,branding:c})=>{let{state:l,connected:u,ask:d,choose:f,delegate:p,navigate:m,filter:h,clearFilter:g,setQuickFilterText:_,stageViewChange:v,stageViewMembership:b,saveLayout:x,discardChange:S,stageChange:C,clearChangeset:w,undoChangeset:T,redoChangeset:E,commitChangeset:D,end:O}=FE(e),k=(0,y.useMemo)(()=>Wy(c),[c]),[A,j]=(0,y.useReducer)(cE,{width:window.innerWidth,height:window.innerHeight},({width:e,height:t})=>sE(e,t)),[M,N]=(0,y.useState)(null),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(void 0),[B,V]=(0,y.useState)(void 0),[H,U]=(0,y.useState)(r??{}),W=(0,y.useRef)(null),G=(0,y.useRef)({graph:null,readOnly:n,stagedPins:{},views:[]});G.current={graph:l.model?.graph??null,readOnly:n,stagedPins:l.pendingChangeset.sourceDigests,views:l.views},(0,y.useEffect)(()=>{a?.(JT(()=>G.current,j,V,U,m))},[a,m]);let K=(0,y.useRef)(!1);(0,y.useEffect)(()=>{K.current||l.model===null||(K.current=!0,s?.())},[l.model,s]);let q=(0,y.useRef)(!1);(0,y.useEffect)(()=>{q.current||o===void 0||l.model!==null&&(q.current=!0,l.views.some(e=>e.id===o)&&m(o))},[o,l.model,l.views,m]),(0,y.useEffect)(()=>{let e=()=>j({type:`viewport.resized`,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight});return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let J=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(l.activeView===``){J.current=null;return}let e=nE(l.activeView,l.views,J.current,u);if(e!==null){J.current=e.id,h(e.query,`view`,e.presentation?.nesting,e.presentation?.showResponsibility);for(let t of tE(e.presentation))j(t)}},[l.activeView,l.views,u,h]);let ee=(0,y.useRef)({transcriptLength:l.transcript.length,choices:l.choices,diagnostics:l.diagnostics});(0,y.useEffect)(()=>{let e=ee.current,t=!1;for(let n=e.transcriptLength;n<l.transcript.length;n+=1)if(l.transcript[n]?.speaker===`agent`){t=!0;break}let n=t||l.choices!==null&&l.choices!==e.choices||l.diagnostics.length>0&&l.diagnostics!==e.diagnostics;ee.current={transcriptLength:l.transcript.length,choices:l.choices,diagnostics:l.diagnostics},n&&j({type:`attention.received`})},[l.transcript.length,l.choices,l.diagnostics]);let Y=(0,y.useRef)(l.model);(0,y.useEffect)(()=>{l.model!==Y.current&&(Y.current=l.model,j({type:`model.replaced`,graph:l.model?.graph??null}))},[l.model]);let X=l.model===null?l.lifecycle===`connecting`?`Reading the session`:`No model to draw`:M,te=l.pendingChangeset.operations.length+l.pendingChangeset.viewOperations.length,ne=e=>!A.conversation.collapsed.includes(e),re=l.model?.interrogation,ie=(0,y.useMemo)(()=>new Map(Object.entries(re?.subjects??{}).map(([e,t])=>[e,t.length])),[re]),ae=re?.next?.subjectId??null,oe=(0,y.useMemo)(()=>{let e=l.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:l.model?.memberships??[],nesting:A.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=A.folded.includes(e),n=A.unfolded.includes(e);(t||A.foldMode===`instances`&&!n)&&i.add(e)}return{folded:i,insideCounts:n,insideIds:r}},[l.model,A.nesting,A.foldMode,A.folded,A.unfolded]),se=oe.folded,ce=n?t.filter(e=>e!==`palette`&&e!==`changes`):t,le=re===void 0?ce.filter(e=>e!==`questions`):ce,ue=A.selectedSubject?.type===`element`?A.selectedSubject.id:null,de=re===void 0?void 0:ue===null?re.workspace.length:ie.get(ue)??0,fe=l.model?.vocabulary.conceptKinds??[],pe=l.model?.vocabulary.patterns,me=(0,y.useMemo)(()=>new Set(A.tree.collapsed),[A.tree.collapsed]),he=A.conversation.hidden,ge={"--conversation-width":he?`0px`:`${A.conversation.width}px`,"--changes-height":ne(`changes`)?`${A.conversation.changesHeight}px`:`auto`,"--chat-height":ne(`chat`)?`${A.conversation.chatHeight}px`:`auto`,...k.accent===void 0?{}:{"--accent":k.accent}},_e=e=>{V(e),j({type:`subject.draft.opened`})},ve=(e,t)=>j({type:`menu.opened`,target:e,x:t.x,y:t.y}),ye=l.views.find(({id:e})=>e===l.activeView)?.title,be=l.chatEnabled?`Answer via agent`:i===void 0?`Copy for my assistant`:`Answer via assistant`,xe=A.contextMenu===null?[]:dD(A.contextMenu.target,{graph:l.model?.graph??null,relationshipKinds:l.model?.vocabulary.relationshipKinds??[],activeViewId:l.activeView,filtered:l.activeFilter!==null,membership:ME(l),folded:se,containerIds:new Set(oe.insideCounts.keys()),instanceIds:new Set((l.model?.memberships??[]).map(({instance:e})=>e)),selectedIds:A.selectedSubject===null?[]:[A.selectedSubject.id],...jE(l)===void 0?{}:{focusReturnLabel:jE(l)},readOnly:n,...re===void 0?{}:{questions:re},delegateLabel:be}),Se=(e,t)=>{if(e?.kind===`connect`&&t!==null){j({type:`connection.started`,from:t,kinds:e.kinds,direction:e.direction});return}if(e?.kind===`add`){V(e.subjectKind),j({type:`subject.draft.opened`});return}if(t!==null){let e=l.model?.graph.nodes.find(e=>e.id===t);e!==void 0&&j({type:`subject.selected`,subject:UT(e)})}ne(`properties`)||j({type:`section.toggled`,section:`properties`})},Ce=e=>{if(e.subjectId===void 0)j({type:`subject.cleared`});else{let t=l.model?.graph.nodes.find(t=>t.id===e.subjectId);t!==void 0&&j({type:`subject.selected`,subject:UT(t)})}ne(`questions`)||j({type:`section.toggled`,section:`questions`})},we=(e,t)=>{if(l.chatEnabled){p(e);return}if(i!==void 0){i(e);return}let n=(e.subjectId===null?re?.workspace:re?.subjects[e.subjectId])?.find(t=>t.questionId===e.questionId),r=e.subjectId===null?null:{id:e.subjectId,name:t??e.subjectId};navigator.clipboard?.writeText(nC(n??{questionId:e.questionId,question:e.question,authority:`human`},r))},Te=e=>{let t=l.model?.graph??null;switch(e.type){case`question.answer`:Se(e.verb,e.subjectId);return;case`question.delegate`:{let n=t?.nodes.find(t=>t.id===e.subjectId);we({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;j({type:`subject.selected`,subject:UT(n)});return}case`relationship.inspect`:{let n=t?.edges.find(t=>t.id===e.id);if(n===void 0||t===null)return;j({type:`subject.selected`,subject:WT(n,new Map(t.nodes.map(e=>[e.id,e.name])))});return}case`subject.connect`:j({type:`connection.started`,from:e.from});return;case`subject.delete`:case`relationship.delete`:j({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 Qw(n.document,n.localId,`kind`,n.kindLabel,e.kind))C(t);j({type:`menu.dismissed`});return}case`canvas.draft-subject`:V(void 0),j({type:`subject.draft.opened`});return;case`view.add-subject`:case`view.remove-subject`:b(l.activeView,e.id,e.type===`view.add-subject`?`add`:`remove`),j({type:`menu.dismissed`});return;case`view.open`:m(e.id),j({type:`menu.dismissed`});return;case`view.clear`:g(),j({type:`menu.dismissed`});return;case`subject.fold`:case`subject.unfold`:j({type:`fold.toggled`,id:e.id}),j({type:`menu.dismissed`});return;case`subject.unfold-all`:{let t=oe.insideIds.get(e.id)??[];j({type:`fold.all`,folded:!1,ids:[e.id,...t]}),j({type:`menu.dismissed`});return}case`selection.fold`:case`selection.unfold`:for(let t of e.ids)se.has(t)!==(e.type===`selection.fold`)&&j({type:`fold.toggled`,id:t});j({type:`menu.dismissed`});return;case`canvas.fold-all`:case`canvas.unfold-all`:j({type:`fold.all`,folded:e.type===`canvas.fold-all`,ids:[...oe.insideCounts.keys()]}),j({type:`menu.dismissed`});return;case`subject.focus-instance`:h({instances:[e.id],relationships:`between`},`focus`,A.nesting,A.showResponsibility),j({type:`menu.dismissed`});return;case`subject.focus`:case`relationship.focus`:{let t=l.model?.graph??null;if(t===null){j({type:`menu.dismissed`});return}let n=e.type===`subject.focus`?ew(t,e.id):tw(t,e.id);if(n.length===0){j({type:`menu.dismissed`});return}h({subjects:[...n],relationships:`between`},`focus`,A.nesting,A.showResponsibility),j({type:`menu.dismissed`});return}case`view.new`:z(void 0),F(!0),j({type:`menu.dismissed`});return;case`view.delete`:j({type:`viewDeletion.asked`,id:e.id});return;case`view.rename`:j({type:`viewRename.asked`,id:e.id});return;case`view.new-folder`:L(!0),j({type:`menu.dismissed`});return;case`view.duplicate`:{let t=l.views.find(t=>t.id===e.id);if(t===void 0)return;let n=BS(t,new Set(l.views.map(e=>e.id)));v({op:`write-view`,...n}),j({type:`menu.dismissed`});return}case`view.new-in-folder`:{let t=l.views.find(t=>t.id===e.id);if(t===void 0)return;z(RS(t)),F(!0),j({type:`menu.dismissed`});return}case`view.copy-path`:{let t=l.views.find(t=>t.id===e.id);if(t===void 0)return;navigator.clipboard?.writeText(t.path),j({type:`menu.dismissed`});return}case`canvas.export-png`:{let e=W.current;if(e===null)return;let t=document.createElement(`a`);t.href=e(),t.download=`${l.activeView===``?`all-subjects`:l.activeView}.png`,t.click(),j({type:`menu.dismissed`});return}}},Ee=A.pendingViewDeletion===null?null:l.views.find(e=>e.id===A.pendingViewDeletion)??null,De=A.pendingViewRename===null?null:l.views.find(e=>e.id===A.pendingViewRename)??null,Z=[`Show the session panel`,...A.conversation.unread===0?[]:[`${A.conversation.unread} unread`],...l.choices===null?[]:[`the agent is waiting on a choice`]].join(`, `);return(0,$.jsxs)(`main`,{className:`visual-shell`,style:ge,children:[(0,$.jsx)(wD,{state:l,connection:xD(l,u),brand:k}),(0,$.jsxs)(`div`,{className:`workspace`,"data-rail":A.railHidden?`hidden`:void 0,children:[A.railHidden?(0,$.jsx)(`button`,{type:`button`,className:`rail-reopen`,title:`Show the view tree`,"aria-label":ye===void 0?`Show the view tree`:`Show the view tree, showing ${ye}`,onClick:()=>j({type:`rail.toggled`}),children:(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`»`})}):(0,$.jsx)(YC,{views:l.views,stagedViewOperations:l.pendingChangeset.viewOperations,activeViewId:l.activeView,nodes:l.model?.graph.nodes??[],folded:se,insideCounts:oe.insideCounts,inViewIds:l.activeFilter===null?null:new Set(l.activeFilter.matchedIds),filterText:A.tree.filterText,collapsed:me,onFilterChange:e=>j({type:`tree.filtered`,filterText:e}),onToggle:e=>j({type:`tree.toggled`,key:e}),onSelectView:e=>m(e),onClearView:g,onNewView:()=>{z(void 0),F(!0)},onSelectSubject:e=>{let t=l.model?.graph.nodes.find(t=>t.id===e);t!==void 0&&j({type:`subject.selected`,subject:UT(t)})},onRowMenu:(e,t)=>ve(e.kind===`view`?{kind:`view-row`,id:e.id}:{kind:`model-row`,id:e.id},t),readOnly:n,onHide:()=>j({type:`rail.toggled`})}),(0,$.jsx)(DD,{state:l,selectedId:A.selectedSubject?.id??null,waiting:X,layout:A.layout,nesting:A.nesting,folded:se,memberships:l.model?.memberships,direction:A.direction,onLayoutChange:e=>j({type:`layout.set`,layout:e}),onDirectionChange:e=>j({type:`direction.set`,direction:e}),stylePreset:A.stylePreset,onStyleChange:e=>{$g(e),j({type:`style.set`,preset:e})},decorations:H,connection:A.connection,onConnectTarget:e=>j({type:`connection.targeted`,to:e}),onConnectCancel:()=>j({type:`connection.cancelled`}),onConnectStage:C,onDraftStage:e=>{C(e),e.op===`add-concept`&&b(l.activeView,e.concept.id,`add`)},draftingSubject:A.draftingSubject,draftInitialKind:B,draftPattern:(l.model?.vocabulary.patterns??[]).find(e=>e.label===B),onKindDrop:e=>_e(e),onDraftSubject:()=>{V(void 0),j({type:`subject.draft.opened`})},onDraftSubjectClose:()=>j({type:`subject.draft.closed`}),pendingDeletion:A.pendingDeletion,onDeletionDismiss:()=>j({type:`deletion.dismissed`}),showLifecycle:A.showLifecycle,showEvidence:A.showEvidence,showOwnership:A.showOwnership,showResponsibility:A.showResponsibility,showKindLabels:A.showKindLabels,showNudges:A.showNudges,openQuestionCounts:ie,onSelect:e=>j({type:`subject.selected`,subject:e}),onCanvasMenu:(e,t)=>ve(e.type===`node`?{kind:`subject`,id:e.id??``}:e.type===`edge`?{kind:`relationship`,id:e.id??``}:{kind:`canvas`},t),onClearFilter:g,onSaveLayout:e=>x({...e,folded:[...A.folded],unfolded:[...A.unfolded]}),onCanvasReady:e=>{W.current=e},onQuickFilterChange:_,view:l.views.find(e=>e.id===l.activeView)??null,nextQuestionSubjectId:ae,nextQuestion:re?.next,delegateLabel:be,onNextVerb:(e,t)=>Se(e,t),onNextDelegate:e=>we({questionId:e.questionId,subjectId:e.subjectId??null,question:e.question},e.subjectName??null),onNextGo:Ce,bottomPanel:A.bottomPanel,onTogglePresentation:(e,t)=>{j({type:`presentation.toggled`,flag:e,value:t}),e===`showResponsibility`&&l.activeFilter!==null&&h(l.activeFilter.query,l.activeFilter.source,A.nesting,t)},onToggleBottomPanel:()=>j({type:`bottomPanel.toggled`}),onSelectBottomTab:e=>j({type:`bottomPanel.tabSelected`,tab:e}),onApplyFilter:e=>h(e,`editor`,A.nesting,A.showResponsibility),onStageView:v,readOnly:n,paletteReachable:ce.includes(`palette`)}),he?(0,$.jsxs)(`button`,{type:`button`,className:`conversation-reopen`,title:`Show the session panel`,"aria-label":Z,onClick:()=>j({type:`conversation.toggled`}),children:[(0,$.jsx)(`span`,{className:`reopen-chevron`,"aria-hidden":`true`,children:`«`}),A.conversation.unread===0?null:(0,$.jsx)(`span`,{className:`attention-count`,children:A.conversation.unread}),l.choices===null?null:(0,$.jsx)(`span`,{className:`attention-choice`,title:`The agent is waiting on a choice`,children:`?`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(PD,{width:A.conversation.width,viewportWidth:A.viewportWidth,onResize:e=>j({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:()=>j({type:`conversation.toggled`}),children:`»`})}),fE(le,{palette:(0,$.jsx)(uE,{id:`palette`,label:`Kind palette`,meta:fe.length===0?void 0:fe.length===1?`1 kind`:`${fe.length} kinds`,open:ne(`palette`),onToggle:()=>j({type:`section.toggled`,section:`palette`}),children:fe.length===0?(0,$.jsx)(`p`,{className:`section-empty`,children:`No model yet. The kinds arrive with it.`}):(0,$.jsx)(av,{kinds:fe,patterns:pe,onPick:_e})}),properties:(0,$.jsx)(uE,{id:`properties`,label:`Element properties`,meta:A.selectedSubject?.id,open:ne(`properties`),onToggle:()=>j({type:`section.toggled`,section:`properties`}),children:A.selectedSubject===null||l.model===null?(0,$.jsx)(`p`,{className:`section-empty`,children:`Nothing selected. Pick a subject on the canvas or in the rail.`}):(0,$.jsx)(kD,{subject:A.selectedSubject,model:l.model,operations:l.pendingChangeset.operations,expanded:A.descriptionExpanded,onToggleDescription:()=>j({type:`description.toggled`}),onClear:()=>j({type:`subject.cleared`}),onConnect:e=>j({type:`connection.started`,from:e}),onDelete:e=>j({type:`deletion.asked`,id:e}),onStageChange:C,readOnly:n})}),questions:(0,$.jsx)(uE,{id:`questions`,label:`Open questions`,meta:de===void 0?void 0:de===0?`nothing open`:`${de} open`,open:ne(`questions`),onToggle:()=>j({type:`section.toggled`,section:`questions`}),children:re===void 0?null:(0,$.jsx)(PT,{overlay:re,selectedId:ue,readOnly:n,onVerb:(e,t,n)=>Se(t,n),delegateLabel:be,onDelegate:(e,t)=>we({questionId:e.questionId,subjectId:t,question:e.question},A.selectedSubject?.type===`element`?A.selectedSubject.title:null)})}),changes:(0,$.jsx)(uE,{id:`changes`,label:`Changes`,meta:te===0?`nothing staged`:`${te} staged`,open:ne(`changes`),onToggle:()=>j({type:`section.toggled`,section:`changes`}),children:(0,$.jsx)(mw,{state:l,onDiscardChange:S,onClearChangeset:w,onUndoChangeset:T,onRedoChangeset:E,onCommitChangeset:D})}),chat:(0,$.jsx)(uE,{id:`chat`,label:`Chat`,meta:A.conversation.unread===0?MD(l):(0,$.jsx)(`span`,{className:`attention-count`,children:A.conversation.unread}),open:ne(`chat`),onToggle:()=>j({type:`section.toggled`,section:`chat`}),children:(0,$.jsx)(ND,{state:l,disabled:!l.composerEnabled,selectedSubject:A.selectedSubject,onSend:e=>d(lE(e,A.selectedSubject)),onChoice:f,onClearSubject:()=>j({type:`subject.cleared`}),onEnd:O})})},{changes:(0,$.jsx)(dE,{label:`Resize the changes section`,height:A.conversation.changesHeight,viewportHeight:A.viewportHeight,onResize:e=>j({type:`section.resized`,section:`changes`,height:e})}),chat:(0,$.jsx)(dE,{label:`Resize the chat section`,height:A.conversation.chatHeight,viewportHeight:A.viewportHeight,onResize:e=>j({type:`section.resized`,section:`chat`,height:e})})})]})]})]}),A.contextMenu===null?null:(0,$.jsx)(pD,{groups:xe,x:A.contextMenu.x,y:A.contextMenu.y,onChoose:Te,onDismiss:()=>j({type:`menu.dismissed`})}),(0,$.jsx)(QC,{views:l.views,activeViewId:l.activeView,query:l.activeFilter?.query??null,layout:A.layout,direction:A.direction,showLifecycle:A.showLifecycle,showEvidence:A.showEvidence,showOwnership:A.showOwnership,showKindLabels:A.showKindLabels,open:P,folder:R,onClose:()=>F(!1),onStage:v}),I?(0,$.jsx)(qE,{title:`New folder`,label:`Folder`,initialValue:``,confirmLabel:`Continue`,cancelLabel:`Cancel`,onConfirm:e=>{L(!1);let t=e.trim();t!==``&&(z(t),F(!0))},onCancel:()=>L(!1)}):null,De===null?null:(0,$.jsx)(qE,{title:`Rename view`,label:`Title`,initialValue:De.title,confirmLabel:`Rename`,cancelLabel:`Cancel`,onConfirm:e=>{v({op:`write-view`,...zS(De,e)}),j({type:`viewRename.dismissed`})},onCancel:()=>j({type:`viewRename.dismissed`})}),Ee===null?null:(0,$.jsx)(KE,{title:`Delete view`,message:`Stage the removal of "${Ee.title}"? The projection document goes when the changeset is committed; no subject is touched.`,confirmLabel:`Delete`,cancelLabel:`Keep`,onConfirm:()=>{v({op:`delete-view`,path:Ee.path}),j({type:`viewDeletion.dismissed`})},onCancel:()=>j({type:`viewDeletion.dismissed`})})]})},ID=`/api/session`,LD=`/socket`,RD=1e3,zD=(e={})=>{let t=null,n=e.retryMs??RD,r=(t,n)=>e.reconnectWindowMs===void 0?yE(t,n):n-t<e.reconnectWindowMs;return{open:i=>{let a=!1,o,s=null,c=()=>{let t=i.session().lastSequence;if(typeof e.socket==`function`)return new URL(String(e.socket(t)),window.location.href);let n=new URL(e.socket??LD,window.location.href);return n.protocol=n.protocol===`https:`?`wss:`:n.protocol===`http:`?`ws:`:n.protocol,n.searchParams.set(`after`,String(t)),n},l=()=>{if(!a){if(s??=Date.now(),!r(s,Date.now())){i.frame({kind:`closing`,reason:`browser-timeout`});return}o=setTimeout(u,n)}},u=()=>{if(a)return;let e=new WebSocket(c());t=e,e.addEventListener(`open`,()=>{s=null,i.connected(!0)}),e.addEventListener(`message`,e=>{if(typeof e.data==`string`)try{i.frame(JSON.parse(e.data))}catch{}}),e.addEventListener(`close`,e=>{if(i.connected(!1),t=null,!(a||i.session().closed)){if(e.code>=4e3&&e.code<=4999){i.frame({kind:`closing`,reason:`host-ended`,...e.reason===``?{}:{message:e.reason}});return}i.lost(),l()}}),e.addEventListener(`error`,()=>e.close())};return(async()=>{let t=await fetch(new URL(e.session??ID,window.location.href),{credentials:`same-origin`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(`Session request answered ${t.status}`);let n=await t.json();a||(i.frame({kind:`ready`,snapshot:n}),u())})().catch(()=>{a||(i.lost(),l())}),()=>{a=!0,o!==void 0&&clearTimeout(o),t?.close()}},send:e=>{t!==null&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))}}},BD=document.getElementById(`visual-session`);if(BD===null)throw Error(`The visual session page has no mount point`);Fv(Pv(()=>new v)),(0,_.createRoot)(BD).render((0,$.jsx)(FD,{host:zD()}));export{l as n,o as t};
|