yarramate 1.3.0 → 1.4.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/catalogues/core-enrichment.yaml +13 -1
- package/dist/adapters/visual/workspace-model.d.ts +14 -2
- package/dist/adapters/visual/workspace-model.js +19 -9
- package/dist/ask-command.js +8 -1
- package/dist/compiler.d.ts +13 -1
- package/dist/compiler.js +646 -0
- package/dist/design-command.js +14 -3
- package/dist/graph-projection.d.ts +10 -0
- package/dist/graph-projection.js +1 -0
- package/dist/interrogate-command.d.ts +17 -0
- package/dist/interrogate-command.js +72 -40
- package/dist/relationship-drafting.js +16 -1
- package/dist/visual-app/assets/{index-C3i9SxTe.js → index-yCHtmQUH.js} +1 -1
- package/dist/visual-app/index.html +1 -1
- package/dist/visual-app-lib/editor.js +22875 -22261
- package/dist/visual-app-lib/types/adapters/visual/workspace-model.d.ts +14 -2
- package/dist/visual-app-lib/types/compiler.d.ts +13 -1
- package/dist/visual-app-lib/types/graph-projection.d.ts +10 -0
- package/dist/visual-app-lib/types/interrogate-command.d.ts +17 -0
- package/dist/visual-app-lib/types/visual-app/local-host.d.ts +42 -0
- package/dist/visual-app-lib/types/workspace.d.ts +2 -0
- package/dist/workspace.d.ts +2 -0
- package/dist/workspace.js +1 -0
- package/docs/CONSUMING-YARRAMATE.md +41 -0
- package/package.json +2 -1
- package/schema/yarramate-design-step.schema.json +13 -0
- package/schema/yarramate-document.schema.json +14 -0
- package/schema/yarramate-interrogation-report.schema.json +18 -0
- package/schema/yarramate-pattern.schema.json +133 -0
- package/schema/yarramate-question-catalogue.schema.json +21 -0
- package/schema/yarramate-visual-graph.schema.json +9 -0
- package/schema/yarramate-workspace.schema.json +4 -0
|
@@ -391,4 +391,4 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
391
391
|
`:` `)}return hg({comment:e,type:t,value:s},r,i,a)}};function Yg(e,t){if(Nh(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!jh(r)){if(Ah(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new wg(new Yh(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]=jh(r)?r:new wg(r)}}else t(`Expected a sequence for this tag`);return e}function Xg(e,t,n){let{replacer:r}=n,i=new jg(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(Cg(o,s,n))}return i}var Zg={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:Yg,createNode:Xg},Qg=class e extends jg{constructor(){super(),this.add=kg.prototype.add.bind(this),this.delete=kg.prototype.delete.bind(this),this.get=kg.prototype.get.bind(this),this.has=kg.prototype.has.bind(this),this.set=kg.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(jh(e)?(r=Gh(e.key,``,t),i=Gh(e.value,r,t)):r=Gh(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=Xg(e,t,n),i=new this;return i.items=r.items,i}};Qg.tag=`tag:yaml.org,2002:omap`;var $g={collection:`seq`,identify:e=>e instanceof Map,nodeClass:Qg,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=Yg(e,t),r=[];for(let{key:e}of n.items)Mh(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new Qg,n)},createNode:(e,t,n)=>Qg.from(e,t,n)};function e_({value:e,source:t},n){return t&&(e?t_:n_).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var t_={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 Yh(!0),stringify:e_},n_={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 Yh(!1),stringify:e_},jre={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:Lg},Mre={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():Lg(e)}},Nre={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 Yh(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:Lg},r_=e=>typeof e==`bigint`||Number.isInteger(e);function i_(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 a_(e,t,n){let{value:r}=e;if(r_(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return Lg(e)}var Pre={identify:r_,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>i_(e,2,2,n),stringify:e=>a_(e,2,`0b`)},Fre={identify:r_,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>i_(e,1,8,n),stringify:e=>a_(e,8,`0`)},Ire={identify:r_,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>i_(e,0,10,n),stringify:Lg},Lre={identify:r_,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>i_(e,2,16,n),stringify:e=>a_(e,16,`0x`)},o_=class e extends kg{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=jh(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new wg(e.key,null):new wg(e,null),Og(this.items,t.key)||this.items.push(t)}get(e,t){let n=Og(this.items,e);return!t&&jh(n)?Mh(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=Og(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new wg(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(Cg(e,null,n));return i}};o_.tag=`tag:yaml.org,2002:set`;var s_={collection:`map`,identify:e=>e instanceof Set,nodeClass:o_,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>o_.from(e,t,n),resolve(e,t){if(Ah(e)){if(e.hasAllNullValues(!0))return Object.assign(new o_,e);t(`Set items must all have null values`)}else t(`Expected a mapping for this tag`);return e}};function c_(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 Rre(e){let{value:t}=e,n=e=>e;if(typeof t==`bigint`)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return Lg(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 zre={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})=>c_(e,n),stringify:Rre},Bre={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=>c_(e,!1),stringify:Rre},l_={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(l_.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=c_(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$/,``)??``},u_=[Ag,Ng,Pg,Fg,t_,n_,Pre,Fre,Ire,Lre,jre,Mre,Nre,Jg,bg,$g,Zg,s_,zre,Bre,l_],d_=new Map([[`core`,Ug],[`failsafe`,[Ag,Ng,Pg]],[`json`,qg],[`yaml11`,u_],[`yaml-1.1`,u_]]),Vre={binary:Jg,bool:Ig,float:Bg,floatExp:zg,floatNaN:Rg,floatTime:Bre,int:kre,intHex:Are,intOct:Ore,intTime:zre,map:Ag,merge:bg,null:Fg,omap:$g,pairs:Zg,seq:Ng,set:s_,timestamp:l_},Hre={"tag:yaml.org,2002:binary":Jg,"tag:yaml.org,2002:merge":bg,"tag:yaml.org,2002:omap":$g,"tag:yaml.org,2002:pairs":Zg,"tag:yaml.org,2002:set":s_,"tag:yaml.org,2002:timestamp":l_};function f_(e,t,n){let r=d_.get(t);if(r&&!e)return n&&!r.includes(bg)?r.concat(bg):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(d_.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(bg)),i.reduce((e,t)=>{let n=typeof t==`string`?Vre[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(Vre).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 p_=(e,t)=>e.key<t.key?-1:+(e.key>t.key),m_=class e{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?f_(e,`compat`):e?f_(null,e):null,this.name=typeof i==`string`&&i||`core`,this.knownTags=r?Hre:{},this.tags=f_(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,Ch,{value:Ag}),Object.defineProperty(this,Th,{value:Pg}),Object.defineProperty(this,Eh,{value:Ng}),this.sortMapEntries=typeof a==`function`?a:a===!0?p_:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function Ure(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=yre(e,t),{commentString:a}=i.options;if(e.commentBefore){n.length!==1&&n.unshift(``);let t=a(e.commentBefore);n.unshift(ng(t,``))}let o=!1,s=null;if(e.contents){if(Fh(e.contents)){if(e.contents.spaceBefore&&r&&n.push(``),e.contents.commentBefore){let t=a(e.contents.commentBefore);n.push(ng(t,``))}i.forceBlockIndent=!!e.comment,s=e.contents.comment}let t=s?void 0:()=>o=!0,c=gg(e.contents,i,()=>s=null,t);s&&(c+=rg(c,``,a(s))),(c[0]===`|`||c[0]===`>`)&&n[n.length-1]===`---`?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(gg(e.contents,i));if(e.directives?.docEnd){if(e.comment){let t=a(e.comment);t.includes(`
|
|
392
392
|
`)?(n.push(`...`),n.push(ng(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(ng(a(t),``)))}return n.join(`
|
|
393
393
|
`)+`
|
|
394
|
-
`}var Wre=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Dh,{value:Sh});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 Uh({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[Dh]:{value:Sh}});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=Fh(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){h_(this.contents)&&this.contents.add(e)}addIn(e,t){h_(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=fre(this);e.anchor=!t||n.has(t)?pre(t||`a`,n):t}return new hre(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}=mre(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=Qh(e,l,p);return o&&Ph(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new wg(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return h_(this.contents)?this.contents.delete(e):!1}deleteIn(e){return eg(e)?this.contents!=null&&(this.contents=null,!0):h_(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Ph(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return eg(e)?!t&&Mh(this.contents)?this.contents.value:this.contents:Ph(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Ph(this.contents)?this.contents.has(e):!1}hasIn(e){return eg(e)?this.contents!==void 0:Ph(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=$h(this.schema,[e],t):h_(this.contents)&&this.contents.set(e,t)}setIn(e,t){eg(e)?this.contents=t:this.contents==null?this.contents=$h(this.schema,Array.from(e),t):h_(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 Uh({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 Uh({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 m_(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=Gh(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`?Wh(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 Ure(this,e)}};function h_(e){if(Ph(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var g_=Symbol(`break visit`),Gre=Symbol(`skip children`),__=Symbol(`remove item`);function v_(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),y_(Object.freeze([]),e,t)}v_.BREAK=g_,v_.SKIP=Gre,v_.REMOVE=__,v_.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},v_.parentCollection=(e,t)=>{let n=v_.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 y_(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=y_(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===g_)return g_;else r===__&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function Kre(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 kh(e)&&!r?e.toString(n):new Wre(e,r,n).toString(n)}var qre=`.yarramate/projections`,Jre=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t.length===0?`view`:/^[a-z]/.test(t)?t:`view-${t}`},Yre=(e,t)=>{if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;return`${e}-${n}`},Xre=(e,t)=>Yre(Jre(e),t),b_=e=>`${qre}/${e}.yaml`,Zre=e=>e.presentation?.folder??``,Qre=(e,t)=>({path:e.path,projection:S_({id:e.id,title:t,description:e.description,query:e.query,presentation:e.presentation})}),x_=(e,t)=>{let n=`${e.title} copy`,r=Xre(n,t);return{path:b_(r),projection:S_({id:r,title:n,description:e.description,query:e.query,presentation:e.presentation})}},S_=e=>({format:`yarramate/projection/v1`,id:e.id,version:`1.0`,query:e.query,presentation:{...e.presentation??{},title:e.title,description:e.description}}),C_=e=>e.subjects!==void 0,w_=(e,t,n)=>{if(!C_(e.query))return $re(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)}}},$re=(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}}},T_=(e,t)=>{if(!C_(e)&&!C_(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!C_(e)||!C_(t)?[]:[...t.subjects.filter(t=>!e.subjects.includes(t)).map(e=>`+${e}`),...e.subjects.filter(e=>!t.subjects.includes(e)).map(e=>`-${e}`)]},eie=(e,t)=>E_(e)===E_(t),E_=e=>Array.isArray(e)?`[${e.map(E_).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)}:${E_(t)}`).join(`,`)}}`:JSON.stringify(e)??`null`,tie={subjects:[],documents:[],kinds:[],layers:[],statuses:[],excludeStatuses:[],states:[],owners:[],constraints:[],relationshipKinds:[],kindMatching:``,relationships:``,isolatedConcepts:``},nie=[`planned`,`current`,`retired`],rie=e=>e===null?tie:{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??``},iie=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}}),D_=({id:e,label:t,values:n,onChange:r})=>{let[i,a]=(0,v.useState)(``),o=()=>{let e=i.trim();a(``),!(e===``||n.includes(e))&&r([...n,e])};return(0,k.jsxs)(`div`,{className:`filter-field`,children:[(0,k.jsx)(`label`,{htmlFor:e,children:t}),(0,k.jsxs)(`div`,{className:`tag-input`,children:[n.map(e=>(0,k.jsxs)(`span`,{className:`tag-chip`,children:[e,(0,k.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>r(n.filter(t=>t!==e)),children:`×`})]},e)),(0,k.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})]})]})},O_=({legend:e,values:t,onChange:n})=>(0,k.jsxs)(`fieldset`,{className:`filter-field filter-checkbox-group`,children:[(0,k.jsx)(`legend`,{children:e}),nie.map(e=>(0,k.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:t.includes(e),onChange:r=>n(r.target.checked?[...t,e]:t.filter(t=>t!==e))}),e]},e))]}),k_=({id:e,label:t,value:n,options:r,onChange:i})=>(0,k.jsxs)(`div`,{className:`filter-field`,children:[(0,k.jsx)(`label`,{htmlFor:e,children:t}),(0,k.jsxs)(`select`,{id:e,value:n,onChange:e=>i(e.target.value),children:[(0,k.jsx)(`option`,{value:``,children:`Any`}),r.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))]})]}),A_=(e,t)=>n=>e(t,n);function aie({fields:e,onChange:t}){return(0,k.jsxs)(`div`,{className:`filter-grid`,children:[(0,k.jsx)(D_,{id:`filter-subjects`,label:`Subjects`,values:e.subjects,onChange:e=>t(`subjects`,e)}),(0,k.jsx)(D_,{id:`filter-documents`,label:`Documents`,values:e.documents,onChange:e=>t(`documents`,e)}),(0,k.jsx)(D_,{id:`filter-kinds`,label:`Kinds`,values:e.kinds,onChange:e=>t(`kinds`,e)}),(0,k.jsx)(D_,{id:`filter-layers`,label:`Layers`,values:e.layers,onChange:e=>t(`layers`,e)}),(0,k.jsx)(D_,{id:`filter-states`,label:`States`,values:e.states,onChange:e=>t(`states`,e)}),(0,k.jsx)(D_,{id:`filter-owners`,label:`Owners`,values:e.owners,onChange:e=>t(`owners`,e)}),(0,k.jsx)(D_,{id:`filter-constraints`,label:`Constraints`,values:e.constraints,onChange:e=>t(`constraints`,e)}),(0,k.jsx)(D_,{id:`filter-relationship-kinds`,label:`Relationship kinds`,values:e.relationshipKinds,onChange:e=>t(`relationshipKinds`,e)}),(0,k.jsx)(O_,{legend:`Statuses`,values:e.statuses,onChange:e=>t(`statuses`,e)}),(0,k.jsx)(O_,{legend:`Exclude statuses`,values:e.excludeStatuses,onChange:e=>t(`excludeStatuses`,e)}),(0,k.jsx)(k_,{id:`filter-kind-matching`,label:`Kind matching`,value:e.kindMatching,options:[`exact`,`descendants`],onChange:e=>t(`kindMatching`,e)}),(0,k.jsx)(k_,{id:`filter-relationships`,label:`Relationships`,value:e.relationships,options:[`between`,`connected`,`none`],onChange:e=>t(`relationships`,e)}),(0,k.jsx)(k_,{id:`filter-isolated-concepts`,label:`Isolated concepts`,value:e.isolatedConcepts,options:[`include`,`exclude`],onChange:e=>t(`isolatedConcepts`,e)})]})}function j_({showLifecycle:e,showEvidence:t,showOwnership:n,showNudges:r,onTogglePresentation:i}){return(0,k.jsxs)(`fieldset`,{className:`filter-field filter-presentation-group`,children:[(0,k.jsx)(`legend`,{children:`Presentation`}),(0,k.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>A_(i,`showLifecycle`)(e.currentTarget.checked)}),`Lifecycle badges`]}),(0,k.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>A_(i,`showEvidence`)(e.currentTarget.checked)}),`Evidence badges`]}),(0,k.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>A_(i,`showOwnership`)(e.currentTarget.checked)}),`Ownership badges`]}),(0,k.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>A_(i,`showNudges`)(e.currentTarget.checked)}),`Open-question badges`]})]})}var M_=[{id:`view-query`,label:`View query`}],N_=e=>JSON.stringify(Object.entries(e??{}).sort(([e],[t])=>e<t?-1:1)),P_=(e,t)=>N_(e)===N_(t),F_={exclude:`Taken out of this view`,states:`States`,subjects:`Subjects`,documents:`Documents`,kinds:`Kinds`,layers:`Layers`,statuses:`Statuses`,excludeStatuses:`Excluded statuses`,owners:`Owners`,constraints:`Constraints`,isolatedConcepts:`Isolated concepts`,unreported:`Not reported`},oie=Object.keys(F_),sie=(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 oie.flatMap(e=>{let t=a.get(e);return t===void 0?[]:[{reason:e,label:F_[e],subjects:t}]})},cie=(e,t)=>{if(t===null)return e.length;let n=new Set(t);return e.filter(e=>n.has(e.id)).length},I_=(e,t)=>{if(e===null||t===null)return 0;let n=new Set(e);return t.filter(({id:e})=>n.has(e)).length},lie=(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`)}},uie=({view:e,query:t,badges:n,opened:r})=>S_({id:e.id,title:e.title,description:e.description,query:t,presentation:lie(e,n,r)}),die=e=>({op:`write-view`,path:e.view.path,projection:uie(e)}),fie=e=>{let t=uie(e),n=S_({id:e.view.id,title:e.view.title,description:e.view.description,query:e.view.query,presentation:e.view.presentation});return N_(t.query)!==N_(n.query)||N_(t.presentation)!==N_(n.presentation)};function pie({nodes:e,activeFilter:t,view:n,open:r,tab:i,showLifecycle:a,showEvidence:o,showOwnership:s,showNudges:c,onTogglePresentation:l,onToggleOpen:u,onSelectTab:d,onApply:f,onStage:p,readOnly:m=!1}){let h=(0,v.useRef)(null),[g,_]=(0,v.useState)(()=>rie(n?.query??t?.query??null)),[y,b]=(0,v.useState)(!1),[x]=(0,v.useState)(()=>({showLifecycle:a,showEvidence:o,showOwnership:s})),S=e=>{h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{h.current=null,f(iie(e))},300)},C=(e,t)=>{b(!1),_(n=>{let r={...n,[e]:t};return S(r),r})},w=iie(g),T=t?.matchedIds??null,E=cie(e,T),D=sie(e,T,t?.excluded??null),ee=I_(T,t?.excluded??null),te=t===null?Object.keys(w).length===0:P_(w,t.query),ne=n===null?null:{view:n,query:w,badges:{showLifecycle:a,showEvidence:o,showOwnership:s},opened:x};return(0,k.jsxs)(`section`,{className:`bottom-panel`,"aria-label":`Canvas panels`,children:[(0,k.jsxs)(`div`,{className:`bottom-panel-tabs`,role:`tablist`,"aria-label":`Canvas panels`,children:[M_.map(e=>(0,k.jsx)(`button`,{type:`button`,role:`tab`,id:`bottom-tab-${e.id}`,className:`bottom-panel-tab`,"aria-selected":r&&i===e.id,"aria-controls":`bottom-panel-${e.id}`,onClick:()=>{if(r&&i===e.id){u();return}d(e.id)},children:e.label},e.id)),(0,k.jsxs)(`span`,{className:`bottom-panel-summary`,role:`status`,children:[E,` `,E===1?`subject`:`subjects`,D.length===0?``:` · ${D.reduce((e,t)=>e+t.subjects.length,0)} excluded`]}),(0,k.jsx)(`button`,{type:`button`,className:`bottom-panel-collapse`,"aria-expanded":r,"aria-controls":`bottom-panel-${i}`,"aria-label":r?`Collapse panel`:`Expand panel`,onClick:u,children:r?`▾`:`▴`})]}),r?(0,k.jsx)(`div`,{className:`bottom-panel-body`,id:`bottom-panel-${i}`,role:`tabpanel`,"aria-labelledby":`bottom-tab-${i}`,children:(0,k.jsxs)(`div`,{className:`query-tab`,children:[(0,k.jsxs)(`div`,{className:`query-tab-fields`,children:[(0,k.jsx)(aie,{fields:g,onChange:C}),(0,k.jsx)(j_,{showLifecycle:a,showEvidence:o,showOwnership:s,showNudges:c,onTogglePresentation:l})]}),(0,k.jsxs)(`div`,{className:`query-tab-outcome`,children:[(0,k.jsx)(`h3`,{children:`Matches`}),(0,k.jsxs)(`p`,{className:`query-match-count`,children:[(0,k.jsx)(`strong`,{children:E}),` `,E===1?`subject`:`subjects`,` of `,e.length]}),te?null:(0,k.jsx)(`p`,{className:`query-outcome-stale`,children:`Describing the query on the canvas, not the edit in progress.`}),E===0&&T!==null?(0,k.jsx)(`p`,{className:`query-outcome-empty`,children:`This query selects nothing.`}):null,ee===0?null:(0,k.jsxs)(`p`,{className:`query-outcome-note`,children:[ee,` a facet dropped `,ee===1?`is`:`are`,` drawn anyway: `,(0,k.jsx)(`code`,{children:`relationships: connected`}),` takes the other end of a relationship with it.`]}),(0,k.jsx)(`h3`,{children:`Excluded, and why`}),D.length===0?(0,k.jsx)(`p`,{className:`query-outcome-note`,children:`Nothing is left out of this view.`}):(0,k.jsx)(`ul`,{className:`query-exclusions`,children:D.map(e=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`query-exclusion-facet`,children:e.label}),` `,(0,k.jsx)(`span`,{className:`query-exclusion-count`,children:e.subjects.length}),(0,k.jsxs)(`ul`,{children:[e.subjects.slice(0,12).map(e=>(0,k.jsx)(`li`,{title:e.id,children:e.title},e.id)),e.subjects.length>12?(0,k.jsxs)(`li`,{className:`query-exclusion-more`,children:[`and `,e.subjects.length-12,` more`]}):null]})]},e.reason))})]}),(0,k.jsxs)(`div`,{className:`query-tab-document`,children:[(0,k.jsx)(`h3`,{children:`Document`}),ne===null?(0,k.jsx)(`p`,{className:`query-outcome-note`,children:m?`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,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`pre`,{className:`query-document`,children:Kre(uie(ne))}),m?null:(0,k.jsxs)(`div`,{className:`query-tab-actions`,children:[(0,k.jsx)(`button`,{type:`button`,disabled:!fie(ne),onClick:()=>{p(die(ne)),b(!0)},children:`Stage view change`}),(0,k.jsx)(`span`,{role:`status`,className:`query-stage-status`,children:y?`Staged. It lands when the changeset is committed.`:``})]})]})]})]})}):null]})}function mie({value:e,onChange:t}){return(0,k.jsx)(`input`,{type:`search`,className:`quick-filter`,value:e,onChange:e=>t(e.currentTarget.value),placeholder:`Filter by name or id…`,"aria-label":`Quick filter`})}var hie=`views`,gie=`model`,_ie=e=>`view-folder:${e}`,L_=e=>`model-layer:${e}`,vie=e=>`model-folder:${e}`,yie=`unlayered`,R_=(e,t)=>t===``||e.toLowerCase().includes(t),bie=(e,t)=>R_(e,ch(t)),z_=e=>e.presentation?.folder??``,xie=({views:e,stagedOperations:t,activeViewId:n,activeSubjects:r,filterText:i})=>{let a=ch(i),o=a!==``,s=r===null?null:Ene(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?z_(t):r.presentation?.folder??``,f=t.id===n;!R_(c,a)&&!R_(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??``;!R_(n,a)&&!R_(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:_ie(e),name:e,views:[...t].sort(d)}));return{folders:p,loose:f,matched:f.length+p.reduce((e,t)=>e+t.views.length,0)}},B_=({nodes:e,inViewIds:t,filterText:n})=>{let r=ch(n),i=new Map,a=new Map;for(let n of e){let e=n.layer,o=n.folder,s=o??e??`unlayered`;if(!lh(r,n.id,n.name,n.kindLabel)&&!R_(s,r))continue;let c={id:n.id,name:n.name,kindLabel:n.kindLabel,layer:e,folder:o,inView:t===null||t.has(n.id)},l=o===null?a:i,u=l.get(s);u===void 0?l.set(s,[c]):u.push(c)}let o=(e,t)=>e.name.localeCompare(t.name),s=[...i.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:vie(e),label:e,grouping:`folder`,subjects:[...t].sort(o)})),c=[...one,yie];return[...s,...c.flatMap(e=>{let t=a.get(e);return t===void 0||t.length===0?[]:[{key:L_(e),label:e,grouping:`layer`,subjects:[...t].sort(o)}]})]},Sie=`All subjects`,V_=`M2 3.5 5 6.5 8 3.5`,Cie=`M3.5 2 6.5 5 3.5 8`;function wie({open:e}){return(0,k.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`none`,"aria-hidden":!0,children:(0,k.jsx)(`path`,{d:e?V_:Cie,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function H_(){return(0,k.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":!0,children:[(0,k.jsx)(`rect`,{x:`1.5`,y:`2.5`,width:`9`,height:`7`,stroke:`currentColor`,strokeWidth:`1.2`}),(0,k.jsx)(`path`,{d:`M1.5 5h9`,stroke:`currentColor`,strokeWidth:`1.2`})]})}function U_({layer:e}){let t=e===null?null:oh[e];return(0,k.jsx)(`span`,{className:`tree-swatch`,style:t==null?void 0:{background:t.fill,borderColor:t.border},"aria-hidden":!0})}var W_=(e,t)=>n=>{n.preventDefault(),t(e,{x:n.clientX,y:n.clientY})};function G_({row:e,depth:t,onSelect:n,onMenu:r}){let i=e.staged!==`new`;return(0,k.jsx)(`li`,{children:(0,k.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?W_({kind:`view`,id:e.id},r):void 0,children:[(0,k.jsx)(H_,{}),(0,k.jsx)(`span`,{className:`tree-label`,children:e.title}),e.staged===null?null:(0,k.jsx)(`span`,{className:`tree-staged`,children:e.staged===`delete`?`staged delete`:`staged`}),e.subjectCount===null?null:(0,k.jsx)(`span`,{className:`tree-count`,children:e.subjectCount})]})})}function K_({label:e,open:t,count:n,depth:r,onToggle:i}){return(0,k.jsxs)(`button`,{type:`button`,className:`tree-row tree-branch tree-depth-${r}`,"aria-expanded":t,onClick:i,children:[(0,k.jsx)(wie,{open:t}),(0,k.jsx)(`span`,{className:`tree-label`,children:e}),n===void 0?null:(0,k.jsx)(`span`,{className:`tree-count`,children:n})]})}function Tie({views:e,stagedViewOperations:t,activeViewId:n,nodes:r,inViewIds:i,filterText:a,collapsed:o,onFilterChange:s,onToggle:c,onSelectView:l,onClearView:u,onNewView:d,onSelectSubject:f,onRowMenu:p,readOnly:m=!1}){let h=xie({views:e,stagedOperations:t,activeViewId:n,activeSubjects:i===null?null:r.filter(e=>i.has(e.id)),filterText:a}),g=B_({nodes:r,inViewIds:i,filterText:a}),_=!o.has(hie),v=!o.has(gie),y=a.trim()!==``,b=n===``&&i===null,x=bie(Sie,a);return(0,k.jsxs)(`aside`,{className:`view-tree`,"aria-label":`Views and model`,children:[(0,k.jsxs)(`div`,{className:`view-tree-head`,children:[(0,k.jsx)(`input`,{type:`search`,className:`view-tree-filter`,placeholder:`Filter tree`,"aria-label":`Filter views and subjects`,value:a,onChange:e=>s(e.currentTarget.value)}),m?null:(0,k.jsx)(`button`,{type:`button`,className:`view-tree-new`,title:`New view`,"aria-label":`New view`,onClick:d,children:(0,k.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":!0,children:(0,k.jsx)(`path`,{d:`M7 3v8M3 7h8`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinecap:`round`})})})]}),(0,k.jsxs)(`div`,{className:`view-tree-body`,children:[(0,k.jsx)(K_,{label:`Views`,open:_,depth:0,onToggle:()=>c(hie)}),_?(0,k.jsxs)(`ul`,{className:`tree-list`,children:[x?(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,className:`tree-row tree-view tree-depth-1${b?` tree-row-active`:``}`,"aria-current":b?`true`:void 0,onClick:u,onContextMenu:W_({kind:`view`,id:``},p),children:[(0,k.jsx)(H_,{}),(0,k.jsx)(`span`,{className:`tree-label`,children:Sie}),(0,k.jsx)(`span`,{className:`tree-count`,children:Ene(r,a)})]})}):null,h.loose.map(e=>(0,k.jsx)(G_,{row:e,depth:1,onSelect:l,onMenu:p},e.id)),h.folders.map(e=>{let t=y||!o.has(e.key);return(0,k.jsxs)(`li`,{children:[(0,k.jsx)(K_,{label:e.name,open:t,count:t?void 0:e.views.length,depth:1,onToggle:()=>c(e.key)}),t?(0,k.jsx)(`ul`,{className:`tree-list`,children:e.views.map(e=>(0,k.jsx)(G_,{row:e,depth:2,onSelect:l,onMenu:p},e.id))}):null]},e.key)}),!y||h.matched!==0||x?null:(0,k.jsx)(`li`,{className:`tree-empty`,children:`No view matches that.`})]}):null,(0,k.jsx)(K_,{label:`Model`,open:v,depth:0,onToggle:()=>c(gie)}),v?(0,k.jsxs)(`ul`,{className:`tree-list`,children:[g.map(e=>{let t=y||!o.has(e.key);return(0,k.jsxs)(`li`,{children:[(0,k.jsx)(K_,{label:e.label,open:t,count:t?void 0:e.subjects.length,depth:1,onToggle:()=>c(e.key)}),t?(0,k.jsx)(`ul`,{className:`tree-list`,children:e.subjects.map(e=>(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,className:`tree-row tree-subject tree-depth-2${e.inView?``:` tree-row-quiet`}`,title:`${e.name} — ${e.kindLabel}`,onClick:()=>f(e.id),onContextMenu:W_({kind:`subject`,id:e.id},p),children:[(0,k.jsx)(U_,{layer:e.layer}),(0,k.jsx)(`span`,{className:`tree-label`,children:e.name}),e.inView?null:(0,k.jsx)(`span`,{className:`tree-count`,children:`not in view`})]})},e.id))}):null]},e.key)}),g.length!==0||!y?null:(0,k.jsx)(`li`,{className:`tree-empty`,children:`No subject matches that.`})]}):null]})]})}var Eie=({id:e,taken:t,path:n,folder:r,title:i,description:a,query:o,layout:s,showLifecycle:c,showEvidence:l,showOwnership:u,carriedDirection:d})=>{let f=e??Xre(i,t);return{op:`write-view`,path:n??b_(f),projection:S_({id:f,title:i,description:a,query:o??{},presentation:{layout:s,...d===void 0?{}:{direction:d},...r===void 0||r===``?{}:{folder:r},showLifecycle:c,showEvidence:l,showOwnership:u}})}};function Die({activeView:e,presetFolder:t,onSubmit:n,onCancel:r}){let[i,a]=(0,v.useState)(e?.title??``),[o,s]=(0,v.useState)(e?.description??``),c=i.trim()===``||o.trim()===``,l=t!==void 0;return(0,k.jsx)(`div`,{className:`save-view-panel`,children:(0,k.jsx)(`div`,{id:`save-view-panel-body`,className:`save-view-panel-body`,children:(0,k.jsxs)(`form`,{className:`save-view-form`,onSubmit:t=>{t.preventDefault(),!c&&n(l?void 0:e?.id,i,o)},children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{htmlFor:`save-view-title`,children:`Title`}),(0,k.jsx)(`input`,{id:`save-view-title`,type:`text`,value:i,onChange:e=>a(e.currentTarget.value),required:!0})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{htmlFor:`save-view-description`,children:`Description`}),(0,k.jsx)(`textarea`,{id:`save-view-description`,value:o,onChange:e=>s(e.currentTarget.value),required:!0})]}),(0,k.jsxs)(`div`,{className:`save-view-actions`,children:[(0,k.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,k.jsx)(`button`,{type:`button`,disabled:c,onClick:()=>{c||n(void 0,i,o)},children:`Save As New`}),(0,k.jsx)(`button`,{type:`button`,onClick:r,children:`Cancel`})]})]})})})}function Oie({views:e,activeViewId:t,query:n,layout:r,showLifecycle:i,showEvidence:a,showOwnership:o,open:s,folder:c,onClose:l,onStage:u}){let d=e.find(e=>e.id===t)??null,f=(t,s,l)=>{u(Eie({id:t,taken:new Set(e.map(e=>e.id)),path:t===void 0?void 0:d?.path,folder:t===void 0?c:d?.presentation?.folder,title:s,description:l,query:n,layout:r,showLifecycle:i,showEvidence:a,showOwnership:o,carriedDirection:t===void 0?void 0:d?.presentation?.direction}))};return s?(0,k.jsx)(`div`,{className:`save-view-control`,children:(0,k.jsx)(Die,{activeView:d,presetFolder:c,onSubmit:(e,t,n)=>{f(e,t,n),l()},onCancel:l},t)}):null}function q_(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 kie=(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}},Aie=e=>{let t=new Set;for(let n of e)for(let e of n.subjects??[])t.add(e);return t},J_=(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},jie=(e,t,n)=>[...e.operations.map(e=>Nie(e,t)),...e.viewOperations.map(e=>Mie(e,n))],Mie=(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?[]:T_(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`}},Nie=(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=J_(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:J_(e.document,r.id,t),fields:Object.keys(r).filter(e=>e!==`id`),removedFields:n,scope:`model`}},Y_=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(`, `)}`},j=/^\/operations\/(\d+)(\/|$)/,X_=e=>{let t=new Map,n=[];for(let r of e){let e=j.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}},Pie=(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},Fie=({diagnostic:e})=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`code`,children:e.code}),` `,e.message,e.path===``?null:(0,k.jsxs)(`span`,{className:`where`,children:[e.path,`:`,e.line,`:`,e.column]})]}),Z_=({index:e,row:t,diagnostics:n,conflict:r,onDiscard:i})=>(0,k.jsxs)(`li`,{className:r===null?`changeset-row`:`changeset-row conflicted`,children:[(0,k.jsxs)(`div`,{className:`changeset-row-line`,children:[(0,k.jsx)(`span`,{className:`changeset-row-label`,children:Y_(t)}),(0,k.jsx)(`span`,{className:`changeset-row-scope changeset-scope-${t.scope}`,children:t.scope}),(0,k.jsx)(`button`,{type:`button`,className:`changeset-row-discard`,onClick:i,children:`Discard`})]}),r===null?null:(0,k.jsxs)(`p`,{className:`changeset-row-conflict`,role:`status`,children:[r,` changed after this edit was staged`]}),n.length===0?null:(0,k.jsx)(`ul`,{className:`changeset-row-diagnostics`,children:n.map(e=>(0,k.jsx)(Fie,{diagnostic:e},`${e.code}-${e.pointer}`))})]}),Iie=({state:e,onDiscardChange:t,onClearChangeset:n,onUndoChangeset:r,onRedoChangeset:i,onCommitChangeset:a})=>{let o=e.model?.graph??null,s=jie(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}=X_(e.commitDiagnostics??[]),u=e.commitStatus===`committing`;return(0,k.jsxs)(`section`,{className:`changeset-tray`,"aria-labelledby":`changeset-heading`,children:[(0,k.jsxs)(`div`,{className:`changeset-heading-row`,children:[(0,k.jsx)(`h2`,{id:`changeset-heading`,children:`Pending changes`}),(0,k.jsxs)(`div`,{className:`changeset-history-controls`,children:[(0,k.jsx)(`button`,{type:`button`,className:`changeset-undo`,disabled:e.undoStack.length===0,onClick:r,children:`Undo`}),(0,k.jsx)(`button`,{type:`button`,className:`changeset-redo`,disabled:e.redoStack.length===0,onClick:i,children:`Redo`}),s.length===0?null:(0,k.jsx)(`button`,{type:`button`,className:`changeset-discard-all`,onClick:n,children:`Discard all`})]})]}),e.commitDiagnostics===null||e.commitDiagnostics.length===0||o===null?null:(0,k.jsx)(`p`,{className:`changeset-fault-summary`,role:`status`,children:(()=>{let t=kie(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,k.jsx)(`ul`,{className:`changeset-batch-diagnostics`,role:`alert`,children:l.map(e=>(0,k.jsx)(Fie,{diagnostic:e},`${e.code}-${e.pointer}`))}),s.length===0?null:(0,k.jsx)(`ol`,{className:`changeset-rows`,children:s.map((n,r)=>(0,k.jsx)(Z_,{index:r,row:n,diagnostics:c.get(r)??[],conflict:Pie(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,k.jsx)(`div`,{className:`changeset-actions`,children:(0,k.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,k.jsxs)(`div`,{className:`changeset-notice`,role:`status`,children:[(0,k.jsxs)(`p`,{children:[`Committed · `,e.commitNotice.length,` `,e.commitNotice.length===1?`file`:`files`]}),(0,k.jsx)(`ul`,{children:e.commitNotice.map(e=>(0,k.jsx)(`li`,{children:e},e))})]})]})},Q_=e=>e.slice(e.lastIndexOf(`#`)+1),$_={a:`access`,c:`composition`,f:`flow`,g:`aggregation`,i:`assignment`,n:`influence`,o:`association`,r:`realization`,s:`specialization`,t:`triggering`,v:`serving`},ev=`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(`.`),tv={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`},nv=new Map(ev.map((e,t)=>[e,t])),rv=new Map(Object.entries($_)),iv=new Map;for(let e of ev){let t=tv[e].split(` `);for(let[n,r]of ev.entries()){let i=t[n]??`-`,a=new Set;for(let e of i){let t=rv.get(e);t!==void 0&&a.add(t)}iv.set(`${e}>${r}`,a)}}var Lie=new Set,av=e=>nv.has(e),ov=(e,t)=>iv.get(`${e}>${t}`)??Lie;new Map(ah.map(e=>[e.id,e.aspect]));var sv=sne,cv=(e,t,n)=>{let r=e.nodes.find(e=>e.id===t),i=e.nodes.find(e=>e.id===n);return r===void 0||i===void 0||!av(r.coreKindLabel)||!av(i.coreKindLabel)?[]:[...ov(r.coreKindLabel,i.coreKindLabel)].sort()},lv=(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}},uv=(e,t,n,r,i=[])=>{if(!cv(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:lv(e,t,n,r,i),kind:n,from:t,to:r}}},dv=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}),fv=(e,t,n,r)=>{let i=new Set(cv(e,t.from,t.to));if(i.size===0)return{options:n,narrowed:!1};let a=new Set(sv);return{options:n.filter(e=>i.has(e.coreLabel)||!a.has(e.coreLabel)||e.label===r),narrowed:!0}},pv=[`kind`,`name`,`description`,`status`,`owner`],mv=[`aka`,`constraints`,`references`,`presentIn`,`attestations`,`distinctFrom`,`supersedes`],hv=[`kind`,`from`,`to`,`name`,`description`,`status`,`mode`,`content`],gv=[`references`,`presentIn`],_v=(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)=>_v(e,t[n]));let n=e,r=t,i=Object.keys(n),a=Object.keys(r);return i.length===a.length&&i.every(e=>_v(n[e],r[e]))},Rie=(e,t)=>t===(e??``)?{kind:`none`}:t===``?{kind:`remove`}:{kind:`set`,value:t},vv=(e,t)=>_v(e,t)?{kind:`none`}:t.length>=e.length&&e.every((e,n)=>_v(e,t[n]))?{kind:`append`,added:t.slice(e.length)}:{kind:`replace`,next:t},zie=(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]},yv=(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}},bv=(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]},xv=(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}},Sv=(e,t,n,r,i)=>{let a=Rie(r,i);return a.kind===`none`?[]:a.kind===`remove`?[zie(e,t,n,!1,``)]:[zie(e,t,n,!0,a.value)]},Cv=(e,t,n,r,i)=>{let a=Rie(r,i);return a.kind===`none`?[]:a.kind===`remove`?[bv(e,t,n,!1,``)]:[bv(e,t,n,!0,a.value)]},wv=(e,t,n,r,i)=>{let a=vv(r,i);if(a.kind===`none`)return[];if(a.kind===`append`)return a.added.length===0?[]:[yv(e,t,n,a.added)];let o=[yv(e,t,n,null)];return a.next.length>0&&o.push(yv(e,t,n,a.next)),o},Bie=(e,t,n,r,i)=>{let a=vv(r,i);if(a.kind===`none`)return[];if(a.kind===`append`)return a.added.length===0?[]:[xv(e,t,n,a.added)];let o=[xv(e,t,n,null)];return a.next.length>0&&o.push(xv(e,t,n,a.next)),o},Vie=e=>e.expects===null?{id:e.id,ref:e.ref}:{id:e.id,ref:e.ref,expects:e.expects},Tv=(e,t,n,r)=>{let i=vv(n,r);if(i.kind===`none`)return[];if(i.kind===`append`)return i.added.length===0?[]:[yv(e,t,`constraints`,i.added.map(Vie))];let a=[yv(e,t,`constraints`,null)];return i.next.length>0&&a.push(yv(e,t,`constraints`,i.next.map(Vie))),a},Ev=e=>({topic:e.topic,by:e.by,recordedBy:e.recordedBy??``,on:e.on}),Dv=(e,t,n,r)=>{let i=vv(n,r);if(i.kind===`none`)return[];if(i.kind===`append`)return i.added.length===0?[]:[yv(e,t,`attestations`,i.added.map(Ev))];let a=[yv(e,t,`attestations`,null)];return i.next.length>0&&a.push(yv(e,t,`attestations`,i.next.map(Ev))),a},Ov=(e,t)=>{let n={...e},r=t.concept;for(let e of pv)r[e]!==void 0&&(n[e]=r[e]);for(let e of mv){let t=r[e];t!==void 0&&t.length>0&&(n[e]=[...n[e],...t])}for(let e of t.remove??[])n[e]=mv.includes(e)?[]:null;return n},kv=(e,t)=>{let n=e;for(let r of t)r.op===`update-concept`&&r.document===e.document&&r.concept.id===e.localId&&(n=Ov(n,r));return n},Hie=(e,t)=>{let n={...e},r=t.relationship;for(let e of hv)r[e]!==void 0&&(n[e]=r[e]);for(let e of gv){let t=r[e];t!==void 0&&t.length>0&&(n[e]=[...n[e],...t])}for(let e of t.remove??[])n[e]=gv.includes(e)?[]:null;return n},Uie=(e,t)=>{let n=e;for(let r of t)r.op===`update-relationship`&&r.document===e.document&&r.relationship.id===e.localId&&(n=Hie(n,r));return n},Av=({label:e,value:t,options:n,onCommit:r})=>(0,k.jsxs)(`label`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,k.jsx)(`select`,{value:t,onChange:e=>r(e.target.value),children:n.map(e=>(0,k.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),jv=({label:e,value:t,onCommit:n})=>{let[r,i]=(0,v.useState)(t);return(0,v.useEffect)(()=>i(t),[t]),(0,k.jsxs)(`label`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,k.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),onBlur:()=>n(r)})]})},Mv=({label:e,values:t,emptyRow:n,isRowFilled:r,renderRow:i,onCommit:a})=>{let[o,s]=(0,v.useState)(t);(0,v.useEffect)(()=>s(t),[t]);let c=e=>{s(e),a(e.filter(r))};return(0,k.jsxs)(`div`,{className:`subject-form-field subject-form-list`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:e}),o.map((e,t)=>(0,k.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,k.jsx)(`button`,{type:`button`,className:`subject-form-row-remove`,onClick:()=>c(o.filter((e,n)=>n!==t)),children:`Remove`})]},t)),(0,k.jsxs)(`button`,{type:`button`,className:`subject-form-row-add`,onClick:()=>s([...o,n]),children:[`Add `,e]})]})},Nv=({label:e,values:t,onCommit:n})=>(0,k.jsx)(Mv,{label:e,values:t,emptyRow:``,isRowFilled:e=>e.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n})=>(0,k.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),onBlur:n})}),Pv={id:``,ref:``},Fv=({label:e,values:t,onCommit:n})=>(0,k.jsx)(Mv,{label:e,values:t,emptyRow:Pv,isRowFilled:e=>e.id.trim()!==``&&e.ref.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n})=>(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`input`,{type:`text`,placeholder:`id`,value:e.id,onChange:n=>t({...e,id:n.target.value}),onBlur:n}),(0,k.jsx)(`input`,{type:`text`,placeholder:`ref`,value:e.ref,onChange:n=>t({...e,ref:n.target.value}),onBlur:n})]})}),M={id:``,ref:``,expects:null},Iv=({label:e,values:t,onCommit:n})=>(0,k.jsx)(Mv,{label:e,values:t,emptyRow:M,isRowFilled:e=>e.id.trim()!==``&&e.ref.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n,replace:r})=>(0,k.jsxs)(`div`,{className:`subject-form-row-body`,children:[(0,k.jsx)(`input`,{type:`text`,placeholder:`id`,value:e.id,onChange:n=>t({...e,id:n.target.value}),onBlur:n}),(0,k.jsx)(`input`,{type:`text`,placeholder:`ref`,value:e.ref,onChange:n=>t({...e,ref:n.target.value}),onBlur:n}),(0,k.jsxs)(`label`,{className:`subject-form-toggle`,children:[(0,k.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,k.jsxs)(`div`,{className:`subject-form-row-body`,children:[(0,k.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,k.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,k.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})]})]})}),Wie={topic:``,by:``,on:``,recordedBy:null},Gie=({label:e,values:t,onCommit:n})=>(0,k.jsx)(Mv,{label:e,values:t,emptyRow:Wie,isRowFilled:e=>e.topic.trim()!==``&&e.by.trim()!==``&&e.on.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n})=>(0,k.jsxs)(`div`,{className:`subject-form-row-body`,children:[(0,k.jsx)(`input`,{type:`text`,placeholder:`topic`,value:e.topic,onChange:n=>t({...e,topic:n.target.value}),onBlur:n}),(0,k.jsx)(`input`,{type:`text`,placeholder:`by`,value:e.by,onChange:n=>t({...e,by:n.target.value}),onBlur:n}),(0,k.jsx)(`input`,{type:`text`,placeholder:`on`,value:e.on,onChange:n=>t({...e,on:n.target.value}),onBlur:n}),(0,k.jsx)(`input`,{type:`text`,placeholder:`recorded by`,value:e.recordedBy??``,onChange:n=>t({...e,recordedBy:n.target.value}),onBlur:n})]})}),Kie={value:``,label:`— unset —`},qie=[Kie,{value:`planned`,label:`planned`},{value:`current`,label:`current`},{value:`retired`,label:`retired`}],Jie=[Kie,{value:`read`,label:`read`},{value:`write`,label:`write`},{value:`read-write`,label:`read-write`},{value:`unspecified`,label:`unspecified`}],Lv=(e,t)=>t.find(t=>t.id===e)?.label??Q_(e),Yie=({node:e,model:t,operations:n,onStageChange:r})=>{let i=kv(e,n),a=e.document,o=e.localId,s=e=>e.forEach(r),c=t.vocabulary.conceptKinds.map(e=>({value:e.label,label:e.label})),l=Lv(i.kind,t.vocabulary.conceptKinds);return(0,k.jsxs)(`div`,{className:`subject-form`,children:[(0,k.jsxs)(`div`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,k.jsx)(`code`,{children:e.id})]}),(0,k.jsx)(Av,{label:`Kind`,value:l,options:c,onCommit:e=>s(Sv(a,o,`kind`,l,e))}),(0,k.jsx)(jv,{label:`Name`,value:i.name,onCommit:e=>s(Sv(a,o,`name`,i.name,e))}),(0,k.jsx)(jv,{label:`Description`,value:i.description??``,onCommit:e=>s(Sv(a,o,`description`,i.description,e))}),(0,k.jsx)(Av,{label:`Status`,value:i.status??``,options:qie,onCommit:e=>s(Sv(a,o,`status`,i.status,e))}),(0,k.jsx)(jv,{label:`Owner`,value:i.owner??``,onCommit:e=>s(Sv(a,o,`owner`,i.owner,e))}),(0,k.jsx)(Nv,{label:`Aka`,values:i.aka,onCommit:e=>s(wv(a,o,`aka`,i.aka,e))}),(0,k.jsx)(Nv,{label:`Distinct from`,values:i.distinctFrom,onCommit:e=>s(wv(a,o,`distinctFrom`,i.distinctFrom,e))}),(0,k.jsx)(Nv,{label:`Supersedes`,values:i.supersedes,onCommit:e=>s(wv(a,o,`supersedes`,i.supersedes,e))}),(0,k.jsx)(Nv,{label:`Present in`,values:i.presentIn,onCommit:e=>s(wv(a,o,`presentIn`,i.presentIn,e))}),(0,k.jsx)(Fv,{label:`References`,values:i.references,onCommit:e=>s(wv(a,o,`references`,i.references,e))}),(0,k.jsx)(Iv,{label:`Constraints`,values:i.constraints,onCommit:e=>s(Tv(a,o,i.constraints,e))}),(0,k.jsx)(Gie,{label:`Attestations`,values:i.attestations,onCommit:e=>s(Dv(a,o,i.attestations,e))})]})},Rv=({label:e,value:t})=>t===``?null:(0,k.jsxs)(`div`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,k.jsx)(`span`,{className:`subject-fact-value`,children:t})]}),Xie=({node:e,model:t})=>(0,k.jsxs)(`div`,{className:`subject-form subject-facts`,children:[(0,k.jsxs)(`div`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,k.jsx)(`code`,{children:e.id})]}),(0,k.jsx)(Rv,{label:`Kind`,value:Lv(e.kind,t.vocabulary.conceptKinds)}),(0,k.jsx)(Rv,{label:`Name`,value:e.name}),(0,k.jsx)(Rv,{label:`Status`,value:e.status??``}),(0,k.jsx)(Rv,{label:`Owner`,value:e.owner??``}),(0,k.jsx)(Rv,{label:`Aka`,value:e.aka.join(`, `)}),(0,k.jsx)(Rv,{label:`Distinct from`,value:e.distinctFrom.join(`, `)}),(0,k.jsx)(Rv,{label:`Supersedes`,value:e.supersedes.join(`, `)}),(0,k.jsx)(Rv,{label:`Present in`,value:e.presentIn.join(`, `)}),(0,k.jsx)(Rv,{label:`References`,value:e.references.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,k.jsx)(Rv,{label:`Constraints`,value:e.constraints.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,k.jsx)(Rv,{label:`Attestations`,value:e.attestations.map(e=>`${e.topic} by ${e.by} on ${e.on}`).join(`; `)})]}),Zie=({edge:e,model:t})=>{let n=e=>t.graph.nodes.find(t=>t.id===e)?.name??e;return(0,k.jsxs)(`div`,{className:`subject-form subject-facts`,children:[(0,k.jsxs)(`div`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,k.jsx)(`code`,{children:e.id})]}),(0,k.jsx)(Rv,{label:`Kind`,value:Lv(e.kind,t.vocabulary.relationshipKinds)}),(0,k.jsx)(Rv,{label:`From`,value:n(e.from)}),(0,k.jsx)(Rv,{label:`To`,value:n(e.to)}),(0,k.jsx)(Rv,{label:`Name`,value:e.name??``}),(0,k.jsx)(Rv,{label:`Mode`,value:e.mode??``}),(0,k.jsx)(Rv,{label:`Content`,value:e.content??``}),(0,k.jsx)(Rv,{label:`Status`,value:e.status??``}),(0,k.jsx)(Rv,{label:`References`,value:e.references.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,k.jsx)(Rv,{label:`Present in`,value:e.presentIn.join(`, `)})]})},Qie=({edge:e,model:t,operations:n,onStageChange:r})=>{let i=Uie(e,n),a=e.document,o=e.localId,s=e=>e.forEach(r),c=Lv(i.kind,t.vocabulary.relationshipKinds),l=fv(t.graph,{from:i.from,to:i.to},t.vocabulary.relationshipKinds,c).options.map(e=>({value:e.label,label:e.label})),u=t.graph.nodes.map(e=>({value:e.id,label:e.name}));return(0,k.jsxs)(`div`,{className:`subject-form`,children:[(0,k.jsxs)(`div`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,k.jsx)(`code`,{children:e.id})]}),(0,k.jsx)(Av,{label:`Kind`,value:c,options:l,onCommit:e=>s(Cv(a,o,`kind`,c,e))}),(0,k.jsx)(Av,{label:`From`,value:i.from,options:u,onCommit:e=>s(Cv(a,o,`from`,i.from,e))}),(0,k.jsx)(Av,{label:`To`,value:i.to,options:u,onCommit:e=>s(Cv(a,o,`to`,i.to,e))}),(0,k.jsx)(jv,{label:`Name`,value:i.name??``,onCommit:e=>s(Cv(a,o,`name`,i.name,e))}),(0,k.jsx)(jv,{label:`Description`,value:i.description??``,onCommit:e=>s(Cv(a,o,`description`,i.description,e))}),(0,k.jsx)(Av,{label:`Mode`,value:i.mode??``,options:Jie,onCommit:e=>s(Cv(a,o,`mode`,i.mode,e))}),(0,k.jsx)(jv,{label:`Content`,value:i.content??``,onCommit:e=>s(Cv(a,o,`content`,i.content,e))}),(0,k.jsx)(Av,{label:`Status`,value:i.status??``,options:qie,onCommit:e=>s(Cv(a,o,`status`,i.status,e))}),(0,k.jsx)(Fv,{label:`References`,values:i.references,onCommit:e=>s(Bie(a,o,`references`,i.references,e))}),(0,k.jsx)(Nv,{label:`Present in`,values:i.presentIn,onCommit:e=>s(Bie(a,o,`presentIn`,i.presentIn,e))})]})};function $ie({overlay:e,selectedId:t}){let n=t===null?e.workspace:e.subjects[t]??[],r=t===null?`Whole-model questions. Select a subject to see what names it.`:null;return(0,k.jsxs)(`div`,{className:`open-questions`,children:[r===null?null:(0,k.jsx)(`p`,{className:`open-questions-scope`,children:r}),n.length===0?(0,k.jsx)(`p`,{className:`section-empty`,children:t===null?`Nothing open at the whole-model level.`:`No open questions name this subject.`}):(0,k.jsx)(`ul`,{className:`question-list`,children:n.map(e=>(0,k.jsx)(eae,{entry:e},e.questionId))}),(0,k.jsxs)(`p`,{className:`open-questions-catalogue`,children:[`Catalogue `,e.catalogue,` · answers land through the changeset, never here.`]})]})}var eae=({entry:e})=>(0,k.jsxs)(`li`,{className:`question-row`,children:[(0,k.jsx)(`span`,{className:`question-text`,children:e.question}),(0,k.jsxs)(`span`,{className:`question-meta`,children:[(0,k.jsx)(`span`,{className:`question-authority question-authority-${e.authority}`,children:e.authority}),e.since===void 0?null:(0,k.jsxs)(`span`,{className:`question-since`,children:[`since `,e.since]})]})]}),zv=[`composition`],tae=`top-down`,Bv=e=>{let t=e?.trim()??``;return t===``?null:t},Vv=e=>({type:`element`,id:e.id,title:e.name,kind:e.kindLabel,description:Bv(e.description)}),Hv=(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:Bv(e.name),description:Bv(e.description),kind:e.kindLabel}},Uv=e=>new Map(e.nodes.map(e=>[e.id,e.name])),nae=(e,t)=>{let n=e.nodes.find(e=>e.id===t);return n===void 0?null:Vv(n)},rae=(e,t)=>{let n=e.edges.find(e=>e.id===t);return n===void 0?null:Hv(n,Uv(e))},iae=(e,t,n,r)=>({select:n=>{let{graph:r}=e();if(r===null)return!1;let i=nae(r,n)??rae(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)},setDecorations:e=>(r(e),!0)}),aae=[`palette`,`properties`,`questions`,`changes`,`chat`],oae=e=>({min:96,max:Math.max(96,e-160)}),Wv=(e,t)=>{let{min:n,max:r}=oae(t);return Math.min(r,Math.max(n,e))},sae=.45,cae=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),lae=e=>{let t=[];return e?.layout!==void 0&&t.push({type:`layout.set`,layout:e.layout}),t.push({type:`nesting.set`,nesting:e?.nesting??zv}),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}),t},Gv=(e,t,n,r)=>!r||e===``||e===n?null:t.find(t=>t.id===e)??null,Kv=e=>({min:320,max:Math.max(320,Math.min(640,e*sae))}),qv=(e,t)=>{let{min:n,max:r}=Kv(t);return Math.min(r,Math.max(n,e))},Jv=480,Yv=(e,t)=>{let{min:n,max:r}=Kv(t);return Math.min(Math.min(r,Jv),Math.max(n,e))},Xv=(e,t=0)=>({conversation:{width:Yv(e*.28,e),hidden:!1,unread:0,collapsed:[],changesHeight:200,chatHeight:300},viewportWidth:e,viewportHeight:t,selectedSubject:null,descriptionExpanded:!1,detailsOpen:!1,bottomPanel:{open:!1,tab:`view-query`},tree:{filterText:``,collapsed:[]},connection:null,draftingSubject:!1,pendingDeletion:null,pendingViewDeletion:null,pendingViewRename:null,contextMenu:null,nesting:zv,direction:tae,layout:`layered`,showLifecycle:!0,showEvidence:!0,showOwnership:!1,showNudges:!0}),Zv=(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=Wv(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=qv(t.width,e.viewportWidth);return n===e.conversation.width?e:{...e,conversation:{...e.conversation,width:n}}}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=qv(e.conversation.width,t.viewportWidth),r=t.viewportHeight??e.viewportHeight,i=Wv(e.conversation.changesHeight,r),a=Wv(e.conversation.chatHeight,r);return n===e.conversation.width&&i===e.conversation.changesHeight&&a===e.conversation.chatHeight&&t.viewportWidth===e.viewportWidth&&r===e.viewportHeight?e:{...e,conversation:{...e.conversation,width:n,changesHeight:i,chatHeight:a},viewportWidth:t.viewportWidth,viewportHeight:r}}case`attention.received`:return e.conversation.hidden||e.conversation.collapsed.includes(`chat`)?{...e,conversation:{...e.conversation,unread:e.conversation.unread+1}}:e;case`menu.opened`:return{...e,contextMenu:{target:t.target,x:t.x,y:t.y}};case`menu.dismissed`:return e.contextMenu===null?e:{...e,contextMenu:null};case`connection.started`:return{...e,connection:{from:t.from,to:null},draftingSubject:!1,contextMenu:null};case`connection.targeted`:return e.connection===null?e:t.to===e.connection.from?{...e,connection:null}:{...e,connection:{...e.connection,to:t.to}};case`connection.cancelled`:return e.connection===null?e:{...e,connection:null};case`subject.draft.opened`:return{...e,draftingSubject:!0,connection:null,contextMenu:null};case`subject.draft.closed`:return e.draftingSubject?{...e,draftingSubject:!1}:e;case`deletion.asked`:return{...e,pendingDeletion:t.id,connection:null,draftingSubject:!1,contextMenu:null};case`deletion.dismissed`:return e.pendingDeletion===null?e:{...e,pendingDeletion:null};case`viewDeletion.asked`:return{...e,pendingViewDeletion:t.id,contextMenu:null};case`viewDeletion.dismissed`:return e.pendingViewDeletion===null?e:{...e,pendingViewDeletion:null};case`viewRename.asked`:return{...e,pendingViewRename:t.id,contextMenu:null};case`viewRename.dismissed`:return e.pendingViewRename===null?e:{...e,pendingViewRename:null};case`subject.selected`:return{...e,conversation:{...e.conversation,collapsed:e.conversation.collapsed.filter(e=>e!==`properties`)},selectedSubject:t.subject,descriptionExpanded:!1,contextMenu:null};case`subject.cleared`:return e.selectedSubject===null?e:{...e,selectedSubject:null,descriptionExpanded:!1};case`description.toggled`:return e.selectedSubject===null?e:{...e,descriptionExpanded:!e.descriptionExpanded};case`details.toggled`:return{...e,detailsOpen:!e.detailsOpen};case`bottomPanel.toggled`:return{...e,bottomPanel:{...e.bottomPanel,open:!e.bottomPanel.open}};case`bottomPanel.tabSelected`:return e.bottomPanel.open&&e.bottomPanel.tab===t.tab?e:{...e,bottomPanel:{open:!0,tab:t.tab}};case`tree.filtered`:return e.tree.filterText===t.filterText?e:{...e,tree:{...e.tree,filterText:t.filterText}};case`tree.toggled`:{let n=e.tree.collapsed.includes(t.key);return{...e,tree:{...e.tree,collapsed:n?e.tree.collapsed.filter(e=>e!==t.key):[...e.tree.collapsed,t.key]}}}case`nesting.set`:return cae(e.nesting,t.nesting)?e:{...e,nesting:t.nesting};case`direction.set`:return e.direction===t.direction?e:{...e,direction:t.direction};case`layout.set`:return{...e,layout:t.layout};case`presentation.toggled`:return{...e,[t.flag]:t.value};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`?nae(i,r.id):rae(i,r.id);return a===null?{...n,selectedSubject:null,descriptionExpanded:!1}:{...n,selectedSubject:a}}}},Qv=(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 $v({id:e,label:t,meta:n,open:r,onToggle:i,children:a}){return(0,k.jsxs)(`section`,{className:`stack-section stack-section-${e}`,children:[(0,k.jsxs)(`h2`,{className:`section-head`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`section-toggle`,"aria-expanded":r,"aria-controls":`section-${e}`,onClick:i,children:[(0,k.jsx)(`span`,{className:`section-chevron`,"aria-hidden":`true`,children:r?`▾`:`▸`}),(0,k.jsx)(`span`,{className:`section-label`,children:t})]}),n===void 0?null:(0,k.jsx)(`span`,{className:`section-meta`,children:n})]}),(0,k.jsx)(`div`,{className:`section-body`,id:`section-${e}`,hidden:!r,children:a})]})}function ey({label:e,height:t,viewportHeight:n,onResize:r}){let i=oae(n),a=(0,v.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,k.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 ty=(e,t,n)=>aae.filter(t=>e.includes(t)).flatMap((e,r)=>{let i=r===0?void 0:n[e];return[...i===void 0?[]:[(0,k.jsx)(v.Fragment,{children:i},`splitter-${e}`)],(0,k.jsx)(v.Fragment,{children:t[e]},e)]}),ny={messageBytes:65536,modelBytes:5242880,transcriptBytes:5242880,pendingEvents:32,reconnectMs:3e5,staleSessionMs:864e5}.reconnectMs,ry=`Returning control to the main agent`,iy={operations:[],viewOperations:[],sourceDigests:{}},ay=e=>e.operations.length===0&&e.viewOperations.length===0,oy={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,quickFilterText:``,closedReason:null,pendingChangeset:iy,undoStack:[],redoStack:[],commitStatus:`idle`,commitDiagnostics:null,commitNotice:null,layoutNotice:null},sy=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}),cy=(e,t)=>t-e<ny,ly=(e,t,n)=>({id:`local-${e.localRecords}`,speaker:t,text:n}),uy=(e,t)=>e.transcript.some(e=>e.id===t.id)?e.transcript:[...e.transcript,t],dy=e=>e.initialView,fy={awaitingAgent:!1,agentStatus:null},py=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`])}`},my=(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},hy=(e,t,n)=>{let r=n.operations??e.operations,i=n.viewOperations??e.viewOperations;return{operations:r,viewOperations:i,sourceDigests:my(r,i,e.sourceDigests,t)}},uae=(e,t)=>{switch(t.type){case`session.loaded`:return{...e,...t.snapshot,lifecycle:e.lifecycle===`ending`?`ending`:`active`,activeView:dy(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,...fy};case`chat.sent`:return{...e,transcript:uy(e,ly(e,`reviewer`,t.text)),localRecords:e.localRecords+1,choices:null,awaitingAgent:!0};case`chat.received`:return{...e,transcript:uy(e,{id:t.id,speaker:`agent`,text:t.text}),...fy};case`status.received`:return{...e,agentStatus:t.status};case`choice.presented`:return{...e,choices:t.choice,...fy};case`choice.sent`:{let n=e.choices?.options.find(e=>e.id===t.optionId);return n===void 0?e:{...e,transcript:uy(e,ly(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};case`handoff.received`:return{...e,handoff:t.handoff,transcript:uy(e,{id:t.id,speaker:`agent`,text:t.handoff.summary}),...fy};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`)?fy:{}}}case`end.requested`:return{...e,lifecycle:`ending`,choices:null,transcript:uy(e,ly(e,`session`,ry)),localRecords:e.localRecords+1};case`connection.lost`:return{...e,lifecycle:`disconnected`};case`session.closed`:return{...e,lifecycle:`closed`,closedReason:t.reason};case`filter.applied`:return{...e,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,activeFilter:null,activeView:``};case`quickFilter.changed`:return e.quickFilterText===t.text?e:{...e,quickFilterText:t.text};case`changeset.staged`:{let n=py(t.operation),r=[...e.pendingChangeset.operations.filter(e=>py(e)!==n),t.operation];return{...e,pendingChangeset:hy(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:hy(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=S_({id:n.id,title:n.title,description:n.description,query:n.query,presentation:n.presentation}),a=w_(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=eie(a,i);return{...e,pendingChangeset:hy(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:hy(e.pendingChangeset,e.model,a),undoStack:[...e.undoStack,e.pendingChangeset],redoStack:[],commitDiagnostics:null}}case`changeset.cleared`:{let t=ay(e.pendingChangeset);return{...e,pendingChangeset:iy,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:iy,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}}}},dae=e=>e.lifecycle===`active`&&e.chatEnabled&&!e.frozen&&!e.awaitingAgent;function fae(e,t){if(e.lifecycle===`closed`)return e;let n=uae(e,t);return n===e?e:{...n,composerEnabled:dae(n)}}var gy=(e,t)=>{let n=t.lastSequence;switch(e.kind){case`chat`:return{type:`chat.message`,lastAcknowledgedSequence:n,payload:{text:e.text}};case`choice`:return{type:`choice.selected`,lastAcknowledgedSequence:n,payload:{choiceId:e.choiceId,optionId:e.optionId}};case`navigate`:return{type:`view.navigate`,lastAcknowledgedSequence:n,payload:{viewId:e.viewId,requiresAttention:!1}};case`end`:return{type:`session.end`,lastAcknowledgedSequence:n,payload:{reason:`user-ended`}};case`filter`:return{type:`filter.query`,lastAcknowledgedSequence:n,payload:{query:e.query}};case`commit-changeset`:return{type:`changeset.commit`,lastAcknowledgedSequence:n,payload:t.pendingChangeset};case`save-layout`:return{type:`layout.save`,lastAcknowledgedSequence:n,payload:e.payload}}},pae=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 C_(r)?{kind:`enumerated`,subjects:r.subjects}:{kind:`faceted`,excluded:r.exclude??[]}},mae=(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}},hae=(e,t=`panel`)=>{switch(e.kind){case`ready`:return[{type:`session.loaded`,snapshot:sy(e.snapshot)}];case`accepted`:return[{type:`event.acknowledged`,sequence:e.sequence}];case`rejected`:return[{type:`input.refused`,...e.refused===void 0?{}:{refused:e.refused},diagnostics:e.diagnostics,frozen:e.frozen!==void 0}];case`model`:return[{type:`model.received`,model:e.model,views:e.views}];case`closing`:return[{type:`session.closed`,reason:e.reason}];case`filter-result`:return[{type:`filter.applied`,query:e.result.query,matchedIds:e.result.matchedIds,excluded:e.result.excluded,source:t}];case`response`:switch(e.response.type){case`chat.response`:{let t=[{type:`chat.received`,id:e.response.responseId,text:e.response.payload.text}],n=e.response.payload.appliedQuery;return n&&t.push({type:`filter.applied`,query:n.query,matchedIds:n.matchedIds??[],excluded:null,source:`chat`}),t}case`agent.status`:return[{type:`status.received`,status:e.response.payload}];case`choice.present`:return[{type:`choice.presented`,choice:e.response.payload}];case`handoff.complete`:return[{type:`handoff.received`,id:e.response.responseId,handoff:e.response.payload}];case`diagnostic`:return[{type:`diagnostic.received`,diagnostics:e.response.payload.diagnostics}]}case`apply-result`:{let t=[];return e.result.ok?t.push({type:`changeset.committed`,documents:e.result.result.documents}):t.push({type:`apply.failed`,diagnostics:e.result.diagnostics}),t}case`layout-save-result`:return[{type:`layout.saved`,result:e.result}]}},gae=e=>{let[t,n]=(0,v.useReducer)(fae,oy),[r,i]=(0,v.useState)(!1),a=(0,v.useRef)(t);a.current=t;let o=(0,v.useRef)(`panel`),s=(0,v.useRef)(e);s.current=e,(0,v.useEffect)(()=>s.current.open({frame:e=>{for(let t of hae(e,o.current))n(t);let t=mae(e,a.current);t!==null&&(o.current=t.source,s.current.send(gy({kind:`filter`,query:t.query},a.current)))},connected:i,lost:()=>n({type:`connection.lost`}),session:()=>({lastSequence:a.current.lastSequence,closed:a.current.lifecycle===`closed`})}),[]);let c=(0,v.useCallback)(e=>{s.current.send(gy(e,a.current))},[]),l=(0,v.useCallback)(e=>{n({type:`chat.sent`,text:e}),c({kind:`chat`,text:e})},[c]),u=(0,v.useCallback)(e=>{let t=a.current.choices?.choiceId;t!==void 0&&(n({type:`choice.sent`,optionId:e}),c({kind:`choice`,choiceId:t,optionId:e}))},[c]),d=(0,v.useCallback)(e=>{n({type:`view.navigated`,viewId:e}),c({kind:`navigate`,viewId:e})},[c]),f=(0,v.useCallback)((e,t=`panel`)=>{o.current=t,c({kind:`filter`,query:e})},[c]),p=(0,v.useCallback)(()=>{n({type:`filter.cleared`})},[]),m=(0,v.useCallback)(e=>{n({type:`quickFilter.changed`,text:e})},[]),h=(0,v.useCallback)(e=>{n({type:`changeset.staged`,operation:e})},[]);return{state:t,connected:r,ask:l,choose:u,navigate:d,filter:f,clearFilter:p,setQuickFilterText:m,stageViewChange:(0,v.useCallback)(e=>{n({type:`changeset.viewStaged`,operation:e})},[]),stageViewMembership:(0,v.useCallback)((e,t,r)=>{n({type:`changeset.viewMembership`,viewId:e,subjectId:t,membership:r})},[]),stageChange:h,discardChange:(0,v.useCallback)(e=>{n({type:`changeset.discarded`,index:e})},[]),clearChangeset:(0,v.useCallback)(()=>{n({type:`changeset.cleared`})},[]),undoChangeset:(0,v.useCallback)(()=>{n({type:`changeset.undone`})},[]),redoChangeset:(0,v.useCallback)(()=>{n({type:`changeset.redone`})},[]),commitChangeset:(0,v.useCallback)(()=>{ay(a.current.pendingChangeset)||(n({type:`changeset.commit.sent`}),c({kind:`commit-changeset`}))},[c]),saveLayout:(0,v.useCallback)(e=>{c({kind:`save-layout`,payload:e})},[c]),end:(0,v.useCallback)(()=>{n({type:`end.requested`}),c({kind:`end`})},[c])}},_ae=({draft:e,graph:t,reservedIds:n,onStage:r,onCancel:i})=>{let a=e=>t.nodes.find(t=>t.id===e)?.name??e;if(e.to===null)return(0,k.jsxs)(`section`,{className:`connection-panel`,"aria-label":`Connect subjects`,children:[(0,k.jsxs)(`p`,{className:`connection-prompt`,children:[`Connecting from `,(0,k.jsx)(`strong`,{children:a(e.from)}),`. Choose a target on the diagram.`]}),(0,k.jsx)(`button`,{type:`button`,onClick:i,children:`Cancel`})]});let o=e.to,s=cv(t,e.from,o);return(0,k.jsxs)(`section`,{className:`connection-panel`,"aria-label":`Connect subjects`,children:[(0,k.jsxs)(`p`,{className:`connection-prompt`,children:[(0,k.jsx)(`strong`,{children:a(e.from)}),` to`,` `,(0,k.jsx)(`strong`,{children:a(o)})]}),s.length===0?(0,k.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,k.jsx)(`ul`,{className:`connection-kinds`,children:s.map(a=>(0,k.jsx)(`li`,{children:(0,k.jsx)(`button`,{type:`button`,onClick:()=>{let s=uv(t,e.from,a,o,n);s!==null&&r(s),i()},children:a})},a))}),(0,k.jsx)(`button`,{type:`button`,onClick:i,children:`Cancel`})]})},vae=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,_y=(e,t,n=[])=>{let r=t.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase();if(r===``||!vae.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}},yae=(e,t,n,r=[])=>{if(t.document===``||!n.includes(t.kind))return null;let i=t.name.trim();if(i===``)return null;let a=_y(e,i,r);return a===null?null:{op:`add-concept`,document:t.document,concept:{id:a,kind:t.kind,name:i}}},vy=({graph:e,kinds:t,documents:n,defaultDocument:r,initialKind:i,reservedIds:a,onStage:o,onCancel:s})=>{let[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(i??``),[f,p]=(0,v.useState)(r),m=c.trim()===``?null:_y(e,c,a),h=m===null?null:yae(e,{name:c,kind:u,document:f},t.map(e=>e.label),a);return(0,k.jsxs)(`section`,{className:`subject-draft-panel`,"aria-label":`Add a subject`,children:[(0,k.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`subject-draft-name`,children:[(0,k.jsx)(`span`,{children:`Name`}),(0,k.jsx)(`input`,{id:`subject-draft-name`,type:`text`,value:c,onChange:e=>l(e.target.value)})]}),(0,k.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`subject-draft-kind`,children:[(0,k.jsx)(`span`,{children:`Kind`}),(0,k.jsxs)(`select`,{id:`subject-draft-kind`,value:u,onChange:e=>d(e.target.value),children:[(0,k.jsx)(`option`,{value:``,children:`Choose a kind`}),t.map(e=>(0,k.jsx)(`option`,{value:e.label,children:e.label},e.id))]})]}),(0,k.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`subject-draft-document`,children:[(0,k.jsx)(`span`,{children:`Document`}),(0,k.jsx)(`select`,{id:`subject-draft-document`,value:f,onChange:e=>p(e.target.value),children:n.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))})]}),(0,k.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,k.jsxs)(k.Fragment,{children:[`Id: `,(0,k.jsx)(`code`,{children:m})]})}),(0,k.jsx)(`button`,{type:`button`,disabled:h===null,onClick:()=>{h!==null&&(o(h),s())},children:`Add`}),(0,k.jsx)(`button`,{type:`button`,onClick:s,children:`Cancel`})]})};function yy({title:e,message:t,confirmLabel:n,cancelLabel:r,onConfirm:i,onCancel:a}){return(0,k.jsx)(`div`,{className:`confirm-dialog-backdrop`,role:`presentation`,onClick:a,children:(0,k.jsxs)(`div`,{className:`confirm-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`confirm-dialog-title`,onClick:e=>e.stopPropagation(),children:[(0,k.jsx)(`h2`,{id:`confirm-dialog-title`,children:e}),(0,k.jsx)(`p`,{children:t}),(0,k.jsxs)(`div`,{className:`confirm-dialog-actions`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:a,children:r}),(0,k.jsx)(`button`,{type:`button`,onClick:i,children:n})]})]})})}function by({title:e,label:t,initialValue:n,confirmLabel:r,cancelLabel:i,onConfirm:a,onCancel:o}){let[s,c]=(0,v.useState)(n),l=s.trim()===``;return(0,k.jsx)(`div`,{className:`confirm-dialog-backdrop`,role:`presentation`,onClick:o,children:(0,k.jsxs)(`div`,{className:`confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-dialog-title`,onClick:e=>e.stopPropagation(),children:[(0,k.jsx)(`h2`,{id:`prompt-dialog-title`,children:e}),(0,k.jsxs)(`form`,{className:`prompt-dialog-form`,onSubmit:e=>{e.preventDefault(),!l&&a(s.trim())},children:[(0,k.jsx)(`label`,{htmlFor:`prompt-dialog-value`,children:t}),(0,k.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,k.jsxs)(`div`,{className:`confirm-dialog-actions`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:o,children:i}),(0,k.jsx)(`button`,{type:`submit`,disabled:l,children:r})]})]})]})})}var xy=new Set([`subject.inspect`,`relationship.inspect`,`view.open`,`view.clear`,`view.copy-path`,`canvas.export-png`]),Sy=(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}}]}],Cy={key:`view.new`,label:`New view…`,intent:{type:`view.new`}},wy={key:`view.new-folder`,label:`New folder…`,intent:{type:`view.new-folder`}},Ty={key:`view.clear`,label:`Show all subjects`,intent:{type:`view.clear`}},Ey=(e,t)=>({key:`delete`,scope:`model`,label:null,destructive:!0,items:[{key:`delete`,label:t,intent:e}]}),bae=(e,t)=>t.graph?.nodes.find(t=>t.id===e)===void 0?[]:[...Sy(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}}]},Ey({type:`subject.delete`,id:e},`Delete from model…`)],xae=(e,t)=>{let n=t.graph,r=n?.edges.find(t=>t.id===e);if(n==null||r===void 0)return[];let i=fv(n,{from:r.from,to:r.to},t.relationshipKinds,r.kindLabel),a=[{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(Ey({type:`relationship.delete`,id:e},`Delete from model…`)),a},Dy=e=>e.graph===null?[]:[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:[Cy,wy,...e.filtered?[Ty]:[],{key:`canvas.export-png`,label:`Export PNG`,intent:{type:`canvas.export-png`}}]},{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`add`,label:`Add subject…`,intent:{type:`canvas.draft-subject`}}]}],Oy=(e,t)=>{let n=[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:e===``?[Ty,Cy,wy]:[{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}},Cy,wy,{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},ky=(e,t)=>t.graph?.nodes.find(t=>t.id===e)===void 0?[]:[...Sy(e,t),{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`inspect`,label:`Properties`,intent:{type:`subject.inspect`,id:e}}]},Ey({type:`subject.delete`,id:e},`Delete from model…`)],Ay=(e,t)=>{let n=(()=>{switch(e.kind){case`subject`:return bae(e.id,t);case`relationship`:return xae(e.id,t);case`canvas`:return Dy(t);case`view-row`:return Oy(e.id,t);case`model-row`:return ky(e.id,t)}})();return t.readOnly===!0?n.flatMap(e=>{let t=e.items.filter(e=>xy.has(e.intent.type));return t.length===0?[]:[{...e,items:t}]}):n},jy=(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 My({groups:e,x:t,y:n,onChoose:r,onDismiss:i}){let a=(0,v.useRef)(null),[o,s]=(0,v.useState)(null);return(0,v.useLayoutEffect)(()=>{let e=a.current;if(e===null)return;let r=e.getBoundingClientRect();s(jy({x:t,y:n},{width:r.width,height:r.height},{width:window.innerWidth,height:window.innerHeight})),e.focus()},[t,n,e]),(0,v.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,k.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,k.jsxs)(`div`,{className:`context-menu-group context-menu-${e.scope}${e.destructive?` context-menu-destructive`:``}`,children:[e.label===null?null:(0,k.jsx)(`p`,{className:`context-menu-heading`,children:e.label}),(0,k.jsx)(`ul`,{children:e.items.map(e=>(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,className:`context-menu-item`,"aria-current":e.current===!0?`true`:void 0,onClick:()=>r(e.intent),children:[(0,k.jsx)(`span`,{className:`context-menu-tick`,"aria-hidden":!0,children:e.current===!0?`•`:``}),(0,k.jsx)(`span`,{className:`context-menu-label`,children:e.label})]})},e.key))})]},e.key))})}var Ny=(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},Sae=(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}}]},Cae=(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=Ny(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.`},wae={reviewer:`You`,agent:`Agent`,session:`Session`},Py={thinking:`Agent is thinking`,compiling:`Agent is compiling the model`,waiting:`Agent is waiting`,idle:`Agent is idle`},Tae=(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`}},Eae=e=>e.lifecycle===`closed`?`Visual conversation ended. Continue in the main agent.`:e.lifecycle===`ending`?e.handoff===null?`Ending conversation — preparing a handoff for the main agent.`:`Handoff ready — returning control to the main agent.`:``,Fy=({state:e,connection:t})=>(0,k.jsxs)(`header`,{className:`command-strip`,children:[(0,k.jsxs)(`div`,{className:`command-identity`,children:[(0,k.jsx)(`h1`,{children:e.title===``?`Opening the session`:e.title}),(0,k.jsx)(`span`,{className:`beta-badge`,children:`Beta`}),(0,k.jsx)(`span`,{className:`authority`,children:`Checked YarraMate model`}),(0,k.jsx)(`span`,{className:`connection-state`,role:`status`,children:t})]}),e.description===``?null:(0,k.jsx)(`p`,{className:`session-description`,title:e.description,children:e.description})]}),Dae=({choices:e,disabled:t,onChoice:n})=>(0,k.jsxs)(`div`,{className:`choices`,children:[(0,k.jsx)(`p`,{className:`question`,children:e.question}),(0,k.jsx)(`ul`,{children:e.options.map(e=>(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),disabled:t,children:[(0,k.jsx)(`span`,{className:`label`,children:e.label}),e.description===void 0?null:(0,k.jsx)(`span`,{className:`detail`,children:e.description})]})},e.id))})]}),Oae=({diagnostics:e})=>e.length===0?null:(0,k.jsxs)(`div`,{className:`faults`,role:`alert`,children:[(0,k.jsx)(`p`,{className:`faults-title`,children:`The last change did not compile. The diagram still shows the model that did.`}),(0,k.jsx)(`ul`,{children:e.map(e=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`code`,children:e.code}),` `,e.message,(0,k.jsxs)(`span`,{className:`where`,children:[e.path,`:`,e.line]})]},`${e.code}-${e.pointer}`))})]}),kae=({state:e,selectedId:t,waiting:n,layout:r,nesting:i,direction:a,showLifecycle:o,showEvidence:s,showOwnership:c,showNudges:l,openQuestionCounts:u,decorations:d,connection:f,onConnectTarget:p,onConnectCancel:m,onConnectStage:h,onDraftStage:g,draftingSubject:_,draftInitialKind:y,onKindDrop:b,onDraftSubject:x,onDraftSubjectClose:S,pendingDeletion:C,onDeletionDismiss:w,onSelect:T,onCanvasMenu:E,onClearFilter:D,onSaveLayout:ee,onCanvasReady:te,onQuickFilterChange:ne,view:re,bottomPanel:ie,onTogglePresentation:ae,onToggleBottomPanel:oe,onSelectBottomTab:se,onApplyFilter:ce,onStageView:le,readOnly:ue})=>{let de=(0,v.useMemo)(()=>new Map((e.model?.graph.nodes??[]).map(e=>[e.id,e.name])),[e.model]),fe=e.model?.graph.nodes??[],pe=e.activeFilter?.matchedIds??null,me=fe.length>0&&(e.activeFilter!==null||e.quickFilterText.trim()!==``)&&_h(fe,pe,e.quickFilterText)===0,he=e.activeFilter!==null&&_h(fe,pe,``)===0;return(0,k.jsxs)(`section`,{className:`diagram-workspace`,"aria-label":`Architecture diagram`,children:[e.activeFilter!==null&&e.activeFilter.source!==`view`&&e.activeFilter.source!==`editor`?(0,k.jsxs)(`div`,{className:`filter-pill`,role:`status`,children:[(0,k.jsxs)(`span`,{children:[`Filtered by `,e.activeFilter.source,`:`,` `,(0,k.jsx)(`code`,{children:q_(e.activeFilter.query)})]}),(0,k.jsx)(`button`,{type:`button`,onClick:D,children:`Show all`})]}):null,(0,k.jsxs)(`div`,{className:`canvas`,children:[e.model===null?null:(0,k.jsxs)(`div`,{className:`canvas-controls`,children:[(0,k.jsx)(mie,{value:e.quickFilterText,onChange:ne}),ue?null:(0,k.jsx)(`button`,{type:`button`,className:`subject-draft-open`,onClick:x,children:`Add subject`})]}),!_||e.model===null?null:(0,k.jsx)(vy,{initialKind:y,graph:e.model.graph,kinds:e.model.vocabulary.conceptKinds,documents:e.model.documents,reservedIds:dv(e.pendingChangeset.operations),defaultDocument:(t===null?void 0:e.model.graph.nodes.find(e=>e.id===t)?.document)??e.model.documents[0]??``,onStage:g,onCancel:S},y??``),C===null||e.model===null?null:(0,k.jsx)(yy,{title:`Delete`,message:Cae(e.model.graph,C)??`That subject is no longer on the diagram.`,confirmLabel:`Delete`,cancelLabel:`Keep`,onConfirm:()=>{for(let t of Sae(e.model.graph,C))h(t);w()},onCancel:w}),f===null||e.model===null?null:(0,k.jsx)(_ae,{draft:f,graph:e.model.graph,reservedIds:dv(e.pendingChangeset.operations),onStage:h,onCancel:m}),e.model===null?null:(0,k.jsx)(ore,{graph:e.model.graph,selectedId:t,onSelect:(t,n)=>{let r=e.model.graph;if(n===`node`){if(f!==null){p(t);return}let e=r.nodes.find(e=>e.id===t);e!==void 0&&T(Vv(e))}else{let e=r.edges.find(e=>e.id===t);e!==void 0&&T(Hv(e,de))}},onContextMenu:E,matchedIds:e.activeFilter?.matchedIds??null,quickFilterText:e.quickFilterText,nesting:i,faultedIds:Aie(e.commitDiagnostics??[]),decorations:d,showLifecycle:o,showEvidence:s,showOwnership:c,showNudges:l,openQuestionCounts:u,activeViewId:e.activeView,direction:a,savedPositions:e.model.layouts[e.activeView],onSaveLayout:ue?()=>void 0:ee,onKindDrop:ue?void 0:b,onCanvasReady:te}),me?(0,k.jsx)(`div`,{className:`filter-empty-pill`,role:`status`,children:he&&e.activeFilter!==null?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{children:[`Nothing matches this filter:`,` `,(0,k.jsx)(`code`,{children:q_(e.activeFilter.query)})]}),(0,k.jsx)(`button`,{type:`button`,onClick:D,children:`Show all`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{children:[`Nothing matches “`,e.quickFilterText.trim(),`”`]}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>ne(``),children:`Clear filter`})]})}):null,e.layoutNotice===null?null:(0,k.jsx)(`div`,{className:`layout-notice-pill`,role:`status`,children:(0,k.jsx)(`span`,{children:e.layoutNotice})}),n===null?null:(0,k.jsx)(`p`,{className:`waiting`,children:n})]}),(0,k.jsx)(pie,{nodes:e.model?.graph.nodes??[],activeFilter:e.activeFilter,view:re,open:ie.open,tab:ie.tab,showLifecycle:o,showEvidence:s,showOwnership:c,showNudges:l,onTogglePresentation:ae,onToggleOpen:oe,onSelectTab:se,onApply:ce,onStage:le,readOnly:ue},e.activeView)]})},Aae=({text:e,expanded:t,onToggle:n})=>{let r=e??`No description declared in this model`,i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1);return(0,v.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,k.jsxs)(`div`,{className:`subject-description`,children:[(0,k.jsx)(`p`,{ref:i,className:t?`description-expanded`:`description-clamped`,children:r}),a||t?(0,k.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:n,children:t?`Show less`:`Show more`}):null]})},jae=({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,k.jsxs)(`section`,{className:`subject-inspector`,"aria-labelledby":`subject-heading`,children:[(0,k.jsxs)(`div`,{className:`subject-heading-row`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`p`,{className:`subject-type`,children:e.type===`element`?`Selected element`:`Selected relationship`}),(0,k.jsx)(`h2`,{id:`subject-heading`,children:e.type===`element`?e.title:`${e.sourceTitle} → ${e.targetTitle}`})]}),e.type===`element`&&!l?(0,k.jsx)(`button`,{type:`button`,className:`subject-connect`,onClick:()=>o(e.id),children:`Connect`}):null,l?null:(0,k.jsx)(`button`,{type:`button`,className:`subject-delete`,onClick:()=>s(e.id),children:`Delete`}),(0,k.jsx)(`button`,{type:`button`,className:`subject-clear`,onClick:a,children:`Clear`})]}),u===void 0?null:l?(0,k.jsx)(Xie,{node:u,model:t}):(0,k.jsx)(Yie,{node:u,model:t,operations:n,onStageChange:c}),d===void 0?null:l?(0,k.jsx)(Zie,{edge:d,model:t}):(0,k.jsx)(Qie,{edge:d,model:t,operations:n,onStageChange:c}),(0,k.jsx)(Aae,{text:e.description,expanded:r,onToggle:i})]})},Iy=e=>e.lifecycle===`active`?e.awaitingAgent?Py[e.agentStatus?.state??`thinking`]??`working`:`agent idle`:`closed`,Ly=({state:e,disabled:t,selectedSubject:n,onSend:r,onChoice:i,onClearSubject:a,onEnd:o})=>{let[s,c]=(0,v.useState)(``),l=e.lifecycle===`active`&&e.awaitingAgent,u=e.lifecycle===`active`?e.agentStatus:null;return(0,k.jsxs)(`div`,{className:`talk`,children:[(0,k.jsxs)(`div`,{className:`conversation-scroll`,children:[(0,k.jsx)(`ol`,{className:`ledger`,role:`log`,"aria-live":`polite`,children:e.transcript.length===0?(0,k.jsx)(`li`,{className:`empty`,children:(0,k.jsx)(`p`,{children:`Nothing asked yet. Question anything on the diagram.`})}):e.transcript.map(e=>(0,k.jsxs)(`li`,{className:`said said-${e.speaker}`,children:[(0,k.jsx)(`p`,{className:`who`,children:wae[e.speaker]}),(0,k.jsx)(`p`,{className:`words`,children:e.text})]},e.id))}),(0,k.jsx)(Oae,{diagnostics:e.diagnostics}),e.choices===null?null:(0,k.jsx)(Dae,{choices:e.choices,disabled:t,onChoice:i})]}),(0,k.jsxs)(`form`,{className:`composer`,onSubmit:e=>{e.preventDefault();let n=s.trim();n===``||t||(r(n),c(``))},children:[n===null?null:(0,k.jsxs)(`div`,{className:`subject-chip`,children:[(0,k.jsx)(`span`,{children:n.type===`element`?n.title:`${n.sourceTitle} → ${n.targetTitle}`}),(0,k.jsx)(`button`,{type:`button`,"aria-label":`Remove selected diagram context`,onClick:a,children:`Remove`})]}),(0,k.jsx)(`label`,{className:`offscreen`,htmlFor:`composer-text`,children:`Ask about this design`}),(0,k.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,k.jsxs)(`div`,{className:`composer-foot`,children:[(0,k.jsxs)(`p`,{className:`agent-status`,role:`status`,"aria-live":`polite`,"aria-busy":l,children:[l?(0,k.jsx)(`span`,{className:`agent-spinner`,"aria-hidden":`true`}):null,(0,k.jsx)(`span`,{children:u===null?l?`Awaiting agent response`:`\xA0`:Py[u.state]??`\xA0`})]}),(0,k.jsx)(`button`,{type:`submit`,disabled:t||s.trim()===``,children:`Send`})]}),(0,k.jsxs)(`div`,{className:`session-foot`,children:[(0,k.jsx)(`span`,{className:`end-transition-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:Eae(e)}),(0,k.jsx)(`button`,{type:`button`,className:`end-session`,onClick:o,disabled:e.lifecycle!==`active`,children:e.lifecycle===`ending`||e.lifecycle===`closed`?`Returning…`:`Return to agent`})]})]})]})},Ry=({width:e,viewportWidth:t,onResize:n})=>{let r=Kv(t),i=(0,v.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,k.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))}})},zy=({host:e,sections:t=aae,readOnly:n=!1,decorations:r,onReady:i})=>{let{state:a,connected:o,ask:s,choose:c,navigate:l,filter:u,clearFilter:d,setQuickFilterText:f,stageViewChange:p,stageViewMembership:m,saveLayout:h,discardChange:g,stageChange:_,clearChangeset:y,undoChangeset:b,redoChangeset:x,commitChangeset:S,end:C}=gae(e),[w,T]=(0,v.useReducer)(Zv,{width:window.innerWidth,height:window.innerHeight},({width:e,height:t})=>Xv(e,t)),[E,D]=(0,v.useState)(null),[ee,te]=(0,v.useState)(!1),[ne,re]=(0,v.useState)(!1),[ie,ae]=(0,v.useState)(void 0),[oe,se]=(0,v.useState)(void 0),[ce,le]=(0,v.useState)(r??{}),ue=(0,v.useRef)(null),de=(0,v.useRef)({graph:null,readOnly:n});de.current={graph:a.model?.graph??null,readOnly:n},(0,v.useEffect)(()=>{i?.(iae(()=>de.current,T,se,le))},[i]),(0,v.useEffect)(()=>{let e=()=>T({type:`viewport.resized`,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight});return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let fe=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(a.activeView===``){fe.current=null;return}let e=Gv(a.activeView,a.views,fe.current,o);if(e!==null){fe.current=e.id,u(e.query,`view`);for(let t of lae(e.presentation))T(t)}},[a.activeView,a.views,o,u]);let pe=(0,v.useRef)({transcriptLength:a.transcript.length,choices:a.choices,diagnostics:a.diagnostics});(0,v.useEffect)(()=>{let e=pe.current,t=!1;for(let n=e.transcriptLength;n<a.transcript.length;n+=1)if(a.transcript[n]?.speaker===`agent`){t=!0;break}let n=t||a.choices!==null&&a.choices!==e.choices||a.diagnostics.length>0&&a.diagnostics!==e.diagnostics;pe.current={transcriptLength:a.transcript.length,choices:a.choices,diagnostics:a.diagnostics},n&&T({type:`attention.received`})},[a.transcript.length,a.choices,a.diagnostics]);let me=(0,v.useRef)(a.model);(0,v.useEffect)(()=>{a.model!==me.current&&(me.current=a.model,T({type:`model.replaced`,graph:a.model?.graph??null}))},[a.model]);let he=a.model===null?a.lifecycle===`connecting`?`Reading the session`:`No model to draw`:E,ge=a.pendingChangeset.operations.length+a.pendingChangeset.viewOperations.length,_e=e=>!w.conversation.collapsed.includes(e),ve=a.model?.interrogation,ye=(0,v.useMemo)(()=>new Map(Object.entries(ve?.subjects??{}).map(([e,t])=>[e,t.length])),[ve]),be=n?t.filter(e=>e!==`palette`&&e!==`changes`):t,xe=ve===void 0?be.filter(e=>e!==`questions`):be,Se=w.selectedSubject?.type===`element`?w.selectedSubject.id:null,Ce=ve===void 0?void 0:Se===null?ve.workspace.length:ye.get(Se)??0,we=a.model?.vocabulary.conceptKinds??[],Te=(0,v.useMemo)(()=>new Set(w.tree.collapsed),[w.tree.collapsed]),Ee=w.conversation.hidden,De={"--conversation-width":Ee?`0px`:`${w.conversation.width}px`,"--changes-height":_e(`changes`)?`${w.conversation.changesHeight}px`:`auto`,"--chat-height":_e(`chat`)?`${w.conversation.chatHeight}px`:`auto`},Oe=e=>{se(e),T({type:`subject.draft.opened`})},ke=(e,t)=>T({type:`menu.opened`,target:e,x:t.x,y:t.y}),Ae=w.contextMenu===null?[]:Ay(w.contextMenu.target,{graph:a.model?.graph??null,relationshipKinds:a.model?.vocabulary.relationshipKinds??[],activeViewId:a.activeView,filtered:a.activeFilter!==null,membership:pae(a),readOnly:n}),je=e=>{let t=a.model?.graph??null;switch(e.type){case`subject.inspect`:{let n=t?.nodes.find(t=>t.id===e.id);if(n===void 0)return;T({type:`subject.selected`,subject:Vv(n)});return}case`relationship.inspect`:{let n=t?.edges.find(t=>t.id===e.id);if(n===void 0||t===null)return;T({type:`subject.selected`,subject:Hv(n,new Map(t.nodes.map(e=>[e.id,e.name])))});return}case`subject.connect`:T({type:`connection.started`,from:e.from});return;case`subject.delete`:case`relationship.delete`:T({type:`deletion.asked`,id:e.id});return;case`relationship.retype`:{let n=t?.edges.find(t=>t.id===e.id);if(n===void 0)return;for(let t of Cv(n.document,n.localId,`kind`,n.kindLabel,e.kind))_(t);T({type:`menu.dismissed`});return}case`canvas.draft-subject`:se(void 0),T({type:`subject.draft.opened`});return;case`view.add-subject`:case`view.remove-subject`:m(a.activeView,e.id,e.type===`view.add-subject`?`add`:`remove`),T({type:`menu.dismissed`});return;case`view.open`:l(e.id),T({type:`menu.dismissed`});return;case`view.clear`:d(),T({type:`menu.dismissed`});return;case`view.new`:ae(void 0),te(!0),T({type:`menu.dismissed`});return;case`view.delete`:T({type:`viewDeletion.asked`,id:e.id});return;case`view.rename`:T({type:`viewRename.asked`,id:e.id});return;case`view.new-folder`:re(!0),T({type:`menu.dismissed`});return;case`view.duplicate`:{let t=a.views.find(t=>t.id===e.id);if(t===void 0)return;let n=x_(t,new Set(a.views.map(e=>e.id)));p({op:`write-view`,...n}),T({type:`menu.dismissed`});return}case`view.new-in-folder`:{let t=a.views.find(t=>t.id===e.id);if(t===void 0)return;ae(Zre(t)),te(!0),T({type:`menu.dismissed`});return}case`view.copy-path`:{let t=a.views.find(t=>t.id===e.id);if(t===void 0)return;navigator.clipboard?.writeText(t.path),T({type:`menu.dismissed`});return}case`canvas.export-png`:{let e=ue.current;if(e===null)return;let t=document.createElement(`a`);t.href=e(),t.download=`${a.activeView===``?`all-subjects`:a.activeView}.png`,t.click(),T({type:`menu.dismissed`});return}}},Me=w.pendingViewDeletion===null?null:a.views.find(e=>e.id===w.pendingViewDeletion)??null,Ne=w.pendingViewRename===null?null:a.views.find(e=>e.id===w.pendingViewRename)??null,Pe=[`Show the session panel`,...w.conversation.unread===0?[]:[`${w.conversation.unread} unread`],...a.choices===null?[]:[`the agent is waiting on a choice`]].join(`, `);return(0,k.jsxs)(`main`,{className:`visual-shell`,style:De,children:[(0,k.jsx)(Fy,{state:a,connection:Tae(a,o)}),(0,k.jsxs)(`div`,{className:`workspace`,children:[(0,k.jsx)(Tie,{views:a.views,stagedViewOperations:a.pendingChangeset.viewOperations,activeViewId:a.activeView,nodes:a.model?.graph.nodes??[],inViewIds:a.activeFilter===null?null:new Set(a.activeFilter.matchedIds),filterText:w.tree.filterText,collapsed:Te,onFilterChange:e=>T({type:`tree.filtered`,filterText:e}),onToggle:e=>T({type:`tree.toggled`,key:e}),onSelectView:e=>l(e),onClearView:d,onNewView:()=>{ae(void 0),te(!0)},onSelectSubject:e=>{let t=a.model?.graph.nodes.find(t=>t.id===e);t!==void 0&&T({type:`subject.selected`,subject:Vv(t)})},onRowMenu:(e,t)=>ke(e.kind===`view`?{kind:`view-row`,id:e.id}:{kind:`model-row`,id:e.id},t),readOnly:n}),(0,k.jsx)(kae,{state:a,selectedId:w.selectedSubject?.id??null,waiting:he,layout:w.layout,nesting:w.nesting,direction:w.direction,decorations:ce,connection:w.connection,onConnectTarget:e=>T({type:`connection.targeted`,to:e}),onConnectCancel:()=>T({type:`connection.cancelled`}),onConnectStage:_,onDraftStage:e=>{_(e),e.op===`add-concept`&&m(a.activeView,e.concept.id,`add`)},draftingSubject:w.draftingSubject,draftInitialKind:oe,onKindDrop:e=>Oe(e),onDraftSubject:()=>{se(void 0),T({type:`subject.draft.opened`})},onDraftSubjectClose:()=>T({type:`subject.draft.closed`}),pendingDeletion:w.pendingDeletion,onDeletionDismiss:()=>T({type:`deletion.dismissed`}),showLifecycle:w.showLifecycle,showEvidence:w.showEvidence,showOwnership:w.showOwnership,showNudges:w.showNudges,openQuestionCounts:ye,onSelect:e=>T({type:`subject.selected`,subject:e}),onCanvasMenu:(e,t)=>ke(e.type===`node`?{kind:`subject`,id:e.id??``}:e.type===`edge`?{kind:`relationship`,id:e.id??``}:{kind:`canvas`},t),onClearFilter:d,onSaveLayout:h,onCanvasReady:e=>{ue.current=e},onQuickFilterChange:f,view:a.views.find(e=>e.id===a.activeView)??null,bottomPanel:w.bottomPanel,onTogglePresentation:(e,t)=>T({type:`presentation.toggled`,flag:e,value:t}),onToggleBottomPanel:()=>T({type:`bottomPanel.toggled`}),onSelectBottomTab:e=>T({type:`bottomPanel.tabSelected`,tab:e}),onApplyFilter:e=>u(e,`editor`),onStageView:p,readOnly:n}),Ee?(0,k.jsxs)(`button`,{type:`button`,className:`conversation-reopen`,title:`Show the session panel`,"aria-label":Pe,onClick:()=>T({type:`conversation.toggled`}),children:[(0,k.jsx)(`span`,{className:`reopen-chevron`,"aria-hidden":`true`,children:`«`}),w.conversation.unread===0?null:(0,k.jsx)(`span`,{className:`attention-count`,children:w.conversation.unread}),a.choices===null?null:(0,k.jsx)(`span`,{className:`attention-choice`,title:`The agent is waiting on a choice`,children:`?`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(Ry,{width:w.conversation.width,viewportWidth:w.viewportWidth,onResize:e=>T({type:`conversation.resized`,width:e})}),(0,k.jsxs)(`aside`,{className:`section-stack`,"aria-label":`Session`,children:[(0,k.jsx)(`div`,{className:`stack-rim`,children:(0,k.jsx)(`button`,{type:`button`,className:`conversation-hide`,title:`Hide the session panel`,"aria-label":`Hide the session panel`,onClick:()=>T({type:`conversation.toggled`}),children:`»`})}),ty(xe,{palette:(0,k.jsx)($v,{id:`palette`,label:`Kind palette`,meta:we.length===0?void 0:we.length===1?`1 kind`:`${we.length} kinds`,open:_e(`palette`),onToggle:()=>T({type:`section.toggled`,section:`palette`}),children:we.length===0?(0,k.jsx)(`p`,{className:`section-empty`,children:`No model yet. The kinds arrive with it.`}):(0,k.jsx)(Tne,{kinds:we,onPick:Oe})}),properties:(0,k.jsx)($v,{id:`properties`,label:`Element properties`,meta:w.selectedSubject?.id,open:_e(`properties`),onToggle:()=>T({type:`section.toggled`,section:`properties`}),children:w.selectedSubject===null||a.model===null?(0,k.jsx)(`p`,{className:`section-empty`,children:`Nothing selected. Pick a subject on the canvas or in the rail.`}):(0,k.jsx)(jae,{subject:w.selectedSubject,model:a.model,operations:a.pendingChangeset.operations,expanded:w.descriptionExpanded,onToggleDescription:()=>T({type:`description.toggled`}),onClear:()=>T({type:`subject.cleared`}),onConnect:e=>T({type:`connection.started`,from:e}),onDelete:e=>T({type:`deletion.asked`,id:e}),onStageChange:_,readOnly:n})}),questions:(0,k.jsx)($v,{id:`questions`,label:`Open questions`,meta:Ce===void 0?void 0:Ce===0?`nothing open`:`${Ce} open`,open:_e(`questions`),onToggle:()=>T({type:`section.toggled`,section:`questions`}),children:ve===void 0?null:(0,k.jsx)($ie,{overlay:ve,selectedId:Se})}),changes:(0,k.jsx)($v,{id:`changes`,label:`Changes`,meta:ge===0?`nothing staged`:`${ge} staged`,open:_e(`changes`),onToggle:()=>T({type:`section.toggled`,section:`changes`}),children:(0,k.jsx)(Iie,{state:a,onDiscardChange:g,onClearChangeset:y,onUndoChangeset:b,onRedoChangeset:x,onCommitChangeset:S})}),chat:(0,k.jsx)($v,{id:`chat`,label:`Chat`,meta:w.conversation.unread===0?Iy(a):(0,k.jsx)(`span`,{className:`attention-count`,children:w.conversation.unread}),open:_e(`chat`),onToggle:()=>T({type:`section.toggled`,section:`chat`}),children:(0,k.jsx)(Ly,{state:a,disabled:!a.composerEnabled,selectedSubject:w.selectedSubject,onSend:e=>s(Qv(e,w.selectedSubject)),onChoice:c,onClearSubject:()=>T({type:`subject.cleared`}),onEnd:C})})},{changes:(0,k.jsx)(ey,{label:`Resize the changes section`,height:w.conversation.changesHeight,viewportHeight:w.viewportHeight,onResize:e=>T({type:`section.resized`,section:`changes`,height:e})}),chat:(0,k.jsx)(ey,{label:`Resize the chat section`,height:w.conversation.chatHeight,viewportHeight:w.viewportHeight,onResize:e=>T({type:`section.resized`,section:`chat`,height:e})})})]})]})]}),w.contextMenu===null?null:(0,k.jsx)(My,{groups:Ae,x:w.contextMenu.x,y:w.contextMenu.y,onChoose:je,onDismiss:()=>T({type:`menu.dismissed`})}),(0,k.jsx)(Oie,{views:a.views,activeViewId:a.activeView,query:a.activeFilter?.query??null,layout:w.layout,showLifecycle:w.showLifecycle,showEvidence:w.showEvidence,showOwnership:w.showOwnership,open:ee,folder:ie,onClose:()=>te(!1),onStage:p}),ne?(0,k.jsx)(by,{title:`New folder`,label:`Folder`,initialValue:``,confirmLabel:`Continue`,cancelLabel:`Cancel`,onConfirm:e=>{re(!1);let t=e.trim();t!==``&&(ae(t),te(!0))},onCancel:()=>re(!1)}):null,Ne===null?null:(0,k.jsx)(by,{title:`Rename view`,label:`Title`,initialValue:Ne.title,confirmLabel:`Rename`,cancelLabel:`Cancel`,onConfirm:e=>{p({op:`write-view`,...Qre(Ne,e)}),T({type:`viewRename.dismissed`})},onCancel:()=>T({type:`viewRename.dismissed`})}),Me===null?null:(0,k.jsx)(yy,{title:`Delete view`,message:`Stage the removal of "${Me.title}"? The projection document goes when the changeset is committed; no subject is touched.`,confirmLabel:`Delete`,cancelLabel:`Keep`,onConfirm:()=>{p({op:`delete-view`,path:Me.path}),T({type:`viewDeletion.dismissed`})},onCancel:()=>T({type:`viewDeletion.dismissed`})})]})},By=`/api/session`,Mae=`/socket`,Nae=1e3,Vy=()=>{let e=null;return{open:t=>{let n=!1,r,i=null,a=()=>{let e=new URL(Mae,window.location.href);return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.searchParams.set(`after`,String(t.session().lastSequence)),e},o=()=>{if(!n){if(i??=Date.now(),!cy(i,Date.now())){t.frame({kind:`closing`,reason:`browser-timeout`});return}r=setTimeout(s,Nae)}},s=()=>{if(n)return;let r=new WebSocket(a());e=r,r.addEventListener(`open`,()=>{i=null,t.connected(!0)}),r.addEventListener(`message`,e=>{if(typeof e.data==`string`)try{t.frame(JSON.parse(e.data))}catch{}}),r.addEventListener(`close`,()=>{t.connected(!1),e=null,!(n||t.session().closed)&&(t.lost(),o())}),r.addEventListener(`error`,()=>r.close())};return(async()=>{let e=await fetch(By,{credentials:`same-origin`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(`Session request answered ${e.status}`);let r=await e.json();n||(t.frame({kind:`ready`,snapshot:r}),s())})().catch(()=>{n||(t.lost(),o())}),()=>{n=!0,r!==void 0&&clearTimeout(r),e?.close()}},send:t=>{e!==null&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify(t))}}},Pae=document.getElementById(`visual-session`);if(Pae===null)throw Error(`The visual session page has no mount point`);(0,y.createRoot)(Pae).render((0,k.jsx)(zy,{host:Vy()}));
|
|
394
|
+
`}var Wre=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Dh,{value:Sh});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 Uh({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[Dh]:{value:Sh}});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=Fh(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){h_(this.contents)&&this.contents.add(e)}addIn(e,t){h_(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=fre(this);e.anchor=!t||n.has(t)?pre(t||`a`,n):t}return new hre(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}=mre(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=Qh(e,l,p);return o&&Ph(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new wg(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return h_(this.contents)?this.contents.delete(e):!1}deleteIn(e){return eg(e)?this.contents!=null&&(this.contents=null,!0):h_(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Ph(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return eg(e)?!t&&Mh(this.contents)?this.contents.value:this.contents:Ph(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Ph(this.contents)?this.contents.has(e):!1}hasIn(e){return eg(e)?this.contents!==void 0:Ph(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=$h(this.schema,[e],t):h_(this.contents)&&this.contents.set(e,t)}setIn(e,t){eg(e)?this.contents=t:this.contents==null?this.contents=$h(this.schema,Array.from(e),t):h_(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 Uh({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 Uh({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 m_(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=Gh(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`?Wh(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 Ure(this,e)}};function h_(e){if(Ph(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var g_=Symbol(`break visit`),Gre=Symbol(`skip children`),__=Symbol(`remove item`);function v_(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),y_(Object.freeze([]),e,t)}v_.BREAK=g_,v_.SKIP=Gre,v_.REMOVE=__,v_.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},v_.parentCollection=(e,t)=>{let n=v_.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 y_(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=y_(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===g_)return g_;else r===__&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function Kre(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 kh(e)&&!r?e.toString(n):new Wre(e,r,n).toString(n)}var qre=`.yarramate/projections`,Jre=e=>{let t=e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);return t.length===0?`view`:/^[a-z]/.test(t)?t:`view-${t}`},Yre=(e,t)=>{if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;return`${e}-${n}`},Xre=(e,t)=>Yre(Jre(e),t),b_=e=>`${qre}/${e}.yaml`,Zre=e=>e.presentation?.folder??``,Qre=(e,t)=>({path:e.path,projection:S_({id:e.id,title:t,description:e.description,query:e.query,presentation:e.presentation})}),x_=(e,t)=>{let n=`${e.title} copy`,r=Xre(n,t);return{path:b_(r),projection:S_({id:r,title:n,description:e.description,query:e.query,presentation:e.presentation})}},S_=e=>({format:`yarramate/projection/v1`,id:e.id,version:`1.0`,query:e.query,presentation:{...e.presentation??{},title:e.title,description:e.description}}),C_=e=>e.subjects!==void 0,w_=(e,t,n)=>{if(!C_(e.query))return $re(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)}}},$re=(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}}},T_=(e,t)=>{if(!C_(e)&&!C_(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!C_(e)||!C_(t)?[]:[...t.subjects.filter(t=>!e.subjects.includes(t)).map(e=>`+${e}`),...e.subjects.filter(e=>!t.subjects.includes(e)).map(e=>`-${e}`)]},eie=(e,t)=>E_(e)===E_(t),E_=e=>Array.isArray(e)?`[${e.map(E_).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)}:${E_(t)}`).join(`,`)}}`:JSON.stringify(e)??`null`,tie={subjects:[],documents:[],kinds:[],layers:[],statuses:[],excludeStatuses:[],states:[],owners:[],constraints:[],relationshipKinds:[],kindMatching:``,relationships:``,isolatedConcepts:``},nie=[`planned`,`current`,`retired`],rie=e=>e===null?tie:{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??``},iie=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}}),D_=({id:e,label:t,values:n,onChange:r})=>{let[i,a]=(0,v.useState)(``),o=()=>{let e=i.trim();a(``),!(e===``||n.includes(e))&&r([...n,e])};return(0,k.jsxs)(`div`,{className:`filter-field`,children:[(0,k.jsx)(`label`,{htmlFor:e,children:t}),(0,k.jsxs)(`div`,{className:`tag-input`,children:[n.map(e=>(0,k.jsxs)(`span`,{className:`tag-chip`,children:[e,(0,k.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e}`,onClick:()=>r(n.filter(t=>t!==e)),children:`×`})]},e)),(0,k.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})]})]})},O_=({legend:e,values:t,onChange:n})=>(0,k.jsxs)(`fieldset`,{className:`filter-field filter-checkbox-group`,children:[(0,k.jsx)(`legend`,{children:e}),nie.map(e=>(0,k.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:t.includes(e),onChange:r=>n(r.target.checked?[...t,e]:t.filter(t=>t!==e))}),e]},e))]}),k_=({id:e,label:t,value:n,options:r,onChange:i})=>(0,k.jsxs)(`div`,{className:`filter-field`,children:[(0,k.jsx)(`label`,{htmlFor:e,children:t}),(0,k.jsxs)(`select`,{id:e,value:n,onChange:e=>i(e.target.value),children:[(0,k.jsx)(`option`,{value:``,children:`Any`}),r.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))]})]}),A_=(e,t)=>n=>e(t,n);function aie({fields:e,onChange:t}){return(0,k.jsxs)(`div`,{className:`filter-grid`,children:[(0,k.jsx)(D_,{id:`filter-subjects`,label:`Subjects`,values:e.subjects,onChange:e=>t(`subjects`,e)}),(0,k.jsx)(D_,{id:`filter-documents`,label:`Documents`,values:e.documents,onChange:e=>t(`documents`,e)}),(0,k.jsx)(D_,{id:`filter-kinds`,label:`Kinds`,values:e.kinds,onChange:e=>t(`kinds`,e)}),(0,k.jsx)(D_,{id:`filter-layers`,label:`Layers`,values:e.layers,onChange:e=>t(`layers`,e)}),(0,k.jsx)(D_,{id:`filter-states`,label:`States`,values:e.states,onChange:e=>t(`states`,e)}),(0,k.jsx)(D_,{id:`filter-owners`,label:`Owners`,values:e.owners,onChange:e=>t(`owners`,e)}),(0,k.jsx)(D_,{id:`filter-constraints`,label:`Constraints`,values:e.constraints,onChange:e=>t(`constraints`,e)}),(0,k.jsx)(D_,{id:`filter-relationship-kinds`,label:`Relationship kinds`,values:e.relationshipKinds,onChange:e=>t(`relationshipKinds`,e)}),(0,k.jsx)(O_,{legend:`Statuses`,values:e.statuses,onChange:e=>t(`statuses`,e)}),(0,k.jsx)(O_,{legend:`Exclude statuses`,values:e.excludeStatuses,onChange:e=>t(`excludeStatuses`,e)}),(0,k.jsx)(k_,{id:`filter-kind-matching`,label:`Kind matching`,value:e.kindMatching,options:[`exact`,`descendants`],onChange:e=>t(`kindMatching`,e)}),(0,k.jsx)(k_,{id:`filter-relationships`,label:`Relationships`,value:e.relationships,options:[`between`,`connected`,`none`],onChange:e=>t(`relationships`,e)}),(0,k.jsx)(k_,{id:`filter-isolated-concepts`,label:`Isolated concepts`,value:e.isolatedConcepts,options:[`include`,`exclude`],onChange:e=>t(`isolatedConcepts`,e)})]})}function j_({showLifecycle:e,showEvidence:t,showOwnership:n,showNudges:r,onTogglePresentation:i}){return(0,k.jsxs)(`fieldset`,{className:`filter-field filter-presentation-group`,children:[(0,k.jsx)(`legend`,{children:`Presentation`}),(0,k.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>A_(i,`showLifecycle`)(e.currentTarget.checked)}),`Lifecycle badges`]}),(0,k.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>A_(i,`showEvidence`)(e.currentTarget.checked)}),`Evidence badges`]}),(0,k.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>A_(i,`showOwnership`)(e.currentTarget.checked)}),`Ownership badges`]}),(0,k.jsxs)(`label`,{className:`filter-checkbox-option`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>A_(i,`showNudges`)(e.currentTarget.checked)}),`Open-question badges`]})]})}var M_=[{id:`view-query`,label:`View query`}],N_=e=>JSON.stringify(Object.entries(e??{}).sort(([e],[t])=>e<t?-1:1)),P_=(e,t)=>N_(e)===N_(t),F_={exclude:`Taken out of this view`,states:`States`,subjects:`Subjects`,documents:`Documents`,kinds:`Kinds`,layers:`Layers`,statuses:`Statuses`,excludeStatuses:`Excluded statuses`,owners:`Owners`,constraints:`Constraints`,isolatedConcepts:`Isolated concepts`,unreported:`Not reported`},oie=Object.keys(F_),sie=(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 oie.flatMap(e=>{let t=a.get(e);return t===void 0?[]:[{reason:e,label:F_[e],subjects:t}]})},cie=(e,t)=>{if(t===null)return e.length;let n=new Set(t);return e.filter(e=>n.has(e.id)).length},I_=(e,t)=>{if(e===null||t===null)return 0;let n=new Set(e);return t.filter(({id:e})=>n.has(e)).length},lie=(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`)}},uie=({view:e,query:t,badges:n,opened:r})=>S_({id:e.id,title:e.title,description:e.description,query:t,presentation:lie(e,n,r)}),die=e=>({op:`write-view`,path:e.view.path,projection:uie(e)}),fie=e=>{let t=uie(e),n=S_({id:e.view.id,title:e.view.title,description:e.view.description,query:e.view.query,presentation:e.view.presentation});return N_(t.query)!==N_(n.query)||N_(t.presentation)!==N_(n.presentation)};function pie({nodes:e,activeFilter:t,view:n,open:r,tab:i,showLifecycle:a,showEvidence:o,showOwnership:s,showNudges:c,onTogglePresentation:l,onToggleOpen:u,onSelectTab:d,onApply:f,onStage:p,readOnly:m=!1}){let h=(0,v.useRef)(null),[g,_]=(0,v.useState)(()=>rie(n?.query??t?.query??null)),[y,b]=(0,v.useState)(!1),[x]=(0,v.useState)(()=>({showLifecycle:a,showEvidence:o,showOwnership:s})),S=e=>{h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{h.current=null,f(iie(e))},300)},C=(e,t)=>{b(!1),_(n=>{let r={...n,[e]:t};return S(r),r})},w=iie(g),T=t?.matchedIds??null,E=cie(e,T),D=sie(e,T,t?.excluded??null),ee=I_(T,t?.excluded??null),te=t===null?Object.keys(w).length===0:P_(w,t.query),ne=n===null?null:{view:n,query:w,badges:{showLifecycle:a,showEvidence:o,showOwnership:s},opened:x};return(0,k.jsxs)(`section`,{className:`bottom-panel`,"aria-label":`Canvas panels`,children:[(0,k.jsxs)(`div`,{className:`bottom-panel-tabs`,role:`tablist`,"aria-label":`Canvas panels`,children:[M_.map(e=>(0,k.jsx)(`button`,{type:`button`,role:`tab`,id:`bottom-tab-${e.id}`,className:`bottom-panel-tab`,"aria-selected":r&&i===e.id,"aria-controls":`bottom-panel-${e.id}`,onClick:()=>{if(r&&i===e.id){u();return}d(e.id)},children:e.label},e.id)),(0,k.jsxs)(`span`,{className:`bottom-panel-summary`,role:`status`,children:[E,` `,E===1?`subject`:`subjects`,D.length===0?``:` · ${D.reduce((e,t)=>e+t.subjects.length,0)} excluded`]}),(0,k.jsx)(`button`,{type:`button`,className:`bottom-panel-collapse`,"aria-expanded":r,"aria-controls":`bottom-panel-${i}`,"aria-label":r?`Collapse panel`:`Expand panel`,onClick:u,children:r?`▾`:`▴`})]}),r?(0,k.jsx)(`div`,{className:`bottom-panel-body`,id:`bottom-panel-${i}`,role:`tabpanel`,"aria-labelledby":`bottom-tab-${i}`,children:(0,k.jsxs)(`div`,{className:`query-tab`,children:[(0,k.jsxs)(`div`,{className:`query-tab-fields`,children:[(0,k.jsx)(aie,{fields:g,onChange:C}),(0,k.jsx)(j_,{showLifecycle:a,showEvidence:o,showOwnership:s,showNudges:c,onTogglePresentation:l})]}),(0,k.jsxs)(`div`,{className:`query-tab-outcome`,children:[(0,k.jsx)(`h3`,{children:`Matches`}),(0,k.jsxs)(`p`,{className:`query-match-count`,children:[(0,k.jsx)(`strong`,{children:E}),` `,E===1?`subject`:`subjects`,` of `,e.length]}),te?null:(0,k.jsx)(`p`,{className:`query-outcome-stale`,children:`Describing the query on the canvas, not the edit in progress.`}),E===0&&T!==null?(0,k.jsx)(`p`,{className:`query-outcome-empty`,children:`This query selects nothing.`}):null,ee===0?null:(0,k.jsxs)(`p`,{className:`query-outcome-note`,children:[ee,` a facet dropped `,ee===1?`is`:`are`,` drawn anyway: `,(0,k.jsx)(`code`,{children:`relationships: connected`}),` takes the other end of a relationship with it.`]}),(0,k.jsx)(`h3`,{children:`Excluded, and why`}),D.length===0?(0,k.jsx)(`p`,{className:`query-outcome-note`,children:`Nothing is left out of this view.`}):(0,k.jsx)(`ul`,{className:`query-exclusions`,children:D.map(e=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`query-exclusion-facet`,children:e.label}),` `,(0,k.jsx)(`span`,{className:`query-exclusion-count`,children:e.subjects.length}),(0,k.jsxs)(`ul`,{children:[e.subjects.slice(0,12).map(e=>(0,k.jsx)(`li`,{title:e.id,children:e.title},e.id)),e.subjects.length>12?(0,k.jsxs)(`li`,{className:`query-exclusion-more`,children:[`and `,e.subjects.length-12,` more`]}):null]})]},e.reason))})]}),(0,k.jsxs)(`div`,{className:`query-tab-document`,children:[(0,k.jsx)(`h3`,{children:`Document`}),ne===null?(0,k.jsx)(`p`,{className:`query-outcome-note`,children:m?`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,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`pre`,{className:`query-document`,children:Kre(uie(ne))}),m?null:(0,k.jsxs)(`div`,{className:`query-tab-actions`,children:[(0,k.jsx)(`button`,{type:`button`,disabled:!fie(ne),onClick:()=>{p(die(ne)),b(!0)},children:`Stage view change`}),(0,k.jsx)(`span`,{role:`status`,className:`query-stage-status`,children:y?`Staged. It lands when the changeset is committed.`:``})]})]})]})]})}):null]})}function mie({value:e,onChange:t}){return(0,k.jsx)(`input`,{type:`search`,className:`quick-filter`,value:e,onChange:e=>t(e.currentTarget.value),placeholder:`Filter by name or id…`,"aria-label":`Quick filter`})}var hie=`views`,gie=`model`,_ie=e=>`view-folder:${e}`,L_=e=>`model-layer:${e}`,vie=e=>`model-folder:${e}`,yie=`unlayered`,R_=(e,t)=>t===``||e.toLowerCase().includes(t),bie=(e,t)=>R_(e,ch(t)),z_=e=>e.presentation?.folder??``,xie=({views:e,stagedOperations:t,activeViewId:n,activeSubjects:r,filterText:i})=>{let a=ch(i),o=a!==``,s=r===null?null:Ene(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?z_(t):r.presentation?.folder??``,f=t.id===n;!R_(c,a)&&!R_(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??``;!R_(n,a)&&!R_(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:_ie(e),name:e,views:[...t].sort(d)}));return{folders:p,loose:f,matched:f.length+p.reduce((e,t)=>e+t.views.length,0)}},B_=({nodes:e,inViewIds:t,filterText:n})=>{let r=ch(n),i=new Map,a=new Map;for(let n of e){let e=n.layer,o=n.folder,s=o??e??`unlayered`;if(!lh(r,n.id,n.name,n.kindLabel)&&!R_(s,r))continue;let c={id:n.id,name:n.name,kindLabel:n.kindLabel,layer:e,folder:o,inView:t===null||t.has(n.id)},l=o===null?a:i,u=l.get(s);u===void 0?l.set(s,[c]):u.push(c)}let o=(e,t)=>e.name.localeCompare(t.name),s=[...i.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({key:vie(e),label:e,grouping:`folder`,subjects:[...t].sort(o)})),c=[...one,yie];return[...s,...c.flatMap(e=>{let t=a.get(e);return t===void 0||t.length===0?[]:[{key:L_(e),label:e,grouping:`layer`,subjects:[...t].sort(o)}]})]},Sie=`All subjects`,V_=`M2 3.5 5 6.5 8 3.5`,Cie=`M3.5 2 6.5 5 3.5 8`;function wie({open:e}){return(0,k.jsx)(`svg`,{width:`10`,height:`10`,viewBox:`0 0 10 10`,fill:`none`,"aria-hidden":!0,children:(0,k.jsx)(`path`,{d:e?V_:Cie,stroke:`currentColor`,strokeWidth:`1.2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function H_(){return(0,k.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":!0,children:[(0,k.jsx)(`rect`,{x:`1.5`,y:`2.5`,width:`9`,height:`7`,stroke:`currentColor`,strokeWidth:`1.2`}),(0,k.jsx)(`path`,{d:`M1.5 5h9`,stroke:`currentColor`,strokeWidth:`1.2`})]})}function U_({layer:e}){let t=e===null?null:oh[e];return(0,k.jsx)(`span`,{className:`tree-swatch`,style:t==null?void 0:{background:t.fill,borderColor:t.border},"aria-hidden":!0})}var W_=(e,t)=>n=>{n.preventDefault(),t(e,{x:n.clientX,y:n.clientY})};function G_({row:e,depth:t,onSelect:n,onMenu:r}){let i=e.staged!==`new`;return(0,k.jsx)(`li`,{children:(0,k.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?W_({kind:`view`,id:e.id},r):void 0,children:[(0,k.jsx)(H_,{}),(0,k.jsx)(`span`,{className:`tree-label`,children:e.title}),e.staged===null?null:(0,k.jsx)(`span`,{className:`tree-staged`,children:e.staged===`delete`?`staged delete`:`staged`}),e.subjectCount===null?null:(0,k.jsx)(`span`,{className:`tree-count`,children:e.subjectCount})]})})}function K_({label:e,open:t,count:n,depth:r,onToggle:i}){return(0,k.jsxs)(`button`,{type:`button`,className:`tree-row tree-branch tree-depth-${r}`,"aria-expanded":t,onClick:i,children:[(0,k.jsx)(wie,{open:t}),(0,k.jsx)(`span`,{className:`tree-label`,children:e}),n===void 0?null:(0,k.jsx)(`span`,{className:`tree-count`,children:n})]})}function Tie({views:e,stagedViewOperations:t,activeViewId:n,nodes:r,inViewIds:i,filterText:a,collapsed:o,onFilterChange:s,onToggle:c,onSelectView:l,onClearView:u,onNewView:d,onSelectSubject:f,onRowMenu:p,readOnly:m=!1}){let h=xie({views:e,stagedOperations:t,activeViewId:n,activeSubjects:i===null?null:r.filter(e=>i.has(e.id)),filterText:a}),g=B_({nodes:r,inViewIds:i,filterText:a}),_=!o.has(hie),v=!o.has(gie),y=a.trim()!==``,b=n===``&&i===null,x=bie(Sie,a);return(0,k.jsxs)(`aside`,{className:`view-tree`,"aria-label":`Views and model`,children:[(0,k.jsxs)(`div`,{className:`view-tree-head`,children:[(0,k.jsx)(`input`,{type:`search`,className:`view-tree-filter`,placeholder:`Filter tree`,"aria-label":`Filter views and subjects`,value:a,onChange:e=>s(e.currentTarget.value)}),m?null:(0,k.jsx)(`button`,{type:`button`,className:`view-tree-new`,title:`New view`,"aria-label":`New view`,onClick:d,children:(0,k.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 14 14`,fill:`none`,"aria-hidden":!0,children:(0,k.jsx)(`path`,{d:`M7 3v8M3 7h8`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinecap:`round`})})})]}),(0,k.jsxs)(`div`,{className:`view-tree-body`,children:[(0,k.jsx)(K_,{label:`Views`,open:_,depth:0,onToggle:()=>c(hie)}),_?(0,k.jsxs)(`ul`,{className:`tree-list`,children:[x?(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,className:`tree-row tree-view tree-depth-1${b?` tree-row-active`:``}`,"aria-current":b?`true`:void 0,onClick:u,onContextMenu:W_({kind:`view`,id:``},p),children:[(0,k.jsx)(H_,{}),(0,k.jsx)(`span`,{className:`tree-label`,children:Sie}),(0,k.jsx)(`span`,{className:`tree-count`,children:Ene(r,a)})]})}):null,h.loose.map(e=>(0,k.jsx)(G_,{row:e,depth:1,onSelect:l,onMenu:p},e.id)),h.folders.map(e=>{let t=y||!o.has(e.key);return(0,k.jsxs)(`li`,{children:[(0,k.jsx)(K_,{label:e.name,open:t,count:t?void 0:e.views.length,depth:1,onToggle:()=>c(e.key)}),t?(0,k.jsx)(`ul`,{className:`tree-list`,children:e.views.map(e=>(0,k.jsx)(G_,{row:e,depth:2,onSelect:l,onMenu:p},e.id))}):null]},e.key)}),!y||h.matched!==0||x?null:(0,k.jsx)(`li`,{className:`tree-empty`,children:`No view matches that.`})]}):null,(0,k.jsx)(K_,{label:`Model`,open:v,depth:0,onToggle:()=>c(gie)}),v?(0,k.jsxs)(`ul`,{className:`tree-list`,children:[g.map(e=>{let t=y||!o.has(e.key);return(0,k.jsxs)(`li`,{children:[(0,k.jsx)(K_,{label:e.label,open:t,count:t?void 0:e.subjects.length,depth:1,onToggle:()=>c(e.key)}),t?(0,k.jsx)(`ul`,{className:`tree-list`,children:e.subjects.map(e=>(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,className:`tree-row tree-subject tree-depth-2${e.inView?``:` tree-row-quiet`}`,title:`${e.name} — ${e.kindLabel}`,onClick:()=>f(e.id),onContextMenu:W_({kind:`subject`,id:e.id},p),children:[(0,k.jsx)(U_,{layer:e.layer}),(0,k.jsx)(`span`,{className:`tree-label`,children:e.name}),e.inView?null:(0,k.jsx)(`span`,{className:`tree-count`,children:`not in view`})]})},e.id))}):null]},e.key)}),g.length!==0||!y?null:(0,k.jsx)(`li`,{className:`tree-empty`,children:`No subject matches that.`})]}):null]})]})}var Eie=({id:e,taken:t,path:n,folder:r,title:i,description:a,query:o,layout:s,showLifecycle:c,showEvidence:l,showOwnership:u,carriedDirection:d})=>{let f=e??Xre(i,t);return{op:`write-view`,path:n??b_(f),projection:S_({id:f,title:i,description:a,query:o??{},presentation:{layout:s,...d===void 0?{}:{direction:d},...r===void 0||r===``?{}:{folder:r},showLifecycle:c,showEvidence:l,showOwnership:u}})}};function Die({activeView:e,presetFolder:t,onSubmit:n,onCancel:r}){let[i,a]=(0,v.useState)(e?.title??``),[o,s]=(0,v.useState)(e?.description??``),c=i.trim()===``||o.trim()===``,l=t!==void 0;return(0,k.jsx)(`div`,{className:`save-view-panel`,children:(0,k.jsx)(`div`,{id:`save-view-panel-body`,className:`save-view-panel-body`,children:(0,k.jsxs)(`form`,{className:`save-view-form`,onSubmit:t=>{t.preventDefault(),!c&&n(l?void 0:e?.id,i,o)},children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{htmlFor:`save-view-title`,children:`Title`}),(0,k.jsx)(`input`,{id:`save-view-title`,type:`text`,value:i,onChange:e=>a(e.currentTarget.value),required:!0})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`label`,{htmlFor:`save-view-description`,children:`Description`}),(0,k.jsx)(`textarea`,{id:`save-view-description`,value:o,onChange:e=>s(e.currentTarget.value),required:!0})]}),(0,k.jsxs)(`div`,{className:`save-view-actions`,children:[(0,k.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,k.jsx)(`button`,{type:`button`,disabled:c,onClick:()=>{c||n(void 0,i,o)},children:`Save As New`}),(0,k.jsx)(`button`,{type:`button`,onClick:r,children:`Cancel`})]})]})})})}function Oie({views:e,activeViewId:t,query:n,layout:r,showLifecycle:i,showEvidence:a,showOwnership:o,open:s,folder:c,onClose:l,onStage:u}){let d=e.find(e=>e.id===t)??null,f=(t,s,l)=>{u(Eie({id:t,taken:new Set(e.map(e=>e.id)),path:t===void 0?void 0:d?.path,folder:t===void 0?c:d?.presentation?.folder,title:s,description:l,query:n,layout:r,showLifecycle:i,showEvidence:a,showOwnership:o,carriedDirection:t===void 0?void 0:d?.presentation?.direction}))};return s?(0,k.jsx)(`div`,{className:`save-view-control`,children:(0,k.jsx)(Die,{activeView:d,presetFolder:c,onSubmit:(e,t,n)=>{f(e,t,n),l()},onCancel:l},t)}):null}function q_(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 kie=(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}},Aie=e=>{let t=new Set;for(let n of e)for(let e of n.subjects??[])t.add(e);return t},J_=(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},jie=(e,t,n)=>[...e.operations.map(e=>Nie(e,t)),...e.viewOperations.map(e=>Mie(e,n))],Mie=(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?[]:T_(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`}},Nie=(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=J_(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:J_(e.document,r.id,t),fields:Object.keys(r).filter(e=>e!==`id`),removedFields:n,scope:`model`}},Y_=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(`, `)}`},j=/^\/operations\/(\d+)(\/|$)/,X_=e=>{let t=new Map,n=[];for(let r of e){let e=j.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}},Pie=(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},Fie=({diagnostic:e})=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`code`,children:e.code}),` `,e.message,e.path===``?null:(0,k.jsxs)(`span`,{className:`where`,children:[e.path,`:`,e.line,`:`,e.column]})]}),Z_=({index:e,row:t,diagnostics:n,conflict:r,onDiscard:i})=>(0,k.jsxs)(`li`,{className:r===null?`changeset-row`:`changeset-row conflicted`,children:[(0,k.jsxs)(`div`,{className:`changeset-row-line`,children:[(0,k.jsx)(`span`,{className:`changeset-row-label`,children:Y_(t)}),(0,k.jsx)(`span`,{className:`changeset-row-scope changeset-scope-${t.scope}`,children:t.scope}),(0,k.jsx)(`button`,{type:`button`,className:`changeset-row-discard`,onClick:i,children:`Discard`})]}),r===null?null:(0,k.jsxs)(`p`,{className:`changeset-row-conflict`,role:`status`,children:[r,` changed after this edit was staged`]}),n.length===0?null:(0,k.jsx)(`ul`,{className:`changeset-row-diagnostics`,children:n.map(e=>(0,k.jsx)(Fie,{diagnostic:e},`${e.code}-${e.pointer}`))})]}),Iie=({state:e,onDiscardChange:t,onClearChangeset:n,onUndoChangeset:r,onRedoChangeset:i,onCommitChangeset:a})=>{let o=e.model?.graph??null,s=jie(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}=X_(e.commitDiagnostics??[]),u=e.commitStatus===`committing`;return(0,k.jsxs)(`section`,{className:`changeset-tray`,"aria-labelledby":`changeset-heading`,children:[(0,k.jsxs)(`div`,{className:`changeset-heading-row`,children:[(0,k.jsx)(`h2`,{id:`changeset-heading`,children:`Pending changes`}),(0,k.jsxs)(`div`,{className:`changeset-history-controls`,children:[(0,k.jsx)(`button`,{type:`button`,className:`changeset-undo`,disabled:e.undoStack.length===0,onClick:r,children:`Undo`}),(0,k.jsx)(`button`,{type:`button`,className:`changeset-redo`,disabled:e.redoStack.length===0,onClick:i,children:`Redo`}),s.length===0?null:(0,k.jsx)(`button`,{type:`button`,className:`changeset-discard-all`,onClick:n,children:`Discard all`})]})]}),e.commitDiagnostics===null||e.commitDiagnostics.length===0||o===null?null:(0,k.jsx)(`p`,{className:`changeset-fault-summary`,role:`status`,children:(()=>{let t=kie(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,k.jsx)(`ul`,{className:`changeset-batch-diagnostics`,role:`alert`,children:l.map(e=>(0,k.jsx)(Fie,{diagnostic:e},`${e.code}-${e.pointer}`))}),s.length===0?null:(0,k.jsx)(`ol`,{className:`changeset-rows`,children:s.map((n,r)=>(0,k.jsx)(Z_,{index:r,row:n,diagnostics:c.get(r)??[],conflict:Pie(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,k.jsx)(`div`,{className:`changeset-actions`,children:(0,k.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,k.jsxs)(`div`,{className:`changeset-notice`,role:`status`,children:[(0,k.jsxs)(`p`,{children:[`Committed · `,e.commitNotice.length,` `,e.commitNotice.length===1?`file`:`files`]}),(0,k.jsx)(`ul`,{children:e.commitNotice.map(e=>(0,k.jsx)(`li`,{children:e},e))})]})]})},Q_=e=>e.slice(e.lastIndexOf(`#`)+1),$_={a:`access`,c:`composition`,f:`flow`,g:`aggregation`,i:`assignment`,n:`influence`,o:`association`,r:`realization`,s:`specialization`,t:`triggering`,v:`serving`},ev=`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(`.`),tv={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`},nv=new Map(ev.map((e,t)=>[e,t])),rv=new Map(Object.entries($_)),iv=new Map;for(let e of ev){let t=tv[e].split(` `);for(let[n,r]of ev.entries()){let i=t[n]??`-`,a=new Set;for(let e of i){let t=rv.get(e);t!==void 0&&a.add(t)}iv.set(`${e}>${r}`,a)}}var Lie=new Set,av=e=>nv.has(e),ov=(e,t)=>iv.get(`${e}>${t}`)??Lie;new Map(ah.map(e=>[e.id,e.aspect]));var sv=sne,cv=(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||!av(r.coreKindLabel)||!av(i.coreKindLabel))return[];let a=[...ov(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},lv=(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}},uv=(e,t,n,r,i=[])=>{if(!cv(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:lv(e,t,n,r,i),kind:n,from:t,to:r}}},dv=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}),fv=(e,t,n,r)=>{let i=new Set(cv(e,t.from,t.to));if(i.size===0)return{options:n,narrowed:!1};let a=new Set(sv);return{options:n.filter(e=>i.has(e.coreLabel)||!a.has(e.coreLabel)||e.label===r),narrowed:!0}},pv=[`kind`,`name`,`description`,`status`,`owner`],mv=[`aka`,`constraints`,`references`,`presentIn`,`attestations`,`distinctFrom`,`supersedes`],hv=[`kind`,`from`,`to`,`name`,`description`,`status`,`mode`,`content`],gv=[`references`,`presentIn`],_v=(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)=>_v(e,t[n]));let n=e,r=t,i=Object.keys(n),a=Object.keys(r);return i.length===a.length&&i.every(e=>_v(n[e],r[e]))},Rie=(e,t)=>t===(e??``)?{kind:`none`}:t===``?{kind:`remove`}:{kind:`set`,value:t},vv=(e,t)=>_v(e,t)?{kind:`none`}:t.length>=e.length&&e.every((e,n)=>_v(e,t[n]))?{kind:`append`,added:t.slice(e.length)}:{kind:`replace`,next:t},zie=(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]},yv=(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}},bv=(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]},xv=(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}},Sv=(e,t,n,r,i)=>{let a=Rie(r,i);return a.kind===`none`?[]:a.kind===`remove`?[zie(e,t,n,!1,``)]:[zie(e,t,n,!0,a.value)]},Cv=(e,t,n,r,i)=>{let a=Rie(r,i);return a.kind===`none`?[]:a.kind===`remove`?[bv(e,t,n,!1,``)]:[bv(e,t,n,!0,a.value)]},wv=(e,t,n,r,i)=>{let a=vv(r,i);if(a.kind===`none`)return[];if(a.kind===`append`)return a.added.length===0?[]:[yv(e,t,n,a.added)];let o=[yv(e,t,n,null)];return a.next.length>0&&o.push(yv(e,t,n,a.next)),o},Bie=(e,t,n,r,i)=>{let a=vv(r,i);if(a.kind===`none`)return[];if(a.kind===`append`)return a.added.length===0?[]:[xv(e,t,n,a.added)];let o=[xv(e,t,n,null)];return a.next.length>0&&o.push(xv(e,t,n,a.next)),o},Vie=e=>e.expects===null?{id:e.id,ref:e.ref}:{id:e.id,ref:e.ref,expects:e.expects},Tv=(e,t,n,r)=>{let i=vv(n,r);if(i.kind===`none`)return[];if(i.kind===`append`)return i.added.length===0?[]:[yv(e,t,`constraints`,i.added.map(Vie))];let a=[yv(e,t,`constraints`,null)];return i.next.length>0&&a.push(yv(e,t,`constraints`,i.next.map(Vie))),a},Ev=e=>({topic:e.topic,by:e.by,recordedBy:e.recordedBy??``,on:e.on}),Dv=(e,t,n,r)=>{let i=vv(n,r);if(i.kind===`none`)return[];if(i.kind===`append`)return i.added.length===0?[]:[yv(e,t,`attestations`,i.added.map(Ev))];let a=[yv(e,t,`attestations`,null)];return i.next.length>0&&a.push(yv(e,t,`attestations`,i.next.map(Ev))),a},Ov=(e,t)=>{let n={...e},r=t.concept;for(let e of pv)r[e]!==void 0&&(n[e]=r[e]);for(let e of mv){let t=r[e];t!==void 0&&t.length>0&&(n[e]=[...n[e],...t])}for(let e of t.remove??[])n[e]=mv.includes(e)?[]:null;return n},kv=(e,t)=>{let n=e;for(let r of t)r.op===`update-concept`&&r.document===e.document&&r.concept.id===e.localId&&(n=Ov(n,r));return n},Hie=(e,t)=>{let n={...e},r=t.relationship;for(let e of hv)r[e]!==void 0&&(n[e]=r[e]);for(let e of gv){let t=r[e];t!==void 0&&t.length>0&&(n[e]=[...n[e],...t])}for(let e of t.remove??[])n[e]=gv.includes(e)?[]:null;return n},Uie=(e,t)=>{let n=e;for(let r of t)r.op===`update-relationship`&&r.document===e.document&&r.relationship.id===e.localId&&(n=Hie(n,r));return n},Av=({label:e,value:t,options:n,onCommit:r})=>(0,k.jsxs)(`label`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,k.jsx)(`select`,{value:t,onChange:e=>r(e.target.value),children:n.map(e=>(0,k.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),jv=({label:e,value:t,onCommit:n})=>{let[r,i]=(0,v.useState)(t);return(0,v.useEffect)(()=>i(t),[t]),(0,k.jsxs)(`label`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,k.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),onBlur:()=>n(r)})]})},Mv=({label:e,values:t,emptyRow:n,isRowFilled:r,renderRow:i,onCommit:a})=>{let[o,s]=(0,v.useState)(t);(0,v.useEffect)(()=>s(t),[t]);let c=e=>{s(e),a(e.filter(r))};return(0,k.jsxs)(`div`,{className:`subject-form-field subject-form-list`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:e}),o.map((e,t)=>(0,k.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,k.jsx)(`button`,{type:`button`,className:`subject-form-row-remove`,onClick:()=>c(o.filter((e,n)=>n!==t)),children:`Remove`})]},t)),(0,k.jsxs)(`button`,{type:`button`,className:`subject-form-row-add`,onClick:()=>s([...o,n]),children:[`Add `,e]})]})},Nv=({label:e,values:t,onCommit:n})=>(0,k.jsx)(Mv,{label:e,values:t,emptyRow:``,isRowFilled:e=>e.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n})=>(0,k.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),onBlur:n})}),Pv={id:``,ref:``},Fv=({label:e,values:t,onCommit:n})=>(0,k.jsx)(Mv,{label:e,values:t,emptyRow:Pv,isRowFilled:e=>e.id.trim()!==``&&e.ref.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n})=>(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`input`,{type:`text`,placeholder:`id`,value:e.id,onChange:n=>t({...e,id:n.target.value}),onBlur:n}),(0,k.jsx)(`input`,{type:`text`,placeholder:`ref`,value:e.ref,onChange:n=>t({...e,ref:n.target.value}),onBlur:n})]})}),M={id:``,ref:``,expects:null},Iv=({label:e,values:t,onCommit:n})=>(0,k.jsx)(Mv,{label:e,values:t,emptyRow:M,isRowFilled:e=>e.id.trim()!==``&&e.ref.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n,replace:r})=>(0,k.jsxs)(`div`,{className:`subject-form-row-body`,children:[(0,k.jsx)(`input`,{type:`text`,placeholder:`id`,value:e.id,onChange:n=>t({...e,id:n.target.value}),onBlur:n}),(0,k.jsx)(`input`,{type:`text`,placeholder:`ref`,value:e.ref,onChange:n=>t({...e,ref:n.target.value}),onBlur:n}),(0,k.jsxs)(`label`,{className:`subject-form-toggle`,children:[(0,k.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,k.jsxs)(`div`,{className:`subject-form-row-body`,children:[(0,k.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,k.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,k.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})]})]})}),Wie={topic:``,by:``,on:``,recordedBy:null},Gie=({label:e,values:t,onCommit:n})=>(0,k.jsx)(Mv,{label:e,values:t,emptyRow:Wie,isRowFilled:e=>e.topic.trim()!==``&&e.by.trim()!==``&&e.on.trim()!==``,onCommit:n,renderRow:(e,{set:t,commit:n})=>(0,k.jsxs)(`div`,{className:`subject-form-row-body`,children:[(0,k.jsx)(`input`,{type:`text`,placeholder:`topic`,value:e.topic,onChange:n=>t({...e,topic:n.target.value}),onBlur:n}),(0,k.jsx)(`input`,{type:`text`,placeholder:`by`,value:e.by,onChange:n=>t({...e,by:n.target.value}),onBlur:n}),(0,k.jsx)(`input`,{type:`text`,placeholder:`on`,value:e.on,onChange:n=>t({...e,on:n.target.value}),onBlur:n}),(0,k.jsx)(`input`,{type:`text`,placeholder:`recorded by`,value:e.recordedBy??``,onChange:n=>t({...e,recordedBy:n.target.value}),onBlur:n})]})}),Kie={value:``,label:`— unset —`},qie=[Kie,{value:`planned`,label:`planned`},{value:`current`,label:`current`},{value:`retired`,label:`retired`}],Jie=[Kie,{value:`read`,label:`read`},{value:`write`,label:`write`},{value:`read-write`,label:`read-write`},{value:`unspecified`,label:`unspecified`}],Lv=(e,t)=>t.find(t=>t.id===e)?.label??Q_(e),Yie=({node:e,model:t,operations:n,onStageChange:r})=>{let i=kv(e,n),a=e.document,o=e.localId,s=e=>e.forEach(r),c=t.vocabulary.conceptKinds.map(e=>({value:e.label,label:e.label})),l=Lv(i.kind,t.vocabulary.conceptKinds);return(0,k.jsxs)(`div`,{className:`subject-form`,children:[(0,k.jsxs)(`div`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,k.jsx)(`code`,{children:e.id})]}),(0,k.jsx)(Av,{label:`Kind`,value:l,options:c,onCommit:e=>s(Sv(a,o,`kind`,l,e))}),(0,k.jsx)(jv,{label:`Name`,value:i.name,onCommit:e=>s(Sv(a,o,`name`,i.name,e))}),(0,k.jsx)(jv,{label:`Description`,value:i.description??``,onCommit:e=>s(Sv(a,o,`description`,i.description,e))}),(0,k.jsx)(Av,{label:`Status`,value:i.status??``,options:qie,onCommit:e=>s(Sv(a,o,`status`,i.status,e))}),(0,k.jsx)(jv,{label:`Owner`,value:i.owner??``,onCommit:e=>s(Sv(a,o,`owner`,i.owner,e))}),(0,k.jsx)(Nv,{label:`Aka`,values:i.aka,onCommit:e=>s(wv(a,o,`aka`,i.aka,e))}),(0,k.jsx)(Nv,{label:`Distinct from`,values:i.distinctFrom,onCommit:e=>s(wv(a,o,`distinctFrom`,i.distinctFrom,e))}),(0,k.jsx)(Nv,{label:`Supersedes`,values:i.supersedes,onCommit:e=>s(wv(a,o,`supersedes`,i.supersedes,e))}),(0,k.jsx)(Nv,{label:`Present in`,values:i.presentIn,onCommit:e=>s(wv(a,o,`presentIn`,i.presentIn,e))}),(0,k.jsx)(Fv,{label:`References`,values:i.references,onCommit:e=>s(wv(a,o,`references`,i.references,e))}),(0,k.jsx)(Iv,{label:`Constraints`,values:i.constraints,onCommit:e=>s(Tv(a,o,i.constraints,e))}),(0,k.jsx)(Gie,{label:`Attestations`,values:i.attestations,onCommit:e=>s(Dv(a,o,i.attestations,e))})]})},Rv=({label:e,value:t})=>t===``?null:(0,k.jsxs)(`div`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:e}),(0,k.jsx)(`span`,{className:`subject-fact-value`,children:t})]}),Xie=({node:e,model:t})=>(0,k.jsxs)(`div`,{className:`subject-form subject-facts`,children:[(0,k.jsxs)(`div`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,k.jsx)(`code`,{children:e.id})]}),(0,k.jsx)(Rv,{label:`Kind`,value:Lv(e.kind,t.vocabulary.conceptKinds)}),(0,k.jsx)(Rv,{label:`Name`,value:e.name}),(0,k.jsx)(Rv,{label:`Status`,value:e.status??``}),(0,k.jsx)(Rv,{label:`Owner`,value:e.owner??``}),(0,k.jsx)(Rv,{label:`Aka`,value:e.aka.join(`, `)}),(0,k.jsx)(Rv,{label:`Distinct from`,value:e.distinctFrom.join(`, `)}),(0,k.jsx)(Rv,{label:`Supersedes`,value:e.supersedes.join(`, `)}),(0,k.jsx)(Rv,{label:`Present in`,value:e.presentIn.join(`, `)}),(0,k.jsx)(Rv,{label:`References`,value:e.references.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,k.jsx)(Rv,{label:`Constraints`,value:e.constraints.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,k.jsx)(Rv,{label:`Attestations`,value:e.attestations.map(e=>`${e.topic} by ${e.by} on ${e.on}`).join(`; `)})]}),Zie=({edge:e,model:t})=>{let n=e=>t.graph.nodes.find(t=>t.id===e)?.name??e;return(0,k.jsxs)(`div`,{className:`subject-form subject-facts`,children:[(0,k.jsxs)(`div`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,k.jsx)(`code`,{children:e.id})]}),(0,k.jsx)(Rv,{label:`Kind`,value:Lv(e.kind,t.vocabulary.relationshipKinds)}),(0,k.jsx)(Rv,{label:`From`,value:n(e.from)}),(0,k.jsx)(Rv,{label:`To`,value:n(e.to)}),(0,k.jsx)(Rv,{label:`Name`,value:e.name??``}),(0,k.jsx)(Rv,{label:`Mode`,value:e.mode??``}),(0,k.jsx)(Rv,{label:`Content`,value:e.content??``}),(0,k.jsx)(Rv,{label:`Status`,value:e.status??``}),(0,k.jsx)(Rv,{label:`References`,value:e.references.map(e=>`${e.id}: ${e.ref}`).join(`; `)}),(0,k.jsx)(Rv,{label:`Present in`,value:e.presentIn.join(`, `)})]})},Qie=({edge:e,model:t,operations:n,onStageChange:r})=>{let i=Uie(e,n),a=e.document,o=e.localId,s=e=>e.forEach(r),c=Lv(i.kind,t.vocabulary.relationshipKinds),l=fv(t.graph,{from:i.from,to:i.to},t.vocabulary.relationshipKinds,c).options.map(e=>({value:e.label,label:e.label})),u=t.graph.nodes.map(e=>({value:e.id,label:e.name}));return(0,k.jsxs)(`div`,{className:`subject-form`,children:[(0,k.jsxs)(`div`,{className:`subject-form-field`,children:[(0,k.jsx)(`span`,{className:`subject-form-label`,children:`Identity`}),(0,k.jsx)(`code`,{children:e.id})]}),(0,k.jsx)(Av,{label:`Kind`,value:c,options:l,onCommit:e=>s(Cv(a,o,`kind`,c,e))}),(0,k.jsx)(Av,{label:`From`,value:i.from,options:u,onCommit:e=>s(Cv(a,o,`from`,i.from,e))}),(0,k.jsx)(Av,{label:`To`,value:i.to,options:u,onCommit:e=>s(Cv(a,o,`to`,i.to,e))}),(0,k.jsx)(jv,{label:`Name`,value:i.name??``,onCommit:e=>s(Cv(a,o,`name`,i.name,e))}),(0,k.jsx)(jv,{label:`Description`,value:i.description??``,onCommit:e=>s(Cv(a,o,`description`,i.description,e))}),(0,k.jsx)(Av,{label:`Mode`,value:i.mode??``,options:Jie,onCommit:e=>s(Cv(a,o,`mode`,i.mode,e))}),(0,k.jsx)(jv,{label:`Content`,value:i.content??``,onCommit:e=>s(Cv(a,o,`content`,i.content,e))}),(0,k.jsx)(Av,{label:`Status`,value:i.status??``,options:qie,onCommit:e=>s(Cv(a,o,`status`,i.status,e))}),(0,k.jsx)(Fv,{label:`References`,values:i.references,onCommit:e=>s(Bie(a,o,`references`,i.references,e))}),(0,k.jsx)(Nv,{label:`Present in`,values:i.presentIn,onCommit:e=>s(Bie(a,o,`presentIn`,i.presentIn,e))})]})};function $ie({overlay:e,selectedId:t}){let n=t===null?e.workspace:e.subjects[t]??[],r=t===null?`Whole-model questions. Select a subject to see what names it.`:null;return(0,k.jsxs)(`div`,{className:`open-questions`,children:[r===null?null:(0,k.jsx)(`p`,{className:`open-questions-scope`,children:r}),n.length===0?(0,k.jsx)(`p`,{className:`section-empty`,children:t===null?`Nothing open at the whole-model level.`:`No open questions name this subject.`}):(0,k.jsx)(`ul`,{className:`question-list`,children:n.map(e=>(0,k.jsx)(eae,{entry:e},e.questionId))}),(0,k.jsxs)(`p`,{className:`open-questions-catalogue`,children:[`Catalogue `,e.catalogue,` · answers land through the changeset, never here.`]})]})}var eae=({entry:e})=>(0,k.jsxs)(`li`,{className:`question-row`,children:[(0,k.jsx)(`span`,{className:`question-text`,children:e.question}),(0,k.jsxs)(`span`,{className:`question-meta`,children:[(0,k.jsx)(`span`,{className:`question-authority question-authority-${e.authority}`,children:e.authority}),e.since===void 0?null:(0,k.jsxs)(`span`,{className:`question-since`,children:[`since `,e.since]})]})]}),zv=[`composition`],tae=`top-down`,Bv=e=>{let t=e?.trim()??``;return t===``?null:t},Vv=e=>({type:`element`,id:e.id,title:e.name,kind:e.kindLabel,description:Bv(e.description)}),Hv=(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:Bv(e.name),description:Bv(e.description),kind:e.kindLabel}},Uv=e=>new Map(e.nodes.map(e=>[e.id,e.name])),nae=(e,t)=>{let n=e.nodes.find(e=>e.id===t);return n===void 0?null:Vv(n)},rae=(e,t)=>{let n=e.edges.find(e=>e.id===t);return n===void 0?null:Hv(n,Uv(e))},iae=(e,t,n,r)=>({select:n=>{let{graph:r}=e();if(r===null)return!1;let i=nae(r,n)??rae(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)},setDecorations:e=>(r(e),!0)}),aae=[`palette`,`properties`,`questions`,`changes`,`chat`],oae=e=>({min:96,max:Math.max(96,e-160)}),Wv=(e,t)=>{let{min:n,max:r}=oae(t);return Math.min(r,Math.max(n,e))},sae=.45,cae=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),lae=e=>{let t=[];return e?.layout!==void 0&&t.push({type:`layout.set`,layout:e.layout}),t.push({type:`nesting.set`,nesting:e?.nesting??zv}),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}),t},Gv=(e,t,n,r)=>!r||e===``||e===n?null:t.find(t=>t.id===e)??null,Kv=e=>({min:320,max:Math.max(320,Math.min(640,e*sae))}),qv=(e,t)=>{let{min:n,max:r}=Kv(t);return Math.min(r,Math.max(n,e))},Jv=480,Yv=(e,t)=>{let{min:n,max:r}=Kv(t);return Math.min(Math.min(r,Jv),Math.max(n,e))},Xv=(e,t=0)=>({conversation:{width:Yv(e*.28,e),hidden:!1,unread:0,collapsed:[],changesHeight:200,chatHeight:300},viewportWidth:e,viewportHeight:t,selectedSubject:null,descriptionExpanded:!1,detailsOpen:!1,bottomPanel:{open:!1,tab:`view-query`},tree:{filterText:``,collapsed:[]},connection:null,draftingSubject:!1,pendingDeletion:null,pendingViewDeletion:null,pendingViewRename:null,contextMenu:null,nesting:zv,direction:tae,layout:`layered`,showLifecycle:!0,showEvidence:!0,showOwnership:!1,showNudges:!0}),Zv=(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=Wv(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=qv(t.width,e.viewportWidth);return n===e.conversation.width?e:{...e,conversation:{...e.conversation,width:n}}}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=qv(e.conversation.width,t.viewportWidth),r=t.viewportHeight??e.viewportHeight,i=Wv(e.conversation.changesHeight,r),a=Wv(e.conversation.chatHeight,r);return n===e.conversation.width&&i===e.conversation.changesHeight&&a===e.conversation.chatHeight&&t.viewportWidth===e.viewportWidth&&r===e.viewportHeight?e:{...e,conversation:{...e.conversation,width:n,changesHeight:i,chatHeight:a},viewportWidth:t.viewportWidth,viewportHeight:r}}case`attention.received`:return e.conversation.hidden||e.conversation.collapsed.includes(`chat`)?{...e,conversation:{...e.conversation,unread:e.conversation.unread+1}}:e;case`menu.opened`:return{...e,contextMenu:{target:t.target,x:t.x,y:t.y}};case`menu.dismissed`:return e.contextMenu===null?e:{...e,contextMenu:null};case`connection.started`:return{...e,connection:{from:t.from,to:null},draftingSubject:!1,contextMenu:null};case`connection.targeted`:return e.connection===null?e:t.to===e.connection.from?{...e,connection:null}:{...e,connection:{...e.connection,to:t.to}};case`connection.cancelled`:return e.connection===null?e:{...e,connection:null};case`subject.draft.opened`:return{...e,draftingSubject:!0,connection:null,contextMenu:null};case`subject.draft.closed`:return e.draftingSubject?{...e,draftingSubject:!1}:e;case`deletion.asked`:return{...e,pendingDeletion:t.id,connection:null,draftingSubject:!1,contextMenu:null};case`deletion.dismissed`:return e.pendingDeletion===null?e:{...e,pendingDeletion:null};case`viewDeletion.asked`:return{...e,pendingViewDeletion:t.id,contextMenu:null};case`viewDeletion.dismissed`:return e.pendingViewDeletion===null?e:{...e,pendingViewDeletion:null};case`viewRename.asked`:return{...e,pendingViewRename:t.id,contextMenu:null};case`viewRename.dismissed`:return e.pendingViewRename===null?e:{...e,pendingViewRename:null};case`subject.selected`:return{...e,conversation:{...e.conversation,collapsed:e.conversation.collapsed.filter(e=>e!==`properties`)},selectedSubject:t.subject,descriptionExpanded:!1,contextMenu:null};case`subject.cleared`:return e.selectedSubject===null?e:{...e,selectedSubject:null,descriptionExpanded:!1};case`description.toggled`:return e.selectedSubject===null?e:{...e,descriptionExpanded:!e.descriptionExpanded};case`details.toggled`:return{...e,detailsOpen:!e.detailsOpen};case`bottomPanel.toggled`:return{...e,bottomPanel:{...e.bottomPanel,open:!e.bottomPanel.open}};case`bottomPanel.tabSelected`:return e.bottomPanel.open&&e.bottomPanel.tab===t.tab?e:{...e,bottomPanel:{open:!0,tab:t.tab}};case`tree.filtered`:return e.tree.filterText===t.filterText?e:{...e,tree:{...e.tree,filterText:t.filterText}};case`tree.toggled`:{let n=e.tree.collapsed.includes(t.key);return{...e,tree:{...e.tree,collapsed:n?e.tree.collapsed.filter(e=>e!==t.key):[...e.tree.collapsed,t.key]}}}case`nesting.set`:return cae(e.nesting,t.nesting)?e:{...e,nesting:t.nesting};case`direction.set`:return e.direction===t.direction?e:{...e,direction:t.direction};case`layout.set`:return{...e,layout:t.layout};case`presentation.toggled`:return{...e,[t.flag]:t.value};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`?nae(i,r.id):rae(i,r.id);return a===null?{...n,selectedSubject:null,descriptionExpanded:!1}:{...n,selectedSubject:a}}}},Qv=(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 $v({id:e,label:t,meta:n,open:r,onToggle:i,children:a}){return(0,k.jsxs)(`section`,{className:`stack-section stack-section-${e}`,children:[(0,k.jsxs)(`h2`,{className:`section-head`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`section-toggle`,"aria-expanded":r,"aria-controls":`section-${e}`,onClick:i,children:[(0,k.jsx)(`span`,{className:`section-chevron`,"aria-hidden":`true`,children:r?`▾`:`▸`}),(0,k.jsx)(`span`,{className:`section-label`,children:t})]}),n===void 0?null:(0,k.jsx)(`span`,{className:`section-meta`,children:n})]}),(0,k.jsx)(`div`,{className:`section-body`,id:`section-${e}`,hidden:!r,children:a})]})}function ey({label:e,height:t,viewportHeight:n,onResize:r}){let i=oae(n),a=(0,v.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,k.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 ty=(e,t,n)=>aae.filter(t=>e.includes(t)).flatMap((e,r)=>{let i=r===0?void 0:n[e];return[...i===void 0?[]:[(0,k.jsx)(v.Fragment,{children:i},`splitter-${e}`)],(0,k.jsx)(v.Fragment,{children:t[e]},e)]}),ny={messageBytes:65536,modelBytes:5242880,transcriptBytes:5242880,pendingEvents:32,reconnectMs:3e5,staleSessionMs:864e5}.reconnectMs,ry=`Returning control to the main agent`,iy={operations:[],viewOperations:[],sourceDigests:{}},ay=e=>e.operations.length===0&&e.viewOperations.length===0,oy={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,quickFilterText:``,closedReason:null,pendingChangeset:iy,undoStack:[],redoStack:[],commitStatus:`idle`,commitDiagnostics:null,commitNotice:null,layoutNotice:null},sy=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}),cy=(e,t)=>t-e<ny,ly=(e,t,n)=>({id:`local-${e.localRecords}`,speaker:t,text:n}),uy=(e,t)=>e.transcript.some(e=>e.id===t.id)?e.transcript:[...e.transcript,t],dy=e=>e.initialView,fy={awaitingAgent:!1,agentStatus:null},py=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`])}`},my=(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},hy=(e,t,n)=>{let r=n.operations??e.operations,i=n.viewOperations??e.viewOperations;return{operations:r,viewOperations:i,sourceDigests:my(r,i,e.sourceDigests,t)}},uae=(e,t)=>{switch(t.type){case`session.loaded`:return{...e,...t.snapshot,lifecycle:e.lifecycle===`ending`?`ending`:`active`,activeView:dy(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,...fy};case`chat.sent`:return{...e,transcript:uy(e,ly(e,`reviewer`,t.text)),localRecords:e.localRecords+1,choices:null,awaitingAgent:!0};case`chat.received`:return{...e,transcript:uy(e,{id:t.id,speaker:`agent`,text:t.text}),...fy};case`status.received`:return{...e,agentStatus:t.status};case`choice.presented`:return{...e,choices:t.choice,...fy};case`choice.sent`:{let n=e.choices?.options.find(e=>e.id===t.optionId);return n===void 0?e:{...e,transcript:uy(e,ly(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};case`handoff.received`:return{...e,handoff:t.handoff,transcript:uy(e,{id:t.id,speaker:`agent`,text:t.handoff.summary}),...fy};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`)?fy:{}}}case`end.requested`:return{...e,lifecycle:`ending`,choices:null,transcript:uy(e,ly(e,`session`,ry)),localRecords:e.localRecords+1};case`connection.lost`:return{...e,lifecycle:`disconnected`};case`session.closed`:return{...e,lifecycle:`closed`,closedReason:t.reason};case`filter.applied`:return{...e,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,activeFilter:null,activeView:``};case`quickFilter.changed`:return e.quickFilterText===t.text?e:{...e,quickFilterText:t.text};case`changeset.staged`:{let n=py(t.operation),r=[...e.pendingChangeset.operations.filter(e=>py(e)!==n),t.operation];return{...e,pendingChangeset:hy(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:hy(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=S_({id:n.id,title:n.title,description:n.description,query:n.query,presentation:n.presentation}),a=w_(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=eie(a,i);return{...e,pendingChangeset:hy(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:hy(e.pendingChangeset,e.model,a),undoStack:[...e.undoStack,e.pendingChangeset],redoStack:[],commitDiagnostics:null}}case`changeset.cleared`:{let t=ay(e.pendingChangeset);return{...e,pendingChangeset:iy,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:iy,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}}}},dae=e=>e.lifecycle===`active`&&e.chatEnabled&&!e.frozen&&!e.awaitingAgent;function fae(e,t){if(e.lifecycle===`closed`)return e;let n=uae(e,t);return n===e?e:{...n,composerEnabled:dae(n)}}var gy=(e,t)=>{let n=t.lastSequence;switch(e.kind){case`chat`:return{type:`chat.message`,lastAcknowledgedSequence:n,payload:{text:e.text}};case`choice`:return{type:`choice.selected`,lastAcknowledgedSequence:n,payload:{choiceId:e.choiceId,optionId:e.optionId}};case`navigate`:return{type:`view.navigate`,lastAcknowledgedSequence:n,payload:{viewId:e.viewId,requiresAttention:!1}};case`end`:return{type:`session.end`,lastAcknowledgedSequence:n,payload:{reason:`user-ended`}};case`filter`:return{type:`filter.query`,lastAcknowledgedSequence:n,payload:{query:e.query}};case`commit-changeset`:return{type:`changeset.commit`,lastAcknowledgedSequence:n,payload:t.pendingChangeset};case`save-layout`:return{type:`layout.save`,lastAcknowledgedSequence:n,payload:e.payload}}},pae=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 C_(r)?{kind:`enumerated`,subjects:r.subjects}:{kind:`faceted`,excluded:r.exclude??[]}},mae=(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}},hae=(e,t=`panel`)=>{switch(e.kind){case`ready`:return[{type:`session.loaded`,snapshot:sy(e.snapshot)}];case`accepted`:return[{type:`event.acknowledged`,sequence:e.sequence}];case`rejected`:return[{type:`input.refused`,...e.refused===void 0?{}:{refused:e.refused},diagnostics:e.diagnostics,frozen:e.frozen!==void 0}];case`model`:return[{type:`model.received`,model:e.model,views:e.views}];case`closing`:return[{type:`session.closed`,reason:e.reason}];case`filter-result`:return[{type:`filter.applied`,query:e.result.query,matchedIds:e.result.matchedIds,excluded:e.result.excluded,source:t}];case`response`:switch(e.response.type){case`chat.response`:{let t=[{type:`chat.received`,id:e.response.responseId,text:e.response.payload.text}],n=e.response.payload.appliedQuery;return n&&t.push({type:`filter.applied`,query:n.query,matchedIds:n.matchedIds??[],excluded:null,source:`chat`}),t}case`agent.status`:return[{type:`status.received`,status:e.response.payload}];case`choice.present`:return[{type:`choice.presented`,choice:e.response.payload}];case`handoff.complete`:return[{type:`handoff.received`,id:e.response.responseId,handoff:e.response.payload}];case`diagnostic`:return[{type:`diagnostic.received`,diagnostics:e.response.payload.diagnostics}]}case`apply-result`:{let t=[];return e.result.ok?t.push({type:`changeset.committed`,documents:e.result.result.documents}):t.push({type:`apply.failed`,diagnostics:e.result.diagnostics}),t}case`layout-save-result`:return[{type:`layout.saved`,result:e.result}]}},gae=e=>{let[t,n]=(0,v.useReducer)(fae,oy),[r,i]=(0,v.useState)(!1),a=(0,v.useRef)(t);a.current=t;let o=(0,v.useRef)(`panel`),s=(0,v.useRef)(e);s.current=e,(0,v.useEffect)(()=>s.current.open({frame:e=>{for(let t of hae(e,o.current))n(t);let t=mae(e,a.current);t!==null&&(o.current=t.source,s.current.send(gy({kind:`filter`,query:t.query},a.current)))},connected:i,lost:()=>n({type:`connection.lost`}),session:()=>({lastSequence:a.current.lastSequence,closed:a.current.lifecycle===`closed`})}),[]);let c=(0,v.useCallback)(e=>{s.current.send(gy(e,a.current))},[]),l=(0,v.useCallback)(e=>{n({type:`chat.sent`,text:e}),c({kind:`chat`,text:e})},[c]),u=(0,v.useCallback)(e=>{let t=a.current.choices?.choiceId;t!==void 0&&(n({type:`choice.sent`,optionId:e}),c({kind:`choice`,choiceId:t,optionId:e}))},[c]),d=(0,v.useCallback)(e=>{n({type:`view.navigated`,viewId:e}),c({kind:`navigate`,viewId:e})},[c]),f=(0,v.useCallback)((e,t=`panel`)=>{o.current=t,c({kind:`filter`,query:e})},[c]),p=(0,v.useCallback)(()=>{n({type:`filter.cleared`})},[]),m=(0,v.useCallback)(e=>{n({type:`quickFilter.changed`,text:e})},[]),h=(0,v.useCallback)(e=>{n({type:`changeset.staged`,operation:e})},[]);return{state:t,connected:r,ask:l,choose:u,navigate:d,filter:f,clearFilter:p,setQuickFilterText:m,stageViewChange:(0,v.useCallback)(e=>{n({type:`changeset.viewStaged`,operation:e})},[]),stageViewMembership:(0,v.useCallback)((e,t,r)=>{n({type:`changeset.viewMembership`,viewId:e,subjectId:t,membership:r})},[]),stageChange:h,discardChange:(0,v.useCallback)(e=>{n({type:`changeset.discarded`,index:e})},[]),clearChangeset:(0,v.useCallback)(()=>{n({type:`changeset.cleared`})},[]),undoChangeset:(0,v.useCallback)(()=>{n({type:`changeset.undone`})},[]),redoChangeset:(0,v.useCallback)(()=>{n({type:`changeset.redone`})},[]),commitChangeset:(0,v.useCallback)(()=>{ay(a.current.pendingChangeset)||(n({type:`changeset.commit.sent`}),c({kind:`commit-changeset`}))},[c]),saveLayout:(0,v.useCallback)(e=>{c({kind:`save-layout`,payload:e})},[c]),end:(0,v.useCallback)(()=>{n({type:`end.requested`}),c({kind:`end`})},[c])}},_ae=({draft:e,graph:t,reservedIds:n,onStage:r,onCancel:i})=>{let a=e=>t.nodes.find(t=>t.id===e)?.name??e;if(e.to===null)return(0,k.jsxs)(`section`,{className:`connection-panel`,"aria-label":`Connect subjects`,children:[(0,k.jsxs)(`p`,{className:`connection-prompt`,children:[`Connecting from `,(0,k.jsx)(`strong`,{children:a(e.from)}),`. Choose a target on the diagram.`]}),(0,k.jsx)(`button`,{type:`button`,onClick:i,children:`Cancel`})]});let o=e.to,s=cv(t,e.from,o);return(0,k.jsxs)(`section`,{className:`connection-panel`,"aria-label":`Connect subjects`,children:[(0,k.jsxs)(`p`,{className:`connection-prompt`,children:[(0,k.jsx)(`strong`,{children:a(e.from)}),` to`,` `,(0,k.jsx)(`strong`,{children:a(o)})]}),s.length===0?(0,k.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,k.jsx)(`ul`,{className:`connection-kinds`,children:s.map(a=>(0,k.jsx)(`li`,{children:(0,k.jsx)(`button`,{type:`button`,onClick:()=>{let s=uv(t,e.from,a,o,n);s!==null&&r(s),i()},children:a})},a))}),(0,k.jsx)(`button`,{type:`button`,onClick:i,children:`Cancel`})]})},vae=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,_y=(e,t,n=[])=>{let r=t.normalize(`NFKD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase();if(r===``||!vae.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}},yae=(e,t,n,r=[])=>{if(t.document===``||!n.includes(t.kind))return null;let i=t.name.trim();if(i===``)return null;let a=_y(e,i,r);return a===null?null:{op:`add-concept`,document:t.document,concept:{id:a,kind:t.kind,name:i}}},vy=({graph:e,kinds:t,documents:n,defaultDocument:r,initialKind:i,reservedIds:a,onStage:o,onCancel:s})=>{let[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(i??``),[f,p]=(0,v.useState)(r),m=c.trim()===``?null:_y(e,c,a),h=m===null?null:yae(e,{name:c,kind:u,document:f},t.map(e=>e.label),a);return(0,k.jsxs)(`section`,{className:`subject-draft-panel`,"aria-label":`Add a subject`,children:[(0,k.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`subject-draft-name`,children:[(0,k.jsx)(`span`,{children:`Name`}),(0,k.jsx)(`input`,{id:`subject-draft-name`,type:`text`,value:c,onChange:e=>l(e.target.value)})]}),(0,k.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`subject-draft-kind`,children:[(0,k.jsx)(`span`,{children:`Kind`}),(0,k.jsxs)(`select`,{id:`subject-draft-kind`,value:u,onChange:e=>d(e.target.value),children:[(0,k.jsx)(`option`,{value:``,children:`Choose a kind`}),t.map(e=>(0,k.jsx)(`option`,{value:e.label,children:e.label},e.id))]})]}),(0,k.jsxs)(`label`,{className:`subject-draft-field`,htmlFor:`subject-draft-document`,children:[(0,k.jsx)(`span`,{children:`Document`}),(0,k.jsx)(`select`,{id:`subject-draft-document`,value:f,onChange:e=>p(e.target.value),children:n.map(e=>(0,k.jsx)(`option`,{value:e,children:e},e))})]}),(0,k.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,k.jsxs)(k.Fragment,{children:[`Id: `,(0,k.jsx)(`code`,{children:m})]})}),(0,k.jsx)(`button`,{type:`button`,disabled:h===null,onClick:()=>{h!==null&&(o(h),s())},children:`Add`}),(0,k.jsx)(`button`,{type:`button`,onClick:s,children:`Cancel`})]})};function yy({title:e,message:t,confirmLabel:n,cancelLabel:r,onConfirm:i,onCancel:a}){return(0,k.jsx)(`div`,{className:`confirm-dialog-backdrop`,role:`presentation`,onClick:a,children:(0,k.jsxs)(`div`,{className:`confirm-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`confirm-dialog-title`,onClick:e=>e.stopPropagation(),children:[(0,k.jsx)(`h2`,{id:`confirm-dialog-title`,children:e}),(0,k.jsx)(`p`,{children:t}),(0,k.jsxs)(`div`,{className:`confirm-dialog-actions`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:a,children:r}),(0,k.jsx)(`button`,{type:`button`,onClick:i,children:n})]})]})})}function by({title:e,label:t,initialValue:n,confirmLabel:r,cancelLabel:i,onConfirm:a,onCancel:o}){let[s,c]=(0,v.useState)(n),l=s.trim()===``;return(0,k.jsx)(`div`,{className:`confirm-dialog-backdrop`,role:`presentation`,onClick:o,children:(0,k.jsxs)(`div`,{className:`confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`prompt-dialog-title`,onClick:e=>e.stopPropagation(),children:[(0,k.jsx)(`h2`,{id:`prompt-dialog-title`,children:e}),(0,k.jsxs)(`form`,{className:`prompt-dialog-form`,onSubmit:e=>{e.preventDefault(),!l&&a(s.trim())},children:[(0,k.jsx)(`label`,{htmlFor:`prompt-dialog-value`,children:t}),(0,k.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,k.jsxs)(`div`,{className:`confirm-dialog-actions`,children:[(0,k.jsx)(`button`,{type:`button`,onClick:o,children:i}),(0,k.jsx)(`button`,{type:`submit`,disabled:l,children:r})]})]})]})})}var xy=new Set([`subject.inspect`,`relationship.inspect`,`view.open`,`view.clear`,`view.copy-path`,`canvas.export-png`]),Sy=(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}}]}],Cy={key:`view.new`,label:`New view…`,intent:{type:`view.new`}},wy={key:`view.new-folder`,label:`New folder…`,intent:{type:`view.new-folder`}},Ty={key:`view.clear`,label:`Show all subjects`,intent:{type:`view.clear`}},Ey=(e,t)=>({key:`delete`,scope:`model`,label:null,destructive:!0,items:[{key:`delete`,label:t,intent:e}]}),bae=(e,t)=>t.graph?.nodes.find(t=>t.id===e)===void 0?[]:[...Sy(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}}]},Ey({type:`subject.delete`,id:e},`Delete from model…`)],xae=(e,t)=>{let n=t.graph,r=n?.edges.find(t=>t.id===e);if(n==null||r===void 0)return[];let i=fv(n,{from:r.from,to:r.to},t.relationshipKinds,r.kindLabel),a=[{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(Ey({type:`relationship.delete`,id:e},`Delete from model…`)),a},Dy=e=>e.graph===null?[]:[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:[Cy,wy,...e.filtered?[Ty]:[],{key:`canvas.export-png`,label:`Export PNG`,intent:{type:`canvas.export-png`}}]},{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`add`,label:`Add subject…`,intent:{type:`canvas.draft-subject`}}]}],Oy=(e,t)=>{let n=[{key:`view`,scope:`view`,label:`View`,destructive:!1,items:e===``?[Ty,Cy,wy]:[{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}},Cy,wy,{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},ky=(e,t)=>t.graph?.nodes.find(t=>t.id===e)===void 0?[]:[...Sy(e,t),{key:`model`,scope:`model`,label:`Model`,destructive:!1,items:[{key:`inspect`,label:`Properties`,intent:{type:`subject.inspect`,id:e}}]},Ey({type:`subject.delete`,id:e},`Delete from model…`)],Ay=(e,t)=>{let n=(()=>{switch(e.kind){case`subject`:return bae(e.id,t);case`relationship`:return xae(e.id,t);case`canvas`:return Dy(t);case`view-row`:return Oy(e.id,t);case`model-row`:return ky(e.id,t)}})();return t.readOnly===!0?n.flatMap(e=>{let t=e.items.filter(e=>xy.has(e.intent.type));return t.length===0?[]:[{...e,items:t}]}):n},jy=(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 My({groups:e,x:t,y:n,onChoose:r,onDismiss:i}){let a=(0,v.useRef)(null),[o,s]=(0,v.useState)(null);return(0,v.useLayoutEffect)(()=>{let e=a.current;if(e===null)return;let r=e.getBoundingClientRect();s(jy({x:t,y:n},{width:r.width,height:r.height},{width:window.innerWidth,height:window.innerHeight})),e.focus()},[t,n,e]),(0,v.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,k.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,k.jsxs)(`div`,{className:`context-menu-group context-menu-${e.scope}${e.destructive?` context-menu-destructive`:``}`,children:[e.label===null?null:(0,k.jsx)(`p`,{className:`context-menu-heading`,children:e.label}),(0,k.jsx)(`ul`,{children:e.items.map(e=>(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,className:`context-menu-item`,"aria-current":e.current===!0?`true`:void 0,onClick:()=>r(e.intent),children:[(0,k.jsx)(`span`,{className:`context-menu-tick`,"aria-hidden":!0,children:e.current===!0?`•`:``}),(0,k.jsx)(`span`,{className:`context-menu-label`,children:e.label})]})},e.key))})]},e.key))})}var Ny=(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},Sae=(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}}]},Cae=(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=Ny(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.`},wae={reviewer:`You`,agent:`Agent`,session:`Session`},Py={thinking:`Agent is thinking`,compiling:`Agent is compiling the model`,waiting:`Agent is waiting`,idle:`Agent is idle`},Tae=(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`}},Eae=e=>e.lifecycle===`closed`?`Visual conversation ended. Continue in the main agent.`:e.lifecycle===`ending`?e.handoff===null?`Ending conversation — preparing a handoff for the main agent.`:`Handoff ready — returning control to the main agent.`:``,Fy=({state:e,connection:t})=>(0,k.jsxs)(`header`,{className:`command-strip`,children:[(0,k.jsxs)(`div`,{className:`command-identity`,children:[(0,k.jsx)(`h1`,{children:e.title===``?`Opening the session`:e.title}),(0,k.jsx)(`span`,{className:`beta-badge`,children:`Beta`}),(0,k.jsx)(`span`,{className:`authority`,children:`Checked YarraMate model`}),(0,k.jsx)(`span`,{className:`connection-state`,role:`status`,children:t})]}),e.description===``?null:(0,k.jsx)(`p`,{className:`session-description`,title:e.description,children:e.description})]}),Dae=({choices:e,disabled:t,onChoice:n})=>(0,k.jsxs)(`div`,{className:`choices`,children:[(0,k.jsx)(`p`,{className:`question`,children:e.question}),(0,k.jsx)(`ul`,{children:e.options.map(e=>(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),disabled:t,children:[(0,k.jsx)(`span`,{className:`label`,children:e.label}),e.description===void 0?null:(0,k.jsx)(`span`,{className:`detail`,children:e.description})]})},e.id))})]}),Oae=({diagnostics:e})=>e.length===0?null:(0,k.jsxs)(`div`,{className:`faults`,role:`alert`,children:[(0,k.jsx)(`p`,{className:`faults-title`,children:`The last change did not compile. The diagram still shows the model that did.`}),(0,k.jsx)(`ul`,{children:e.map(e=>(0,k.jsxs)(`li`,{children:[(0,k.jsx)(`span`,{className:`code`,children:e.code}),` `,e.message,(0,k.jsxs)(`span`,{className:`where`,children:[e.path,`:`,e.line]})]},`${e.code}-${e.pointer}`))})]}),kae=({state:e,selectedId:t,waiting:n,layout:r,nesting:i,direction:a,showLifecycle:o,showEvidence:s,showOwnership:c,showNudges:l,openQuestionCounts:u,decorations:d,connection:f,onConnectTarget:p,onConnectCancel:m,onConnectStage:h,onDraftStage:g,draftingSubject:_,draftInitialKind:y,onKindDrop:b,onDraftSubject:x,onDraftSubjectClose:S,pendingDeletion:C,onDeletionDismiss:w,onSelect:T,onCanvasMenu:E,onClearFilter:D,onSaveLayout:ee,onCanvasReady:te,onQuickFilterChange:ne,view:re,bottomPanel:ie,onTogglePresentation:ae,onToggleBottomPanel:oe,onSelectBottomTab:se,onApplyFilter:ce,onStageView:le,readOnly:ue})=>{let de=(0,v.useMemo)(()=>new Map((e.model?.graph.nodes??[]).map(e=>[e.id,e.name])),[e.model]),fe=e.model?.graph.nodes??[],pe=e.activeFilter?.matchedIds??null,me=fe.length>0&&(e.activeFilter!==null||e.quickFilterText.trim()!==``)&&_h(fe,pe,e.quickFilterText)===0,he=e.activeFilter!==null&&_h(fe,pe,``)===0;return(0,k.jsxs)(`section`,{className:`diagram-workspace`,"aria-label":`Architecture diagram`,children:[e.activeFilter!==null&&e.activeFilter.source!==`view`&&e.activeFilter.source!==`editor`?(0,k.jsxs)(`div`,{className:`filter-pill`,role:`status`,children:[(0,k.jsxs)(`span`,{children:[`Filtered by `,e.activeFilter.source,`:`,` `,(0,k.jsx)(`code`,{children:q_(e.activeFilter.query)})]}),(0,k.jsx)(`button`,{type:`button`,onClick:D,children:`Show all`})]}):null,(0,k.jsxs)(`div`,{className:`canvas`,children:[e.model===null?null:(0,k.jsxs)(`div`,{className:`canvas-controls`,children:[(0,k.jsx)(mie,{value:e.quickFilterText,onChange:ne}),ue?null:(0,k.jsx)(`button`,{type:`button`,className:`subject-draft-open`,onClick:x,children:`Add subject`})]}),!_||e.model===null?null:(0,k.jsx)(vy,{initialKind:y,graph:e.model.graph,kinds:e.model.vocabulary.conceptKinds,documents:e.model.documents,reservedIds:dv(e.pendingChangeset.operations),defaultDocument:(t===null?void 0:e.model.graph.nodes.find(e=>e.id===t)?.document)??e.model.documents[0]??``,onStage:g,onCancel:S},y??``),C===null||e.model===null?null:(0,k.jsx)(yy,{title:`Delete`,message:Cae(e.model.graph,C)??`That subject is no longer on the diagram.`,confirmLabel:`Delete`,cancelLabel:`Keep`,onConfirm:()=>{for(let t of Sae(e.model.graph,C))h(t);w()},onCancel:w}),f===null||e.model===null?null:(0,k.jsx)(_ae,{draft:f,graph:e.model.graph,reservedIds:dv(e.pendingChangeset.operations),onStage:h,onCancel:m}),e.model===null?null:(0,k.jsx)(ore,{graph:e.model.graph,selectedId:t,onSelect:(t,n)=>{let r=e.model.graph;if(n===`node`){if(f!==null){p(t);return}let e=r.nodes.find(e=>e.id===t);e!==void 0&&T(Vv(e))}else{let e=r.edges.find(e=>e.id===t);e!==void 0&&T(Hv(e,de))}},onContextMenu:E,matchedIds:e.activeFilter?.matchedIds??null,quickFilterText:e.quickFilterText,nesting:i,faultedIds:Aie(e.commitDiagnostics??[]),decorations:d,showLifecycle:o,showEvidence:s,showOwnership:c,showNudges:l,openQuestionCounts:u,activeViewId:e.activeView,direction:a,savedPositions:e.model.layouts[e.activeView],onSaveLayout:ue?()=>void 0:ee,onKindDrop:ue?void 0:b,onCanvasReady:te}),me?(0,k.jsx)(`div`,{className:`filter-empty-pill`,role:`status`,children:he&&e.activeFilter!==null?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{children:[`Nothing matches this filter:`,` `,(0,k.jsx)(`code`,{children:q_(e.activeFilter.query)})]}),(0,k.jsx)(`button`,{type:`button`,onClick:D,children:`Show all`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{children:[`Nothing matches “`,e.quickFilterText.trim(),`”`]}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>ne(``),children:`Clear filter`})]})}):null,e.layoutNotice===null?null:(0,k.jsx)(`div`,{className:`layout-notice-pill`,role:`status`,children:(0,k.jsx)(`span`,{children:e.layoutNotice})}),n===null?null:(0,k.jsx)(`p`,{className:`waiting`,children:n})]}),(0,k.jsx)(pie,{nodes:e.model?.graph.nodes??[],activeFilter:e.activeFilter,view:re,open:ie.open,tab:ie.tab,showLifecycle:o,showEvidence:s,showOwnership:c,showNudges:l,onTogglePresentation:ae,onToggleOpen:oe,onSelectTab:se,onApply:ce,onStage:le,readOnly:ue},e.activeView)]})},Aae=({text:e,expanded:t,onToggle:n})=>{let r=e??`No description declared in this model`,i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1);return(0,v.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,k.jsxs)(`div`,{className:`subject-description`,children:[(0,k.jsx)(`p`,{ref:i,className:t?`description-expanded`:`description-clamped`,children:r}),a||t?(0,k.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:n,children:t?`Show less`:`Show more`}):null]})},jae=({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,k.jsxs)(`section`,{className:`subject-inspector`,"aria-labelledby":`subject-heading`,children:[(0,k.jsxs)(`div`,{className:`subject-heading-row`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`p`,{className:`subject-type`,children:e.type===`element`?`Selected element`:`Selected relationship`}),(0,k.jsx)(`h2`,{id:`subject-heading`,children:e.type===`element`?e.title:`${e.sourceTitle} → ${e.targetTitle}`})]}),e.type===`element`&&!l?(0,k.jsx)(`button`,{type:`button`,className:`subject-connect`,onClick:()=>o(e.id),children:`Connect`}):null,l?null:(0,k.jsx)(`button`,{type:`button`,className:`subject-delete`,onClick:()=>s(e.id),children:`Delete`}),(0,k.jsx)(`button`,{type:`button`,className:`subject-clear`,onClick:a,children:`Clear`})]}),u===void 0?null:l?(0,k.jsx)(Xie,{node:u,model:t}):(0,k.jsx)(Yie,{node:u,model:t,operations:n,onStageChange:c}),d===void 0?null:l?(0,k.jsx)(Zie,{edge:d,model:t}):(0,k.jsx)(Qie,{edge:d,model:t,operations:n,onStageChange:c}),(0,k.jsx)(Aae,{text:e.description,expanded:r,onToggle:i})]})},Iy=e=>e.lifecycle===`active`?e.awaitingAgent?Py[e.agentStatus?.state??`thinking`]??`working`:`agent idle`:`closed`,Ly=({state:e,disabled:t,selectedSubject:n,onSend:r,onChoice:i,onClearSubject:a,onEnd:o})=>{let[s,c]=(0,v.useState)(``),l=e.lifecycle===`active`&&e.awaitingAgent,u=e.lifecycle===`active`?e.agentStatus:null;return(0,k.jsxs)(`div`,{className:`talk`,children:[(0,k.jsxs)(`div`,{className:`conversation-scroll`,children:[(0,k.jsx)(`ol`,{className:`ledger`,role:`log`,"aria-live":`polite`,children:e.transcript.length===0?(0,k.jsx)(`li`,{className:`empty`,children:(0,k.jsx)(`p`,{children:`Nothing asked yet. Question anything on the diagram.`})}):e.transcript.map(e=>(0,k.jsxs)(`li`,{className:`said said-${e.speaker}`,children:[(0,k.jsx)(`p`,{className:`who`,children:wae[e.speaker]}),(0,k.jsx)(`p`,{className:`words`,children:e.text})]},e.id))}),(0,k.jsx)(Oae,{diagnostics:e.diagnostics}),e.choices===null?null:(0,k.jsx)(Dae,{choices:e.choices,disabled:t,onChoice:i})]}),(0,k.jsxs)(`form`,{className:`composer`,onSubmit:e=>{e.preventDefault();let n=s.trim();n===``||t||(r(n),c(``))},children:[n===null?null:(0,k.jsxs)(`div`,{className:`subject-chip`,children:[(0,k.jsx)(`span`,{children:n.type===`element`?n.title:`${n.sourceTitle} → ${n.targetTitle}`}),(0,k.jsx)(`button`,{type:`button`,"aria-label":`Remove selected diagram context`,onClick:a,children:`Remove`})]}),(0,k.jsx)(`label`,{className:`offscreen`,htmlFor:`composer-text`,children:`Ask about this design`}),(0,k.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,k.jsxs)(`div`,{className:`composer-foot`,children:[(0,k.jsxs)(`p`,{className:`agent-status`,role:`status`,"aria-live":`polite`,"aria-busy":l,children:[l?(0,k.jsx)(`span`,{className:`agent-spinner`,"aria-hidden":`true`}):null,(0,k.jsx)(`span`,{children:u===null?l?`Awaiting agent response`:`\xA0`:Py[u.state]??`\xA0`})]}),(0,k.jsx)(`button`,{type:`submit`,disabled:t||s.trim()===``,children:`Send`})]}),(0,k.jsxs)(`div`,{className:`session-foot`,children:[(0,k.jsx)(`span`,{className:`end-transition-status`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:Eae(e)}),(0,k.jsx)(`button`,{type:`button`,className:`end-session`,onClick:o,disabled:e.lifecycle!==`active`,children:e.lifecycle===`ending`||e.lifecycle===`closed`?`Returning…`:`Return to agent`})]})]})]})},Ry=({width:e,viewportWidth:t,onResize:n})=>{let r=Kv(t),i=(0,v.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,k.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))}})},zy=({host:e,sections:t=aae,readOnly:n=!1,decorations:r,onReady:i})=>{let{state:a,connected:o,ask:s,choose:c,navigate:l,filter:u,clearFilter:d,setQuickFilterText:f,stageViewChange:p,stageViewMembership:m,saveLayout:h,discardChange:g,stageChange:_,clearChangeset:y,undoChangeset:b,redoChangeset:x,commitChangeset:S,end:C}=gae(e),[w,T]=(0,v.useReducer)(Zv,{width:window.innerWidth,height:window.innerHeight},({width:e,height:t})=>Xv(e,t)),[E,D]=(0,v.useState)(null),[ee,te]=(0,v.useState)(!1),[ne,re]=(0,v.useState)(!1),[ie,ae]=(0,v.useState)(void 0),[oe,se]=(0,v.useState)(void 0),[ce,le]=(0,v.useState)(r??{}),ue=(0,v.useRef)(null),de=(0,v.useRef)({graph:null,readOnly:n});de.current={graph:a.model?.graph??null,readOnly:n},(0,v.useEffect)(()=>{i?.(iae(()=>de.current,T,se,le))},[i]),(0,v.useEffect)(()=>{let e=()=>T({type:`viewport.resized`,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight});return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let fe=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(a.activeView===``){fe.current=null;return}let e=Gv(a.activeView,a.views,fe.current,o);if(e!==null){fe.current=e.id,u(e.query,`view`);for(let t of lae(e.presentation))T(t)}},[a.activeView,a.views,o,u]);let pe=(0,v.useRef)({transcriptLength:a.transcript.length,choices:a.choices,diagnostics:a.diagnostics});(0,v.useEffect)(()=>{let e=pe.current,t=!1;for(let n=e.transcriptLength;n<a.transcript.length;n+=1)if(a.transcript[n]?.speaker===`agent`){t=!0;break}let n=t||a.choices!==null&&a.choices!==e.choices||a.diagnostics.length>0&&a.diagnostics!==e.diagnostics;pe.current={transcriptLength:a.transcript.length,choices:a.choices,diagnostics:a.diagnostics},n&&T({type:`attention.received`})},[a.transcript.length,a.choices,a.diagnostics]);let me=(0,v.useRef)(a.model);(0,v.useEffect)(()=>{a.model!==me.current&&(me.current=a.model,T({type:`model.replaced`,graph:a.model?.graph??null}))},[a.model]);let he=a.model===null?a.lifecycle===`connecting`?`Reading the session`:`No model to draw`:E,ge=a.pendingChangeset.operations.length+a.pendingChangeset.viewOperations.length,_e=e=>!w.conversation.collapsed.includes(e),ve=a.model?.interrogation,ye=(0,v.useMemo)(()=>new Map(Object.entries(ve?.subjects??{}).map(([e,t])=>[e,t.length])),[ve]),be=n?t.filter(e=>e!==`palette`&&e!==`changes`):t,xe=ve===void 0?be.filter(e=>e!==`questions`):be,Se=w.selectedSubject?.type===`element`?w.selectedSubject.id:null,Ce=ve===void 0?void 0:Se===null?ve.workspace.length:ye.get(Se)??0,we=a.model?.vocabulary.conceptKinds??[],Te=(0,v.useMemo)(()=>new Set(w.tree.collapsed),[w.tree.collapsed]),Ee=w.conversation.hidden,De={"--conversation-width":Ee?`0px`:`${w.conversation.width}px`,"--changes-height":_e(`changes`)?`${w.conversation.changesHeight}px`:`auto`,"--chat-height":_e(`chat`)?`${w.conversation.chatHeight}px`:`auto`},Oe=e=>{se(e),T({type:`subject.draft.opened`})},ke=(e,t)=>T({type:`menu.opened`,target:e,x:t.x,y:t.y}),Ae=w.contextMenu===null?[]:Ay(w.contextMenu.target,{graph:a.model?.graph??null,relationshipKinds:a.model?.vocabulary.relationshipKinds??[],activeViewId:a.activeView,filtered:a.activeFilter!==null,membership:pae(a),readOnly:n}),je=e=>{let t=a.model?.graph??null;switch(e.type){case`subject.inspect`:{let n=t?.nodes.find(t=>t.id===e.id);if(n===void 0)return;T({type:`subject.selected`,subject:Vv(n)});return}case`relationship.inspect`:{let n=t?.edges.find(t=>t.id===e.id);if(n===void 0||t===null)return;T({type:`subject.selected`,subject:Hv(n,new Map(t.nodes.map(e=>[e.id,e.name])))});return}case`subject.connect`:T({type:`connection.started`,from:e.from});return;case`subject.delete`:case`relationship.delete`:T({type:`deletion.asked`,id:e.id});return;case`relationship.retype`:{let n=t?.edges.find(t=>t.id===e.id);if(n===void 0)return;for(let t of Cv(n.document,n.localId,`kind`,n.kindLabel,e.kind))_(t);T({type:`menu.dismissed`});return}case`canvas.draft-subject`:se(void 0),T({type:`subject.draft.opened`});return;case`view.add-subject`:case`view.remove-subject`:m(a.activeView,e.id,e.type===`view.add-subject`?`add`:`remove`),T({type:`menu.dismissed`});return;case`view.open`:l(e.id),T({type:`menu.dismissed`});return;case`view.clear`:d(),T({type:`menu.dismissed`});return;case`view.new`:ae(void 0),te(!0),T({type:`menu.dismissed`});return;case`view.delete`:T({type:`viewDeletion.asked`,id:e.id});return;case`view.rename`:T({type:`viewRename.asked`,id:e.id});return;case`view.new-folder`:re(!0),T({type:`menu.dismissed`});return;case`view.duplicate`:{let t=a.views.find(t=>t.id===e.id);if(t===void 0)return;let n=x_(t,new Set(a.views.map(e=>e.id)));p({op:`write-view`,...n}),T({type:`menu.dismissed`});return}case`view.new-in-folder`:{let t=a.views.find(t=>t.id===e.id);if(t===void 0)return;ae(Zre(t)),te(!0),T({type:`menu.dismissed`});return}case`view.copy-path`:{let t=a.views.find(t=>t.id===e.id);if(t===void 0)return;navigator.clipboard?.writeText(t.path),T({type:`menu.dismissed`});return}case`canvas.export-png`:{let e=ue.current;if(e===null)return;let t=document.createElement(`a`);t.href=e(),t.download=`${a.activeView===``?`all-subjects`:a.activeView}.png`,t.click(),T({type:`menu.dismissed`});return}}},Me=w.pendingViewDeletion===null?null:a.views.find(e=>e.id===w.pendingViewDeletion)??null,Ne=w.pendingViewRename===null?null:a.views.find(e=>e.id===w.pendingViewRename)??null,Pe=[`Show the session panel`,...w.conversation.unread===0?[]:[`${w.conversation.unread} unread`],...a.choices===null?[]:[`the agent is waiting on a choice`]].join(`, `);return(0,k.jsxs)(`main`,{className:`visual-shell`,style:De,children:[(0,k.jsx)(Fy,{state:a,connection:Tae(a,o)}),(0,k.jsxs)(`div`,{className:`workspace`,children:[(0,k.jsx)(Tie,{views:a.views,stagedViewOperations:a.pendingChangeset.viewOperations,activeViewId:a.activeView,nodes:a.model?.graph.nodes??[],inViewIds:a.activeFilter===null?null:new Set(a.activeFilter.matchedIds),filterText:w.tree.filterText,collapsed:Te,onFilterChange:e=>T({type:`tree.filtered`,filterText:e}),onToggle:e=>T({type:`tree.toggled`,key:e}),onSelectView:e=>l(e),onClearView:d,onNewView:()=>{ae(void 0),te(!0)},onSelectSubject:e=>{let t=a.model?.graph.nodes.find(t=>t.id===e);t!==void 0&&T({type:`subject.selected`,subject:Vv(t)})},onRowMenu:(e,t)=>ke(e.kind===`view`?{kind:`view-row`,id:e.id}:{kind:`model-row`,id:e.id},t),readOnly:n}),(0,k.jsx)(kae,{state:a,selectedId:w.selectedSubject?.id??null,waiting:he,layout:w.layout,nesting:w.nesting,direction:w.direction,decorations:ce,connection:w.connection,onConnectTarget:e=>T({type:`connection.targeted`,to:e}),onConnectCancel:()=>T({type:`connection.cancelled`}),onConnectStage:_,onDraftStage:e=>{_(e),e.op===`add-concept`&&m(a.activeView,e.concept.id,`add`)},draftingSubject:w.draftingSubject,draftInitialKind:oe,onKindDrop:e=>Oe(e),onDraftSubject:()=>{se(void 0),T({type:`subject.draft.opened`})},onDraftSubjectClose:()=>T({type:`subject.draft.closed`}),pendingDeletion:w.pendingDeletion,onDeletionDismiss:()=>T({type:`deletion.dismissed`}),showLifecycle:w.showLifecycle,showEvidence:w.showEvidence,showOwnership:w.showOwnership,showNudges:w.showNudges,openQuestionCounts:ye,onSelect:e=>T({type:`subject.selected`,subject:e}),onCanvasMenu:(e,t)=>ke(e.type===`node`?{kind:`subject`,id:e.id??``}:e.type===`edge`?{kind:`relationship`,id:e.id??``}:{kind:`canvas`},t),onClearFilter:d,onSaveLayout:h,onCanvasReady:e=>{ue.current=e},onQuickFilterChange:f,view:a.views.find(e=>e.id===a.activeView)??null,bottomPanel:w.bottomPanel,onTogglePresentation:(e,t)=>T({type:`presentation.toggled`,flag:e,value:t}),onToggleBottomPanel:()=>T({type:`bottomPanel.toggled`}),onSelectBottomTab:e=>T({type:`bottomPanel.tabSelected`,tab:e}),onApplyFilter:e=>u(e,`editor`),onStageView:p,readOnly:n}),Ee?(0,k.jsxs)(`button`,{type:`button`,className:`conversation-reopen`,title:`Show the session panel`,"aria-label":Pe,onClick:()=>T({type:`conversation.toggled`}),children:[(0,k.jsx)(`span`,{className:`reopen-chevron`,"aria-hidden":`true`,children:`«`}),w.conversation.unread===0?null:(0,k.jsx)(`span`,{className:`attention-count`,children:w.conversation.unread}),a.choices===null?null:(0,k.jsx)(`span`,{className:`attention-choice`,title:`The agent is waiting on a choice`,children:`?`})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(Ry,{width:w.conversation.width,viewportWidth:w.viewportWidth,onResize:e=>T({type:`conversation.resized`,width:e})}),(0,k.jsxs)(`aside`,{className:`section-stack`,"aria-label":`Session`,children:[(0,k.jsx)(`div`,{className:`stack-rim`,children:(0,k.jsx)(`button`,{type:`button`,className:`conversation-hide`,title:`Hide the session panel`,"aria-label":`Hide the session panel`,onClick:()=>T({type:`conversation.toggled`}),children:`»`})}),ty(xe,{palette:(0,k.jsx)($v,{id:`palette`,label:`Kind palette`,meta:we.length===0?void 0:we.length===1?`1 kind`:`${we.length} kinds`,open:_e(`palette`),onToggle:()=>T({type:`section.toggled`,section:`palette`}),children:we.length===0?(0,k.jsx)(`p`,{className:`section-empty`,children:`No model yet. The kinds arrive with it.`}):(0,k.jsx)(Tne,{kinds:we,onPick:Oe})}),properties:(0,k.jsx)($v,{id:`properties`,label:`Element properties`,meta:w.selectedSubject?.id,open:_e(`properties`),onToggle:()=>T({type:`section.toggled`,section:`properties`}),children:w.selectedSubject===null||a.model===null?(0,k.jsx)(`p`,{className:`section-empty`,children:`Nothing selected. Pick a subject on the canvas or in the rail.`}):(0,k.jsx)(jae,{subject:w.selectedSubject,model:a.model,operations:a.pendingChangeset.operations,expanded:w.descriptionExpanded,onToggleDescription:()=>T({type:`description.toggled`}),onClear:()=>T({type:`subject.cleared`}),onConnect:e=>T({type:`connection.started`,from:e}),onDelete:e=>T({type:`deletion.asked`,id:e}),onStageChange:_,readOnly:n})}),questions:(0,k.jsx)($v,{id:`questions`,label:`Open questions`,meta:Ce===void 0?void 0:Ce===0?`nothing open`:`${Ce} open`,open:_e(`questions`),onToggle:()=>T({type:`section.toggled`,section:`questions`}),children:ve===void 0?null:(0,k.jsx)($ie,{overlay:ve,selectedId:Se})}),changes:(0,k.jsx)($v,{id:`changes`,label:`Changes`,meta:ge===0?`nothing staged`:`${ge} staged`,open:_e(`changes`),onToggle:()=>T({type:`section.toggled`,section:`changes`}),children:(0,k.jsx)(Iie,{state:a,onDiscardChange:g,onClearChangeset:y,onUndoChangeset:b,onRedoChangeset:x,onCommitChangeset:S})}),chat:(0,k.jsx)($v,{id:`chat`,label:`Chat`,meta:w.conversation.unread===0?Iy(a):(0,k.jsx)(`span`,{className:`attention-count`,children:w.conversation.unread}),open:_e(`chat`),onToggle:()=>T({type:`section.toggled`,section:`chat`}),children:(0,k.jsx)(Ly,{state:a,disabled:!a.composerEnabled,selectedSubject:w.selectedSubject,onSend:e=>s(Qv(e,w.selectedSubject)),onChoice:c,onClearSubject:()=>T({type:`subject.cleared`}),onEnd:C})})},{changes:(0,k.jsx)(ey,{label:`Resize the changes section`,height:w.conversation.changesHeight,viewportHeight:w.viewportHeight,onResize:e=>T({type:`section.resized`,section:`changes`,height:e})}),chat:(0,k.jsx)(ey,{label:`Resize the chat section`,height:w.conversation.chatHeight,viewportHeight:w.viewportHeight,onResize:e=>T({type:`section.resized`,section:`chat`,height:e})})})]})]})]}),w.contextMenu===null?null:(0,k.jsx)(My,{groups:Ae,x:w.contextMenu.x,y:w.contextMenu.y,onChoose:je,onDismiss:()=>T({type:`menu.dismissed`})}),(0,k.jsx)(Oie,{views:a.views,activeViewId:a.activeView,query:a.activeFilter?.query??null,layout:w.layout,showLifecycle:w.showLifecycle,showEvidence:w.showEvidence,showOwnership:w.showOwnership,open:ee,folder:ie,onClose:()=>te(!1),onStage:p}),ne?(0,k.jsx)(by,{title:`New folder`,label:`Folder`,initialValue:``,confirmLabel:`Continue`,cancelLabel:`Cancel`,onConfirm:e=>{re(!1);let t=e.trim();t!==``&&(ae(t),te(!0))},onCancel:()=>re(!1)}):null,Ne===null?null:(0,k.jsx)(by,{title:`Rename view`,label:`Title`,initialValue:Ne.title,confirmLabel:`Rename`,cancelLabel:`Cancel`,onConfirm:e=>{p({op:`write-view`,...Qre(Ne,e)}),T({type:`viewRename.dismissed`})},onCancel:()=>T({type:`viewRename.dismissed`})}),Me===null?null:(0,k.jsx)(yy,{title:`Delete view`,message:`Stage the removal of "${Me.title}"? The projection document goes when the changeset is committed; no subject is touched.`,confirmLabel:`Delete`,cancelLabel:`Keep`,onConfirm:()=>{p({op:`delete-view`,path:Me.path}),T({type:`viewDeletion.dismissed`})},onCancel:()=>T({type:`viewDeletion.dismissed`})})]})},By=`/api/session`,Mae=`/socket`,Nae=1e3,Vy=()=>{let e=null;return{open:t=>{let n=!1,r,i=null,a=()=>{let e=new URL(Mae,window.location.href);return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.searchParams.set(`after`,String(t.session().lastSequence)),e},o=()=>{if(!n){if(i??=Date.now(),!cy(i,Date.now())){t.frame({kind:`closing`,reason:`browser-timeout`});return}r=setTimeout(s,Nae)}},s=()=>{if(n)return;let r=new WebSocket(a());e=r,r.addEventListener(`open`,()=>{i=null,t.connected(!0)}),r.addEventListener(`message`,e=>{if(typeof e.data==`string`)try{t.frame(JSON.parse(e.data))}catch{}}),r.addEventListener(`close`,()=>{t.connected(!1),e=null,!(n||t.session().closed)&&(t.lost(),o())}),r.addEventListener(`error`,()=>r.close())};return(async()=>{let e=await fetch(By,{credentials:`same-origin`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(`Session request answered ${e.status}`);let r=await e.json();n||(t.frame({kind:`ready`,snapshot:r}),s())})().catch(()=>{n||(t.lost(),o())}),()=>{n=!0,r!==void 0&&clearTimeout(r),e?.close()}},send:t=>{e!==null&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify(t))}}},Pae=document.getElementById(`visual-session`);if(Pae===null)throw Error(`The visual session page has no mount point`);(0,y.createRoot)(Pae).render((0,k.jsx)(zy,{host:Vy()}));
|