likec4 1.19.1 → 1.19.2

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.
@@ -0,0 +1,9 @@
1
+ function be(n,e){if(typeof n>"u"||n==null)throw new Error(e??`Expected defined value, but received ${n}`);return n}function re(n,e){if(!n)throw new Error(e??"Invariant failed")}function Be(n){throw new Error(`NonExhaustive value: ${n}`)}function us(n,e,t){let r=i=>n(i,...e);return t===void 0?r:Object.assign(r,{lazy:t,lazyArgs:e})}function ue(n,e,t){let r=n.length-e.length;if(r===0)return n(...e);if(r===1)return us(n,e,t);throw new Error("Wrong number of arguments")}function Wn(...n){return ue(cs,n,ds)}var cs=(n,e)=>n.length<e.length?n.map((t,r)=>[t,e[r]]):e.map((t,r)=>[n[r],t]),ds=n=>(e,t)=>({hasNext:!0,next:[e,n[t]],done:t>=n.length-1}),ls={done:!0,hasNext:!1},Fn={done:!1,hasNext:!1},hs=()=>ls;function J(n,...e){let t=n,r=e.map(a=>"lazy"in a?fs(a):void 0),i=0;for(;i<e.length;){if(r[i]===void 0||!ps(t)){let m=e[i];t=m(t),i+=1;continue}let a=[];for(let m=i;m<e.length;m++){let b=r[m];if(b===void 0||(a.push(b),b.isSingle))break}let p=[];for(let m of t)if(ni(m,p,a))break;let{isSingle:f}=a.at(-1);t=f?p[0]:p,i+=a.length}return t}function ni(n,e,t){if(t.length===0)return e.push(n),!1;let r=n,i=Fn,a=!1;for(let[p,f]of t.entries()){let{index:m,items:b}=f;if(b.push(r),i=f(r,m,b),f.index+=1,i.hasNext){if(i.hasMany??!1){for(let S of i.next)if(ni(S,e,t.slice(p+1)))return!0;return a}r=i.next}if(!i.hasNext)break;i.done&&(a=!0)}return i.hasNext&&e.push(r),a}function fs(n){let{lazy:e,lazyArgs:t}=n,r=e(...t);return Object.assign(r,{isSingle:e.single??!1,index:0,items:[]})}function ps(n){return typeof n=="string"||typeof n=="object"&&n!==null&&Symbol.iterator in n}function tt(...n){return ue(gs,n)}var gs=(n,e)=>n.length>=e;function ri(...n){return ue(ms,n)}function ms(n,e){let t=[];for(let[r,i]of n.entries()){if(!e(i,r,n))break;t.push(i)}return t}function xe(...n){return ue(ys,n,ws)}var ys=(n,e)=>n.map(e),ws=n=>(e,t,r)=>({done:!1,hasNext:!0,next:n(e,t,r)});function wn(n){return typeof n=="string"}function Pn(n){return typeof n=="function"}function qn(n){return n!=null}function vn(n){return n!==void 0}function bt(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Yn,ii;function vs(){if(ii)return Yn;ii=1;function n(e){if(typeof e!="function")throw new Error("mnemonist/DefaultMap.constructor: expecting a function.");this.items=new Map,this.factory=e,this.size=0}return n.prototype.clear=function(){this.items.clear(),this.size=0},n.prototype.get=function(e){var t=this.items.get(e);return typeof t>"u"&&(t=this.factory(e,this.size),this.items.set(e,t),this.size++),t},n.prototype.peek=function(e){return this.items.get(e)},n.prototype.set=function(e,t){return this.items.set(e,t),this.size=this.items.size,this},n.prototype.has=function(e){return this.items.has(e)},n.prototype.delete=function(e){var t=this.items.delete(e);return this.size=this.items.size,t},n.prototype.forEach=function(e,t){t=arguments.length>1?t:this,this.items.forEach(e,t)},n.prototype.entries=function(){return this.items.entries()},n.prototype.keys=function(){return this.items.keys()},n.prototype.values=function(){return this.items.values()},typeof Symbol<"u"&&(n.prototype[Symbol.iterator]=n.prototype.entries),n.prototype.inspect=function(){return this.items},typeof Symbol<"u"&&(n.prototype[Symbol.for("nodejs.util.inspect.custom")]=n.prototype.inspect),n.autoIncrement=function(){var e=0;return function(){return e++}},Yn=n,Yn}var bs=vs();const De=bt(bs);var Kn,oi;function Xn(){if(oi)return Kn;oi=1;function n(e){if(typeof e!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=e}return typeof Symbol<"u"&&(n.prototype[Symbol.iterator]=function(){return this}),n.of=function(){var e=arguments,t=e.length,r=0;return new n(function(){return r>=t?{done:!0}:{done:!1,value:e[r++]}})},n.empty=function(){var e=new n(function(){return{done:!0}});return e},n.fromSequence=function(e){var t=0,r=e.length;return new n(function(){return t>=r?{done:!0}:{done:!1,value:e[t++]}})},n.is=function(e){return e instanceof n?!0:typeof e=="object"&&e!==null&&typeof e.next=="function"},Kn=n,Kn}var Vn={},si;function xs(){return si||(si=1,Vn.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u",Vn.SYMBOL_SUPPORT=typeof Symbol<"u"),Vn}var Hn,ai;function Jn(){if(ai)return Hn;ai=1;var n=xs(),e=n.ARRAY_BUFFER_SUPPORT,t=n.SYMBOL_SUPPORT;return Hn=function(r,i){var a,p,f,m,b;if(!r)throw new Error("obliterator/forEach: invalid iterable.");if(typeof i!="function")throw new Error("obliterator/forEach: expecting a callback.");if(Array.isArray(r)||e&&ArrayBuffer.isView(r)||typeof r=="string"||r.toString()==="[object Arguments]"){for(f=0,m=r.length;f<m;f++)i(r[f],f);return}if(typeof r.forEach=="function"){r.forEach(i);return}if(t&&Symbol.iterator in r&&typeof r.next!="function"&&(r=r[Symbol.iterator]()),typeof r.next=="function"){for(a=r,f=0;b=a.next(),b.done!==!0;)i(b.value,f),f++;return}for(p in r)r.hasOwnProperty(p)&&i(r[p],p)},Hn}function Es(n,e,t){return n.length===0||e.length===0?[]:(t??=Object.is,J(Wn(n,e),ri(([r,i])=>t(r,i)),xe(([r,i])=>r)))}var Qn={exports:{}},ui;function ks(){if(ui)return Qn.exports;ui=1;var n=function(e,t){var r,i,a=1,p=0,f=0,m=String.alphabet;function b(S,D,G){if(G){for(r=D;G=b(S,r),G<76&&G>65;)++r;return+S.slice(D-1,r)}return G=m&&m.indexOf(S.charAt(D)),G>-1?G+76:(G=S.charCodeAt(D)||0,G<45||G>127?G:G<46?65:G<48?G-1:G<58?G+18:G<65?G-11:G<91?G+11:G<97?G-37:G<123?G+5:G-63)}if((e+="")!=(t+="")){for(;a;)if(i=b(e,p++),a=b(t,f++),i<76&&a<76&&i>66&&a>66&&(i=b(e,p,p),a=b(t,f,p=r),f=r),i!=a)return i<a?-1:1}return 0};try{Qn.exports=n}catch{String.naturalCompare=n}return Qn.exports}var _s=ks();const Ss=bt(_s);function bn(n,e){return n===e?0:wn(n)?wn(e)?Ss(n,e):1:wn(e)?-1:0}function lt(n){return n!=null&&typeof n=="string"}function Zn(n){return!!n&&Array.isArray(n)&&n.length>0}function ut(n){const e=n.lastIndexOf(".");return e>0?n.slice(0,e):null}function ci(n){const e=n.lastIndexOf(".");return e>0?n.slice(e+1):n}const Jt=n=>lt(n)?n:n.id;function ye(n,e){const t=Jt(n);return e?Jt(e).startsWith(t+"."):r=>{const i=Jt(r);return t.startsWith(i+".")}}function Ot(n,e){if(!e)return i=>Ot(n,i);const t=Jt(n),r=Jt(e);return t===r||r.startsWith(t+".")||t.startsWith(r+".")}function ht(n,e){return e?ye(e,n):t=>ye(n,t)}function Mt(n){return(lt(n)?n:n.id).split(".").length}function As(n,e){const t=lt(n)?n:n.id,r=lt(e)?e:e.id;if(t===r)return 0;const i=Mt(t),a=Mt(r);if(Ot(t,r))return Math.abs(i-a);const p=ft(t,r),f=p?Mt(p):0;return i+a-(2*f+1)}function ft(n,e){const t=n.split(".");if(t.length<2)return null;const r=e.split(".");if(r.length<2)return null;let i=[];for(let a=0;a<Math.min(t.length,r.length)-1&&t[a]===r[a];a++)i.push(t[a]);return i.length===0?null:i.join(".")}function pt(n){const e=n.split(".");return e.pop(),e.length===0?[]:e.reduce((t,r,i)=>i===0?(t.push(r),t):(t.unshift(`${t[0]}.${r}`),t),[])}function di(n,e){const t=n.split(".").length,r=e.split(".").length;switch(!0){case t>r:return 1;case t<r:return-1;default:return 0}}function li(n,e){return di(n.id,e.id)}function er(n){return n.map(e=>({item:e,fqn:e.id.split(".")})).sort((e,t)=>e.fqn.length-t.fqn.length).map(({item:e})=>e)}function Is(n,e){let t=e;for(const r of n)ye(r,t)&&(t=r);return t!==e?t:null}function xn(n){const e=[],t=[...n];let r;for(;r=t.shift();){let i;for(;i=Is(t,r);)e.push(t.splice(t.indexOf(i),1)[0]);e.push(r)}return e}function En(n,e){if(!n||lt(n)){const r=n??"asc";return i=>En(i,r)}const t=e==="desc"?-1:1;return n.map(r=>({item:r,fqn:r.id.split(".")})).sort((r,i)=>{if(r.fqn.length!==i.fqn.length)return(r.fqn.length-i.fqn.length)*t;for(let a=0;a<r.fqn.length;a++){const p=bn(r.fqn[a],i.fqn[a]);if(p!==0)return p}return 0}).map(({item:r})=>r)}function tr(n,e,t){let r=n.get(e);return r||(r=t(e),n.set(e,r)),r}function xt(n){return qn(n)&&typeof n=="object"&&Symbol.iterator in n}function Re(n,e){const t=e??n;re(Pn(t));function*r(i){for(const a of i)t(a)&&(yield a)}return e?r(n):r}function $s(n){return n?hi(n):hi}function*hi(n){for(const e of n)yield*e}function Gs(n,e){const t=e??n;re(Pn(t));function*r(i){for(const a of i)yield t(a)}return e?r(n):r}function Qt(n,e){const t=e??n;re(Pn(t));function r(i){for(const a of i)if(t(a))return!0;return!1}return e?r(n):r}function ce(n){return n?Array.from(n):e=>Array.from(e)}function nt(n){return n?new Set(n):e=>new Set(e)}function fi(n){return n?function*(){yield*pi(n)}():pi}function*pi(n){const e=new Set;for(const t of n)e.has(t)||(e.add(t),yield t)}var gi={},mi;function Cs(){return mi||(mi=1,function(n){n.intersection=function(){if(arguments.length<2)throw new Error("mnemonist/Set.intersection: needs at least two arguments.");var e=new Set,t=1/0,r=null,i,a,p=arguments.length;for(a=0;a<p;a++){if(i=arguments[a],i.size===0)return e;i.size<t&&(t=i.size,r=i)}for(var f=r.values(),m,b,S,D;m=f.next(),!m.done;){for(b=m.value,S=!0,a=0;a<p;a++)if(D=arguments[a],D!==r&&!D.has(b)){S=!1;break}S&&e.add(b)}return e},n.union=function(){if(arguments.length<2)throw new Error("mnemonist/Set.union: needs at least two arguments.");var e=new Set,t,r=arguments.length,i,a;for(t=0;t<r;t++)for(i=arguments[t].values();a=i.next(),!a.done;)e.add(a.value);return e},n.difference=function(e,t){if(!e.size)return new Set;if(!t.size)return new Set(e);for(var r=new Set,i=e.values(),a;a=i.next(),!a.done;)t.has(a.value)||r.add(a.value);return r},n.symmetricDifference=function(e,t){for(var r=new Set,i=e.values(),a;a=i.next(),!a.done;)t.has(a.value)||r.add(a.value);for(i=t.values();a=i.next(),!a.done;)e.has(a.value)||r.add(a.value);return r},n.isSubset=function(e,t){var r=e.values(),i;if(e===t)return!0;if(e.size>t.size)return!1;for(;i=r.next(),!i.done;)if(!t.has(i.value))return!1;return!0},n.isSuperset=function(e,t){return n.isSubset(t,e)},n.add=function(e,t){for(var r=t.values(),i;i=r.next(),!i.done;)e.add(i.value)},n.subtract=function(e,t){for(var r=t.values(),i;i=r.next(),!i.done;)e.delete(i.value)},n.intersect=function(e,t){for(var r=e.values(),i;i=r.next(),!i.done;)t.has(i.value)||e.delete(i.value)},n.disjunct=function(e,t){for(var r=e.values(),i,a=[];i=r.next(),!i.done;)t.has(i.value)&&a.push(i.value);for(r=t.values();i=r.next(),!i.done;)e.has(i.value)||e.add(i.value);for(var p=0,f=a.length;p<f;p++)e.delete(a[p])},n.intersectionSize=function(e,t){var r;if(e.size>t.size&&(r=e,e=t,t=r),e.size===0)return 0;if(e===t)return e.size;for(var i=e.values(),a,p=0;a=i.next(),!a.done;)t.has(a.value)&&p++;return p},n.unionSize=function(e,t){var r=n.intersectionSize(e,t);return e.size+t.size-r},n.jaccard=function(e,t){var r=n.intersectionSize(e,t);if(r===0)return 0;var i=e.size+t.size-r;return r/i},n.overlap=function(e,t){var r=n.intersectionSize(e,t);return r===0?0:r/Math.min(e.size,t.size)}}(gi)),gi}var Ds=Cs();function Ee(...n){let e=new Set;for(const t of n)for(const r of t)e.add(r);return e}function Le(n,...e){let t=new Set;if(n.size===0)return t;let r=e.length>1?Ds.intersection(...e):e[0];if(r.size===0)return t;for(const i of n)r.has(i)&&t.add(i);return t}function pe(n,e){if(n.size===0)return new Set;if(e.size===0)return new Set(n);let t=new Set;for(const r of n)e.has(r)||t.add(r);return t}function nr(n,e){return n.size===e.size&&[...n].every(t=>e.has(t))}function yi(n,e){if(n.size===0||e.size===0)return!1;e.size<n.size&&([n,e]=[e,n]);for(const t of n)if(e.has(t))return!0;return!1}function rr(n){let e=5381;const t=n.length;re(t>0,"stringHash: empty string");for(let r=0;r<t;r++)e=e*33^n.charCodeAt(r);return(e>>>0).toString(36)}function kn(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var wi={exports:{}},vi;function Ls(){return vi||(vi=1,function(n,e){(function(t){n.exports=t()})(function(){return function t(r,i,a){function p(b,S){if(!i[b]){if(!r[b]){var D=typeof kn=="function"&&kn;if(!S&&D)return D(b,!0);if(f)return f(b,!0);throw new Error("Cannot find module '"+b+"'")}S=i[b]={exports:{}},r[b][0].call(S.exports,function(G){var O=r[b][1][G];return p(O||G)},S,S.exports,t,r,i,a)}return i[b].exports}for(var f=typeof kn=="function"&&kn,m=0;m<a.length;m++)p(a[m]);return p}({1:[function(t,r,i){(function(a,p,f,m,b,S,D,G,O){var k=t("crypto");function j(_,z){z=X(_,z);var x;return(x=z.algorithm!=="passthrough"?k.createHash(z.algorithm):new V).write===void 0&&(x.write=x.update,x.end=x.update),F(z,x).dispatch(_),x.update||x.end(""),x.digest?x.digest(z.encoding==="buffer"?void 0:z.encoding):(_=x.read(),z.encoding!=="buffer"?_.toString(z.encoding):_)}(i=r.exports=j).sha1=function(_){return j(_)},i.keys=function(_){return j(_,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},i.MD5=function(_){return j(_,{algorithm:"md5",encoding:"hex"})},i.keysMD5=function(_){return j(_,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var I=k.getHashes?k.getHashes().slice():["sha1","md5"],W=(I.push("passthrough"),["buffer","hex","binary","base64"]);function X(_,z){var x={};if(x.algorithm=(z=z||{}).algorithm||"sha1",x.encoding=z.encoding||"hex",x.excludeValues=!!z.excludeValues,x.algorithm=x.algorithm.toLowerCase(),x.encoding=x.encoding.toLowerCase(),x.ignoreUnknown=z.ignoreUnknown===!0,x.respectType=z.respectType!==!1,x.respectFunctionNames=z.respectFunctionNames!==!1,x.respectFunctionProperties=z.respectFunctionProperties!==!1,x.unorderedArrays=z.unorderedArrays===!0,x.unorderedSets=z.unorderedSets!==!1,x.unorderedObjects=z.unorderedObjects!==!1,x.replacer=z.replacer||void 0,x.excludeKeys=z.excludeKeys||void 0,_===void 0)throw new Error("Object argument required.");for(var E=0;E<I.length;++E)I[E].toLowerCase()===x.algorithm.toLowerCase()&&(x.algorithm=I[E]);if(I.indexOf(x.algorithm)===-1)throw new Error('Algorithm "'+x.algorithm+'" not supported. supported values: '+I.join(", "));if(W.indexOf(x.encoding)===-1&&x.algorithm!=="passthrough")throw new Error('Encoding "'+x.encoding+'" not supported. supported values: '+W.join(", "));return x}function P(_){if(typeof _=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(_))!=null}function F(_,z,x){x=x||[];function E(w){return z.update?z.update(w,"utf8"):z.write(w,"utf8")}return{dispatch:function(w){return this["_"+((w=_.replacer?_.replacer(w):w)===null?"null":typeof w)](w)},_object:function(w){var C,M=Object.prototype.toString.call(w),ee=/\[object (.*)\]/i.exec(M);if(ee=(ee=ee?ee[1]:"unknown:["+M+"]").toLowerCase(),0<=(M=x.indexOf(w)))return this.dispatch("[CIRCULAR:"+M+"]");if(x.push(w),f!==void 0&&f.isBuffer&&f.isBuffer(w))return E("buffer:"),E(w);if(ee==="object"||ee==="function"||ee==="asyncfunction")return M=Object.keys(w),_.unorderedObjects&&(M=M.sort()),_.respectType===!1||P(w)||M.splice(0,0,"prototype","__proto__","constructor"),_.excludeKeys&&(M=M.filter(function(Q){return!_.excludeKeys(Q)})),E("object:"+M.length+":"),C=this,M.forEach(function(Q){C.dispatch(Q),E(":"),_.excludeValues||C.dispatch(w[Q]),E(",")});if(!this["_"+ee]){if(_.ignoreUnknown)return E("["+ee+"]");throw new Error('Unknown object type "'+ee+'"')}this["_"+ee](w)},_array:function(w,Q){Q=Q!==void 0?Q:_.unorderedArrays!==!1;var M=this;if(E("array:"+w.length+":"),!Q||w.length<=1)return w.forEach(function(ne){return M.dispatch(ne)});var ee=[],Q=w.map(function(ne){var H=new V,oe=x.slice();return F(_,H,oe).dispatch(ne),ee=ee.concat(oe.slice(x.length)),H.read().toString()});return x=x.concat(ee),Q.sort(),this._array(Q,!1)},_date:function(w){return E("date:"+w.toJSON())},_symbol:function(w){return E("symbol:"+w.toString())},_error:function(w){return E("error:"+w.toString())},_boolean:function(w){return E("bool:"+w.toString())},_string:function(w){E("string:"+w.length+":"),E(w.toString())},_function:function(w){E("fn:"),P(w)?this.dispatch("[native]"):this.dispatch(w.toString()),_.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(w.name)),_.respectFunctionProperties&&this._object(w)},_number:function(w){return E("number:"+w.toString())},_xml:function(w){return E("xml:"+w.toString())},_null:function(){return E("Null")},_undefined:function(){return E("Undefined")},_regexp:function(w){return E("regex:"+w.toString())},_uint8array:function(w){return E("uint8array:"),this.dispatch(Array.prototype.slice.call(w))},_uint8clampedarray:function(w){return E("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(w))},_int8array:function(w){return E("int8array:"),this.dispatch(Array.prototype.slice.call(w))},_uint16array:function(w){return E("uint16array:"),this.dispatch(Array.prototype.slice.call(w))},_int16array:function(w){return E("int16array:"),this.dispatch(Array.prototype.slice.call(w))},_uint32array:function(w){return E("uint32array:"),this.dispatch(Array.prototype.slice.call(w))},_int32array:function(w){return E("int32array:"),this.dispatch(Array.prototype.slice.call(w))},_float32array:function(w){return E("float32array:"),this.dispatch(Array.prototype.slice.call(w))},_float64array:function(w){return E("float64array:"),this.dispatch(Array.prototype.slice.call(w))},_arraybuffer:function(w){return E("arraybuffer:"),this.dispatch(new Uint8Array(w))},_url:function(w){return E("url:"+w.toString())},_map:function(w){return E("map:"),w=Array.from(w),this._array(w,_.unorderedSets!==!1)},_set:function(w){return E("set:"),w=Array.from(w),this._array(w,_.unorderedSets!==!1)},_file:function(w){return E("file:"),this.dispatch([w.name,w.size,w.type,w.lastModfied])},_blob:function(){if(_.ignoreUnknown)return E("[blob]");throw Error(`Hashing Blob objects is currently not supported
2
+ (see https://github.com/puleos/object-hash/issues/26)
3
+ Use "options.replacer" or "options.ignoreUnknown"
4
+ `)},_domwindow:function(){return E("domwindow")},_bigint:function(w){return E("bigint:"+w.toString())},_process:function(){return E("process")},_timer:function(){return E("timer")},_pipe:function(){return E("pipe")},_tcp:function(){return E("tcp")},_udp:function(){return E("udp")},_tty:function(){return E("tty")},_statwatcher:function(){return E("statwatcher")},_securecontext:function(){return E("securecontext")},_connection:function(){return E("connection")},_zlib:function(){return E("zlib")},_context:function(){return E("context")},_nodescript:function(){return E("nodescript")},_httpparser:function(){return E("httpparser")},_dataview:function(){return E("dataview")},_signal:function(){return E("signal")},_fsevent:function(){return E("fsevent")},_tlswrap:function(){return E("tlswrap")}}}function V(){return{buf:"",write:function(_){this.buf+=_},end:function(_){this.buf+=_},read:function(){return this.buf}}}i.writeToStream=function(_,z,x){return x===void 0&&(x=z,z={}),F(z=X(_,z),x).dispatch(_)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(t,r,i){(function(a,p,f,m,b,S,D,G,O){(function(k){var j=typeof Uint8Array<"u"?Uint8Array:Array,I=43,W=47,X=48,P=97,F=65,V=45,_=95;function z(x){return x=x.charCodeAt(0),x===I||x===V?62:x===W||x===_?63:x<X?-1:x<X+10?x-X+26+26:x<F+26?x-F:x<P+26?x-P+26:void 0}k.toByteArray=function(x){var E,w;if(0<x.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var C=x.length,C=x.charAt(C-2)==="="?2:x.charAt(C-1)==="="?1:0,M=new j(3*x.length/4-C),ee=0<C?x.length-4:x.length,Q=0;function ne(H){M[Q++]=H}for(E=0;E<ee;E+=4,0)ne((16711680&(w=z(x.charAt(E))<<18|z(x.charAt(E+1))<<12|z(x.charAt(E+2))<<6|z(x.charAt(E+3))))>>16),ne((65280&w)>>8),ne(255&w);return C==2?ne(255&(w=z(x.charAt(E))<<2|z(x.charAt(E+1))>>4)):C==1&&(ne((w=z(x.charAt(E))<<10|z(x.charAt(E+1))<<4|z(x.charAt(E+2))>>2)>>8&255),ne(255&w)),M},k.fromByteArray=function(x){var E,w,C,M,ee=x.length%3,Q="";function ne(H){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(H)}for(E=0,C=x.length-ee;E<C;E+=3)w=(x[E]<<16)+(x[E+1]<<8)+x[E+2],Q+=ne((M=w)>>18&63)+ne(M>>12&63)+ne(M>>6&63)+ne(63&M);switch(ee){case 1:Q=(Q+=ne((w=x[x.length-1])>>2))+ne(w<<4&63)+"==";break;case 2:Q=(Q=(Q+=ne((w=(x[x.length-2]<<8)+x[x.length-1])>>10))+ne(w>>4&63))+ne(w<<2&63)+"="}return Q}})(i===void 0?this.base64js={}:i)}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(t,r,i){(function(a,p,I,m,b,S,D,G,O){var k=t("base64-js"),j=t("ieee754");function I(l,y,A){if(!(this instanceof I))return new I(l,y,A);var B,T,Y,te,ge=typeof l;if(y==="base64"&&ge=="string")for(l=(te=l).trim?te.trim():te.replace(/^\s+|\s+$/g,"");l.length%4!=0;)l+="=";if(ge=="number")B=se(l);else if(ge=="string")B=I.byteLength(l,y);else{if(ge!="object")throw new Error("First argument needs to be a number, array or string.");B=se(l.length)}if(I._useTypedArrays?T=I._augment(new Uint8Array(B)):((T=this).length=B,T._isBuffer=!0),I._useTypedArrays&&typeof l.byteLength=="number")T._set(l);else if(le(te=l)||I.isBuffer(te)||te&&typeof te=="object"&&typeof te.length=="number")for(Y=0;Y<B;Y++)I.isBuffer(l)?T[Y]=l.readUInt8(Y):T[Y]=l[Y];else if(ge=="string")T.write(l,0,y);else if(ge=="number"&&!I._useTypedArrays&&!A)for(Y=0;Y<B;Y++)T[Y]=0;return T}function W(l,y,A,B){return I._charsWritten=It(function(T){for(var Y=[],te=0;te<T.length;te++)Y.push(255&T.charCodeAt(te));return Y}(y),l,A,B)}function X(l,y,A,B){return I._charsWritten=It(function(T){for(var Y,te,ge=[],Se=0;Se<T.length;Se++)te=T.charCodeAt(Se),Y=te>>8,te=te%256,ge.push(te),ge.push(Y);return ge}(y),l,A,B)}function P(l,y,A){var B="";A=Math.min(l.length,A);for(var T=y;T<A;T++)B+=String.fromCharCode(l[T]);return B}function F(l,y,A,Y){Y||(L(typeof A=="boolean","missing or invalid endian"),L(y!=null,"missing offset"),L(y+1<l.length,"Trying to read beyond buffer length"));var T,Y=l.length;if(!(Y<=y))return A?(T=l[y],y+1<Y&&(T|=l[y+1]<<8)):(T=l[y]<<8,y+1<Y&&(T|=l[y+1])),T}function V(l,y,A,Y){Y||(L(typeof A=="boolean","missing or invalid endian"),L(y!=null,"missing offset"),L(y+3<l.length,"Trying to read beyond buffer length"));var T,Y=l.length;if(!(Y<=y))return A?(y+2<Y&&(T=l[y+2]<<16),y+1<Y&&(T|=l[y+1]<<8),T|=l[y],y+3<Y&&(T+=l[y+3]<<24>>>0)):(y+1<Y&&(T=l[y+1]<<16),y+2<Y&&(T|=l[y+2]<<8),y+3<Y&&(T|=l[y+3]),T+=l[y]<<24>>>0),T}function _(l,y,A,B){if(B||(L(typeof A=="boolean","missing or invalid endian"),L(y!=null,"missing offset"),L(y+1<l.length,"Trying to read beyond buffer length")),!(l.length<=y))return B=F(l,y,A,!0),32768&B?-1*(65535-B+1):B}function z(l,y,A,B){if(B||(L(typeof A=="boolean","missing or invalid endian"),L(y!=null,"missing offset"),L(y+3<l.length,"Trying to read beyond buffer length")),!(l.length<=y))return B=V(l,y,A,!0),2147483648&B?-1*(4294967295-B+1):B}function x(l,y,A,B){return B||(L(typeof A=="boolean","missing or invalid endian"),L(y+3<l.length,"Trying to read beyond buffer length")),j.read(l,y,A,23,4)}function E(l,y,A,B){return B||(L(typeof A=="boolean","missing or invalid endian"),L(y+7<l.length,"Trying to read beyond buffer length")),j.read(l,y,A,52,8)}function w(l,y,A,B,T){if(T||(L(y!=null,"missing value"),L(typeof B=="boolean","missing or invalid endian"),L(A!=null,"missing offset"),L(A+1<l.length,"trying to write beyond buffer length"),Xt(y,65535)),T=l.length,!(T<=A))for(var Y=0,te=Math.min(T-A,2);Y<te;Y++)l[A+Y]=(y&255<<8*(B?Y:1-Y))>>>8*(B?Y:1-Y)}function C(l,y,A,B,T){if(T||(L(y!=null,"missing value"),L(typeof B=="boolean","missing or invalid endian"),L(A!=null,"missing offset"),L(A+3<l.length,"trying to write beyond buffer length"),Xt(y,4294967295)),T=l.length,!(T<=A))for(var Y=0,te=Math.min(T-A,4);Y<te;Y++)l[A+Y]=y>>>8*(B?Y:3-Y)&255}function M(l,y,A,B,T){T||(L(y!=null,"missing value"),L(typeof B=="boolean","missing or invalid endian"),L(A!=null,"missing offset"),L(A+1<l.length,"Trying to write beyond buffer length"),$t(y,32767,-32768)),l.length<=A||w(l,0<=y?y:65535+y+1,A,B,T)}function ee(l,y,A,B,T){T||(L(y!=null,"missing value"),L(typeof B=="boolean","missing or invalid endian"),L(A!=null,"missing offset"),L(A+3<l.length,"Trying to write beyond buffer length"),$t(y,2147483647,-2147483648)),l.length<=A||C(l,0<=y?y:4294967295+y+1,A,B,T)}function Q(l,y,A,B,T){T||(L(y!=null,"missing value"),L(typeof B=="boolean","missing or invalid endian"),L(A!=null,"missing offset"),L(A+3<l.length,"Trying to write beyond buffer length"),Gt(y,34028234663852886e22,-34028234663852886e22)),l.length<=A||j.write(l,y,A,B,23,4)}function ne(l,y,A,B,T){T||(L(y!=null,"missing value"),L(typeof B=="boolean","missing or invalid endian"),L(A!=null,"missing offset"),L(A+7<l.length,"Trying to write beyond buffer length"),Gt(y,17976931348623157e292,-17976931348623157e292)),l.length<=A||j.write(l,y,A,B,52,8)}i.Buffer=I,i.SlowBuffer=I,i.INSPECT_MAX_BYTES=50,I.poolSize=8192,I._useTypedArrays=function(){try{var l=new ArrayBuffer(0),y=new Uint8Array(l);return y.foo=function(){return 42},y.foo()===42&&typeof y.subarray=="function"}catch{return!1}}(),I.isEncoding=function(l){switch(String(l).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},I.isBuffer=function(l){return!(l==null||!l._isBuffer)},I.byteLength=function(l,y){var A;switch(l+="",y||"utf8"){case"hex":A=l.length/2;break;case"utf8":case"utf-8":A=qe(l).length;break;case"ascii":case"binary":case"raw":A=l.length;break;case"base64":A=fn(l).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":A=2*l.length;break;default:throw new Error("Unknown encoding")}return A},I.concat=function(l,y){if(L(le(l),`Usage: Buffer.concat(list, [totalLength])
5
+ list should be an Array.`),l.length===0)return new I(0);if(l.length===1)return l[0];if(typeof y!="number")for(T=y=0;T<l.length;T++)y+=l[T].length;for(var A=new I(y),B=0,T=0;T<l.length;T++){var Y=l[T];Y.copy(A,B),B+=Y.length}return A},I.prototype.write=function(l,y,A,B){isFinite(y)?isFinite(A)||(B=A,A=void 0):(Se=B,B=y,y=A,A=Se),y=Number(y)||0;var T,Y,te,ge,Se=this.length-y;switch((!A||Se<(A=Number(A)))&&(A=Se),B=String(B||"utf8").toLowerCase()){case"hex":T=function(Ue,ze,me,Ae){me=Number(me)||0;var ve=Ue.length-me;(!Ae||ve<(Ae=Number(Ae)))&&(Ae=ve),L((ve=ze.length)%2==0,"Invalid hex string"),ve/2<Ae&&(Ae=ve/2);for(var dt=0;dt<Ae;dt++){var Ct=parseInt(ze.substr(2*dt,2),16);L(!isNaN(Ct),"Invalid hex string"),Ue[me+dt]=Ct}return I._charsWritten=2*dt,dt}(this,l,y,A);break;case"utf8":case"utf-8":Y=this,te=y,ge=A,T=I._charsWritten=It(qe(l),Y,te,ge);break;case"ascii":case"binary":T=W(this,l,y,A);break;case"base64":Y=this,te=y,ge=A,T=I._charsWritten=It(fn(l),Y,te,ge);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":T=X(this,l,y,A);break;default:throw new Error("Unknown encoding")}return T},I.prototype.toString=function(l,y,A){var B,T,Y,te,ge=this;if(l=String(l||"utf8").toLowerCase(),y=Number(y)||0,(A=A!==void 0?Number(A):ge.length)===y)return"";switch(l){case"hex":B=function(Se,Ue,ze){var me=Se.length;(!Ue||Ue<0)&&(Ue=0),(!ze||ze<0||me<ze)&&(ze=me);for(var Ae="",ve=Ue;ve<ze;ve++)Ae+=de(Se[ve]);return Ae}(ge,y,A);break;case"utf8":case"utf-8":B=function(Se,Ue,ze){var me="",Ae="";ze=Math.min(Se.length,ze);for(var ve=Ue;ve<ze;ve++)Se[ve]<=127?(me+=Kt(Ae)+String.fromCharCode(Se[ve]),Ae=""):Ae+="%"+Se[ve].toString(16);return me+Kt(Ae)}(ge,y,A);break;case"ascii":case"binary":B=P(ge,y,A);break;case"base64":T=ge,te=A,B=(Y=y)===0&&te===T.length?k.fromByteArray(T):k.fromByteArray(T.slice(Y,te));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":B=function(Se,Ue,ze){for(var me=Se.slice(Ue,ze),Ae="",ve=0;ve<me.length;ve+=2)Ae+=String.fromCharCode(me[ve]+256*me[ve+1]);return Ae}(ge,y,A);break;default:throw new Error("Unknown encoding")}return B},I.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},I.prototype.copy=function(l,y,A,B){if(y=y||0,(B=B||B===0?B:this.length)!==(A=A||0)&&l.length!==0&&this.length!==0){L(A<=B,"sourceEnd < sourceStart"),L(0<=y&&y<l.length,"targetStart out of bounds"),L(0<=A&&A<this.length,"sourceStart out of bounds"),L(0<=B&&B<=this.length,"sourceEnd out of bounds"),B>this.length&&(B=this.length);var T=(B=l.length-y<B-A?l.length-y+A:B)-A;if(T<100||!I._useTypedArrays)for(var Y=0;Y<T;Y++)l[Y+y]=this[Y+A];else l._set(this.subarray(A,A+T),y)}},I.prototype.slice=function(l,y){var A=this.length;if(l=oe(l,A,0),y=oe(y,A,A),I._useTypedArrays)return I._augment(this.subarray(l,y));for(var B=y-l,T=new I(B,void 0,!0),Y=0;Y<B;Y++)T[Y]=this[Y+l];return T},I.prototype.get=function(l){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(l)},I.prototype.set=function(l,y){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(l,y)},I.prototype.readUInt8=function(l,y){if(y||(L(l!=null,"missing offset"),L(l<this.length,"Trying to read beyond buffer length")),!(l>=this.length))return this[l]},I.prototype.readUInt16LE=function(l,y){return F(this,l,!0,y)},I.prototype.readUInt16BE=function(l,y){return F(this,l,!1,y)},I.prototype.readUInt32LE=function(l,y){return V(this,l,!0,y)},I.prototype.readUInt32BE=function(l,y){return V(this,l,!1,y)},I.prototype.readInt8=function(l,y){if(y||(L(l!=null,"missing offset"),L(l<this.length,"Trying to read beyond buffer length")),!(l>=this.length))return 128&this[l]?-1*(255-this[l]+1):this[l]},I.prototype.readInt16LE=function(l,y){return _(this,l,!0,y)},I.prototype.readInt16BE=function(l,y){return _(this,l,!1,y)},I.prototype.readInt32LE=function(l,y){return z(this,l,!0,y)},I.prototype.readInt32BE=function(l,y){return z(this,l,!1,y)},I.prototype.readFloatLE=function(l,y){return x(this,l,!0,y)},I.prototype.readFloatBE=function(l,y){return x(this,l,!1,y)},I.prototype.readDoubleLE=function(l,y){return E(this,l,!0,y)},I.prototype.readDoubleBE=function(l,y){return E(this,l,!1,y)},I.prototype.writeUInt8=function(l,y,A){A||(L(l!=null,"missing value"),L(y!=null,"missing offset"),L(y<this.length,"trying to write beyond buffer length"),Xt(l,255)),y>=this.length||(this[y]=l)},I.prototype.writeUInt16LE=function(l,y,A){w(this,l,y,!0,A)},I.prototype.writeUInt16BE=function(l,y,A){w(this,l,y,!1,A)},I.prototype.writeUInt32LE=function(l,y,A){C(this,l,y,!0,A)},I.prototype.writeUInt32BE=function(l,y,A){C(this,l,y,!1,A)},I.prototype.writeInt8=function(l,y,A){A||(L(l!=null,"missing value"),L(y!=null,"missing offset"),L(y<this.length,"Trying to write beyond buffer length"),$t(l,127,-128)),y>=this.length||(0<=l?this.writeUInt8(l,y,A):this.writeUInt8(255+l+1,y,A))},I.prototype.writeInt16LE=function(l,y,A){M(this,l,y,!0,A)},I.prototype.writeInt16BE=function(l,y,A){M(this,l,y,!1,A)},I.prototype.writeInt32LE=function(l,y,A){ee(this,l,y,!0,A)},I.prototype.writeInt32BE=function(l,y,A){ee(this,l,y,!1,A)},I.prototype.writeFloatLE=function(l,y,A){Q(this,l,y,!0,A)},I.prototype.writeFloatBE=function(l,y,A){Q(this,l,y,!1,A)},I.prototype.writeDoubleLE=function(l,y,A){ne(this,l,y,!0,A)},I.prototype.writeDoubleBE=function(l,y,A){ne(this,l,y,!1,A)},I.prototype.fill=function(l,y,A){if(y=y||0,A=A||this.length,L(typeof(l=typeof(l=l||0)=="string"?l.charCodeAt(0):l)=="number"&&!isNaN(l),"value is not a number"),L(y<=A,"end < start"),A!==y&&this.length!==0){L(0<=y&&y<this.length,"start out of bounds"),L(0<=A&&A<=this.length,"end out of bounds");for(var B=y;B<A;B++)this[B]=l}},I.prototype.inspect=function(){for(var l=[],y=this.length,A=0;A<y;A++)if(l[A]=de(this[A]),A===i.INSPECT_MAX_BYTES){l[A+1]="...";break}return"<Buffer "+l.join(" ")+">"},I.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(I._useTypedArrays)return new I(this).buffer;for(var l=new Uint8Array(this.length),y=0,A=l.length;y<A;y+=1)l[y]=this[y];return l.buffer};var H=I.prototype;function oe(l,y,A){return typeof l!="number"?A:y<=(l=~~l)?y:0<=l||0<=(l+=y)?l:0}function se(l){return(l=~~Math.ceil(+l))<0?0:l}function le(l){return(Array.isArray||function(y){return Object.prototype.toString.call(y)==="[object Array]"})(l)}function de(l){return l<16?"0"+l.toString(16):l.toString(16)}function qe(l){for(var y=[],A=0;A<l.length;A++){var B=l.charCodeAt(A);if(B<=127)y.push(l.charCodeAt(A));else for(var T=A,Y=(55296<=B&&B<=57343&&A++,encodeURIComponent(l.slice(T,A+1)).substr(1).split("%")),te=0;te<Y.length;te++)y.push(parseInt(Y[te],16))}return y}function fn(l){return k.toByteArray(l)}function It(l,y,A,B){for(var T=0;T<B&&!(T+A>=y.length||T>=l.length);T++)y[T+A]=l[T];return T}function Kt(l){try{return decodeURIComponent(l)}catch{return"\uFFFD"}}function Xt(l,y){L(typeof l=="number","cannot write a non-number as a number"),L(0<=l,"specified a negative value for writing an unsigned value"),L(l<=y,"value is larger than maximum value for type"),L(Math.floor(l)===l,"value has a fractional component")}function $t(l,y,A){L(typeof l=="number","cannot write a non-number as a number"),L(l<=y,"value larger than maximum allowed value"),L(A<=l,"value smaller than minimum allowed value"),L(Math.floor(l)===l,"value has a fractional component")}function Gt(l,y,A){L(typeof l=="number","cannot write a non-number as a number"),L(l<=y,"value larger than maximum allowed value"),L(A<=l,"value smaller than minimum allowed value")}function L(l,y){if(!l)throw new Error(y||"Failed assertion")}I._augment=function(l){return l._isBuffer=!0,l._get=l.get,l._set=l.set,l.get=H.get,l.set=H.set,l.write=H.write,l.toString=H.toString,l.toLocaleString=H.toString,l.toJSON=H.toJSON,l.copy=H.copy,l.slice=H.slice,l.readUInt8=H.readUInt8,l.readUInt16LE=H.readUInt16LE,l.readUInt16BE=H.readUInt16BE,l.readUInt32LE=H.readUInt32LE,l.readUInt32BE=H.readUInt32BE,l.readInt8=H.readInt8,l.readInt16LE=H.readInt16LE,l.readInt16BE=H.readInt16BE,l.readInt32LE=H.readInt32LE,l.readInt32BE=H.readInt32BE,l.readFloatLE=H.readFloatLE,l.readFloatBE=H.readFloatBE,l.readDoubleLE=H.readDoubleLE,l.readDoubleBE=H.readDoubleBE,l.writeUInt8=H.writeUInt8,l.writeUInt16LE=H.writeUInt16LE,l.writeUInt16BE=H.writeUInt16BE,l.writeUInt32LE=H.writeUInt32LE,l.writeUInt32BE=H.writeUInt32BE,l.writeInt8=H.writeInt8,l.writeInt16LE=H.writeInt16LE,l.writeInt16BE=H.writeInt16BE,l.writeInt32LE=H.writeInt32LE,l.writeInt32BE=H.writeInt32BE,l.writeFloatLE=H.writeFloatLE,l.writeFloatBE=H.writeFloatBE,l.writeDoubleLE=H.writeDoubleLE,l.writeDoubleBE=H.writeDoubleBE,l.fill=H.fill,l.inspect=H.inspect,l.toArrayBuffer=H.toArrayBuffer,l}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(t,r,i){(function(a,p,k,m,b,S,D,G,O){var k=t("buffer").Buffer,j=4,I=new k(j);I.fill(0),r.exports={hash:function(W,X,P,F){for(var V=X(function(w,C){w.length%j!=0&&(M=w.length+(j-w.length%j),w=k.concat([w,I],M));for(var M,ee=[],Q=C?w.readInt32BE:w.readInt32LE,ne=0;ne<w.length;ne+=j)ee.push(Q.call(w,ne));return ee}(W=k.isBuffer(W)?W:new k(W),F),8*W.length),X=F,_=new k(P),z=X?_.writeInt32BE:_.writeInt32LE,x=0;x<V.length;x++)z.call(_,V[x],4*x,!0);return _}}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(t,r,i){(function(a,p,k,m,b,S,D,G,O){var k=t("buffer").Buffer,j=t("./sha"),I=t("./sha256"),W=t("./rng"),X={sha1:j,sha256:I,md5:t("./md5")},P=64,F=new k(P);function V(w,C){var M=X[w=w||"sha1"],ee=[];return M||_("algorithm:",w,"is not yet supported"),{update:function(Q){return k.isBuffer(Q)||(Q=new k(Q)),ee.push(Q),Q.length,this},digest:function(Q){var ne=k.concat(ee),ne=C?function(H,oe,se){k.isBuffer(oe)||(oe=new k(oe)),k.isBuffer(se)||(se=new k(se)),oe.length>P?oe=H(oe):oe.length<P&&(oe=k.concat([oe,F],P));for(var le=new k(P),de=new k(P),qe=0;qe<P;qe++)le[qe]=54^oe[qe],de[qe]=92^oe[qe];return se=H(k.concat([le,se])),H(k.concat([de,se]))}(M,C,ne):M(ne);return ee=null,Q?ne.toString(Q):ne}}}function _(){var w=[].slice.call(arguments).join(" ");throw new Error([w,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
6
+ `))}F.fill(0),i.createHash=function(w){return V(w)},i.createHmac=V,i.randomBytes=function(w,C){if(!C||!C.call)return new k(W(w));try{C.call(this,void 0,new k(W(w)))}catch(M){C(M)}};var z,x=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],E=function(w){i[w]=function(){_("sorry,",w,"is not implemented yet")}};for(z in x)E(x[z])}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(t,r,i){(function(a,p,f,m,b,S,D,G,O){var k=t("./helpers");function j(_,z){_[z>>5]|=128<<z%32,_[14+(z+64>>>9<<4)]=z;for(var x=1732584193,E=-271733879,w=-1732584194,C=271733878,M=0;M<_.length;M+=16){var ee=x,Q=E,ne=w,H=C,x=W(x,E,w,C,_[M+0],7,-680876936),C=W(C,x,E,w,_[M+1],12,-389564586),w=W(w,C,x,E,_[M+2],17,606105819),E=W(E,w,C,x,_[M+3],22,-1044525330);x=W(x,E,w,C,_[M+4],7,-176418897),C=W(C,x,E,w,_[M+5],12,1200080426),w=W(w,C,x,E,_[M+6],17,-1473231341),E=W(E,w,C,x,_[M+7],22,-45705983),x=W(x,E,w,C,_[M+8],7,1770035416),C=W(C,x,E,w,_[M+9],12,-1958414417),w=W(w,C,x,E,_[M+10],17,-42063),E=W(E,w,C,x,_[M+11],22,-1990404162),x=W(x,E,w,C,_[M+12],7,1804603682),C=W(C,x,E,w,_[M+13],12,-40341101),w=W(w,C,x,E,_[M+14],17,-1502002290),x=X(x,E=W(E,w,C,x,_[M+15],22,1236535329),w,C,_[M+1],5,-165796510),C=X(C,x,E,w,_[M+6],9,-1069501632),w=X(w,C,x,E,_[M+11],14,643717713),E=X(E,w,C,x,_[M+0],20,-373897302),x=X(x,E,w,C,_[M+5],5,-701558691),C=X(C,x,E,w,_[M+10],9,38016083),w=X(w,C,x,E,_[M+15],14,-660478335),E=X(E,w,C,x,_[M+4],20,-405537848),x=X(x,E,w,C,_[M+9],5,568446438),C=X(C,x,E,w,_[M+14],9,-1019803690),w=X(w,C,x,E,_[M+3],14,-187363961),E=X(E,w,C,x,_[M+8],20,1163531501),x=X(x,E,w,C,_[M+13],5,-1444681467),C=X(C,x,E,w,_[M+2],9,-51403784),w=X(w,C,x,E,_[M+7],14,1735328473),x=P(x,E=X(E,w,C,x,_[M+12],20,-1926607734),w,C,_[M+5],4,-378558),C=P(C,x,E,w,_[M+8],11,-2022574463),w=P(w,C,x,E,_[M+11],16,1839030562),E=P(E,w,C,x,_[M+14],23,-35309556),x=P(x,E,w,C,_[M+1],4,-1530992060),C=P(C,x,E,w,_[M+4],11,1272893353),w=P(w,C,x,E,_[M+7],16,-155497632),E=P(E,w,C,x,_[M+10],23,-1094730640),x=P(x,E,w,C,_[M+13],4,681279174),C=P(C,x,E,w,_[M+0],11,-358537222),w=P(w,C,x,E,_[M+3],16,-722521979),E=P(E,w,C,x,_[M+6],23,76029189),x=P(x,E,w,C,_[M+9],4,-640364487),C=P(C,x,E,w,_[M+12],11,-421815835),w=P(w,C,x,E,_[M+15],16,530742520),x=F(x,E=P(E,w,C,x,_[M+2],23,-995338651),w,C,_[M+0],6,-198630844),C=F(C,x,E,w,_[M+7],10,1126891415),w=F(w,C,x,E,_[M+14],15,-1416354905),E=F(E,w,C,x,_[M+5],21,-57434055),x=F(x,E,w,C,_[M+12],6,1700485571),C=F(C,x,E,w,_[M+3],10,-1894986606),w=F(w,C,x,E,_[M+10],15,-1051523),E=F(E,w,C,x,_[M+1],21,-2054922799),x=F(x,E,w,C,_[M+8],6,1873313359),C=F(C,x,E,w,_[M+15],10,-30611744),w=F(w,C,x,E,_[M+6],15,-1560198380),E=F(E,w,C,x,_[M+13],21,1309151649),x=F(x,E,w,C,_[M+4],6,-145523070),C=F(C,x,E,w,_[M+11],10,-1120210379),w=F(w,C,x,E,_[M+2],15,718787259),E=F(E,w,C,x,_[M+9],21,-343485551),x=V(x,ee),E=V(E,Q),w=V(w,ne),C=V(C,H)}return Array(x,E,w,C)}function I(_,z,x,E,w,C){return V((z=V(V(z,_),V(E,C)))<<w|z>>>32-w,x)}function W(_,z,x,E,w,C,M){return I(z&x|~z&E,_,z,w,C,M)}function X(_,z,x,E,w,C,M){return I(z&E|x&~E,_,z,w,C,M)}function P(_,z,x,E,w,C,M){return I(z^x^E,_,z,w,C,M)}function F(_,z,x,E,w,C,M){return I(x^(z|~E),_,z,w,C,M)}function V(_,z){var x=(65535&_)+(65535&z);return(_>>16)+(z>>16)+(x>>16)<<16|65535&x}r.exports=function(_){return k.hash(_,j,16)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(t,r,i){(function(a,p,f,m,b,S,D,G,O){r.exports=function(k){for(var j,I=new Array(k),W=0;W<k;W++)!(3&W)&&(j=4294967296*Math.random()),I[W]=j>>>((3&W)<<3)&255;return I}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(t,r,i){(function(a,p,f,m,b,S,D,G,O){var k=t("./helpers");function j(X,P){X[P>>5]|=128<<24-P%32,X[15+(P+64>>9<<4)]=P;for(var F,V,_,z=Array(80),x=1732584193,E=-271733879,w=-1732584194,C=271733878,M=-1009589776,ee=0;ee<X.length;ee+=16){for(var Q=x,ne=E,H=w,oe=C,se=M,le=0;le<80;le++){z[le]=le<16?X[ee+le]:W(z[le-3]^z[le-8]^z[le-14]^z[le-16],1);var de=I(I(W(x,5),(de=E,V=w,_=C,(F=le)<20?de&V|~de&_:!(F<40)&&F<60?de&V|de&_|V&_:de^V^_)),I(I(M,z[le]),(F=le)<20?1518500249:F<40?1859775393:F<60?-1894007588:-899497514)),M=C,C=w,w=W(E,30),E=x,x=de}x=I(x,Q),E=I(E,ne),w=I(w,H),C=I(C,oe),M=I(M,se)}return Array(x,E,w,C,M)}function I(X,P){var F=(65535&X)+(65535&P);return(X>>16)+(P>>16)+(F>>16)<<16|65535&F}function W(X,P){return X<<P|X>>>32-P}r.exports=function(X){return k.hash(X,j,20,!0)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(t,r,i){(function(a,p,f,m,b,S,D,G,O){function k(P,F){var V=(65535&P)+(65535&F);return(P>>16)+(F>>16)+(V>>16)<<16|65535&V}function j(P,F){var V,_=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),z=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),x=new Array(64);P[F>>5]|=128<<24-F%32,P[15+(F+64>>9<<4)]=F;for(var E,w,C=0;C<P.length;C+=16){for(var M=z[0],ee=z[1],Q=z[2],ne=z[3],H=z[4],oe=z[5],se=z[6],le=z[7],de=0;de<64;de++)x[de]=de<16?P[de+C]:k(k(k((w=x[de-2],W(w,17)^W(w,19)^X(w,10)),x[de-7]),(w=x[de-15],W(w,7)^W(w,18)^X(w,3))),x[de-16]),V=k(k(k(k(le,W(w=H,6)^W(w,11)^W(w,25)),H&oe^~H&se),_[de]),x[de]),E=k(W(E=M,2)^W(E,13)^W(E,22),M&ee^M&Q^ee&Q),le=se,se=oe,oe=H,H=k(ne,V),ne=Q,Q=ee,ee=M,M=k(V,E);z[0]=k(M,z[0]),z[1]=k(ee,z[1]),z[2]=k(Q,z[2]),z[3]=k(ne,z[3]),z[4]=k(H,z[4]),z[5]=k(oe,z[5]),z[6]=k(se,z[6]),z[7]=k(le,z[7])}return z}var I=t("./helpers"),W=function(P,F){return P>>>F|P<<32-F},X=function(P,F){return P>>>F};r.exports=function(P){return I.hash(P,j,32,!0)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(t,r,i){(function(a,p,f,m,b,S,D,G,O){i.read=function(k,j,I,W,C){var P,F,V=8*C-W-1,_=(1<<V)-1,z=_>>1,x=-7,E=I?C-1:0,w=I?-1:1,C=k[j+E];for(E+=w,P=C&(1<<-x)-1,C>>=-x,x+=V;0<x;P=256*P+k[j+E],E+=w,x-=8);for(F=P&(1<<-x)-1,P>>=-x,x+=W;0<x;F=256*F+k[j+E],E+=w,x-=8);if(P===0)P=1-z;else{if(P===_)return F?NaN:1/0*(C?-1:1);F+=Math.pow(2,W),P-=z}return(C?-1:1)*F*Math.pow(2,P-W)},i.write=function(k,j,I,W,X,M){var F,V,_=8*M-X-1,z=(1<<_)-1,x=z>>1,E=X===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=W?0:M-1,C=W?1:-1,M=j<0||j===0&&1/j<0?1:0;for(j=Math.abs(j),isNaN(j)||j===1/0?(V=isNaN(j)?1:0,F=z):(F=Math.floor(Math.log(j)/Math.LN2),j*(W=Math.pow(2,-F))<1&&(F--,W*=2),2<=(j+=1<=F+x?E/W:E*Math.pow(2,1-x))*W&&(F++,W/=2),z<=F+x?(V=0,F=z):1<=F+x?(V=(j*W-1)*Math.pow(2,X),F+=x):(V=j*Math.pow(2,x-1)*Math.pow(2,X),F=0));8<=X;k[I+w]=255&V,w+=C,V/=256,X-=8);for(F=F<<X|V,_+=X;0<_;k[I+w]=255&F,w+=C,F/=256,_-=8);k[I+w-C]|=128*M}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(t,r,i){(function(a,p,f,m,b,S,D,G,O){var k,j,I;function W(){}(a=r.exports={}).nextTick=(j=typeof window<"u"&&window.setImmediate,I=typeof window<"u"&&window.postMessage&&window.addEventListener,j?function(X){return window.setImmediate(X)}:I?(k=[],window.addEventListener("message",function(X){var P=X.source;P!==window&&P!==null||X.data!=="process-tick"||(X.stopPropagation(),0<k.length&&k.shift()())},!0),function(X){k.push(X),window.postMessage("process-tick","*")}):function(X){setTimeout(X,0)}),a.title="browser",a.browser=!0,a.env={},a.argv=[],a.on=W,a.addListener=W,a.once=W,a.off=W,a.removeListener=W,a.removeAllListeners=W,a.emit=W,a.binding=function(X){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(X){throw new Error("process.chdir is not supported")}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})}(wi)),wi.exports}var Os=Ls();const Ms=bt(Os);function ir(n){return e=>!n(e)}function rt(n){return n==null}function bi(n){return Array.isArray(n)}function zs(...n){return ue(Rs,n)}var Rs=(n,e)=>e.every(t=>t(n));function Je(...n){return ue(js,n)}var js=(n,e)=>e.some(t=>t(n)),_n;(n=>{n.isDeploymentNode=e=>"kind"in e&&!("element"in e),n.isInstance=e=>"element"in e&&!("kind"in e)})(_n||(_n={}));function Us(n,e){return e?e+"."+n:n}var zt;(n=>{n.Group="@group"})(zt||(zt={}));const Zt="primary",Sn="rectangle";function Ke(n){return"element"in n}function gt(n){return"expanded"in n}function An(n){return"custom"in n&&(or(n.custom.expr)||In(n.custom.expr))}function Oe(n){return"wildcard"in n}function Rt(n){return"elementKind"in n&&"isEqual"in n}function jt(n){return"elementTag"in n&&"isEqual"in n}function or(n){return Ke(n)||Oe(n)||Rt(n)||jt(n)||gt(n)}function In(n){return"where"in n&&or(n.where.expr)}function Ns(n){return or(n)||In(n)||An(n)}function sr(n){return"source"in n&&"target"in n}function ar(n){return"inout"in n}function ur(n){return"incoming"in n}function cr(n){return"outgoing"in n}function xi(n){return sr(n)||ar(n)||ur(n)||cr(n)}function dr(n){return"where"in n&&xi(n.where.expr)}function lr(n){return"customRelation"in n}function Ei(n){return xi(n)||dr(n)||lr(n)}var en;(n=>{n.isInsideInstanceRef=e=>"deployment"in e&&"element"in e,n.isDeploymentElementRef=e=>"deployment"in e&&!("element"in e),n.isDeploymentRef=e=>!(0,n.isModelRef)(e),n.isModelRef=e=>"model"in e,n.toDeploymentRef=e=>(re((0,n.isDeploymentRef)(e),"Expected DeploymentRef"),(0,n.isInsideInstanceRef)(e)?{id:e.deployment,element:e.element}:{id:e.deployment})})(en||(en={}));var ie;(n=>{n.isWildcard=e=>"wildcard"in e&&e.wildcard===!0,n.isModelRef=e=>"ref"in e&&en.isModelRef(e.ref),n.isDeploymentRef=e=>"ref"in e&&en.isDeploymentRef(e.ref)})(ie||(ie={}));var Qe;(n=>{n.isDirect=e=>"source"in e&&"target"in e,n.isIncoming=e=>"incoming"in e,n.isOutgoing=e=>"outgoing"in e,n.isInOut=e=>"inout"in e,n.isWhere=e=>"where"in e})(Qe||(Qe={}));var ki;(n=>{n.isFqnExpr=e=>ie.isWildcard(e)||ie.isModelRef(e)||ie.isDeploymentRef(e),n.isRelation=e=>Qe.isDirect(e)||Qe.isIncoming(e)||Qe.isOutgoing(e)||Qe.isInOut(e)})(ki||(ki={}));const Ts=n=>"tag"in n,Bs=n=>"kind"in n,Ws=n=>"not"in n,_i=n=>"and"in n,Si=n=>"or"in n;function ct(n){switch(!0){case Ts(n):{if("eq"in n.tag){const t=n.tag.eq;return r=>Array.isArray(r.tags)&&r.tags.includes(t)}const e=n.tag.neq;return t=>!Array.isArray(t.tags)||!t.tags.includes(e)}case Bs(n):{if("eq"in n.kind){const t=n.kind.eq;return r=>r.kind===t}const e=n.kind.neq;return t=>rt(t.kind)||t.kind!==e}case Ws(n):{const e=ct(n.not);return ir(e)}case _i(n):{const e=n.and.map(ct);return zs(e)}case Si(n):{const e=n.or.map(ct);return Je(e)}default:Be(n)}}const Ai="dashed",hr="normal",Ii="gray";function $n(n){return"include"in n&&Array.isArray(n.include)||"exclude"in n&&Array.isArray(n.exclude)}function $i(n){return"predicateId"in n}function Gi(n){return"style"in n&&"targets"in n&&Array.isArray(n.targets)}function Ci(n){return"styleId"in n}function Fs(n){return n==="TB"||n==="BT"||n==="LR"||n==="RL"}function fr(n){return"direction"in n}function Di(n){return"title"in n&&"groupRules"in n&&Array.isArray(n.groupRules)}function Ps(n){return"__parallel"in n&&bi(n.__parallel)}function Li(n){return n.__==="deployment"}function Oi(n){return n.__==="dynamic"}function tn(n){return rt(n.__)||n.__==="element"}function qs(n){return tn(n)&&"extends"in n}function Mi(n){return tn(n)&&"viewOf"in n}function zi(n,e){const t=`step-${String(n).padStart(2,"0")}`;return e?`${t}.${e}`:t}function Ri(n){return n.startsWith("step-")}function ji(n){if(!Ri(n))throw new Error(`Invalid step edge id: ${n}`);return parseFloat(n.slice(5))}var it;(n=>{function e(i){return i.modelRef===1?i.id:i.modelRef??null}n.modelRef=e;function t(i){return i.deploymentRef===1?i.id:i.deploymentRef??null}n.deploymentRef=t;function r(i){return i.kind===zt.Group}n.isNodesGroup=r})(it||(it={}));var pr;(n=>{function e(i){return i.__==="deployment"}n.isDeployment=e;function t(i){return i.__==="dynamic"}n.isDynamic=t;function r(i){return rt(i.__)||i.__==="element"}n.isElement=r})(pr||(pr={}));var gr;(n=>{function e(i){return i.modelRef===1?i.id:i.modelRef??null}n.modelRef=e;function t(i){return i.deploymentRef===1?i.id:i.deploymentRef??null}n.deploymentRef=t;function r(i){return i.kind===zt.Group}n.isNodesGroup=r})(gr||(gr={}));function Et(...n){return ue(Object.values,n)}function Gn(...n){return n.length===2?(e,...t)=>Ui(e,...n,...t):Ui(...n)}var Ui=(n,e,t,...r)=>e(n,...r)?typeof t=="function"?t(n,...r):t.onTrue(n,...r):typeof t=="function"?n:t.onFalse(n,...r);function Ys(n,e){let t=e.length-n.length;if(t===1){let[r,...i]=e;return J(r,{lazy:n,lazyArgs:i})}if(t===0){let r={lazy:n,lazyArgs:e};return Object.assign(i=>J(i,r),r)}throw new Error("Wrong number of arguments")}function mt(...n){return Ys(Ks,n)}function Ks(){let n=new Set;return e=>n.has(e)?Fn:(n.add(e),{done:!1,hasNext:!0,next:e})}function Ni(...n){return ue(Xs,n,Vs)}var Xs=(n,e)=>e<0?[]:n.slice(0,e);function Vs(n){if(n<=0)return hs;let e=n;return t=>(e-=1,{done:e<=0,hasNext:!0,next:t})}var Ti={asc:(n,e)=>n>e,desc:(n,e)=>n<e};function Hs(n,e){let[t,...r]=e;if(!Js(t)){let a=mr(...r);return n(t,a)}let i=mr(t,...r);return a=>n(a,i)}function mr(n,e,...t){let r=typeof n=="function"?n:n[0],i=typeof n=="function"?"asc":n[1],{[i]:a}=Ti,p=e===void 0?void 0:mr(e,...t);return(f,m)=>{let b=r(f),S=r(m);return a(b,S)?1:a(S,b)?-1:p?.(f,m)??0}}function Js(n){if(Bi(n))return!0;if(typeof n!="object"||!Array.isArray(n))return!1;let[e,t,...r]=n;return Bi(e)&&typeof t=="string"&&t in Ti&&r.length===0}var Bi=n=>typeof n=="function"&&n.length===1;function yr(...n){return ue(Qs,n)}function Qs(n,e){let t=[...n];return t.sort(e),t}function Zs(...n){return Hs(ea,n)}var ea=(n,e)=>[...n].sort(e);function nn(...n){return ue(ta,n)}var ta=(n,e,t)=>n.reduce(e,t);function Wi(...n){return ue(na,n)}function na(n){return[...n].reverse()}function rn(...n){return ue(ra,n)}function ra(n,e){let t={};for(let r of e)r in n&&(t[r]=n[r]);return t}function Fi(...n){return ue(ia,n)}function ia(n,e){let t={};for(let[r,i]of Object.entries(n))e(i,r,n)&&(t[r]=i);return t}function on(...n){return e=>J(e,...n)}function Ze(...n){return ue(oa,n)}var oa=(n,e)=>n[e];function Pi(...n){return ue(sa,n)}function sa(n,e){let t={...n};for(let[r,i]of Object.entries(t))e(i,r,n)&&delete t[r];return t}function ke(...n){return ue(aa,n)}var aa=n=>n.length===1?n[0]:void 0;function Cn(...n){return ue(ua,n)}var ua=(n,e)=>{let t=[[],[]];for(let[r,i]of n.entries())e(i,r,n)?t[0].push(i):t[1].push(i);return t};function ca(...n){return ue(da,n)}var da=n=>n.at(-1);function qi(...n){return ue(la,n)}function la(n,e){let t={};for(let[r,i]of n.entries()){let[a,p]=e(i,r,n);t[a]=p}return t}function Dn(...n){return ue(ha,n)}function ha(n,e){let t={};for(let[r,i]of Object.entries(n)){let a=e(i,r,n);t[r]=a}return t}function _e(n){return!!n}function fa(n){return typeof n=="number"&&!Number.isNaN(n)}function pa(n){return typeof n=="boolean"}function yt(n){return n===void 0?!0:typeof n=="string"||Array.isArray(n)?n.length===0:Object.keys(n).length===0}function ga(...n){return ue(sn,n)}function sn(n,e){if(n===e||Object.is(n,e))return!0;if(typeof n!="object"||typeof e!="object"||n===null||e===null||Object.getPrototypeOf(n)!==Object.getPrototypeOf(e))return!1;if(Array.isArray(n))return ma(n,e);if(n instanceof Map)return ya(n,e);if(n instanceof Set)return wa(n,e);if(n instanceof Date)return n.getTime()===e.getTime();if(n instanceof RegExp)return n.toString()===e.toString();if(Object.keys(n).length!==Object.keys(e).length)return!1;for(let[t,r]of Object.entries(n))if(!(t in e)||!sn(r,e[t]))return!1;return!0}function ma(n,e){if(n.length!==e.length)return!1;for(let[t,r]of n.entries())if(!sn(r,e[t]))return!1;return!0}function ya(n,e){if(n.size!==e.size)return!1;for(let[t,r]of n.entries())if(!e.has(t)||!sn(r,e.get(t)))return!1;return!0}function wa(n,e){if(n.size!==e.size)return!1;let t=[...e];for(let r of n){let i=!1;for(let[a,p]of t.entries())if(sn(r,p)){i=!0,t.splice(a,1);break}if(!i)return!1}return!0}function et(...n){return ue(va,n,ba)}var va=(n,e)=>n.flatMap(e),ba=n=>(e,t,r)=>{let i=n(e,t,r);return Array.isArray(i)?{done:!1,hasNext:!0,hasMany:!0,next:i}:{done:!1,hasNext:!0,next:i}};function We(...n){return ue(xa,n,Ea)}function xa(n,e){return n.forEach(e),n}var Ea=n=>(e,t,r)=>(n(e,t,r),{done:!1,hasNext:!0,next:e});function Ln(...n){return ue(ka,n)}var ka=(n,e)=>{let t={};for(let[r,i]of n.entries()){let a=e(i,r,n);if(a!==void 0){let{[a]:p}=t;p===void 0&&(p=[],t[a]=p),p.push(i)}}return t};function we(...n){return ue(_a,n,Sa)}var _a=(n,e)=>n.filter(e),Sa=n=>(e,t,r)=>n(e,t,r)?{done:!1,hasNext:!0,next:e}:Fn;function wr(...n){return ue(Aa,n)}var Aa=(n,e)=>{for(let t=n.length-1;t>=0;t--){let r=n[t];if(e(r,t,n))return r}};function vr(...n){return ue(Ia,n)}function Ia(n,e){for(let[t,r]of n.entries())if(!e(r,t,n))return n.slice(t);return[]}function br(...n){return ue(Object.entries,n)}function Yi(...n){return ue($a,n)}var $a=(n,e)=>[...n,...e];function On(n){return()=>n}class xr{constructor(e,t){this.$model=e,this.$element=t,this.id=this.$element.id,this.hierarchyLevel=Mt(this.id)}id;hierarchyLevel;get parent(){return this.$model.parent(this)}get kind(){return this.$element.kind}get shape(){return this.$element.shape??Sn}get color(){return this.$element.color??Zt}get tags(){return this.$element.tags??[]}get title(){return this.$element.title}get description(){return this.$element.description}get technology(){return this.$element.technology}get links(){return this.$element.links??[]}get defaultView(){return this.scopedViews().next().value??null}isAncestorOf(e){return ye(this,e)}isDescendantOf(e){return ye(e,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){const t=ft(this.id,e.id);return t?this.$model.element(t):null}children(){return this.$model.children(this)}descendants(e){return e?En([...this.$model.descendants(this)],e)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(const e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(const e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e="all"){return this.$model.incoming(this,e)}*incomers(e="all"){const t=new Set;for(const r of this.incoming(e))t.has(r.source.id)||(t.add(r.source.id),yield r.source)}outgoing(e="all"){return this.$model.outgoing(this,e)}*outgoers(e="all"){const t=new Set;for(const r of this.outgoing(e))t.has(r.target.id)||(t.add(r.target.id),yield r.target)}cachedOutgoing=null;cachedIncoming=null;get allOutgoing(){return this.cachedOutgoing??=new Set(this.outgoing()),this.cachedOutgoing}get allIncoming(){return this.cachedIncoming??=new Set(this.incoming()),this.cachedIncoming}*views(){for(const e of this.$model.views())e.includesElement(this.id)&&(yield e)}*scopedViews(){for(const e of this.$model.views())e.isElementView()&&e.$view.viewOf===this.id&&(yield e)}isDeployed(){return _e(this.deployments().next().value)}deployments(){return this.$model.deployment.instancesOf(this)}}function Er(n){return J(n,Ln(Ze("notation")),Dn(on(Ln(Ze("shape")),Dn(on(Ln(Ze("color")),Dn(on(xe(Ze("kind")),mt())),br(),xe(([e,t])=>({kinds:t,color:e})))),br(),et(([e,t])=>t.map(({color:r,kinds:i})=>({shape:e,color:r,kinds:i}))))),br(),et(([e,t])=>t.map(({shape:r,color:i,kinds:a})=>({title:e,shape:r,color:i,kinds:a}))),Zs(Ze("shape"),Ze("title"),[e=>e.kinds.length,"desc"]))}function kr(n,e){const t=[];let r=n.parent;for(;r;){const i=be(e.get(r),`Parent node ${r} not found`);t.push(i),r=i.parent}return t}function Ki(n,e){for(const t of e){const r=n.get(t.source),i=n.get(t.target);re(r,`Source node ${t.source} not found`),re(i,`Target node ${t.target} not found`),r.outEdges.push(t.id),i.inEdges.push(t.id);const a=kr(r,n),p=kr(i,n),f=a.length>0&&p.length>0?ca(Es(Wi(a),Wi(p))):null;t.parent=f?f.id:null;for(const m of a){if(m===f)break;m.outEdges.push(t.id)}for(const m of p){if(m===f)break;m.inEdges.push(t.id)}}}var _r={exports:{}},Ga=_r.exports,Xi;function Ca(){return Xi||(Xi=1,function(n,e){(function(t,r){n.exports=r()})(Ga,function(){function t(u){return t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},t(u)}function r(u,h){u.prototype=Object.create(h.prototype),u.prototype.constructor=u,a(u,h)}function i(u){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},i(u)}function a(u,h){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,o){return c.__proto__=o,c},a(u,h)}function p(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function f(u,h,c){return f=p()?Reflect.construct.bind():function(o,s,d){var g=[null];g.push.apply(g,s);var v=new(Function.bind.apply(o,g));return d&&a(v,d.prototype),v},f.apply(null,arguments)}function m(u){var h=typeof Map=="function"?new Map:void 0;return m=function(c){if(c===null||(o=c,Function.toString.call(o).indexOf("[native code]")===-1))return c;var o;if(typeof c!="function")throw new TypeError("Super expression must either be null or a function");if(h!==void 0){if(h.has(c))return h.get(c);h.set(c,s)}function s(){return f(c,arguments,i(this).constructor)}return s.prototype=Object.create(c.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),a(s,c)},m(u)}function b(u){if(u===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u}var S=function(){for(var u=arguments[0],h=1,c=arguments.length;h<c;h++)if(arguments[h])for(var o in arguments[h])u[o]=arguments[h][o];return u};function D(u,h,c,o){var s=u._nodes.get(h),d=null;return s?d=o==="mixed"?s.out&&s.out[c]||s.undirected&&s.undirected[c]:o==="directed"?s.out&&s.out[c]:s.undirected&&s.undirected[c]:d}function G(u){return t(u)==="object"&&u!==null}function O(u){var h;for(h in u)return!1;return!0}function k(u,h,c){Object.defineProperty(u,h,{enumerable:!1,configurable:!1,writable:!0,value:c})}function j(u,h,c){var o={enumerable:!0,configurable:!0};typeof c=="function"?o.get=c:(o.value=c,o.writable=!1),Object.defineProperty(u,h,o)}function I(u){return!!G(u)&&!(u.attributes&&!Array.isArray(u.attributes))}typeof Object.assign=="function"&&(S=Object.assign);var W,X={exports:{}},P=typeof Reflect=="object"?Reflect:null,F=P&&typeof P.apply=="function"?P.apply:function(u,h,c){return Function.prototype.apply.call(u,h,c)};W=P&&typeof P.ownKeys=="function"?P.ownKeys:Object.getOwnPropertySymbols?function(u){return Object.getOwnPropertyNames(u).concat(Object.getOwnPropertySymbols(u))}:function(u){return Object.getOwnPropertyNames(u)};var V=Number.isNaN||function(u){return u!=u};function _(){_.init.call(this)}X.exports=_,X.exports.once=function(u,h){return new Promise(function(c,o){function s(g){u.removeListener(h,d),o(g)}function d(){typeof u.removeListener=="function"&&u.removeListener("error",s),c([].slice.call(arguments))}H(u,h,d,{once:!0}),h!=="error"&&function(g,v,$){typeof g.on=="function"&&H(g,"error",v,$)}(u,s,{once:!0})})},_.EventEmitter=_,_.prototype._events=void 0,_.prototype._eventsCount=0,_.prototype._maxListeners=void 0;var z=10;function x(u){if(typeof u!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof u)}function E(u){return u._maxListeners===void 0?_.defaultMaxListeners:u._maxListeners}function w(u,h,c,o){var s,d,g,v;if(x(c),(d=u._events)===void 0?(d=u._events=Object.create(null),u._eventsCount=0):(d.newListener!==void 0&&(u.emit("newListener",h,c.listener?c.listener:c),d=u._events),g=d[h]),g===void 0)g=d[h]=c,++u._eventsCount;else if(typeof g=="function"?g=d[h]=o?[c,g]:[g,c]:o?g.unshift(c):g.push(c),(s=E(u))>0&&g.length>s&&!g.warned){g.warned=!0;var $=new Error("Possible EventEmitter memory leak detected. "+g.length+" "+String(h)+" listeners added. Use emitter.setMaxListeners() to increase limit");$.name="MaxListenersExceededWarning",$.emitter=u,$.type=h,$.count=g.length,v=$,console&&console.warn&&console.warn(v)}return u}function C(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function M(u,h,c){var o={fired:!1,wrapFn:void 0,target:u,type:h,listener:c},s=C.bind(o);return s.listener=c,o.wrapFn=s,s}function ee(u,h,c){var o=u._events;if(o===void 0)return[];var s=o[h];return s===void 0?[]:typeof s=="function"?c?[s.listener||s]:[s]:c?function(d){for(var g=new Array(d.length),v=0;v<g.length;++v)g[v]=d[v].listener||d[v];return g}(s):ne(s,s.length)}function Q(u){var h=this._events;if(h!==void 0){var c=h[u];if(typeof c=="function")return 1;if(c!==void 0)return c.length}return 0}function ne(u,h){for(var c=new Array(h),o=0;o<h;++o)c[o]=u[o];return c}function H(u,h,c,o){if(typeof u.on=="function")o.once?u.once(h,c):u.on(h,c);else{if(typeof u.addEventListener!="function")throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof u);u.addEventListener(h,function s(d){o.once&&u.removeEventListener(h,s),c(d)})}}function oe(u){if(typeof u!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=u}Object.defineProperty(_,"defaultMaxListeners",{enumerable:!0,get:function(){return z},set:function(u){if(typeof u!="number"||u<0||V(u))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+u+".");z=u}}),_.init=function(){this._events!==void 0&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_.prototype.setMaxListeners=function(u){if(typeof u!="number"||u<0||V(u))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+u+".");return this._maxListeners=u,this},_.prototype.getMaxListeners=function(){return E(this)},_.prototype.emit=function(u){for(var h=[],c=1;c<arguments.length;c++)h.push(arguments[c]);var o=u==="error",s=this._events;if(s!==void 0)o=o&&s.error===void 0;else if(!o)return!1;if(o){var d;if(h.length>0&&(d=h[0]),d instanceof Error)throw d;var g=new Error("Unhandled error."+(d?" ("+d.message+")":""));throw g.context=d,g}var v=s[u];if(v===void 0)return!1;if(typeof v=="function")F(v,this,h);else{var $=v.length,N=ne(v,$);for(c=0;c<$;++c)F(N[c],this,h)}return!0},_.prototype.addListener=function(u,h){return w(this,u,h,!1)},_.prototype.on=_.prototype.addListener,_.prototype.prependListener=function(u,h){return w(this,u,h,!0)},_.prototype.once=function(u,h){return x(h),this.on(u,M(this,u,h)),this},_.prototype.prependOnceListener=function(u,h){return x(h),this.prependListener(u,M(this,u,h)),this},_.prototype.removeListener=function(u,h){var c,o,s,d,g;if(x(h),(o=this._events)===void 0)return this;if((c=o[u])===void 0)return this;if(c===h||c.listener===h)--this._eventsCount==0?this._events=Object.create(null):(delete o[u],o.removeListener&&this.emit("removeListener",u,c.listener||h));else if(typeof c!="function"){for(s=-1,d=c.length-1;d>=0;d--)if(c[d]===h||c[d].listener===h){g=c[d].listener,s=d;break}if(s<0)return this;s===0?c.shift():function(v,$){for(;$+1<v.length;$++)v[$]=v[$+1];v.pop()}(c,s),c.length===1&&(o[u]=c[0]),o.removeListener!==void 0&&this.emit("removeListener",u,g||h)}return this},_.prototype.off=_.prototype.removeListener,_.prototype.removeAllListeners=function(u){var h,c,o;if((c=this._events)===void 0)return this;if(c.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):c[u]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete c[u]),this;if(arguments.length===0){var s,d=Object.keys(c);for(o=0;o<d.length;++o)(s=d[o])!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(typeof(h=c[u])=="function")this.removeListener(u,h);else if(h!==void 0)for(o=h.length-1;o>=0;o--)this.removeListener(u,h[o]);return this},_.prototype.listeners=function(u){return ee(this,u,!0)},_.prototype.rawListeners=function(u){return ee(this,u,!1)},_.listenerCount=function(u,h){return typeof u.listenerCount=="function"?u.listenerCount(h):Q.call(u,h)},_.prototype.listenerCount=Q,_.prototype.eventNames=function(){return this._eventsCount>0?W(this._events):[]},typeof Symbol<"u"&&(oe.prototype[Symbol.iterator]=function(){return this}),oe.of=function(){var u=arguments,h=u.length,c=0;return new oe(function(){return c>=h?{done:!0}:{done:!1,value:u[c++]}})},oe.empty=function(){return new oe(function(){return{done:!0}})},oe.fromSequence=function(u){var h=0,c=u.length;return new oe(function(){return h>=c?{done:!0}:{done:!1,value:u[h++]}})},oe.is=function(u){return u instanceof oe||typeof u=="object"&&u!==null&&typeof u.next=="function"};var se=oe,le={};le.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u",le.SYMBOL_SUPPORT=typeof Symbol<"u";var de=se,qe=le,fn=qe.ARRAY_BUFFER_SUPPORT,It=qe.SYMBOL_SUPPORT,Kt=function(u){var h=function(c){return typeof c=="string"||Array.isArray(c)||fn&&ArrayBuffer.isView(c)?de.fromSequence(c):typeof c!="object"||c===null?null:It&&typeof c[Symbol.iterator]=="function"?c[Symbol.iterator]():typeof c.next=="function"?c:null}(u);if(!h)throw new Error("obliterator: target is not iterable nor a valid iterator.");return h},Xt=Kt,$t=function(u,h){for(var c,o=arguments.length>1?h:1/0,s=o!==1/0?new Array(o):[],d=0,g=Xt(u);;){if(d===o)return s;if((c=g.next()).done)return d!==h&&(s.length=d),s;s[d++]=c.value}},Gt=function(u){function h(c){var o;return(o=u.call(this)||this).name="GraphError",o.message=c,o}return r(h,u),h}(m(Error)),L=function(u){function h(c){var o;return(o=u.call(this,c)||this).name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(b(o),h.prototype.constructor),o}return r(h,u),h}(Gt),l=function(u){function h(c){var o;return(o=u.call(this,c)||this).name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(b(o),h.prototype.constructor),o}return r(h,u),h}(Gt),y=function(u){function h(c){var o;return(o=u.call(this,c)||this).name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(b(o),h.prototype.constructor),o}return r(h,u),h}(Gt);function A(u,h){this.key=u,this.attributes=h,this.clear()}function B(u,h){this.key=u,this.attributes=h,this.clear()}function T(u,h){this.key=u,this.attributes=h,this.clear()}function Y(u,h,c,o,s){this.key=h,this.attributes=s,this.undirected=u,this.source=c,this.target=o}A.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},B.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},T.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},Y.prototype.attach=function(){var u="out",h="in";this.undirected&&(u=h="undirected");var c=this.source.key,o=this.target.key;this.source[u][o]=this,this.undirected&&c===o||(this.target[h][c]=this)},Y.prototype.attachMulti=function(){var u="out",h="in",c=this.source.key,o=this.target.key;this.undirected&&(u=h="undirected");var s=this.source[u],d=s[o];if(d===void 0)return s[o]=this,void(this.undirected&&c===o||(this.target[h][c]=this));d.previous=this,this.next=d,s[o]=this,this.target[h][c]=this},Y.prototype.detach=function(){var u=this.source.key,h=this.target.key,c="out",o="in";this.undirected&&(c=o="undirected"),delete this.source[c][h],delete this.target[o][u]},Y.prototype.detachMulti=function(){var u=this.source.key,h=this.target.key,c="out",o="in";this.undirected&&(c=o="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[c][h],delete this.target[o][u]):(this.next.previous=void 0,this.source[c][h]=this.next,this.target[o][u]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};function te(u,h,c,o,s,d,g){var v,$,N,U;if(o=""+o,c===0){if(!(v=u._nodes.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" node in the graph.'));N=s,U=d}else if(c===3){if(s=""+s,!($=u._edges.get(s)))throw new l("Graph.".concat(h,': could not find the "').concat(s,'" edge in the graph.'));var R=$.source.key,q=$.target.key;if(o===R)v=$.target;else{if(o!==q)throw new l("Graph.".concat(h,': the "').concat(o,'" node is not attached to the "').concat(s,'" edge (').concat(R,", ").concat(q,")."));v=$.source}N=d,U=g}else{if(!($=u._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'));v=c===1?$.source:$.target,N=s,U=d}return[v,N,U]}var ge=[{name:function(u){return"get".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g=te(this,h,c,o,s,d),v=g[0],$=g[1];return v.attributes[$]}}},{name:function(u){return"get".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s){return te(this,h,c,o,s)[0].attributes}}},{name:function(u){return"has".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g=te(this,h,c,o,s,d),v=g[0],$=g[1];return v.attributes.hasOwnProperty($)}}},{name:function(u){return"set".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d,g){var v=te(this,h,c,o,s,d,g),$=v[0],N=v[1],U=v[2];return $.attributes[N]=U,this.emit("nodeAttributesUpdated",{key:$.key,type:"set",attributes:$.attributes,name:N}),this}}},{name:function(u){return"update".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d,g){var v=te(this,h,c,o,s,d,g),$=v[0],N=v[1],U=v[2];if(typeof U!="function")throw new L("Graph.".concat(h,": updater should be a function."));var R=$.attributes,q=U(R[N]);return R[N]=q,this.emit("nodeAttributesUpdated",{key:$.key,type:"set",attributes:$.attributes,name:N}),this}}},{name:function(u){return"remove".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g=te(this,h,c,o,s,d),v=g[0],$=g[1];return delete v.attributes[$],this.emit("nodeAttributesUpdated",{key:v.key,type:"remove",attributes:v.attributes,name:$}),this}}},{name:function(u){return"replace".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g=te(this,h,c,o,s,d),v=g[0],$=g[1];if(!G($))throw new L("Graph.".concat(h,": provided attributes are not a plain object."));return v.attributes=$,this.emit("nodeAttributesUpdated",{key:v.key,type:"replace",attributes:v.attributes}),this}}},{name:function(u){return"merge".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g=te(this,h,c,o,s,d),v=g[0],$=g[1];if(!G($))throw new L("Graph.".concat(h,": provided attributes are not a plain object."));return S(v.attributes,$),this.emit("nodeAttributesUpdated",{key:v.key,type:"merge",attributes:v.attributes,data:$}),this}}},{name:function(u){return"update".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g=te(this,h,c,o,s,d),v=g[0],$=g[1];if(typeof $!="function")throw new L("Graph.".concat(h,": provided updater is not a function."));return v.attributes=$(v.attributes),this.emit("nodeAttributesUpdated",{key:v.key,type:"update",attributes:v.attributes}),this}}}],Se=[{name:function(u){return"get".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+o,v=""+s;if(s=arguments[2],!(d=D(this,g,v,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(d=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}return d.attributes[s]}}},{name:function(u){return"get".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o){var s;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var d=""+o,g=""+arguments[1];if(!(s=D(this,d,g,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(d,'" - "').concat(g,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(s=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}return s.attributes}}},{name:function(u){return"has".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+o,v=""+s;if(s=arguments[2],!(d=D(this,g,v,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(d=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}return d.attributes.hasOwnProperty(s)}}},{name:function(u){return"set".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var v=""+o,$=""+s;if(s=arguments[2],d=arguments[3],!(g=D(this,v,$,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(v,'" - "').concat($,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(g=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}return g.attributes[s]=d,this.emit("edgeAttributesUpdated",{key:g.key,type:"set",attributes:g.attributes,name:s}),this}}},{name:function(u){return"update".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s,d){var g;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var v=""+o,$=""+s;if(s=arguments[2],d=arguments[3],!(g=D(this,v,$,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(v,'" - "').concat($,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(g=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}if(typeof d!="function")throw new L("Graph.".concat(h,": updater should be a function."));return g.attributes[s]=d(g.attributes[s]),this.emit("edgeAttributesUpdated",{key:g.key,type:"set",attributes:g.attributes,name:s}),this}}},{name:function(u){return"remove".concat(u,"Attribute")},attacher:function(u,h,c){u.prototype[h]=function(o,s){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+o,v=""+s;if(s=arguments[2],!(d=D(this,g,v,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(d=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}return delete d.attributes[s],this.emit("edgeAttributesUpdated",{key:d.key,type:"remove",attributes:d.attributes,name:s}),this}}},{name:function(u){return"replace".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+o,v=""+s;if(s=arguments[2],!(d=D(this,g,v,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(d=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}if(!G(s))throw new L("Graph.".concat(h,": provided attributes are not a plain object."));return d.attributes=s,this.emit("edgeAttributesUpdated",{key:d.key,type:"replace",attributes:d.attributes}),this}}},{name:function(u){return"merge".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+o,v=""+s;if(s=arguments[2],!(d=D(this,g,v,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(d=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}if(!G(s))throw new L("Graph.".concat(h,": provided attributes are not a plain object."));return S(d.attributes,s),this.emit("edgeAttributesUpdated",{key:d.key,type:"merge",attributes:d.attributes,data:s}),this}}},{name:function(u){return"update".concat(u,"Attributes")},attacher:function(u,h,c){u.prototype[h]=function(o,s){var d;if(this.type!=="mixed"&&c!=="mixed"&&c!==this.type)throw new y("Graph.".concat(h,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new y("Graph.".concat(h,": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about."));var g=""+o,v=""+s;if(s=arguments[2],!(d=D(this,g,v,c)))throw new l("Graph.".concat(h,': could not find an edge for the given path ("').concat(g,'" - "').concat(v,'").'))}else{if(c!=="mixed")throw new y("Graph.".concat(h,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(o=""+o,!(d=this._edges.get(o)))throw new l("Graph.".concat(h,': could not find the "').concat(o,'" edge in the graph.'))}if(typeof s!="function")throw new L("Graph.".concat(h,": provided updater is not a function."));return d.attributes=s(d.attributes),this.emit("edgeAttributesUpdated",{key:d.key,type:"update",attributes:d.attributes}),this}}}],Ue=se,ze=Kt,me=function(){var u=arguments,h=null,c=-1;return new Ue(function(){for(var o=null;;){if(h===null){if(++c>=u.length)return{done:!0};h=ze(u[c])}if((o=h.next()).done!==!0)break;h=null}return o})},Ae=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function ve(u,h,c,o){var s=!1;for(var d in h)if(d!==o){var g=h[d];if(s=c(g.key,g.attributes,g.source.key,g.target.key,g.source.attributes,g.target.attributes,g.undirected),u&&s)return g.key}}function dt(u,h,c,o){var s,d,g,v=!1;for(var $ in h)if($!==o){s=h[$];do{if(d=s.source,g=s.target,v=c(s.key,s.attributes,d.key,g.key,d.attributes,g.attributes,s.undirected),u&&v)return s.key;s=s.next}while(s!==void 0)}}function Ct(u,h){var c,o=Object.keys(u),s=o.length,d=0;return new se(function(){do if(c)c=c.next;else{if(d>=s)return{done:!0};var g=o[d++];if(g===h){c=void 0;continue}c=u[g]}while(!c);return{done:!1,value:{edge:c.key,attributes:c.attributes,source:c.source.key,target:c.target.key,sourceAttributes:c.source.attributes,targetAttributes:c.target.attributes,undirected:c.undirected}}})}function qo(u,h,c,o){var s=h[c];if(s){var d=s.source,g=s.target;return o(s.key,s.attributes,d.key,g.key,d.attributes,g.attributes,s.undirected)&&u?s.key:void 0}}function Yo(u,h,c,o){var s=h[c];if(s){var d=!1;do{if(d=o(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),u&&d)return s.key;s=s.next}while(s!==void 0)}}function Un(u,h){var c=u[h];return c.next!==void 0?new se(function(){if(!c)return{done:!0};var o={edge:c.key,attributes:c.attributes,source:c.source.key,target:c.target.key,sourceAttributes:c.source.attributes,targetAttributes:c.target.attributes,undirected:c.undirected};return c=c.next,{done:!1,value:o}}):se.of({edge:c.key,attributes:c.attributes,source:c.source.key,target:c.target.key,sourceAttributes:c.source.attributes,targetAttributes:c.target.attributes,undirected:c.undirected})}function Ko(u,h){if(u.size===0)return[];if(h==="mixed"||h===u.type)return typeof Array.from=="function"?Array.from(u._edges.keys()):$t(u._edges.keys(),u._edges.size);for(var c,o,s=h==="undirected"?u.undirectedSize:u.directedSize,d=new Array(s),g=h==="undirected",v=u._edges.values(),$=0;(c=v.next()).done!==!0;)(o=c.value).undirected===g&&(d[$++]=o.key);return d}function qr(u,h,c,o){if(h.size!==0){for(var s,d,g=c!=="mixed"&&c!==h.type,v=c==="undirected",$=!1,N=h._edges.values();(s=N.next()).done!==!0;)if(d=s.value,!g||d.undirected===v){var U=d,R=U.key,q=U.attributes,K=U.source,Z=U.target;if($=o(R,q,K.key,Z.key,K.attributes,Z.attributes,d.undirected),u&&$)return R}}}function Xo(u,h){if(u.size===0)return se.empty();var c=h!=="mixed"&&h!==u.type,o=h==="undirected",s=u._edges.values();return new se(function(){for(var d,g;;){if((d=s.next()).done)return d;if(g=d.value,!c||g.undirected===o)break}return{value:{edge:g.key,attributes:g.attributes,source:g.source.key,target:g.target.key,sourceAttributes:g.source.attributes,targetAttributes:g.target.attributes,undirected:g.undirected},done:!1}})}function Nn(u,h,c,o,s,d){var g,v=h?dt:ve;if(c!=="undirected"&&(o!=="out"&&(g=v(u,s.in,d),u&&g)||o!=="in"&&(g=v(u,s.out,d,o?void 0:s.key),u&&g))||c!=="directed"&&(g=v(u,s.undirected,d),u&&g))return g}function Vo(u,h,c,o){var s=[];return Nn(!1,u,h,c,o,function(d){s.push(d)}),s}function Ho(u,h,c){var o=se.empty();return u!=="undirected"&&(h!=="out"&&c.in!==void 0&&(o=me(o,Ct(c.in))),h!=="in"&&c.out!==void 0&&(o=me(o,Ct(c.out,h?void 0:c.key)))),u!=="directed"&&c.undirected!==void 0&&(o=me(o,Ct(c.undirected))),o}function Tn(u,h,c,o,s,d,g){var v,$=c?Yo:qo;if(h!=="undirected"&&(s.in!==void 0&&o!=="out"&&(v=$(u,s.in,d,g),u&&v)||s.out!==void 0&&o!=="in"&&(o||s.key!==d)&&(v=$(u,s.out,d,g),u&&v))||h!=="directed"&&s.undirected!==void 0&&(v=$(u,s.undirected,d,g),u&&v))return v}function Jo(u,h,c,o,s){var d=[];return Tn(!1,u,h,c,o,s,function(g){d.push(g)}),d}function Qo(u,h,c,o){var s=se.empty();return u!=="undirected"&&(c.in!==void 0&&h!=="out"&&o in c.in&&(s=me(s,Un(c.in,o))),c.out!==void 0&&h!=="in"&&o in c.out&&(h||c.key!==o)&&(s=me(s,Un(c.out,o)))),u!=="directed"&&c.undirected!==void 0&&o in c.undirected&&(s=me(s,Un(c.undirected,o))),s}var Zo=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function pn(){this.A=null,this.B=null}function Vt(u,h,c,o,s){for(var d in o){var g=o[d],v=g.source,$=g.target,N=v===c?$:v;if(!h||!h.has(N.key)){var U=s(N.key,N.attributes);if(u&&U)return N.key}}}function Bn(u,h,c,o,s){if(h!=="mixed"){if(h==="undirected")return Vt(u,null,o,o.undirected,s);if(typeof c=="string")return Vt(u,null,o,o[c],s)}var d,g=new pn;if(h!=="undirected"){if(c!=="out"){if(d=Vt(u,null,o,o.in,s),u&&d)return d;g.wrap(o.in)}if(c!=="in"){if(d=Vt(u,g,o,o.out,s),u&&d)return d;g.wrap(o.out)}}if(h!=="directed"&&(d=Vt(u,g,o,o.undirected,s),u&&d))return d}function Ht(u,h,c){var o=Object.keys(c),s=o.length,d=0;return new se(function(){var g=null;do{if(d>=s)return u&&u.wrap(c),{done:!0};var v=c[o[d++]],$=v.source,N=v.target;g=$===h?N:$,u&&u.has(g.key)&&(g=null)}while(g===null);return{done:!1,value:{neighbor:g.key,attributes:g.attributes}}})}function es(u,h){var c=h.name,o=h.type,s=h.direction;u.prototype[c]=function(d){if(o!=="mixed"&&this.type!=="mixed"&&o!==this.type)return[];d=""+d;var g=this._nodes.get(d);if(g===void 0)throw new l("Graph.".concat(c,': could not find the "').concat(d,'" node in the graph.'));return function(v,$,N){if(v!=="mixed"){if(v==="undirected")return Object.keys(N.undirected);if(typeof $=="string")return Object.keys(N[$])}var U=[];return Bn(!1,v,$,N,function(R){U.push(R)}),U}(o==="mixed"?this.type:o,s,g)}}function ts(u,h){var c=h.name,o=h.type,s=h.direction,d=c.slice(0,-1)+"Entries";u.prototype[d]=function(g){if(o!=="mixed"&&this.type!=="mixed"&&o!==this.type)return se.empty();g=""+g;var v=this._nodes.get(g);if(v===void 0)throw new l("Graph.".concat(d,': could not find the "').concat(g,'" node in the graph.'));return function($,N,U){if($!=="mixed"){if($==="undirected")return Ht(null,U,U.undirected);if(typeof N=="string")return Ht(null,U,U[N])}var R=se.empty(),q=new pn;return $!=="undirected"&&(N!=="out"&&(R=me(R,Ht(q,U,U.in))),N!=="in"&&(R=me(R,Ht(q,U,U.out)))),$!=="directed"&&(R=me(R,Ht(q,U,U.undirected))),R}(o==="mixed"?this.type:o,s,v)}}function gn(u,h,c,o,s){for(var d,g,v,$,N,U,R,q=o._nodes.values(),K=o.type;(d=q.next()).done!==!0;){var Z=!1;if(g=d.value,K!=="undirected")for(v in $=g.out){N=$[v];do U=N.target,Z=!0,R=s(g.key,U.key,g.attributes,U.attributes,N.key,N.attributes,N.undirected),N=N.next;while(N)}if(K!=="directed"){for(v in $=g.undirected)if(!(h&&g.key>v)){N=$[v];do(U=N.target).key!==v&&(U=N.source),Z=!0,R=s(g.key,U.key,g.attributes,U.attributes,N.key,N.attributes,N.undirected),N=N.next;while(N)}}c&&!Z&&(R=s(g.key,null,g.attributes,null,null,null,null))}}function ns(u){if(!G(u))throw new L('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in u))throw new L("Graph.import: serialized node is missing its key.");if("attributes"in u&&(!G(u.attributes)||u.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function rs(u){if(!G(u))throw new L('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in u))throw new L("Graph.import: serialized edge is missing its source.");if(!("target"in u))throw new L("Graph.import: serialized edge is missing its target.");if("attributes"in u&&(!G(u.attributes)||u.attributes===null))throw new L("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in u&&typeof u.undirected!="boolean")throw new L("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}pn.prototype.wrap=function(u){this.A===null?this.A=u:this.B===null&&(this.B=u)},pn.prototype.has=function(u){return this.A!==null&&u in this.A||this.B!==null&&u in this.B};var Yr,is=(Yr=255&Math.floor(256*Math.random()),function(){return Yr++}),os=new Set(["directed","undirected","mixed"]),Kr=new Set(["domain","_events","_eventsCount","_maxListeners"]),ss={allowSelfLoops:!0,multi:!1,type:"mixed"};function Xr(u,h,c){var o=new u.NodeDataClass(h,c);return u._nodes.set(h,o),u.emit("nodeAdded",{key:h,attributes:c}),o}function Vr(u,h,c,o,s,d,g,v){if(!o&&u.type==="undirected")throw new y("Graph.".concat(h,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(o&&u.type==="directed")throw new y("Graph.".concat(h,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(v&&!G(v))throw new L("Graph.".concat(h,': invalid attributes. Expecting an object but got "').concat(v,'"'));if(d=""+d,g=""+g,v=v||{},!u.allowSelfLoops&&d===g)throw new y("Graph.".concat(h,': source & target are the same ("').concat(d,`"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`));var $=u._nodes.get(d),N=u._nodes.get(g);if(!$)throw new l("Graph.".concat(h,': source node "').concat(d,'" not found.'));if(!N)throw new l("Graph.".concat(h,': target node "').concat(g,'" not found.'));var U={key:null,undirected:o,source:d,target:g,attributes:v};if(c)s=u._edgeKeyGenerator();else if(s=""+s,u._edges.has(s))throw new y("Graph.".concat(h,': the "').concat(s,'" edge already exists in the graph.'));if(!u.multi&&(o?$.undirected[g]!==void 0:$.out[g]!==void 0))throw new y("Graph.".concat(h,': an edge linking "').concat(d,'" to "').concat(g,`" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`));var R=new Y(o,s,$,N,v);u._edges.set(s,R);var q=d===g;return o?($.undirectedDegree++,N.undirectedDegree++,q&&($.undirectedLoops++,u._undirectedSelfLoopCount++)):($.outDegree++,N.inDegree++,q&&($.directedLoops++,u._directedSelfLoopCount++)),u.multi?R.attachMulti():R.attach(),o?u._undirectedSize++:u._directedSize++,U.key=s,u.emit("edgeAdded",U),s}function as(u,h,c,o,s,d,g,v,$){if(!o&&u.type==="undirected")throw new y("Graph.".concat(h,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(o&&u.type==="directed")throw new y("Graph.".concat(h,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(v){if($){if(typeof v!="function")throw new L("Graph.".concat(h,': invalid updater function. Expecting a function but got "').concat(v,'"'))}else if(!G(v))throw new L("Graph.".concat(h,': invalid attributes. Expecting an object but got "').concat(v,'"'))}var N;if(d=""+d,g=""+g,$&&(N=v,v=void 0),!u.allowSelfLoops&&d===g)throw new y("Graph.".concat(h,': source & target are the same ("').concat(d,`"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`));var U,R,q=u._nodes.get(d),K=u._nodes.get(g);if(!c&&(U=u._edges.get(s))){if(!(U.source.key===d&&U.target.key===g||o&&U.source.key===g&&U.target.key===d))throw new y("Graph.".concat(h,': inconsistency detected when attempting to merge the "').concat(s,'" edge with "').concat(d,'" source & "').concat(g,'" target vs. ("').concat(U.source.key,'", "').concat(U.target.key,'").'));R=U}if(R||u.multi||!q||(R=o?q.undirected[g]:q.out[g]),R){var Z=[R.key,!1,!1,!1];if($?!N:!v)return Z;if($){var ae=R.attributes;R.attributes=N(ae),u.emit("edgeAttributesUpdated",{type:"replace",key:R.key,attributes:R.attributes})}else S(R.attributes,v),u.emit("edgeAttributesUpdated",{type:"merge",key:R.key,attributes:R.attributes,data:v});return Z}v=v||{},$&&N&&(v=N(v));var fe={key:null,undirected:o,source:d,target:g,attributes:v};if(c)s=u._edgeKeyGenerator();else if(s=""+s,u._edges.has(s))throw new y("Graph.".concat(h,': the "').concat(s,'" edge already exists in the graph.'));var Ce=!1,Ge=!1;q||(q=Xr(u,d,{}),Ce=!0,d===g&&(K=q,Ge=!0)),K||(K=Xr(u,g,{}),Ge=!0),U=new Y(o,s,q,K,v),u._edges.set(s,U);var Ne=d===g;return o?(q.undirectedDegree++,K.undirectedDegree++,Ne&&(q.undirectedLoops++,u._undirectedSelfLoopCount++)):(q.outDegree++,K.inDegree++,Ne&&(q.directedLoops++,u._directedSelfLoopCount++)),u.multi?U.attachMulti():U.attach(),o?u._undirectedSize++:u._directedSize++,fe.key=s,u.emit("edgeAdded",fe),[s,!0,Ce,Ge]}function Dt(u,h){u._edges.delete(h.key);var c=h.source,o=h.target,s=h.attributes,d=h.undirected,g=c===o;d?(c.undirectedDegree--,o.undirectedDegree--,g&&(c.undirectedLoops--,u._undirectedSelfLoopCount--)):(c.outDegree--,o.inDegree--,g&&(c.directedLoops--,u._directedSelfLoopCount--)),u.multi?h.detachMulti():h.detach(),d?u._undirectedSize--:u._directedSize--,u.emit("edgeDropped",{key:h.key,attributes:s,source:c.key,target:o.key,undirected:d})}var he=function(u){function h(o){var s;if(s=u.call(this)||this,typeof(o=S({},ss,o)).multi!="boolean")throw new L(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "`.concat(o.multi,'".'));if(!os.has(o.type))throw new L(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "`.concat(o.type,'".'));if(typeof o.allowSelfLoops!="boolean")throw new L(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "`.concat(o.allowSelfLoops,'".'));var d=o.type==="mixed"?A:o.type==="directed"?B:T;k(b(s),"NodeDataClass",d);var g="geid_"+is()+"_",v=0;return k(b(s),"_attributes",{}),k(b(s),"_nodes",new Map),k(b(s),"_edges",new Map),k(b(s),"_directedSize",0),k(b(s),"_undirectedSize",0),k(b(s),"_directedSelfLoopCount",0),k(b(s),"_undirectedSelfLoopCount",0),k(b(s),"_edgeKeyGenerator",function(){var $;do $=g+v++;while(s._edges.has($));return $}),k(b(s),"_options",o),Kr.forEach(function($){return k(b(s),$,s[$])}),j(b(s),"order",function(){return s._nodes.size}),j(b(s),"size",function(){return s._edges.size}),j(b(s),"directedSize",function(){return s._directedSize}),j(b(s),"undirectedSize",function(){return s._undirectedSize}),j(b(s),"selfLoopCount",function(){return s._directedSelfLoopCount+s._undirectedSelfLoopCount}),j(b(s),"directedSelfLoopCount",function(){return s._directedSelfLoopCount}),j(b(s),"undirectedSelfLoopCount",function(){return s._undirectedSelfLoopCount}),j(b(s),"multi",s._options.multi),j(b(s),"type",s._options.type),j(b(s),"allowSelfLoops",s._options.allowSelfLoops),j(b(s),"implementation",function(){return"graphology"}),s}r(h,u);var c=h.prototype;return c._resetInstanceCounters=function(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0},c.hasNode=function(o){return this._nodes.has(""+o)},c.hasDirectedEdge=function(o,s){if(this.type==="undirected")return!1;if(arguments.length===1){var d=""+o,g=this._edges.get(d);return!!g&&!g.undirected}if(arguments.length===2){o=""+o,s=""+s;var v=this._nodes.get(o);return!!v&&v.out.hasOwnProperty(s)}throw new L("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},c.hasUndirectedEdge=function(o,s){if(this.type==="directed")return!1;if(arguments.length===1){var d=""+o,g=this._edges.get(d);return!!g&&g.undirected}if(arguments.length===2){o=""+o,s=""+s;var v=this._nodes.get(o);return!!v&&v.undirected.hasOwnProperty(s)}throw new L("Graph.hasDirectedEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},c.hasEdge=function(o,s){if(arguments.length===1){var d=""+o;return this._edges.has(d)}if(arguments.length===2){o=""+o,s=""+s;var g=this._nodes.get(o);return!!g&&(g.out!==void 0&&g.out.hasOwnProperty(s)||g.undirected!==void 0&&g.undirected.hasOwnProperty(s))}throw new L("Graph.hasEdge: invalid arity (".concat(arguments.length,", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target."))},c.directedEdge=function(o,s){if(this.type!=="undirected"){if(o=""+o,s=""+s,this.multi)throw new y("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var d=this._nodes.get(o);if(!d)throw new l('Graph.directedEdge: could not find the "'.concat(o,'" source node in the graph.'));if(!this._nodes.has(s))throw new l('Graph.directedEdge: could not find the "'.concat(s,'" target node in the graph.'));var g=d.out&&d.out[s]||void 0;return g?g.key:void 0}},c.undirectedEdge=function(o,s){if(this.type!=="directed"){if(o=""+o,s=""+s,this.multi)throw new y("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var d=this._nodes.get(o);if(!d)throw new l('Graph.undirectedEdge: could not find the "'.concat(o,'" source node in the graph.'));if(!this._nodes.has(s))throw new l('Graph.undirectedEdge: could not find the "'.concat(s,'" target node in the graph.'));var g=d.undirected&&d.undirected[s]||void 0;return g?g.key:void 0}},c.edge=function(o,s){if(this.multi)throw new y("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.edge: could not find the "'.concat(o,'" source node in the graph.'));if(!this._nodes.has(s))throw new l('Graph.edge: could not find the "'.concat(s,'" target node in the graph.'));var g=d.out&&d.out[s]||d.undirected&&d.undirected[s]||void 0;if(g)return g.key},c.areDirectedNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areDirectedNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="undirected"&&(s in d.in||s in d.out)},c.areOutNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areOutNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="undirected"&&s in d.out},c.areInNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areInNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="undirected"&&s in d.in},c.areUndirectedNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areUndirectedNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="directed"&&s in d.undirected},c.areNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="undirected"&&(s in d.in||s in d.out)||this.type!=="directed"&&s in d.undirected},c.areInboundNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areInboundNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="undirected"&&s in d.in||this.type!=="directed"&&s in d.undirected},c.areOutboundNeighbors=function(o,s){o=""+o,s=""+s;var d=this._nodes.get(o);if(!d)throw new l('Graph.areOutboundNeighbors: could not find the "'.concat(o,'" node in the graph.'));return this.type!=="undirected"&&s in d.out||this.type!=="directed"&&s in d.undirected},c.inDegree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.inDegree: could not find the "'.concat(o,'" node in the graph.'));return this.type==="undirected"?0:s.inDegree},c.outDegree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.outDegree: could not find the "'.concat(o,'" node in the graph.'));return this.type==="undirected"?0:s.outDegree},c.directedDegree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.directedDegree: could not find the "'.concat(o,'" node in the graph.'));return this.type==="undirected"?0:s.inDegree+s.outDegree},c.undirectedDegree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.undirectedDegree: could not find the "'.concat(o,'" node in the graph.'));return this.type==="directed"?0:s.undirectedDegree},c.inboundDegree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.inboundDegree: could not find the "'.concat(o,'" node in the graph.'));var d=0;return this.type!=="directed"&&(d+=s.undirectedDegree),this.type!=="undirected"&&(d+=s.inDegree),d},c.outboundDegree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.outboundDegree: could not find the "'.concat(o,'" node in the graph.'));var d=0;return this.type!=="directed"&&(d+=s.undirectedDegree),this.type!=="undirected"&&(d+=s.outDegree),d},c.degree=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.degree: could not find the "'.concat(o,'" node in the graph.'));var d=0;return this.type!=="directed"&&(d+=s.undirectedDegree),this.type!=="undirected"&&(d+=s.inDegree+s.outDegree),d},c.inDegreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.inDegreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));return this.type==="undirected"?0:s.inDegree-s.directedLoops},c.outDegreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.outDegreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));return this.type==="undirected"?0:s.outDegree-s.directedLoops},c.directedDegreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.directedDegreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));return this.type==="undirected"?0:s.inDegree+s.outDegree-2*s.directedLoops},c.undirectedDegreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.undirectedDegreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));return this.type==="directed"?0:s.undirectedDegree-2*s.undirectedLoops},c.inboundDegreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.inboundDegreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));var d=0,g=0;return this.type!=="directed"&&(d+=s.undirectedDegree,g+=2*s.undirectedLoops),this.type!=="undirected"&&(d+=s.inDegree,g+=s.directedLoops),d-g},c.outboundDegreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.outboundDegreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));var d=0,g=0;return this.type!=="directed"&&(d+=s.undirectedDegree,g+=2*s.undirectedLoops),this.type!=="undirected"&&(d+=s.outDegree,g+=s.directedLoops),d-g},c.degreeWithoutSelfLoops=function(o){o=""+o;var s=this._nodes.get(o);if(!s)throw new l('Graph.degreeWithoutSelfLoops: could not find the "'.concat(o,'" node in the graph.'));var d=0,g=0;return this.type!=="directed"&&(d+=s.undirectedDegree,g+=2*s.undirectedLoops),this.type!=="undirected"&&(d+=s.inDegree+s.outDegree,g+=2*s.directedLoops),d-g},c.source=function(o){o=""+o;var s=this._edges.get(o);if(!s)throw new l('Graph.source: could not find the "'.concat(o,'" edge in the graph.'));return s.source.key},c.target=function(o){o=""+o;var s=this._edges.get(o);if(!s)throw new l('Graph.target: could not find the "'.concat(o,'" edge in the graph.'));return s.target.key},c.extremities=function(o){o=""+o;var s=this._edges.get(o);if(!s)throw new l('Graph.extremities: could not find the "'.concat(o,'" edge in the graph.'));return[s.source.key,s.target.key]},c.opposite=function(o,s){o=""+o,s=""+s;var d=this._edges.get(s);if(!d)throw new l('Graph.opposite: could not find the "'.concat(s,'" edge in the graph.'));var g=d.source.key,v=d.target.key;if(o===g)return v;if(o===v)return g;throw new l('Graph.opposite: the "'.concat(o,'" node is not attached to the "').concat(s,'" edge (').concat(g,", ").concat(v,")."))},c.hasExtremity=function(o,s){o=""+o,s=""+s;var d=this._edges.get(o);if(!d)throw new l('Graph.hasExtremity: could not find the "'.concat(o,'" edge in the graph.'));return d.source.key===s||d.target.key===s},c.isUndirected=function(o){o=""+o;var s=this._edges.get(o);if(!s)throw new l('Graph.isUndirected: could not find the "'.concat(o,'" edge in the graph.'));return s.undirected},c.isDirected=function(o){o=""+o;var s=this._edges.get(o);if(!s)throw new l('Graph.isDirected: could not find the "'.concat(o,'" edge in the graph.'));return!s.undirected},c.isSelfLoop=function(o){o=""+o;var s=this._edges.get(o);if(!s)throw new l('Graph.isSelfLoop: could not find the "'.concat(o,'" edge in the graph.'));return s.source===s.target},c.addNode=function(o,s){var d=function(g,v,$){if($&&!G($))throw new L('Graph.addNode: invalid attributes. Expecting an object but got "'.concat($,'"'));if(v=""+v,$=$||{},g._nodes.has(v))throw new y('Graph.addNode: the "'.concat(v,'" node already exist in the graph.'));var N=new g.NodeDataClass(v,$);return g._nodes.set(v,N),g.emit("nodeAdded",{key:v,attributes:$}),N}(this,o,s);return d.key},c.mergeNode=function(o,s){if(s&&!G(s))throw new L('Graph.mergeNode: invalid attributes. Expecting an object but got "'.concat(s,'"'));o=""+o,s=s||{};var d=this._nodes.get(o);return d?(s&&(S(d.attributes,s),this.emit("nodeAttributesUpdated",{type:"merge",key:o,attributes:d.attributes,data:s})),[o,!1]):(d=new this.NodeDataClass(o,s),this._nodes.set(o,d),this.emit("nodeAdded",{key:o,attributes:s}),[o,!0])},c.updateNode=function(o,s){if(s&&typeof s!="function")throw new L('Graph.updateNode: invalid updater function. Expecting a function but got "'.concat(s,'"'));o=""+o;var d=this._nodes.get(o);if(d){if(s){var g=d.attributes;d.attributes=s(g),this.emit("nodeAttributesUpdated",{type:"replace",key:o,attributes:d.attributes})}return[o,!1]}var v=s?s({}):{};return d=new this.NodeDataClass(o,v),this._nodes.set(o,d),this.emit("nodeAdded",{key:o,attributes:v}),[o,!0]},c.dropNode=function(o){o=""+o;var s,d=this._nodes.get(o);if(!d)throw new l('Graph.dropNode: could not find the "'.concat(o,'" node in the graph.'));if(this.type!=="undirected"){for(var g in d.out){s=d.out[g];do Dt(this,s),s=s.next;while(s)}for(var v in d.in){s=d.in[v];do Dt(this,s),s=s.next;while(s)}}if(this.type!=="directed")for(var $ in d.undirected){s=d.undirected[$];do Dt(this,s),s=s.next;while(s)}this._nodes.delete(o),this.emit("nodeDropped",{key:o,attributes:d.attributes})},c.dropEdge=function(o){var s;if(arguments.length>1){var d=""+arguments[0],g=""+arguments[1];if(!(s=D(this,d,g,this.type)))throw new l('Graph.dropEdge: could not find the "'.concat(d,'" -> "').concat(g,'" edge in the graph.'))}else if(o=""+o,!(s=this._edges.get(o)))throw new l('Graph.dropEdge: could not find the "'.concat(o,'" edge in the graph.'));return Dt(this,s),this},c.dropDirectedEdge=function(o,s){if(arguments.length<2)throw new y("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new y("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var d=D(this,o=""+o,s=""+s,"directed");if(!d)throw new l('Graph.dropDirectedEdge: could not find a "'.concat(o,'" -> "').concat(s,'" edge in the graph.'));return Dt(this,d),this},c.dropUndirectedEdge=function(o,s){if(arguments.length<2)throw new y("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new y("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");var d=D(this,o,s,"undirected");if(!d)throw new l('Graph.dropUndirectedEdge: could not find a "'.concat(o,'" -> "').concat(s,'" edge in the graph.'));return Dt(this,d),this},c.clear=function(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")},c.clearEdges=function(){for(var o,s=this._nodes.values();(o=s.next()).done!==!0;)o.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")},c.getAttribute=function(o){return this._attributes[o]},c.getAttributes=function(){return this._attributes},c.hasAttribute=function(o){return this._attributes.hasOwnProperty(o)},c.setAttribute=function(o,s){return this._attributes[o]=s,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:o}),this},c.updateAttribute=function(o,s){if(typeof s!="function")throw new L("Graph.updateAttribute: updater should be a function.");var d=this._attributes[o];return this._attributes[o]=s(d),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:o}),this},c.removeAttribute=function(o){return delete this._attributes[o],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:o}),this},c.replaceAttributes=function(o){if(!G(o))throw new L("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=o,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this},c.mergeAttributes=function(o){if(!G(o))throw new L("Graph.mergeAttributes: provided attributes are not a plain object.");return S(this._attributes,o),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:o}),this},c.updateAttributes=function(o){if(typeof o!="function")throw new L("Graph.updateAttributes: provided updater is not a function.");return this._attributes=o(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this},c.updateEachNodeAttributes=function(o,s){if(typeof o!="function")throw new L("Graph.updateEachNodeAttributes: expecting an updater function.");if(s&&!I(s))throw new L("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var d,g,v=this._nodes.values();(d=v.next()).done!==!0;)(g=d.value).attributes=o(g.key,g.attributes);this.emit("eachNodeAttributesUpdated",{hints:s||null})},c.updateEachEdgeAttributes=function(o,s){if(typeof o!="function")throw new L("Graph.updateEachEdgeAttributes: expecting an updater function.");if(s&&!I(s))throw new L("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");for(var d,g,v,$,N=this._edges.values();(d=N.next()).done!==!0;)v=(g=d.value).source,$=g.target,g.attributes=o(g.key,g.attributes,v.key,$.key,v.attributes,$.attributes,g.undirected);this.emit("eachEdgeAttributesUpdated",{hints:s||null})},c.forEachAdjacencyEntry=function(o){if(typeof o!="function")throw new L("Graph.forEachAdjacencyEntry: expecting a callback.");gn(!1,!1,!1,this,o)},c.forEachAdjacencyEntryWithOrphans=function(o){if(typeof o!="function")throw new L("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");gn(!1,!1,!0,this,o)},c.forEachAssymetricAdjacencyEntry=function(o){if(typeof o!="function")throw new L("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");gn(!1,!0,!1,this,o)},c.forEachAssymetricAdjacencyEntryWithOrphans=function(o){if(typeof o!="function")throw new L("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");gn(!1,!0,!0,this,o)},c.nodes=function(){return typeof Array.from=="function"?Array.from(this._nodes.keys()):$t(this._nodes.keys(),this._nodes.size)},c.forEachNode=function(o){if(typeof o!="function")throw new L("Graph.forEachNode: expecting a callback.");for(var s,d,g=this._nodes.values();(s=g.next()).done!==!0;)o((d=s.value).key,d.attributes)},c.findNode=function(o){if(typeof o!="function")throw new L("Graph.findNode: expecting a callback.");for(var s,d,g=this._nodes.values();(s=g.next()).done!==!0;)if(o((d=s.value).key,d.attributes))return d.key},c.mapNodes=function(o){if(typeof o!="function")throw new L("Graph.mapNode: expecting a callback.");for(var s,d,g=this._nodes.values(),v=new Array(this.order),$=0;(s=g.next()).done!==!0;)d=s.value,v[$++]=o(d.key,d.attributes);return v},c.someNode=function(o){if(typeof o!="function")throw new L("Graph.someNode: expecting a callback.");for(var s,d,g=this._nodes.values();(s=g.next()).done!==!0;)if(o((d=s.value).key,d.attributes))return!0;return!1},c.everyNode=function(o){if(typeof o!="function")throw new L("Graph.everyNode: expecting a callback.");for(var s,d,g=this._nodes.values();(s=g.next()).done!==!0;)if(!o((d=s.value).key,d.attributes))return!1;return!0},c.filterNodes=function(o){if(typeof o!="function")throw new L("Graph.filterNodes: expecting a callback.");for(var s,d,g=this._nodes.values(),v=[];(s=g.next()).done!==!0;)o((d=s.value).key,d.attributes)&&v.push(d.key);return v},c.reduceNodes=function(o,s){if(typeof o!="function")throw new L("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new L("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");for(var d,g,v=s,$=this._nodes.values();(d=$.next()).done!==!0;)v=o(v,(g=d.value).key,g.attributes);return v},c.nodeEntries=function(){var o=this._nodes.values();return new se(function(){var s=o.next();if(s.done)return s;var d=s.value;return{value:{node:d.key,attributes:d.attributes},done:!1}})},c.export=function(){var o=this,s=new Array(this._nodes.size),d=0;this._nodes.forEach(function(v,$){s[d++]=function(N,U){var R={key:N};return O(U.attributes)||(R.attributes=S({},U.attributes)),R}($,v)});var g=new Array(this._edges.size);return d=0,this._edges.forEach(function(v,$){g[d++]=function(N,U,R){var q={key:U,source:R.source.key,target:R.target.key};return O(R.attributes)||(q.attributes=S({},R.attributes)),N==="mixed"&&R.undirected&&(q.undirected=!0),q}(o.type,$,v)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:s,edges:g}},c.import=function(o){var s,d,g,v,$,N=this,U=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(o instanceof h)return o.forEachNode(function(Te,He){U?N.mergeNode(Te,He):N.addNode(Te,He)}),o.forEachEdge(function(Te,He,mn,yn,Qu,Zu,ti){U?ti?N.mergeUndirectedEdgeWithKey(Te,mn,yn,He):N.mergeDirectedEdgeWithKey(Te,mn,yn,He):ti?N.addUndirectedEdgeWithKey(Te,mn,yn,He):N.addDirectedEdgeWithKey(Te,mn,yn,He)}),this;if(!G(o))throw new L("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(o.attributes){if(!G(o.attributes))throw new L("Graph.import: invalid attributes. Expecting a plain object.");U?this.mergeAttributes(o.attributes):this.replaceAttributes(o.attributes)}if(o.nodes){if(g=o.nodes,!Array.isArray(g))throw new L("Graph.import: invalid nodes. Expecting an array.");for(s=0,d=g.length;s<d;s++){ns(v=g[s]);var R=v,q=R.key,K=R.attributes;U?this.mergeNode(q,K):this.addNode(q,K)}}if(o.edges){var Z=!1;if(this.type==="undirected"&&(Z=!0),g=o.edges,!Array.isArray(g))throw new L("Graph.import: invalid edges. Expecting an array.");for(s=0,d=g.length;s<d;s++){rs($=g[s]);var ae=$,fe=ae.source,Ce=ae.target,Ge=ae.attributes,Ne=ae.undirected,Ye=Ne===void 0?Z:Ne;"key"in $?(U?Ye?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:Ye?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey).call(this,$.key,fe,Ce,Ge):(U?Ye?this.mergeUndirectedEdge:this.mergeDirectedEdge:Ye?this.addUndirectedEdge:this.addDirectedEdge).call(this,fe,Ce,Ge)}}return this},c.nullCopy=function(o){var s=new h(S({},this._options,o));return s.replaceAttributes(S({},this.getAttributes())),s},c.emptyCopy=function(o){var s=this.nullCopy(o);return this._nodes.forEach(function(d,g){var v=S({},d.attributes);d=new s.NodeDataClass(g,v),s._nodes.set(g,d)}),s},c.copy=function(o){if(typeof(o=o||{}).type=="string"&&o.type!==this.type&&o.type!=="mixed")throw new y('Graph.copy: cannot create an incompatible copy from "'.concat(this.type,'" type to "').concat(o.type,'" because this would mean losing information about the current graph.'));if(typeof o.multi=="boolean"&&o.multi!==this.multi&&o.multi!==!0)throw new y("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof o.allowSelfLoops=="boolean"&&o.allowSelfLoops!==this.allowSelfLoops&&o.allowSelfLoops!==!0)throw new y("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");for(var s,d,g=this.emptyCopy(o),v=this._edges.values();(s=v.next()).done!==!0;)Vr(g,"copy",!1,(d=s.value).undirected,d.key,d.source.key,d.target.key,S({},d.attributes));return g},c.toJSON=function(){return this.export()},c.toString=function(){return"[object Graph]"},c.inspect=function(){var o=this,s={};this._nodes.forEach(function(N,U){s[U]=N.attributes});var d={},g={};this._edges.forEach(function(N,U){var R,q=N.undirected?"--":"->",K="",Z=N.source.key,ae=N.target.key;N.undirected&&Z>ae&&(R=Z,Z=ae,ae=R);var fe="(".concat(Z,")").concat(q,"(").concat(ae,")");U.startsWith("geid_")?o.multi&&(g[fe]===void 0?g[fe]=0:g[fe]++,K+="".concat(g[fe],". ")):K+="[".concat(U,"]: "),d[K+=fe]=N.attributes});var v={};for(var $ in this)this.hasOwnProperty($)&&!Kr.has($)&&typeof this[$]!="function"&&t($)!=="symbol"&&(v[$]=this[$]);return v.attributes=this._attributes,v.nodes=s,v.edges=d,k(v,"constructor",this.constructor),v},h}(X.exports.EventEmitter);typeof Symbol<"u"&&(he.prototype[Symbol.for("nodejs.util.inspect.custom")]=he.prototype.inspect),[{name:function(u){return"".concat(u,"Edge")},generateKey:!0},{name:function(u){return"".concat(u,"DirectedEdge")},generateKey:!0,type:"directed"},{name:function(u){return"".concat(u,"UndirectedEdge")},generateKey:!0,type:"undirected"},{name:function(u){return"".concat(u,"EdgeWithKey")}},{name:function(u){return"".concat(u,"DirectedEdgeWithKey")},type:"directed"},{name:function(u){return"".concat(u,"UndirectedEdgeWithKey")},type:"undirected"}].forEach(function(u){["add","merge","update"].forEach(function(h){var c=u.name(h),o=h==="add"?Vr:as;u.generateKey?he.prototype[c]=function(s,d,g){return o(this,c,!0,(u.type||this.type)==="undirected",null,s,d,g,h==="update")}:he.prototype[c]=function(s,d,g,v){return o(this,c,!1,(u.type||this.type)==="undirected",s,d,g,v,h==="update")}})}),function(u){ge.forEach(function(h){var c=h.name,o=h.attacher;o(u,c("Node"),0),o(u,c("Source"),1),o(u,c("Target"),2),o(u,c("Opposite"),3)})}(he),function(u){Se.forEach(function(h){var c=h.name,o=h.attacher;o(u,c("Edge"),"mixed"),o(u,c("DirectedEdge"),"directed"),o(u,c("UndirectedEdge"),"undirected")})}(he),function(u){Ae.forEach(function(h){(function(c,o){var s=o.name,d=o.type,g=o.direction;c.prototype[s]=function(v,$){if(d!=="mixed"&&this.type!=="mixed"&&d!==this.type)return[];if(!arguments.length)return Ko(this,d);if(arguments.length===1){v=""+v;var N=this._nodes.get(v);if(N===void 0)throw new l("Graph.".concat(s,': could not find the "').concat(v,'" node in the graph.'));return Vo(this.multi,d==="mixed"?this.type:d,g,N)}if(arguments.length===2){v=""+v,$=""+$;var U=this._nodes.get(v);if(!U)throw new l("Graph.".concat(s,': could not find the "').concat(v,'" source node in the graph.'));if(!this._nodes.has($))throw new l("Graph.".concat(s,': could not find the "').concat($,'" target node in the graph.'));return Jo(d,this.multi,g,U,$)}throw new L("Graph.".concat(s,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}})(u,h),function(c,o){var s=o.name,d=o.type,g=o.direction,v="forEach"+s[0].toUpperCase()+s.slice(1,-1);c.prototype[v]=function(R,q,K){if(d==="mixed"||this.type==="mixed"||d===this.type){if(arguments.length===1)return qr(!1,this,d,K=R);if(arguments.length===2){R=""+R,K=q;var Z=this._nodes.get(R);if(Z===void 0)throw new l("Graph.".concat(v,': could not find the "').concat(R,'" node in the graph.'));return Nn(!1,this.multi,d==="mixed"?this.type:d,g,Z,K)}if(arguments.length===3){R=""+R,q=""+q;var ae=this._nodes.get(R);if(!ae)throw new l("Graph.".concat(v,': could not find the "').concat(R,'" source node in the graph.'));if(!this._nodes.has(q))throw new l("Graph.".concat(v,': could not find the "').concat(q,'" target node in the graph.'));return Tn(!1,d,this.multi,g,ae,q,K)}throw new L("Graph.".concat(v,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))}};var $="map"+s[0].toUpperCase()+s.slice(1);c.prototype[$]=function(){var R,q=Array.prototype.slice.call(arguments),K=q.pop();if(q.length===0){var Z=0;d!=="directed"&&(Z+=this.undirectedSize),d!=="undirected"&&(Z+=this.directedSize),R=new Array(Z);var ae=0;q.push(function(fe,Ce,Ge,Ne,Ye,Te,He){R[ae++]=K(fe,Ce,Ge,Ne,Ye,Te,He)})}else R=[],q.push(function(fe,Ce,Ge,Ne,Ye,Te,He){R.push(K(fe,Ce,Ge,Ne,Ye,Te,He))});return this[v].apply(this,q),R};var N="filter"+s[0].toUpperCase()+s.slice(1);c.prototype[N]=function(){var R=Array.prototype.slice.call(arguments),q=R.pop(),K=[];return R.push(function(Z,ae,fe,Ce,Ge,Ne,Ye){q(Z,ae,fe,Ce,Ge,Ne,Ye)&&K.push(Z)}),this[v].apply(this,R),K};var U="reduce"+s[0].toUpperCase()+s.slice(1);c.prototype[U]=function(){var R,q,K=Array.prototype.slice.call(arguments);if(K.length<2||K.length>4)throw new L("Graph.".concat(U,": invalid number of arguments (expecting 2, 3 or 4 and got ").concat(K.length,")."));if(typeof K[K.length-1]=="function"&&typeof K[K.length-2]!="function")throw new L("Graph.".concat(U,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));K.length===2?(R=K[0],q=K[1],K=[]):K.length===3?(R=K[1],q=K[2],K=[K[0]]):K.length===4&&(R=K[2],q=K[3],K=[K[0],K[1]]);var Z=q;return K.push(function(ae,fe,Ce,Ge,Ne,Ye,Te){Z=R(Z,ae,fe,Ce,Ge,Ne,Ye,Te)}),this[v].apply(this,K),Z}}(u,h),function(c,o){var s=o.name,d=o.type,g=o.direction,v="find"+s[0].toUpperCase()+s.slice(1,-1);c.prototype[v]=function(U,R,q){if(d!=="mixed"&&this.type!=="mixed"&&d!==this.type)return!1;if(arguments.length===1)return qr(!0,this,d,q=U);if(arguments.length===2){U=""+U,q=R;var K=this._nodes.get(U);if(K===void 0)throw new l("Graph.".concat(v,': could not find the "').concat(U,'" node in the graph.'));return Nn(!0,this.multi,d==="mixed"?this.type:d,g,K,q)}if(arguments.length===3){U=""+U,R=""+R;var Z=this._nodes.get(U);if(!Z)throw new l("Graph.".concat(v,': could not find the "').concat(U,'" source node in the graph.'));if(!this._nodes.has(R))throw new l("Graph.".concat(v,': could not find the "').concat(R,'" target node in the graph.'));return Tn(!0,d,this.multi,g,Z,R,q)}throw new L("Graph.".concat(v,": too many arguments (expecting 1, 2 or 3 and got ").concat(arguments.length,")."))};var $="some"+s[0].toUpperCase()+s.slice(1,-1);c.prototype[$]=function(){var U=Array.prototype.slice.call(arguments),R=U.pop();return U.push(function(q,K,Z,ae,fe,Ce,Ge){return R(q,K,Z,ae,fe,Ce,Ge)}),!!this[v].apply(this,U)};var N="every"+s[0].toUpperCase()+s.slice(1,-1);c.prototype[N]=function(){var U=Array.prototype.slice.call(arguments),R=U.pop();return U.push(function(q,K,Z,ae,fe,Ce,Ge){return!R(q,K,Z,ae,fe,Ce,Ge)}),!this[v].apply(this,U)}}(u,h),function(c,o){var s=o.name,d=o.type,g=o.direction,v=s.slice(0,-1)+"Entries";c.prototype[v]=function($,N){if(d!=="mixed"&&this.type!=="mixed"&&d!==this.type)return se.empty();if(!arguments.length)return Xo(this,d);if(arguments.length===1){$=""+$;var U=this._nodes.get($);if(!U)throw new l("Graph.".concat(v,': could not find the "').concat($,'" node in the graph.'));return Ho(d,g,U)}if(arguments.length===2){$=""+$,N=""+N;var R=this._nodes.get($);if(!R)throw new l("Graph.".concat(v,': could not find the "').concat($,'" source node in the graph.'));if(!this._nodes.has(N))throw new l("Graph.".concat(v,': could not find the "').concat(N,'" target node in the graph.'));return Qo(d,g,R,N)}throw new L("Graph.".concat(v,": too many arguments (expecting 0, 1 or 2 and got ").concat(arguments.length,")."))}}(u,h)})}(he),function(u){Zo.forEach(function(h){es(u,h),function(c,o){var s=o.name,d=o.type,g=o.direction,v="forEach"+s[0].toUpperCase()+s.slice(1,-1);c.prototype[v]=function(R,q){if(d==="mixed"||this.type==="mixed"||d===this.type){R=""+R;var K=this._nodes.get(R);if(K===void 0)throw new l("Graph.".concat(v,': could not find the "').concat(R,'" node in the graph.'));Bn(!1,d==="mixed"?this.type:d,g,K,q)}};var $="map"+s[0].toUpperCase()+s.slice(1);c.prototype[$]=function(R,q){var K=[];return this[v](R,function(Z,ae){K.push(q(Z,ae))}),K};var N="filter"+s[0].toUpperCase()+s.slice(1);c.prototype[N]=function(R,q){var K=[];return this[v](R,function(Z,ae){q(Z,ae)&&K.push(Z)}),K};var U="reduce"+s[0].toUpperCase()+s.slice(1);c.prototype[U]=function(R,q,K){if(arguments.length<3)throw new L("Graph.".concat(U,": missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array."));var Z=K;return this[v](R,function(ae,fe){Z=q(Z,ae,fe)}),Z}}(u,h),function(c,o){var s=o.name,d=o.type,g=o.direction,v=s[0].toUpperCase()+s.slice(1,-1),$="find"+v;c.prototype[$]=function(R,q){if(d==="mixed"||this.type==="mixed"||d===this.type){R=""+R;var K=this._nodes.get(R);if(K===void 0)throw new l("Graph.".concat($,': could not find the "').concat(R,'" node in the graph.'));return Bn(!0,d==="mixed"?this.type:d,g,K,q)}};var N="some"+v;c.prototype[N]=function(R,q){return!!this[$](R,q)};var U="every"+v;c.prototype[U]=function(R,q){return!this[$](R,function(K,Z){return!q(K,Z)})}}(u,h),ts(u,h)})}(he);var Hr=function(u){function h(c){var o=S({type:"directed"},c);if("multi"in o&&o.multi!==!1)throw new L("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(o.type!=="directed")throw new L('DirectedGraph.from: inconsistent "'+o.type+'" type in given options!');return u.call(this,o)||this}return r(h,u),h}(he),Jr=function(u){function h(c){var o=S({type:"undirected"},c);if("multi"in o&&o.multi!==!1)throw new L("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(o.type!=="undirected")throw new L('UndirectedGraph.from: inconsistent "'+o.type+'" type in given options!');return u.call(this,o)||this}return r(h,u),h}(he),Qr=function(u){function h(c){var o=S({multi:!0},c);if("multi"in o&&o.multi!==!0)throw new L("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");return u.call(this,o)||this}return r(h,u),h}(he),Zr=function(u){function h(c){var o=S({type:"directed",multi:!0},c);if("multi"in o&&o.multi!==!0)throw new L("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(o.type!=="directed")throw new L('MultiDirectedGraph.from: inconsistent "'+o.type+'" type in given options!');return u.call(this,o)||this}return r(h,u),h}(he),ei=function(u){function h(c){var o=S({type:"undirected",multi:!0},c);if("multi"in o&&o.multi!==!0)throw new L("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(o.type!=="undirected")throw new L('MultiUndirectedGraph.from: inconsistent "'+o.type+'" type in given options!');return u.call(this,o)||this}return r(h,u),h}(he);function Lt(u){u.from=function(h,c){var o=S({},h.options,c),s=new u(o);return s.import(h),s}}return Lt(he),Lt(Hr),Lt(Jr),Lt(Qr),Lt(Zr),Lt(ei),he.Graph=he,he.DirectedGraph=Hr,he.UndirectedGraph=Jr,he.MultiGraph=Qr,he.MultiDirectedGraph=Zr,he.MultiUndirectedGraph=ei,he.InvalidArgumentsGraphError=L,he.NotFoundGraphError=l,he.UsageGraphError=y,he})}(_r)),_r.exports}var Da=Ca();const Vi=bt(Da);var Ut={},Hi,Ji;function Qi(){return Ji||(Ji=1,Hi=function(n){return n!==null&&typeof n=="object"&&typeof n.addUndirectedEdgeWithKey=="function"&&typeof n.dropNode=="function"&&typeof n.multi=="boolean"}),Hi}var Nt={},Zi={},eo;function La(){return eo||(eo=1,function(n){var e=Math.pow(2,8)-1,t=Math.pow(2,16)-1,r=Math.pow(2,32)-1,i=Math.pow(2,7)-1,a=Math.pow(2,15)-1,p=Math.pow(2,31)-1;n.getPointerArray=function(m){var b=m-1;if(b<=e)return Uint8Array;if(b<=t)return Uint16Array;if(b<=r)return Uint32Array;throw new Error("mnemonist: Pointer Array of size > 4294967295 is not supported.")},n.getSignedPointerArray=function(m){var b=m-1;return b<=i?Int8Array:b<=a?Int16Array:b<=p?Int32Array:Float64Array},n.getNumberType=function(m){return m===(m|0)?Math.sign(m)===-1?m<=127&&m>=-128?Int8Array:m<=32767&&m>=-32768?Int16Array:Int32Array:m<=255?Uint8Array:m<=65535?Uint16Array:Uint32Array:Float64Array};var f={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};n.getMinimalRepresentation=function(m,b){var S=null,D=0,G,O,k,j,I;for(j=0,I=m.length;j<I;j++)k=b?b(m[j]):m[j],O=n.getNumberType(k),G=f[O.name],G>D&&(D=G,S=O);return S},n.isTypedArray=function(m){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(m)},n.concat=function(){var m=0,b,S,D;for(b=0,D=arguments.length;b<D;b++)m+=arguments[b].length;var G=new arguments[0].constructor(m);for(b=0,S=0;b<D;b++)G.set(arguments[b],S),S+=arguments[b].length;return G},n.indices=function(m){for(var b=n.getPointerArray(m),S=new b(m),D=0;D<m;D++)S[D]=D;return S}}(Zi)),Zi}var to;function Oa(){if(to)return Nt;to=1;var n=Jn(),e=La();function t(p){return Array.isArray(p)||e.isTypedArray(p)}function r(p){if(typeof p.length=="number")return p.length;if(typeof p.size=="number")return p.size}function i(p){var f=r(p),m=typeof f=="number"?new Array(f):[],b=0;return n(p,function(S){m[b++]=S}),m}function a(p){var f=r(p),m=typeof f=="number"?e.getPointerArray(f):Array,b=typeof f=="number"?new Array(f):[],S=typeof f=="number"?new m(f):[],D=0;return n(p,function(G){b[D]=G,S[D]=D++}),[b,S]}return Nt.isArrayLike=t,Nt.guessLength=r,Nt.toArray=i,Nt.toArrayWithIndices=a,Nt}var Sr,no;function Ma(){if(no)return Sr;no=1;var n=Oa(),e=Xn();function t(r,i){if(arguments.length<2)throw new Error("mnemonist/fixed-deque: expecting an Array class and a capacity.");if(typeof i!="number"||i<=0)throw new Error("mnemonist/fixed-deque: `capacity` should be a positive number.");this.ArrayClass=r,this.capacity=i,this.items=new r(this.capacity),this.clear()}return t.prototype.clear=function(){this.start=0,this.size=0},t.prototype.push=function(r){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.push: deque capacity ("+this.capacity+") exceeded!");var i=this.start+this.size;return i>=this.capacity&&(i-=this.capacity),this.items[i]=r,++this.size},t.prototype.unshift=function(r){if(this.size===this.capacity)throw new Error("mnemonist/fixed-deque.unshift: deque capacity ("+this.capacity+") exceeded!");var i=this.start-1;return this.start===0&&(i=this.capacity-1),this.items[i]=r,this.start=i,++this.size},t.prototype.pop=function(){if(this.size!==0){this.size--;var r=this.start+this.size;return r>=this.capacity&&(r-=this.capacity),this.items[r]}},t.prototype.shift=function(){if(this.size!==0){var r=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[r]}},t.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]},t.prototype.peekLast=function(){if(this.size!==0){var r=this.start+this.size-1;return r>=this.capacity&&(r-=this.capacity),this.items[r]}},t.prototype.get=function(r){if(!(this.size===0||r>=this.capacity))return r=this.start+r,r>=this.capacity&&(r-=this.capacity),this.items[r]},t.prototype.forEach=function(r,i){i=arguments.length>1?i:this;for(var a=this.capacity,p=this.size,f=this.start,m=0;m<p;)r.call(i,this.items[f],m,this),f++,m++,f===a&&(f=0)},t.prototype.toArray=function(){var r=this.start+this.size;if(r<this.capacity)return this.items.slice(this.start,r);for(var i=new this.ArrayClass(this.size),a=this.capacity,p=this.size,f=this.start,m=0;m<p;)i[m]=this.items[f],f++,m++,f===a&&(f=0);return i},t.prototype.values=function(){var r=this.items,i=this.capacity,a=this.size,p=this.start,f=0;return new e(function(){if(f>=a)return{done:!0};var m=r[p];return p++,f++,p===i&&(p=0),{value:m,done:!1}})},t.prototype.entries=function(){var r=this.items,i=this.capacity,a=this.size,p=this.start,f=0;return new e(function(){if(f>=a)return{done:!0};var m=r[p];return p++,p===i&&(p=0),{value:[f++,m],done:!1}})},typeof Symbol<"u"&&(t.prototype[Symbol.iterator]=t.prototype.values),t.prototype.inspect=function(){var r=this.toArray();return r.type=this.ArrayClass.name,r.capacity=this.capacity,Object.defineProperty(r,"constructor",{value:t,enumerable:!1}),r},typeof Symbol<"u"&&(t.prototype[Symbol.for("nodejs.util.inspect.custom")]=t.prototype.inspect),t.from=function(r,i,a){if(arguments.length<3&&(a=n.guessLength(r),typeof a!="number"))throw new Error("mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.");var p=new t(i,a);if(n.isArrayLike(r)){var f,m;for(f=0,m=r.length;f<m;f++)p.items[f]=r[f];return p.size=m,p}return n.forEach(r,function(b){p.push(b)}),p},Sr=t,Sr}var ro;function za(){if(ro)return Ut;ro=1;const n=Qi(),e=Ma();function t(f,m){let b=0;return f.forEachInNeighbor(m,()=>{b++}),b}function r(f,m){if(!n(f))throw new Error("graphology-dag/topological-sort: the given graph is not a valid graphology instance.");if(f.type==="undirected"||f.undirectedSize!==0)throw new Error("graphology-dag/topological-sort: cannot work if graph is not directed.");if(f.order===0)return;const b=new e(Array,f.order),S={};let D=0;f.forEachNode((k,j)=>{const I=f.multi?t(f,k):f.inDegree(k);I===0?b.push([k,j,0]):(S[k]=I,D+=I)});let G=0;function O(k,j){const I=--S[k];D--,I===0&&b.push([k,j,G+1]),S[k]=I}for(;b.size!==0;){const[k,j,I]=b.shift();G=I,m(k,j,I),f.forEachOutNeighbor(k,O)}if(D!==0)throw new Error("graphology-dag/topological-sort: given graph is not acyclic.")}function i(f){if(!n(f))throw new Error("graphology-dag/topological-sort: the given graph is not a valid graphology instance.");const m=new Array(f.order);let b=0;return r(f,S=>{m[b++]=S}),m}function a(f,m){if(!n(f))throw new Error("graphology-dag/topological-generations: the given graph is not a valid graphology instance.");if(f.order===0)return;let b=0,S=[];r(f,(D,G,O)=>{O>b&&(m(S),b=O,S=[]),S.push(D)}),m(S)}function p(f){if(!n(f))throw new Error("graphology-dag/topological-generations: the given graph is not a valid graphology instance.");const m=[];return a(f,b=>{m.push(b)}),m}return Ut.topologicalSort=i,Ut.forEachNodeInTopologicalOrder=r,Ut.topologicalGenerations=p,Ut.forEachTopologicalGeneration=a,Ut}var io=za(),Ar,oo;function Ra(){if(oo)return Ar;oo=1;const n=Qi();return Ar=function(e,t,r){if(!n(e))throw new Error("graphology-dag/will-create-cycle: the given graph is not a valid graphology instance.");if(t=""+t,r=""+r,t===r)return!0;if(!e.hasNode(t)||!e.hasNode(r)||e.hasDirectedEdge(t,r))return!1;if(e.hasDirectedEdge(r,t))return!0;const i=e.outNeighbors(r);function a(p){i.push(p)}for(;i.length!==0;){const p=i.pop();if(p===t)return!0;e.forEachOutNeighbor(p,a)}return!1},Ar}var ja=Ra();const Tt=bt(ja);function so(n){const e=[],t=[...n];let r;for(;r=t.shift();){let i=r.parent;if(i){const a=[];for(;i;){const p=t.findIndex(m=>m.id===i);if(p<0)break;const[f]=t.splice(p,1);if(!f)throw new Error("Invalid state, should not happen");a.unshift(f),i=f.parent}e.push(...a)}e.push(r)}return e}function Ua(n){return n.forEach(e=>{e.children.length>0&&(e.children=n.reduce((t,r)=>(r.parent===e.id&&t.push(r.id),t),[]))}),n}function ao(n){let e=so([...n.nodes.values()]),t=[...n.edges];if(e.length<2||t.length===0)return{nodes:e,edges:t};const r=O=>be(n.nodes.get(O)),i=new Vi({multi:!0,allowSelfLoops:!0,type:"directed"}),a=J(t,xe((O,k)=>{const j=r(O.source),I=r(O.target),W=O.parent?r(O.parent):null;return{id:O.id,edge:O,parent:W,source:j,target:I}})),[p,f]=Cn(a,({source:O,target:k})=>O.children.length===0&&k.children.length===0),m=[],b=O=>{i.mergeNode(O.source),i.mergeNode(O.target),m.push(O),Tt(i,O.source,O.target)||i.mergeDirectedEdge(O.source,O.target)};for(const{edge:O,source:k,target:j}of p)if(b(O),j.parent&&j.parent!==O.parent&&J(kr(j,n.nodes),ri(I=>I.inEdges.includes(O.id)),We(I=>{i.mergeNode(I.id),Tt(i,O.source,I.id)||i.mergeDirectedEdge(O.source,I.id),Tt(i,I.id,O.target)||i.mergeDirectedEdge(I.id,O.target)})),k.parent){const I=r(k.parent);i.mergeNode(I.id),Tt(i,I.id,k.id)||i.mergeDirectedEdge(I.id,k.id),j.parent&&j.parent!==k.parent&&(Tt(i,I.id,j.parent)||i.mergeDirectedEdge(I.id,j.parent))}for(const{edge:O}of f)b(O);re(m.length===t.length,"Not all edges were added to the graph");const S=io.topologicalSort(i);let D=[],G=e.slice();for(const O of S){const k=G.findIndex(j=>j.id===O);re(k>=0,`Node "${O}" not found`),D.push(...G.splice(k,1))}return G.length>0&&D.length>0&&(D=D.flatMap(O=>{if(G.length===0)return O;const k=e.slice(0,e.indexOf(O)).filter(j=>G.includes(j));return k.length>0?(G=G.filter(j=>!k.includes(j)),[...k,O]):O})),D.push(...G),{nodes:Ua(so(D)),edges:m}}function Ir(n){const e={id:n.id,__:n.__??"element",autoLayout:n.autoLayout,nodes:J(n.nodes,xe(rn(["id","title","description","technology","shape","icon","children"])),qi(({id:t,icon:r,...i})=>[t,{...i,icon:_e(r)?"Y":"N"}])),edges:J(n.edges,xe(rn(["source","target","label","description","technology","dir","head","tail","line"])),qi(({source:t,target:r,...i})=>[`${t}:${r}`,i]))};return n.hash=Ms(e,{ignoreUnknown:!0,respectType:!1}),n}class uo{constructor(e){this.state=e}get Ctx(){throw new Error("Should not be called in runtime")}get elements(){return this.state.elements}get explicits(){return this.state.explicits}get final(){return this.state.final}get connections(){return this.state.connections}isEmpty(){return this.elements.size===0&&this.connections.length===0&&this.explicits.size===0&&this.final.size===0}}var je;(n=>{n.isInside=e=>t=>ye(e,t.source.id)&&ye(e,t.target.id),n.isDirectedBetween=(e,t)=>r=>(r.source.id===e||ye(e,r.source.id))&&(r.target.id===t||ye(t,r.target.id)),n.isAnyBetween=(e,t)=>{const r=(0,n.isDirectedBetween)(e,t),i=(0,n.isDirectedBetween)(t,e);return a=>r(a)||i(a)},n.isIncoming=e=>t=>(t.target.id===e||ye(e,t.target.id))&&!ye(e,t.source.id),n.isOutgoing=e=>t=>(t.source.id===e||ye(e,t.source.id))&&!ye(e,t.target.id),n.isAnyInOut=e=>{const t=(0,n.isIncoming)(e),r=(0,n.isOutgoing)(e);return i=>t(i)||r(i)}})(je||(je={}));const $r=Symbol.for("nodejs.util.inspect.custom");class co{get style(){return{shape:Sn,color:Zt,...this.$node.style}}get shape(){return this.$node.style?.shape??Sn}get color(){return this.$node.style?.color??Zt}get tags(){return this.$node.tags??[]}get kind(){return this.$node.kind??null}get description(){return this.$node.description??null}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){const t=ft(this.id,e.id);return t?this.$model.node(t):null}siblings(){return this.$model.siblings(this)}isSibling(e){return this.parent===e.parent}*ascendingSiblings(){yield*this.siblings();for(const e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(const e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e="all"){return this.$model.incoming(this,e)}outgoing(e="all"){return this.$model.outgoing(this,e)}*incomers(e="all"){const t=new Set;for(const r of this.incoming(e))t.has(r.source.id)||(t.add(r.source.id),yield r.source)}*outgoers(e="all"){const t=new Set;for(const r of this.outgoing(e))t.has(r.target.id)||(t.add(r.target.id),yield r.target)}*views(){for(const e of this.$model.views())e.isDeploymentView()&&e.includesDeployment(this.id)&&(yield e)}isDeploymentNode(){return!1}isInstance(){return!1}cachedOutgoing=null;cachedIncoming=null;get allOutgoing(){return this.cachedOutgoing??=at.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())),this.cachedOutgoing}get allIncoming(){return this.cachedIncoming??=at.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())),this.cachedIncoming}}class Gr extends co{constructor(e,t){super(),this.$model=e,this.$node=t,this.id=t.id,this.title=t.title,this.hierarchyLevel=Mt(t.id)}id;title;hierarchyLevel;get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}children(){return this.$model.children(this)}descendants(e="desc"){return this.$model.descendants(this,e)}isDeploymentNode(){return!0}*instances(){for(const e of this.descendants("desc"))e.isInstance()&&(yield e)}onlyOneInstance(){const e=this.children();if(e.size!==1)return null;const t=ke([...e]);return t?.isInstance()?t:null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;const{outgoing:e,incoming:t}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(const r of this.instances()){for(const i of r.element.outgoing())e.add(i);for(const i of r.element.incoming())t.add(i)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){const{outgoing:e,incoming:t}=this.relationshipsFromInstances();return Le(t,e)}}class Cr extends co{constructor(e,t,r){super(),this.$model=e,this.$instance=t,this.element=r,this.id=t.id,this.title=t.title??r.title,this.hierarchyLevel=Mt(t.id)}id;title;hierarchyLevel;get $node(){return this.$instance}get parent(){return be(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){const{icon:e,style:t}=this.element.$element;return{shape:this.element.shape,color:this.element.color,...e&&{icon:e},...t,...this.$instance.style}}get shape(){return this.$instance.style?.shape??this.element.shape}get color(){return this.$instance.style?.color??this.element.color}get tags(){return this.$instance.tags??[]}get kind(){return this.$instance.kind??null}get description(){return this.$instance.description??this.element.description}get technology(){return this.$instance.technology??this.element.technology}get links(){return this.$instance.links??this.element.links}isInstance(){return!0}outgoingModelRelationships(){return this.element.outgoing()}incomingModelRelationships(){return this.element.incoming()}*views(){for(const e of this.$model.views())if(e.isDeploymentView()){if(e.includesDeployment(this.id)){yield e;continue}e.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield e)}}}class Na{constructor(e,t){this.instance=e,this.element=t}get id(){return this.instance.id}get style(){const{icon:e,style:t}=this.element.$element;return{shape:this.element.shape,color:this.element.color,...e&&{icon:e},...t}}get shape(){return this.element.shape}get color(){return this.element.color}get title(){return this.element.title}get description(){return this.element.description}get technology(){return this.element.technology}isDeploymentNode(){return!1}isInstance(){return!1}}class lo{constructor(e,t){this.$model=e,this.$relationship=t,this.source=e.deploymentRef(t.source),this.target=e.deploymentRef(t.target);const r=ft(this.source.id,this.target.id);this.boundary=r?this.$model.node(r):null}boundary;source;target;get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return yt(this.$relationship.title)?null:this.$relationship.title}get technology(){return yt(this.$relationship.technology)?null:this.$relationship.technology}get description(){return yt(this.$relationship.description)?null:this.$relationship.description}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}*views(){for(const e of this.$model.views())e.includesRelation(this.id)&&(yield e)}}class at{constructor(e=new Set,t=new Set){this.model=e,this.deployment=t}static empty(){return new at}static from(e,t){return new at(new Set(e),new Set(t))}get isEmpty(){return this.model.size===0&&this.deployment.size===0}get nonEmpty(){return this.model.size>0||this.deployment.size>0}get size(){return this.model.size+this.deployment.size}intersect(e){return at.from(Le(this.model,e.model),Le(this.deployment,e.deployment))}difference(e){return at.from(pe(this.model,e.model),pe(this.deployment,e.deployment))}union(e){return at.from(Ee(this.model,e.model),Ee(this.deployment,e.deployment))}}class st{constructor(e,t,r){this.source=e,this.target=t,this.relations=r,this.id=rr(`deployment:${e.id}:${t.id}`)}id;get expression(){return`${this.source.id} -> ${this.target.id}`}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target),this._boundary}nonEmpty(){return this.relations.nonEmpty}[$r](e,t,r){const i=this.toString();return Object.defineProperty(i,"constructor",{value:st,enumerable:!1}),i}toString(){const e=[...this.relations.model].map(r=>" "+r.expression);e.length?e.unshift(" model:"):e.unshift(" model: []");const t=[...this.relations.deployment].map(r=>" "+r.expression);return t.length?t.unshift(" deployment:"):t.unshift(" deployment: []"),[this.expression,...e,...t].join(`
7
+ `)}hasDirectDeploymentRelation(){for(const e of this.relations.deployment)if(e.source.id===this.source.id||e.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(e){return Array.isArray(e)?e.reduce((t,r)=>t.mergeWith(r),this):(re(this.source.id===e.source.id,"Cannot merge connections with different sources"),re(this.target.id===e.target.id,"Cannot merge connections with different targets"),new st(this.source,this.target,this.relations.union(e.relations)))}difference(e){return new st(this.source,this.target,this.relations.difference(e.relations))}intersect(e){return new st(this.source,this.target,this.relations.intersect(e.relations))}equals(e){return re(e instanceof st,"Other should ne DeploymentConnectionModel"),this.id===e.id&&this.source.id===e.source.id&&this.target.id===e.target.id&&nr(this.relations.model,e.relations.model)&&nr(this.relations.deployment,e.relations.deployment)}update(e){return e&&(e={model:this.relations.model,deployment:this.relations.deployment,...e}),new st(this.source,this.target,e?new at(e.model??new Set,e.deployment??new Set):this.relations)}}function Bt(n,e){if(!e){const p=n;return f=>Bt(f,p)}const t=n.source===e.source,r=n.target===e.target;if(t&&r)return!1;const i=ye(e.source.id,n.source.id),a=ye(e.target.id,n.target.id);return i&&a||t&&a||r&&i}function Dr(n,e){let t=e;for(const r of n)Bt(r,t)&&(t=r);return t!==e?t:null}function Ta(n){const e=[],t=n.slice();let r;for(;r=t.shift();){let i;for(;i=Dr(t,r);){const a=t.indexOf(i);e.push(t.splice(a,1)[0])}e.push(r)}return e}const Ba=n=>n.boundary?.id?`.${n.boundary.id}`:"";function ho(n,e){if(!n||lt(n)){const t=n??"asc";return r=>fo(r,t)}return fo(n,e??"asc")}function fo(n,e){return J(n,xe(t=>({id:Ba(t),conn:t})),En(e),xe(Ze("conn")))}function po(n,e){return n.filter(t=>Bt(e,t))}function go(n,e){return n.filter(Bt(e))}function Wt(n){const e=new Map;for(const t of n){const r=e.get(t.id);r?e.set(t.id,t.mergeWith(r)):e.set(t.id,t)}return[...e.values()]}function Ft(n,e){const t=new Map([...e].map(r=>[r.id,r]));return[...n].reduce((r,i)=>{const a=t.get(i.id);if(!a)return r.push(i),r;const p=i.difference(a);return p.nonEmpty()&&r.push(p),r},[])}function Lr(n,e){return e?n.source===e.source&&n.target===e.target:t=>n.source===t.source&&n.target===t.target}function Wa(n,e){return e?n.source===e.source:t=>n.source===t.source}function Fa(n,e){return e?n.target===e.target:t=>n.target===t.target}function Or(n,e){if(!e){const r=n;return i=>Or(i,r)}const t=n;return ht(t.source,e)&&!ht(t.target,e)}function Mr(n,e){if(!e){const r=n;return i=>Mr(i,r)}const t=n;return ht(t.target,e)&&!ht(t.source,e)}function Mn(n,e){if(!e){const r=n;return i=>Mn(i,r)}const t=n;return ht(t.source,e)!==ht(t.target,e)}function Pt(n,e,t="directed"){if(n===e)return[];if(Ot(n,e))return[];const r=Le(n.allOutgoing,e.allIncoming),i=r.size>0?new $e(n,e,r):null;if(t==="directed")return i?[i]:[];const a=Le(n.allIncoming,e.allOutgoing),p=a.size>0?new $e(e,n,a):null;return i&&p?[i,p]:i?[i]:p?[p]:[]}function Me(n,e,t="both"){if(n.allIncoming.size===0&&n.allOutgoing.size===0)return[];const r=[],i=[];for(const a of e)if(n!==a)for(const p of Pt(n,a,t))p.source===n?r.push(p):i.push(p);return[...r,...i]}function wt(n){return[...n].reduce((e,t,r,i)=>(r===i.length-1||e.push(...Me(t,i.slice(r+1),"both")),e),[])}const Pa={__proto__:null,findConnection:Pt,findConnectionsBetween:Me,findConnectionsWithin:wt};class $e{constructor(e,t,r=new Set){this.source=e,this.target=t,this.relations=r,this.id=rr(`model:${e.id}:${t.id}`)}id;_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target)}get expression(){return`${this.source.id} -> ${this.target.id}`}get isDirect(){return this.nonEmpty()&&!this.isImplicit}get isImplicit(){return this.nonEmpty()&&Qt(this.relations,ir(Lr(this)))}get directRelations(){return new Set(Re(this.relations,Lr(this)))}nonEmpty(){return this.relations.size>0}mergeWith(e){return re(this.source.id===e.source.id,"Cannot merge connections with different sources"),re(this.target.id===e.target.id,"Cannot merge connections with different targets"),new $e(this.source,this.target,Ee(this.relations,e.relations))}difference(e){return new $e(this.source,this.target,pe(this.relations,e.relations))}intersect(e){return re(e instanceof $e,"Cannot intersect connection with different type"),new $e(this.source,this.target,Le(this.relations,e.relations))}equals(e){return re(e instanceof $e,"Cannot merge connection with different type"),this.id===e.id&&this.source.id===e.source.id&&this.target.id===e.target.id&&nr(this.relations,e.relations)}update(e){return new $e(this.source,this.target,e)}[$r](e,t,r){const i=this.toString();return Object.defineProperty(i,"constructor",{value:$e,enumerable:!1}),i}toString(){return[this.expression,this.relations.size?" relations:":" relations: [ ]",...[...this.relations].map(e=>" "+e.expression)].join(`
8
+ `)}reversed(e=!1){if(!e)return new $e(this.target,this.source);const[t]=Pt(this.target,this.source,"directed");return t??new $e(this.target,this.source,new Set)}}function kt(n,e,t="directed"){if(n===e)return[];if(Ot(n,e))return[];const r=n.allOutgoing.intersect(e.allIncoming),i=r.nonEmpty?[new st(n,e,r)]:[];return t==="directed"?i:[...i,...kt(e,n,"directed")]}function Fe(n,e,t="both"){if(n.allIncoming.isEmpty&&n.allOutgoing.isEmpty)return[];const r=[],i=[];for(const a of e)if(n!==a)for(const p of kt(n,a,t))p.source===n?r.push(p):i.push(p);return[...r,...i]}function qt(n){return[...n].reduce((e,t,r,i)=>(r===i.length-1||e.push(...Fe(t,i.slice(r+1),"both")),e),[])}const qa={__proto__:null,findConnection:kt,findConnectionsBetween:Fe,findConnectionsWithin:qt};class mo{constructor(e,t){this.memory=e,this.expression=t}excluded={elements:new Set,connections:[]};markedToMoveExplicitToImplicit=!1;_removeElement(e){this.excluded.elements.add(e)}exclude(e){if(!e)return this;if(xt(e)){for(const t of e)this._removeElement(t);return this}return this._removeElement(e),this}_removeConnection(e){this.excluded.connections.push(e)}excludeConnections(e,t){if(pa(t)&&(re(!this.markedToMoveExplicitToImplicit,"Already marked to move explicits"),this.markedToMoveExplicitToImplicit=t),xt(e)){for(const r of e)this._removeConnection(r);return this}return this._removeConnection(e),this}isDirty(){return this.excluded.elements.size>0||this.excluded.connections.length>0}isEmpty(){return!this.isDirty()}filterForMoveToImplicits(e){return this.markedToMoveExplicitToImplicit||this.excluded.elements.size>0?e:new Set}moveDisconnectedExplicitsToImplicits(e){let t=pe(new Set(this.memory.connections.flatMap(r=>[r.source,r.target])),new Set(e.connections.flatMap(r=>[r.source,r.target])));return t=Le(t,e.elements),t=J(t,Re(r=>e.explicits.has(r)&&!Qt(e.final,ht(r))),nt()),t.size>0&&(t=this.filterForMoveToImplicits(t),e.explicits=pe(e.explicits,t),e.final=pe(e.final,t)),e}removeElements(e){return e.elements=pe(e.elements,this.excluded.elements),e.explicits=pe(e.explicits,this.excluded.elements),e.final=pe(e.final,this.excluded.elements),e}removeConnections(e){const t=this.excluded.connections.reduce((i,a)=>{const p=i.get(a.id);return p?i.set(a.id,p.mergeWith(a)):i.set(a.id,a),i},new Map);let r=new Set;e.connections=e.connections.reduce((i,a)=>{const p=t.get(a.id);if(p){r.add(a.source),r.add(a.target);const f=a.difference(p);f.nonEmpty()&&i.push(f)}else i.push(a);return i},[]);for(const i of e.connections)r.delete(i.source),r.delete(i.target),i.boundary&&e.elements.has(i.boundary)&&r.delete(i.boundary);return r.size===0||(r=pe(r,e.explicits),e.final=pe(e.final,r)),e}precommit(e){return e}postcommit(e){return re(pe(e.explicits,e.elements).size===0,"Explicits must be subset of elements"),re(pe(e.final,e.elements).size===0,"Final elements must be subset of elements"),e}commit(){let e=this.precommit(this.memory.mutableState());if(this.excluded.elements.size>0){const t=e.connections.filter(r=>this.excluded.elements.has(r.source)||this.excluded.elements.has(r.target)).flatMap(r=>[r,...po(e.connections,r).map(i=>i.intersect(r))]).filter(r=>r.nonEmpty());this.excludeConnections(t)}return this.excluded.connections.length>0&&(e=this.removeConnections(e)),this.excluded.elements.size>0&&(e=this.removeElements(e)),e=this.moveDisconnectedExplicitsToImplicits(e),this.memory.update(this.postcommit(e))}}class yo{constructor(e,t){this.memory=e,this.expression=t}explicits=new Set;implicits=new Set;_ordered=new Set;_connections=[];get elements(){return this.explicits}get connections(){return this._connections}mergedConnections(){return Wt([...this.memory.connections,...this._connections])}connectWithExisting(e,t){throw new Error("Method not implements, depends on the model")}_addExplicit(e){this._ordered.add(e),this.explicits.add(e),this.implicits.delete(e)}addExplicit(e){if(!e)return this;if(xt(e)){for(const t of e)this._addExplicit(t);return this}return this._addExplicit(e),this}_addImplicit(e){this.explicits.has(e)||(this._ordered.add(e),this.implicits.add(e))}addImplicit(e){if(!e)return this;if(xt(e)){for(const t of e)this._addImplicit(t);return this}return this._addImplicit(e),this}_addConnection(e){this._connections.push(e),this._addImplicit(e.source),this._addImplicit(e.target)}addConnections(e){if(xt(e)){for(const t of e)this._addConnection(t);return this}return this._addConnection(e),this}isDirty(){return this.explicits.size>0||this.implicits.size>0||this._connections.length>0}isEmpty(){return!this.isDirty()}precommit(e){return e}postcommit(e){return e}processConnections(e){return e}commit(){let e=this.precommit(this.memory.mutableState()),t=new Set;if(this._connections.length>0){const[r,i]=Cn(this._connections,a=>e.final.has(a.source));e.connections=this.processConnections(Wt([...e.connections,...r,...i])),t=new Set(e.connections.flatMap(a=>[a.source,a.target]))}return e.elements=Ee(e.elements,this._ordered,this.explicits,t,this.implicits),e.explicits=Le(e.elements,Ee(e.explicits,this.explicits)),e.final=Le(e.elements,Ee(e.final,this.explicits,t)),this.memory.update(this.postcommit(e))}}function wo(n,e="final"){const t=xn(ce(e==="final"?n.final:n.elements)),r=new Set(n.connections.flatMap(f=>[f.source,f.target])),i=new Set(t),a=new De(()=>null),p=t.reduce((f,m,b,S)=>(f.set(m,S.slice(b+1).filter(D=>ye(m,D)).map(D=>(i.delete(D),D)).reduce((D,G)=>(D.some(O=>ye(O,G))||(D.push(G),a.set(G,m)),D),[])),f),new De(()=>[]));return{root:i,connected:r,hasInOut:f=>n.connections.some(je.isAnyInOut(f.id)),parent:f=>a.get(f),children:f=>p.get(f)}}let Ya=class extends mo{};we(n=>n.nonEmpty());function Ka(n){const e=new De(()=>[]);for(const r of n)for(const i of r.relations.model)e.get(i).push(r);const t=new De(()=>new Set);for(const[r,i]of e)tt(i,2)&&J(i,et(a=>[{group:`$source-${a.source.id}`,conn:a},{group:`$target-${a.target.id}`,conn:a}]),Ln(Ze("group")),Et(),we(tt(2)),We(on(xe(Ze("conn")),ho("desc"),vr((a,p,f)=>p===0||a.boundary===f[p-1].boundary),We(a=>{t.get(a).add(r)}))));return t}function Xa(n){n=Wt(n);const e=Ka(n);for(const t of n){const{source:r,target:i}=t,a=t.relations.model;if(r.isDeploymentNode()!==i.isDeploymentNode()){const p=r.isDeploymentNode()?r:t.target;re(p.isDeploymentNode());const f=p.internalModelRelationships(),m=Le(a,f);for(const b of m)e.get(t).add(b);continue}if(r.isDeploymentNode()&&i.isDeploymentNode()){const p=Ee(Le(t.relations.model,r.internalModelRelationships()),Le(t.relations.model,i.internalModelRelationships()));for(const f of p)e.get(t).add(f)}}return J(e.entries(),Gs(([t,r])=>t.update({model:r,deployment:null})),ce())}function zr(n){return Ft(n,Xa(n))}function Va(n){return J(n,Wt,nn((e,t)=>{const{source:r,target:i,relations:a}=t;if(r.isInstance()&&i.isInstance())return e;let p=at.empty();if(r.isDeploymentNode()&&i.isDeploymentNode()){const[f]=kt(i,r,"directed");f&&(p=a.intersect(f.relations))}for(const f of n)Bt(f,t)&&(p=p.union(a.intersect(f.relations)));return p.nonEmpty&&e.push(new st(r,i,p)),e},[]))}function Rr(n){return Ft(n,Va(n))}let Ha=class extends yo{connectWithExisting(n,e="both"){const t=this._connections.length,r=()=>this._connections.length>t;if(!xt(n)){if(e==="in"||e==="both")for(const a of this.memory.elements)this.addConnections(kt(a,n,"directed"));return(e==="out"||e==="both")&&this.addConnections(Fe(n,this.memory.elements,"directed")),r()}const i=[...n];if(e==="in"||e==="both")for(const a of this.memory.elements)this.addConnections(Fe(a,i,"directed"));if(e==="out"||e==="both")for(const a of i)this.addConnections(Fe(a,this.memory.elements,"directed"));return r()}processConnections(n){const e=J(n,zr,Rr);return J(e,We(({source:t,target:r,boundary:i})=>{J(Wn([...ce(t.ancestors()).reverse(),t],[...ce(r.ancestors()).reverse(),r]),vr(([a,p])=>a===p),Ni(1),We(([a,p])=>{if(t===a&&r===p){this.addImplicit(i);return}a!==t&&a.isDeploymentNode()&&!a.onlyOneInstance()&&this.addImplicit(a),p!==r&&p.isDeploymentNode()&&!p.onlyOneInstance()&&this.addImplicit(p)}))})),e}},Ja=class jn extends uo{static empty(){return new jn({elements:new Set,explicits:new Set,final:new Set,connections:[]})}stageInclude(e){return new Ha(this,e)}stageExclude(e){return new Ya(this,e)}mutableState(){return{elements:new Set(this.state.elements),explicits:new Set(this.state.explicits),final:new Set(this.state.final),connections:[...this.state.connections]}}update(e){return new jn({...this.state,...e})}equals(e){return e instanceof jn&&ga(this.state,e.state)}diff(e){const t=this;return{added:{elements:ce(pe(e.elements,t.elements)),explicits:ce(pe(e.explicits,t.explicits)),final:ce(pe(e.final,t.final)),connections:ce(Ft(e.connections,t.connections))},removed:{elements:ce(pe(t.elements,e.elements)),explicits:ce(pe(t.explicits,e.explicits)),final:ce(pe(t.final,e.final)),connections:Ft(t.connections,e.connections)}}}toString(){return["final:",...[...this.final].map(e=>" "+e.id),"connections:",...this.connections.map(e=>" "+e.expression)].join(`
9
+ `)}[$r](e,t,r){return this.toString()}};function Xe(n){if(In(n)){const e=Xe(n.where.expr),t=ct(n.where.condition);return r=>e(r)&&t(r)}if(Oe(n))return()=>!0;if(Rt(n))return n.isEqual?e=>e.kind===n.elementKind:e=>e.kind!==n.elementKind;if(jt(n))return n.isEqual?({tags:e})=>!!e&&e.includes(n.elementTag):({tags:e})=>rt(e)||!e.includes(n.elementTag);if(gt(n))return e=>e.id===n.expanded||ut(e.id)===n.expanded;if(Ke(n)){const{element:e,isChildren:t,isDescendants:r}=n;return t||r?i=>i.id.startsWith(e+"."):i=>i.id===e}if(An(n))return Xe(n.custom.expr);Be(n)}function vo(n,e,t){J(t,we(ir(it.isNodesGroup)),we(Je(e)),We(r=>{r.shape=n.style.shape??r.shape,r.color=n.style.color??r.color,vn(n.style.icon)&&(r.icon=n.style.icon),vn(n.notation)&&(r.notation=n.notation);let i;vn(n.style.border)&&(i={border:n.style.border}),vn(n.style.opacity)&&(i={...i,opacity:n.style.opacity}),i&&(r.style={...r.style,...i})}))}function bo(n,e){for(const t of n){if(!Gi(t)||t.targets.length===0)continue;const r=t.targets.map(Xe);vo(t,r,e)}return e}function Qa(n,e){let t;for(;n.parent&&(t=e.get(n.parent));){const r=t.depth??1;if(t.depth=Math.max(r,(n.depth??0)+1),t.depth===r)break;n=t}}const Za=n=>({...n,modelRef:1});function eu(n,e){return jr(n.map(Za),e)}function jr(n,e){const t=new Map,r=new Map;e?.forEach(({id:a,parent:p,viewRule:f,elements:m})=>{p&&be(t.get(p),`Parent group node ${p} not found`).children.push(a),t.set(a,{id:a,parent:p,kind:zt.Group,title:f.title??"",color:f.color??"muted",shape:"rectangle",children:[],inEdges:[],outEdges:[],level:0,depth:0,description:null,technology:null,tags:null,links:null,style:{border:f.border??"dashed",opacity:f.opacity??0}});for(const b of m)r.set(b.id,a)}),Array.from(n).sort(li).forEach(({id:a,style:p,kind:f,title:m,color:b,shape:S,...D})=>{let G=ut(a),O=0,k;for(;G&&(k=t.get(G),!k);)G=ut(G);!k&&r.has(a)&&(G=r.get(a),k=t.get(G)),k&&(k.children.length==0&&(k.depth=1,Qa(k,t)),k.children.push(a),O=k.level+1);const j={id:a,parent:G,kind:f,title:m,level:O,color:b??Zt,shape:S??Sn,description:null,technology:null,tags:null,links:null,children:[],inEdges:[],outEdges:[],...D,style:{...p}};t.set(a,j)});const i=new Map;return e?.forEach(({id:a})=>{i.set(a,be(t.get(a)))}),n.forEach(({id:a})=>{i.set(a,be(t.get(a)))}),i}function tu(n){const{title:e,description:t=null,technology:r=null,kind:i=null,color:a=null,line:p=null,head:f=null,tail:m=null,navigateTo:b=null}=n;return{...e&&{title:e,description:t},technology:r,kind:i,color:a,line:p,head:f,tail:m,navigateTo:b}}function xo(n,e){const t=J(n,nn((f,m)=>(_e(m.title)&&!f.title.includes(m.title)&&f.title.push(m.title),_e(m.description)&&!f.description.includes(m.description)&&f.description.push(m.description),_e(m.technology)&&!f.technology.includes(m.technology)&&f.technology.push(m.technology),_e(m.kind)&&!f.kind.includes(m.kind)&&f.kind.push(m.kind),_e(m.color)&&!f.color.includes(m.color)&&f.color.push(m.color),_e(m.line)&&!f.line.includes(m.line)&&f.line.push(m.line),_e(m.head)&&!f.head.includes(m.head)&&f.head.push(m.head),_e(m.tail)&&!f.tail.includes(m.tail)&&f.tail.push(m.tail),_e(m.navigateTo)&&!f.navigateTo.includes(m.navigateTo)&&f.navigateTo.push(m.navigateTo),m.tags&&f.tags.push(...m.tags),m.links&&f.links.push(...m.links),f),{title:[],description:[],technology:[],kind:[],head:[],tail:[],color:[],tags:[],links:[],line:[],navigateTo:[]}));let r=ke(t.technology),i=ke(t.title)??(t.title.length>1?"[...]":null);const a=mt(t.tags);let p=Fi({title:i??(r?`[${r}]`:null),description:ke(t.description),technology:r,kind:ke(t.kind),head:ke(t.head),tail:ke(t.tail),color:ke(t.color),line:ke(t.line),navigateTo:ke(t.navigateTo),...Zn(t.links)&&{links:t.links},...Zn(a)&&{tags:a}},_e);return e?{...p,...Fi(tu(e),_e)}:p}function nu(n){const e=J(n,et(t=>t.tags??[]),mt(),yr(bn));return tt(e,1)?e:null}function ot(n,e){const t=n.element(e.ref.deployment);if(t.isDeploymentNode()){if(e.selector==="children")return[...t.children()];if(e.selector==="expanded")return[t,...t.children()];if(e.selector==="descendants")return[...t.descendants()]}return[t]}function an(n,e){const t=n.$model.element(e.ref.model);return e.selector==="children"?[...t.children()]:e.selector==="expanded"?[t,...t.children()]:e.selector==="descendants"?[...t.descendants()]:[t]}function zn(n){if(ie.isWildcard(n))return()=>!0;if(ie.isDeploymentRef(n)){const e=n.ref.deployment;if(n.selector==="expanded"){const t=e+".";return r=>r.id===e||r.id.startsWith(t)}if(n.selector==="descendants"){const t=e+".";return r=>r.id.startsWith(t)}return n.selector==="children"?t=>ut(t.id)===e:t=>t.id===e}if(ie.isModelRef(n)){const e=r=>wn(r.modelRef)?r.modelRef:fa(r.modelRef)?r.id:null,t=n.ref.model;if(n.selector==="expanded"){const r=t+".";return i=>{const a=e(i);return a?a===t||a.startsWith(r):!0}}if(n.selector==="descendants"){const r=t+".";return i=>{const a=e(i);return a?a.startsWith(r):!0}}return n.selector==="children"?r=>{const i=e(r);return i?ut(i)===t:!0}:r=>{const i=e(r);return i?i===t:!0}}Be(n)}function Eo(n){if(n.isDeploymentNode()){const b=n.onlyOneInstance();let{title:S,kind:D,id:G,...O}=n.$node;const{icon:k,color:j,shape:I,...W}=n.$node.style??{};return b&&S===ci(n.id)&&(S=b.title),{...b&&{...Eo(b),modelRef:b.element.id},title:S,...O,...k&&{icon:k},...j&&{color:j},...I&&{shape:I},style:{...W},deploymentRef:1,kind:D,id:G}}re(n.isInstance(),"Expected Instance");const e=n.$instance,t=n.element.$element,r=e.style?.icon??t.icon,i=e.style?.color??t.color,a=e.style?.shape??t.shape,p=[...t.links??[],...e.links??[]],f={...t.metadata,...e.metadata},m=e.notation??t.notation;return{id:n.id,kind:"instance",title:e.title??t.title,description:e.description??t.description,technology:e.technology??t.technology,tags:nu([t,e]),links:tt(p,1)?p:null,...r&&{icon:r},...i&&{color:i},...a&&{shape:a},style:{...t.style,...e.style},deploymentRef:n.id===e.id?1:e.id,modelRef:n.id===t.id?1:t.id,...m&&{notation:m},...!yt(f)&&{metadata:f}}}function ru(n){return n.reduce((e,t)=>{const r=[...t.relations.model,...t.relations.deployment];re(tt(r,1),"Edge must have at least one relation");const i=t.source.id,a=t.target.id,{title:p,...f}=xo(r.map(S=>S.$relationship)),m={id:t.id,parent:t.boundary?.id??null,source:i,target:a,label:p??null,relations:r.map(S=>S.id),...f},b=e.find(S=>S.source===a&&S.target===i);if(b&&m.label===b.label){b.dir="both";const S=b.head??m.head??hr;return b.head??=S,b.tail??=S,m.color&&(b.color??=m.color),m.line&&(b.line??=m.line),e}return e.push(m),e},[])}function iu(n){return jr([...n.final].map(Eo))}function ou(n,e){for(const t of n){if(!Gi(t)||t.targets.length===0)continue;const r=t.targets.map(zn);vo(t,r,e)}return e}const su={include:n=>{const{expr:e}=n,t=n.model.element(e.ref.deployment);if(Ju(t))return n.stage.addExplicit(t),n.stage.connectWithExisting(t),n.stage;switch(!0){case e.selector==="expanded":uu(t,n);break;case e.selector==="children":au(t,n);break;case e.selector==="descendants":cu(t,n);break;default:n.stage.addExplicit(t),n.stage.connectWithExisting(t)}return n.stage},exclude:({expr:n,stage:e,memory:t})=>{const r=zn(n);return e.exclude([...t.elements].filter(r)),e}};function au(n,{stage:e}){const t=[...n.children()];t.length!==0&&(e.addImplicit(n),e.addConnections(qt(t)),e.connectWithExisting(t),e.addExplicit(t))}function uu(n,{memory:e,stage:t}){const r=[...n.children()];t.addImplicit(n),t.connectWithExisting(n);let i=!1;for(const a of r)if(Fe(a,e.elements).length>0){i=!0;break}i&&(t.connectWithExisting(r,"in"),t.addConnections(qt(r)),t.connectWithExisting(r,"out")),t.addImplicit(r),t.connections.length>0&&t.addExplicit(n)}function cu(n,{stage:e}){const t=a=>{const p=[];for(const f of a.children())f.isDeploymentNode()&&p.push(...t(f)),p.push(f);return e.connectWithExisting(p,"in"),e.addConnections(qt(p)),e.addImplicit(p),p},r=t(n);if(r.length===0)return;e.connectWithExisting(r,"out");const i=du(e);r.forEach(a=>{i.has(a)&&e.addExplicit(a)})}function du(n){return J(n.mergedConnections(),zr,Rr,nn((e,t)=>(e.add(t.source),e.add(t.target),e),new Set))}const lu={include:({expr:n,model:e,memory:t,stage:r,where:i})=>{const a=[...t.elements];if(ie.isWildcard(n.outgoing)){for(const f of a)if(!f.allIncoming.isEmpty)for(const m of dn(f)){const b=Ve(kt(m,f,"directed"),i);r.addConnections(b)}return r}re(ie.isDeploymentRef(n.outgoing),"Only deployment refs are supported in include");const p=ot(e,n.outgoing);for(const f of p){const m=Ve(Fe(f,a,"directed"),i);r.addConnections(m)}return r},exclude:({expr:n,model:e,memory:t,stage:r,where:i})=>{if(ie.isModelRef(n.outgoing)){const f=Ur(e,n.outgoing);return _t(f,{stage:r,memory:t},i)}if(ie.isWildcard(n.outgoing))return r;const a=un(ot(e,n.outgoing)),p=J(t.connections,we(a),Ve(i));return r.excludeConnections(p),r}};function un(n){return Je(n.map(e=>{const t=r=>r===e||ye(e,r);return r=>t(r.source)&&!t(r.target)}))}function Ur(n,e){const t=an(n,e);return new Set(t.flatMap(r=>[...r.allOutgoing]))}const hu={include:({expr:n,model:e,memory:t,stage:r,where:i})=>{const a=[...t.elements];if(ie.isWildcard(n.inout)){for(const f of a){const m=[...dn(f)],b=ko(Fe(f,m,"both"),i);r.addConnections(b)}return r}re(ie.isDeploymentRef(n.inout),"Only deployment refs are supported in include");const p=ot(e,n.inout);for(const f of a){const m=ko(Fe(f,p,"both"),i);r.addConnections(m)}return r},exclude:({expr:n,model:e,memory:t,stage:r,where:i})=>{if(ie.isModelRef(n.inout)){const b=an(e,n.inout);if(b.length===0)return r;const S=Ee(new Set,...b.flatMap(D=>[D.allIncoming,D.allOutgoing]));return _t(S,{stage:r,memory:t},i)}if(ie.isWildcard(n.inout))return r;const a=ot(e,n.inout),p=cn(a),f=un(a),m=J(t.connections,we(b=>p(b)!==f(b)),Ve(i));return r.excludeConnections(m),r}},fu={include:({expr:n,model:e,memory:t,stage:r})=>{const i=ct(n.where.condition);return Nr("include",{expr:n.where.expr,model:e,stage:r,memory:t,where:i})},exclude:({expr:n,model:e,memory:t,stage:r})=>{const i=ct(n.where.condition);return Nr("exclude",{expr:n.where.expr,model:e,stage:r,memory:t,where:i})}},pu={include:({model:n,stage:e})=>{const t=[],r=[...n.roots()].map(i=>(i.onlyOneInstance()||t.push(...i.children()),i));return e.addExplicit(r),t.length>1&&e.addConnections(qt([...r,...t])),e},exclude:({stage:n,memory:e})=>(n.exclude(e.elements),n)};function Nr(n,{expr:e,where:t,...r}){switch(!0){case ie.isModelRef(e):return;case ie.isDeploymentRef(e):return su[n]({...r,expr:e,where:t});case ie.isWildcard(e):return pu[n]({...r,expr:e,where:t});case Qe.isDirect(e):return wu[n]({...r,expr:e,where:t});case Qe.isInOut(e):return hu[n]({...r,expr:e,where:t});case Qe.isOutgoing(e):return lu[n]({...r,expr:e,where:t});case Qe.isIncoming(e):return yu[n]({...r,expr:e,where:t});case Qe.isWhere(e):return fu[n]({...r,expr:e,where:t});default:Be(e)}}function _t(n,{stage:e,memory:t},r,i=()=>!0){if(n.size===0)return e;const a=J(t.connections,we(p=>i(p)),we(p=>yi(p.relations.model,n)),xe(p=>p.update({deployment:null,model:Le(p.relations.model,n)})),Ve(r),we(p=>p.nonEmpty()));return a.length===0?e:e.excludeConnections(a)}function gu(n,e){return Ve(n,e).nonEmpty()}function Ve(...n){if(n.length===1)return i=>Ve(i,n[0]);const[e,t]=n;if(t===null)return e;if(bi(e))return e.map(i=>Ve(i,t)).filter(i=>i.nonEmpty());const r=mu(e.source,e.target);return e.update({model:new Set([...e.relations.model.values()].filter(i=>t(r(i)))),deployment:new Set([...e.relations.deployment.values()].filter(i=>t(r(i))))})}function ko(n,e){return e?J(n,we(t=>gu(t,e))):n}function _o(n){return rn(n,["tags","kind"])}function mu(n,e){return t=>({tags:t.tags,kind:t.kind,source:_o(n),target:_o(e)})}const yu={include:({expr:n,model:e,memory:t,stage:r,where:i})=>{const a=[...t.elements];if(ie.isWildcard(n.incoming)){for(const f of a){if(f.allOutgoing.isEmpty)continue;const m=[...dn(f)],b=Ve(Fe(f,m,"directed"),i);r.addConnections(b)}return r}re(ie.isDeploymentRef(n.incoming),"Only deployment refs are supported in include");const p=ot(e,n.incoming);for(const f of a){const m=Ve(Fe(f,p,"directed"),i);r.addConnections(m)}return r},exclude:({expr:n,model:e,memory:t,stage:r,where:i})=>{if(ie.isModelRef(n.incoming)){const f=So(e,n.incoming);return _t(f,{stage:r,memory:t},i)}if(ie.isWildcard(n.incoming))return r;const a=cn(ot(e,n.incoming)),p=J(t.connections,we(a),Ve(i));return r.excludeConnections(p),r}};function cn(n){return Je(n.map(e=>{const t=r=>r===e||ye(e,r);return r=>!t(r.source)&&t(r.target)}))}function So(n,e){const t=an(n,e);return new Set(t.flatMap(r=>[...r.allIncoming]))}const dn=n=>{const e=new Set;for(let t of n.descendingSiblings())e.add(t);return e},wu={include:({expr:{source:n,target:e,isBidirectional:t=!1},model:r,stage:i,where:a})=>{re(!ie.isModelRef(n),"Invalid source model ref in direct relation"),re(!ie.isModelRef(e),"Invalid target model ref in direct relation");const p=ie.isWildcard(n),f=ie.isWildcard(e),m=t?"both":"directed";let b;switch(!0){case(p&&f):{b=qt(r.instances()).map(S=>(i.addImplicit(S.boundary),S));break}case(!p&&f):{const S=ot(r,n),D=un(S);let G=D;if(t){const O=cn(S);G=k=>D(k)!==O(k)}b=S.flatMap(O=>{const k=dn(O);return Fe(O,k,m)}).filter(G);break}case(p&&!f):{const S=ot(r,e),D=cn(S);let G=D;if(t){const O=un(S);G=k=>O(k)!==D(k)}b=S.flatMap(O=>[...dn(O)].flatMap(k=>kt(k,O,m))).filter(G);break}default:{re(!p,"Inferrence failed - source should be a deployment ref"),re(!f,"Inferrence failed - target should be a deployment ref");const S=ot(r,n),D=ot(r,e),G=un(S),O=cn(D);b=J(S,et(k=>$o(Fe(k,D,m),a)),we(k=>G(k)&&O(k)))}}return i.addConnections(b),ie.isDeploymentRef(n)&&qn(n.selector)&&i.addImplicit(r.element(n.ref.deployment)),ie.isDeploymentRef(e)&&qn(e.selector)&&i.addImplicit(r.element(e.ref.deployment)),i},exclude:({expr:n,model:e,memory:t,stage:r,where:i})=>{const a=zn(n.target),p=zn(n.source);let f;switch(!0){case(ie.isWildcard(n.source)&&ie.isWildcard(n.target)):return r.excludeConnections($o(t.connections,i)),r;case(ie.isModelRef(n.source)&&ie.isModelRef(n.target)):return f=vu({source:n.source,target:n.target,expr:n,model:e}),_t(f,{stage:r,memory:t},i);case(ie.isModelRef(n.source)&&ie.isWildcard(n.target)):return f=Ur(e,n.source),_t(f,{stage:r,memory:t},i);case ie.isModelRef(n.source):return f=Ur(e,n.source),_t(f,{stage:r,memory:t},i,S=>a(S.target));case ie.isModelRef(n.target):return f=So(e,n.target),_t(f,{stage:r,memory:t},i,S=>p(S.source));default:const m=S=>p(S.source)&&a(S.target)||n.isBidirectional===!0&&p(S.target)&&a(S.source),b=J(t.connections,we(m),Ve(i));return b.length===0||r.excludeConnections(b),r}}};function vu({source:n,target:e,expr:t,model:r}){const i=an(r,n),a=an(r,e),p=t.isBidirectional?"both":"directed",f=[];for(const m of i)f.push(...Me(m,a,p));return new Set(f.flatMap(m=>[...m.relations]))}function Ao(n){return rn(n,["tags","kind"])}function Io(n,e){return t=>({tags:t.tags,kind:t.kind,source:Ao(n),target:Ao(e)})}function bu(n,e){return e?[...Array.from(n.relations.deployment.values()).map(Io(n.source,n.target)),...Array.from(n.relations.model.values()).map(Io(n.source,n.target))].filter(e).length>0:!0}function $o(n,e){return e?J(n,we(t=>bu(t,e))):n}let xu=class Po{constructor(e){this.memory=e}static for(e){return new Po(e)}step1CleanConnections(e){if(e.connections.length<2)return e;const t=J(e.connections,zr,Rr),r=Ft(e.connections,t);if(r.length===0)return e;const i=e.stageExclude({});return i.excludeConnections(r,!0),i.commit()}step2ProcessImplicits(e){const t=Ee(this.memory.elements,e.elements),r=Ee(e.final,this.memory.explicits),i=new De(()=>new Set);for(const f of e.connections)if(f.boundary)for(const m of f.relations.model)i.get(m).add(f.boundary);for(const[f,m]of i)if(!(m.size<2))for(const b of m)t.delete(b)&&r.add(b);const a=new Set(r),p=f=>{for(const m of a)if(f===m||ye(f,m))return!0;return!1};return J(pe(t,a),Re(f=>f.isDeploymentNode()),ce(),er,We(f=>{const m=[...f.children()].filter(p).length;if(m>=2){r.add(f);return}m===1&&Qt(f.siblings(),p)&&r.add(f)})),e.update({final:r})}step3ProcessBoundaries(e){const t=new Set;for(const f of e.connections)f.boundary&&t.add(f.boundary);const r=wo(e,"final"),i=e.stageExclude({}),a=f=>!(t.has(f)||e.explicits.has(f)||r.hasInOut(f)||r.root.has(f)),p=ke([...r.root]);p&&!e.explicits.has(p)&&i.exclude(p);for(const f of e.final){const m=ke(r.children(f));m&&!r.hasInOut(m)&&a(f)&&i.exclude(f)}return i.isDirty()?i.commit():e}commit(){const e=this.step1CleanConnections(this.memory),t=this.step2ProcessImplicits(e);return this.step3ProcessBoundaries(t)}};function Eu(n,e){let t=Ja.empty();for(const r of e)if($n(r)){const i="include"in r?"include":"exclude",a=r.include??r.exclude;for(const p of a){let f=i==="include"?t.stageInclude(p):t.stageExclude(p);f=Nr(i,{expr:p,model:n,stage:f,memory:t,where:null})??f,t=f.commit()}}return xu.for(t).commit()}function ku(n,{docUri:e,rules:t,...r}){const i=Eu(n.deployment,t),a=iu(i),p=ru(i.connections);Ki(a,p);const f=ao({nodes:a,edges:p}),m=ou(t,f.nodes),b=wr(t,fr),S=Er(m);return Ir({...r,autoLayout:{direction:b?.direction??"TB",...b?.nodeSep&&{nodeSep:b.nodeSep},...b?.rankSep&&{rankSep:b.rankSep}},edges:f.edges,nodes:xe(m,D=>(delete D.notation,D.icon==="none"&&delete D.icon,D)),...S.length>0&&{notation:{elements:S}}})}function Tr(n){return e=>Di(e)?e.groupRules.flatMap(Tr(n)):$n(e)?"include"in e?e.include.filter(n):[]:[]}function Go(n,e){const t=n.flatMap(Tr(An));if(t.length===0)return e;const r=[...e];for(const{custom:{expr:i,...a}}of t){const{border:p,opacity:f,...m}=Pi(a,rt),b=!yt(m),S=Xe(i);r.forEach((D,G)=>{if(it.isNodesGroup(D)||!S(D))return;b&&(D={...D,isCustomized:!0,...m});let O;p!==void 0&&(O={border:p}),f!==void 0&&(O={...O,opacity:f}),O&&(D={...D,isCustomized:!0,style:{...D.style,...O}}),r[G]=D})}return r}function _u(n,e){return n.reduce((t,r)=>{if($i(r)){const i=e.predicates[r.predicateId];return rt(i)?t:t.concat(i)}if(Ci(r)){const i=e.styles[r.styleId];return rt(i)?t:t.concat(i)}return t.push(r),t},[])}function Su(n,e){return n.reduce((t,r)=>{if($i(r)){const i=e.dynamicPredicates[r.predicateId];return rt(i)?t:t.concat(i)}if(Ci(r)){const i=e.styles[r.styleId];return rt(i)?t:t.concat(i)}return t.push(r),t},[])}class Au{constructor(e,t){this.model=e,this.view=t}explicits=new Set;steps=[];addStep({source:e,target:t,title:r,isBackward:i,navigateTo:a,...p},f,m){const b=m?zi(m,f):zi(f),S=this.model.element(e),D=this.model.element(t);this.explicits.add(S),this.explicits.add(D);const{title:G,relations:O,tags:k,navigateTo:j,head:I,tail:W,color:X,line:P,notation:F}=this.findRelations(S,D),V=_e(a)&&a!==this.view.id?a:j;this.steps.push({id:b,...p,source:S,target:D,title:r??G,relations:O??[],isBackward:i??!1,...V?{navigateTo:V}:{},...k?{tags:k}:{},...I?{head:I}:{},...W?{tail:W}:{},...X?{color:X}:{},...P?{line:P}:{},...F?{notation:F}:{}})}compute(){const{docUri:e,rules:t,steps:r,...i}=this.view;let a=1;for(const O of r){if(Ps(O)){if(O.__parallel.length===0)continue;O.__parallel.length===1?this.addStep(O.__parallel[0],a):O.__parallel.forEach((k,j)=>this.addStep(k,j+1,a))}else this.addStep(O,a);a++}const p=Su(t,this.model.globals());for(const O of p)if($n(O))for(const k of O.include){const j=Xe(k);for(const I of this.model.elements())j(I)&&this.explicits.add(I)}const f=[...this.explicits].map(O=>O.$element),m=eu(f),b=this.steps.map(({source:O,target:k,relations:j,title:I,isBackward:W,...X})=>{const P=be(m.get(O.id),`Source node ${O.id} not found`),F=be(m.get(k.id),`Target node ${k.id} not found`),V={parent:ft(O.id,k.id),source:O.id,target:k.id,label:I,relations:j,color:Ii,line:Ai,head:hr,...X};for(W&&(V.dir="back");V.parent&&!m.has(V.parent);)V.parent=ut(V.parent);P.outEdges.push(V.id),F.inEdges.push(V.id);for(const _ of pt(V.source)){if(_===V.parent)break;m.get(_)?.outEdges.push(V.id)}for(const _ of pt(V.target)){if(_===V.parent)break;m.get(_)?.inEdges.push(V.id)}return V}),S=Go(p,bo(p,f.map(O=>be(m.get(O.id))))),D=wr(p,fr),G=Er(S);return Ir({...i,autoLayout:{direction:D?.direction??"LR",...D?.nodeSep&&{nodeSep:D.nodeSep},...D?.rankSep&&{rankSep:D.rankSep}},nodes:xe(S,O=>(delete O.notation,O.icon==="none"&&delete O.icon,O)),edges:b,...G.length>0&&{notation:{elements:G}}})}findRelations(e,t){const r=Pt(e,t,"directed").flatMap(S=>[...S.relations]);if(r.length===0)return{title:null,tags:null,relations:null,navigateTo:null,tail:null,head:null,color:null,line:null,notation:null};const i=J(r,et(S=>S.tags),we(_e),mt()),a=tt(i,1)?i:null,p=tt(r,1)?xe(r,S=>S.id):null,f=(ke(r)||r.find(S=>S.source===e&&S.target===t))?.$relationship.navigateTo??null,m=f&&f!==this.view.id?f:J(r,xe(S=>S.$relationship.navigateTo),we(_e),we(S=>S!==this.view.id),mt(),ke()),b=J(r,nn((S,{title:D,$relationship:G})=>(_e(D)&&S.title.add(D),_e(G.tail)&&S.tail.add(G.tail),_e(G.head)&&S.head.add(G.head),_e(G.color)&&S.color.add(G.color),_e(G.line)&&S.line.add(G.line),S),{tail:new Set,head:new Set,color:new Set,line:new Set,notation:new Set,title:new Set}));return{tags:a,relations:p,navigateTo:m??null,title:ke([...b.title])??null,tail:ke([...b.tail])??null,head:ke([...b.head])??null,color:ke([...b.color])??null,line:ke([...b.line])??null,notation:ke([...b.notation])??null}}}function Iu(n,e){return new Au(n,e).compute()}function Co(n){switch(!0){case dr(n):{const e=Co(n.where.expr),t=ct(n.where.condition);return r=>e(r)&&t(r)}case sr(n):{const e=Xe(n.source),t=Xe(n.target);return r=>e(r.source)&&t(r.target)||!!n.isBidirectional&&e(r.target)&&t(r.source)}case ar(n):{const e=Xe(n.inout);return t=>e(t.source)||e(t.target)}case ur(n):{const e=Xe(n.incoming);return t=>e(t.target)}case cr(n):{const e=Xe(n.outgoing);return t=>e(t.source)}default:Be(n)}}function $u(n,e,t){const r=n.flatMap(Tr(lr)),i=Array.from(t);if(r.length===0||i.length===0)return i;for(const{customRelation:{relation:a,title:p,...f}}of r){const m=Pi(f,rt),b=Co(a);i.forEach((S,D)=>{const G=e.find(k=>k.id===S.source),O=e.find(k=>k.id===S.target);!G||!O||b({source:G,target:O,...rn(S,["kind","tags"])})&&(i[D]={...S,...m,label:p??S.label,isCustomized:!0})})}return i}var Br,Do;function Gu(){if(Do)return Br;Do=1;var n=Xn(),e=Jn();function t(){this.clear()}return t.prototype.clear=function(){this.items=[],this.size=0},t.prototype.push=function(r){return this.items.push(r),++this.size},t.prototype.pop=function(){if(this.size!==0)return this.size--,this.items.pop()},t.prototype.peek=function(){return this.items[this.size-1]},t.prototype.forEach=function(r,i){i=arguments.length>1?i:this;for(var a=0,p=this.items.length;a<p;a++)r.call(i,this.items[p-a-1],a,this)},t.prototype.toArray=function(){for(var r=new Array(this.size),i=this.size-1,a=this.size;a--;)r[a]=this.items[i-a];return r},t.prototype.values=function(){var r=this.items,i=r.length,a=0;return new n(function(){if(a>=i)return{done:!0};var p=r[i-a-1];return a++,{value:p,done:!1}})},t.prototype.entries=function(){var r=this.items,i=r.length,a=0;return new n(function(){if(a>=i)return{done:!0};var p=r[i-a-1];return{value:[a++,p],done:!1}})},typeof Symbol<"u"&&(t.prototype[Symbol.iterator]=t.prototype.values),t.prototype.toString=function(){return this.toArray().join(",")},t.prototype.toJSON=function(){return this.toArray()},t.prototype.inspect=function(){var r=this.toArray();return Object.defineProperty(r,"constructor",{value:t,enumerable:!1}),r},typeof Symbol<"u"&&(t.prototype[Symbol.for("nodejs.util.inspect.custom")]=t.prototype.inspect),t.from=function(r){var i=new t;return e(r,function(a){i.push(a)}),i},t.of=function(){return t.from(arguments)},Br=t,Br}var Cu=Gu();const Lo=bt(Cu);class hn{constructor(e,t,r=null,i=new Set){this.id=e,this.viewRule=t,this.parent=r,this.elements=i}static kind=zt.Group;isEmpty(){return this.elements.size===0}update(e){return new hn(this.id,this.viewRule,this.parent,e)}clone(){return new hn(this.id,this.viewRule,this.parent,new Set(this.elements))}}class Oo extends mo{excludeRelations(e){return J(this.memory.connections,we(t=>yi(t.relations,e)),We(t=>{this.excludeConnections(t.update(Le(t.relations,e)))})),this}precommit(e){if(this.excluded.elements.size>0){const t=new Set([...this.excluded.elements].flatMap(r=>[...r.incoming("direct"),...r.outgoing("direct")]));this.excludeRelations(t)}return e}postcommit(e){const t=pe(this.memory.explicits,e.explicits);for(const i of t)e.explicitFirstSeenIn.delete(i);const r=pe(this.memory.elements,e.elements);for(const i of r)e.lastSeenIn.delete(i);return e}}class Du extends Oo{constructor(e,t){super(e,t),this.memory=e,this.expression=t}}class Mo extends yo{connectWithExisting(e,t="both"){const r=this._connections.length,i=()=>this._connections.length>r;if(!xt(e)){if(t==="in"||t==="both")for(const p of this.memory.elements)this.addConnections(Pt(p,e,"directed"));return(t==="out"||t==="both")&&this.addConnections(Me(e,this.memory.elements,"directed")),i()}const a=[...e];if(t==="in"||t==="both")for(const p of this.memory.elements)this.addConnections(Me(p,a,"directed"));if(t==="out"||t==="both")for(const p of a)this.addConnections(Me(p,this.memory.elements,"directed"));return i()}addImplicitWithinScope(e){e&&(!this.memory.scope||ye(this.memory.scope,e))&&this.addImplicit(e)}processConnections(e){return Ei(this.expression)||J(e,We(({source:t,target:r,boundary:i})=>{J(Wn([...ce(t.ancestors()).reverse(),t],[...ce(r.ancestors()).reverse(),r]),vr(([a,p])=>a===p),Ni(1),We(([a,p])=>{if(a===t&&p===r){this.addImplicitWithinScope(i);return}a!==t&&this.addImplicitWithinScope(a),p!==r&&this.addImplicitWithinScope(p)}))})),e}postcommit(e){const t=pe(e.explicits,this.memory.explicits);for(const r of t)e.explicitFirstSeenIn.set(r,"@root");return e}}class Lu extends Mo{constructor(e,t){super(e,t),this.memory=e,this.expression=t}postcommit(e){const t=pe(e.explicits,this.memory.explicits);for(const r of t)e.explicitFirstSeenIn.set(r,this.memory.activeGroupId);for(const r of[...this.explicits,...this.implicits])e.lastSeenIn.set(r,this.memory.activeGroupId);return e}}class At extends uo{constructor(e,t){super(e),this.state=e,this.scope=t}static empty(e){return new At({elements:new Set,explicits:new Set,final:new Set,connections:[],groups:[],explicitFirstSeenIn:new Map,lastSeenIn:new Map},e)}get groups(){return this.state.groups}get explicitFirstSeenIn(){return this.state.explicitFirstSeenIn}get lastSeenIn(){return this.state.lastSeenIn}stageInclude(e){return new Mo(this,e)}stageExclude(e){return new Oo(this,e)}mutableState(){return{elements:new Set(this.state.elements),explicits:new Set(this.state.explicits),final:new Set(this.state.final),connections:[...this.state.connections],groups:this.state.groups.map(e=>e.clone()),explicitFirstSeenIn:new Map(this.state.explicitFirstSeenIn),lastSeenIn:new Map(this.state.lastSeenIn)}}update(e){return new At({...this.state,...e},this.scope)}}class vt extends At{constructor(e,t,r){super(e,t),this.state=e,this.scope=t,this.stack=r}static enter(e,t){const r=`@gr${e.groups.length+1}`;if(e instanceof vt){const p=Lo.from(e.stack),f=e.mutableState();return f.groups.push(new hn(r,t,e.activeGroupId)),p.push(r),new vt(f,e.scope,p)}const i=e.mutableState();i.groups.push(new hn(r,t,null));const a=Lo.of(r);return new vt(i,e.scope,a)}get activeGroupId(){return be(this.stack.peek(),"Stack must not be empty")}mutableState(){return{...super.mutableState()}}update(e){const t={...this.state,...e};return new vt(t,this.scope,this.stack)}stageInclude(e){return new Lu(this,e)}stageExclude(e){return new Du(this,e)}leave(){const e=this.mutableState();return this.stack.pop(),this.stack.peek()?new vt(e,this.scope,this.stack):new At(e,this.scope)}}function Ou(n){return J([...n],Wt,nn((e,t,r,i)=>{const a=go(i,t),p=Ee(...a.map(Ze("relations")));let f=Le(t.relations,p);if(a.length>0&&(f=Ee(f,t.directRelations)),Dr(i,t.reversed(!1))&&(f=Ee(f,t.directRelations)),f.size<t.relations.size){const m=i.some(Mn(t.source)),b=i.some(Mn(t.target));m&&(f=Ee(f,nt(Re(t.relations,Or(t.source))))),b&&(f=Ee(f,nt(Re(t.relations,Mr(t.target)))))}return f.size>0&&e.push(t.update(f)),e},[]))}class Pr{constructor(e){this.memory=e}static for(e){return new Pr(e)}step1CleanConnections(e){if(e.connections.length<2)return e;const t=Ou(e.connections);if(t.length===0)return e;const r=e.stageExclude({});return r.excludeConnections(t,!0),r.commit()}step2ProcessImplicits(e){const t=Ee(this.memory.elements,e.elements),r=Ee(e.final,this.memory.explicits),i=new Set(r),a=p=>{for(const f of i)if(p===f||ye(p,f))return!0;return!1};return J(pe(t,i),ce(),er,We(p=>{const f=[...p.children()].filter(a).length;if(f>=2){r.add(p);return}f===1&&Qt(p.siblings(),a)&&r.add(p)})),e.update({final:r})}step3ProcessBoundaries(e){const t=new Set;for(const f of e.connections)f.boundary&&f.boundary!==f.source&&f.boundary!==f.target&&t.add(f.boundary);const r=wo(e,"final"),i=e.stageExclude({}),a=f=>!(t.has(f)||e.explicits.has(f)||r.hasInOut(f)||r.root.has(f)),p=ke([...r.root]);p&&!e.explicits.has(p)&&i.exclude(p);for(const f of e.final){const m=ke(r.children(f));m&&!r.hasInOut(m)&&a(f)&&i.exclude(f)}return i.isDirty()?i.commit():e}commit(){const e=this.step1CleanConnections(this.memory),t=this.step2ProcessImplicits(e);return this.step3ProcessBoundaries(t)}}const Mu={include:({expr:n,model:e,stage:t,where:r})=>{const i=e.element(n.expanded);r(i)&&(t.addExplicit(i),t.connectWithExisting(i));const a=[...i.children()].filter(r),p=[];for(const f of a)t.addImplicit(f),t.connectWithExisting(f)&&p.push(f);return t.addConnections(wt(p)),t},exclude:({expr:n,model:e,stage:t,where:r})=>{const i=e.element(n.expanded),a=[i,...i.children()].filter(r);return t.exclude(a),t}};function Pe(n,e){switch(!0){case gt(e):{const t=n.element(e.expanded);return[t,...t.children()]}case Ke(e):{const t=n.element(e.element);let r;return e.isChildren?r=ce(t.children()):e.isDescendants&&(r=ce(t.descendants())),r&&r.length>0?r:[t]}case Rt(e):return[...Re(n.elements(),t=>e.isEqual===(t.kind===e.elementKind))];case jt(e):return[...Re(n.elements(),t=>e.isEqual===t.tags.includes(e.elementTag))];default:Be(e)}}function Rn(n,e){if(e.isEmpty()||n.length===0)return n;const t=Je(n.map(i=>ht(i))),r=ce(Re(e.elements,i=>!n.includes(i)&&t(i)));return[...n,...r]}function ln(n,{memory:e,model:t}){const r=Pe(t,n);return gt(n)||Ke(n)?n.isDescendants===!0?r:Rn(r,e):r}const zu={include:({expr:n,model:e,stage:t,filterWhere:r})=>{const i=r(Pe(e,n));if(i.length!==0)return t.addExplicit(i),t.connectWithExisting(i),t.addConnections(wt(i)),t},exclude:({expr:n,model:e,stage:t,filterWhere:r})=>{const i=r(Pe(e,n));return t.exclude(i),t}};function zo(n,e){let t;return e.isChildren?t=[...n.children()]:e.isDescendants&&(t=[...n.descendants()]),t&&t.length>0?t:[n]}const Ru={include:({expr:n,model:e,stage:t,where:r})=>{const i=e.element(n.element),a=zo(i,n).filter(r);if(a.length!==0)return t.addExplicit(a),t.connectWithExisting(a),t.addConnections(wt(a)),t},exclude:({expr:n,model:e,stage:t,filterWhere:r})=>{const i=e.element(n.element),a=r(zo(i,n));return t.exclude(a),t}},Yt=()=>!0,ju=n=>n;function Uu(n){return{...n.$element,modelRef:1}}function Nu(n){return n.reduce((e,t)=>{const r=[...t.relations];re(tt(r,1),"Edge must have at least one relation");const i=t.source.id,a=t.target.id,{title:p,...f}=xo(r.map(b=>b.$relationship),r.find(b=>b.source.id===i&&b.target.id===a)?.$relationship),m={id:t.id,parent:t.boundary?.id??null,source:i,target:a,label:p??null,relations:r.map(b=>b.id),...f};return e.push(m),e},[])}function Tu(n){return jr([...n.final].map(Uu),n.groups)}const Bu={include:({expr:{source:n,target:e,isBidirectional:t=!1},memory:r,model:i,stage:a,where:p,filterWhere:f})=>{const m=Oe(n),b=Oe(e),S=[];switch(!0){case(m&&b&&r.isEmpty()&&p!==Yt):{const D=J(i.relationships(),Re(p),ce(),xe(G=>new $e(G.source,G.target,new Set([G]))));return a.addConnections(D),a}case(m&&b&&!r.isEmpty()&&p!==Yt):{S.push(...wt(r.elements));break}case(m&&b):{S.push(...wt(i.roots()));break}case(!m&&b&&p!==Yt):{const D=Pe(i,n),G=J(D,et(O=>J(O,Gn(On(t===!0),{onTrue:k=>Ee(k.allIncoming,k.allOutgoing),onFalse:k=>k.allOutgoing}),Re(p),fi(),ce(),Cn(k=>k.source===O),([k,j])=>Yi(J(k,xe(I=>new $e(O,I.target,new Set([I])))),J(j,xe(I=>new $e(I.source,O,new Set([I]))))))));return a.addConnections(G),a}case(!m&&b):{const[D,G]=Ro(n,{memory:r,model:i}),O=t?"both":"directed";for(const k of D)S.push(...Me(k,G,O));break}case(m&&!b&&p!==Yt):{const D=Pe(i,e),G=J(D,et(O=>J(O,Gn(On(t===!0),{onTrue:k=>Ee(k.allIncoming,k.allOutgoing),onFalse:k=>k.allIncoming}),Re(p),ce(),Cn(k=>k.target===O),([k,j])=>Yi(J(j,xe(I=>new $e(O,I.target,new Set([I])))),J(k,xe(I=>new $e(I.source,O,new Set([I]))))))));return a.addConnections(G),a}case(m&&!b):{const[D,G]=Ro(e,{memory:r,model:i}),O=t?"both":"directed";for(const k of G)S.push(...Me(k,D,O));break}default:{re(!Oe(n),"Inference failed - source must be not a wildcard"),re(!Oe(e),"Inference failed - target must be not a wildcard");const D=ln(n,{memory:r,model:i}),G=ln(e,{memory:r,model:i}),O=t?"both":"directed";for(const k of D)S.push(...Me(k,G,O))}}return a.addConnections(f(S)),a},exclude:({expr:{source:n,target:e,isBidirectional:t},model:r,memory:i,stage:a,where:p})=>{const f=Oe(n),m=Oe(e);let b;switch(!0){case(f&&m):{b=J(i.connections,et(on(Ze("relations"),Re(p),ce())),nt());break}case(!f&&m):{const S=Pe(r,n);b=J(S,et(D=>J(D,Gn(On(t===!0),{onTrue:G=>Ee(G.allIncoming,G.allOutgoing),onFalse:G=>G.allOutgoing}),Re(p),ce())),nt());break}case(f&&!m):{const S=Pe(r,e);b=J(S,et(D=>J(D,Gn(On(t===!0),{onTrue:G=>Ee(G.allIncoming,G.allOutgoing),onFalse:G=>G.allIncoming}),Re(p),ce())),nt());break}default:{re(!Oe(n),"Inferrence failed - source must be not a wildcard"),re(!Oe(e),"Inferrence failed - target must be not a wildcard");const S=Pe(r,n),D=Pe(r,e);let G=new Set;for(const O of S)for(const k of D)Ot(O,k)||(G=Ee(G,Le(O.allOutgoing,k.allIncoming),t?Le(k.allOutgoing,O.allIncoming):new Set));b=nt(Re(G,p))}}return a.excludeRelations(b),a}};function Ro(n,{memory:e,model:t}){let r=Pe(t,n);if(!tt(r,1))return[[],[]];if(gt(n)||Ke(n)){const a=t.element(n.element??n.expanded),p=ce(a.ascendingSiblings());return[Rn(r,e),Rn(p,e)]}const i=J(r,xe(a=>a.ascendingSiblings()),$s(),fi(),ce(),a=>Rn(a,e));return[r,i]}const Wu={include:({expr:n,scope:e,model:t,memory:r,stage:i,filterWhere:a})=>{const p=n.incoming,f=[];if(Oe(p)){if(!e)return;for(const m of e.ascendingSiblings())f.push(...Pt(m,e,"directed"))}else{const m=ln(p,{memory:r,model:t}),b=[...r.elements];b.length===0&&b.push(...mt(m.flatMap(D=>[...D.ascendingSiblings()])));const S=Fu(t,p);for(const D of b)f.push(...Me(D,m,"directed").filter(S))}return i.addConnections(a(f)),i},exclude:({expr:{incoming:n},model:e,scope:t,stage:r,where:i})=>{const a=[];if(Oe(n)){if(!t)return;a.push(...t.allIncoming)}else{const p=Pe(e,n);a.push(...p.flatMap(f=>[...f.allIncoming]))}return r.excludeRelations(new Set(a.filter(i))),r}};function Fu(n,e){switch(!0){case Rt(e):case jt(e):{const t=Xe(e);return r=>t(r.target)}case(Ke(e)&&e.isChildren):return Je([...n.children(e.element)].map(t=>je.isIncoming(t.id)));case(Ke(e)&&e.isDescendants):return Je([je.isInside(e.element),...[...n.children(e.element)].map(t=>je.isIncoming(t.id))]);case gt(e):return Je([je.isIncoming(e.expanded),je.isInside(e.expanded)]);case Ke(e):return je.isIncoming(e.element);default:Be(e)}}const Pu={include:({expr:{inout:n},scope:e,model:t,memory:r,stage:i,filterWhere:a})=>{const p=[];if(Oe(n)){if(!e)return;p.push(...Me(e,e.ascendingSiblings()))}else{const f=ln(n,{memory:r,model:t});let m=[...r.elements];m.length===0&&(m=mt(f.flatMap(b=>ce(b.ascendingSiblings()))));for(const b of f)p.push(...Me(b,m))}return i.addConnections(a(p)),i},exclude:({expr:{inout:n},model:e,scope:t,stage:r,where:i})=>{const a=[];if(Oe(n)){if(!t)return;a.push(...t.allOutgoing),a.push(...t.allIncoming)}else{const p=Pe(e,n);a.push(...p.flatMap(f=>[...f.allOutgoing,...f.allIncoming]))}return r.excludeRelations(nt(a.filter(i))),r}},qu={include:({expr:n,scope:e,model:t,memory:r,stage:i,filterWhere:a})=>{const p=n.outgoing,f=[];if(Oe(p)){if(!e)return;f.push(...Me(e,e.ascendingSiblings(),"directed"))}else{const m=ln(p,{memory:r,model:t}),b=[...r.elements];b.length===0&&b.push(...mt(m.flatMap(D=>[...D.ascendingSiblings()])));const S=Yu(t,p);for(const D of m)f.push(...Me(D,b,"directed").filter(S))}return i.addConnections(a(f)),i},exclude:({expr:{outgoing:n},model:e,scope:t,stage:r,where:i})=>{const a=[];if(Oe(n)){if(!t)return;a.push(...t.allOutgoing)}else{const p=Pe(e,n);a.push(...p.flatMap(f=>[...f.allOutgoing]))}return r.excludeRelations(nt(a.filter(i))),r}};function Yu(n,e){switch(!0){case Rt(e):case jt(e):{const t=Xe(e);return r=>t(r.source)}case(Ke(e)&&e.isChildren):return Je([...n.children(e.element)].map(t=>je.isOutgoing(t.id)));case(Ke(e)&&e.isDescendants):return Je([je.isInside(e.element),...[...n.children(e.element)].map(t=>je.isOutgoing(t.id))]);case gt(e):return Je([je.isOutgoing(e.expanded),je.isInside(e.expanded)]);case Ke(e):return je.isOutgoing(e.element);default:Be(e)}}const Ku={include:({scope:n,model:e,stage:t,memory:r,where:i})=>{if(!n){const b=[...e.roots()].filter(i);return b.length===0?void 0:(t.addExplicit(b),t.addConnections(wt(b)),t.connectWithExisting(b),t)}const a=i(n)?n:null,p=ce(Re(n.children(),i)),f=p.length>0;if(!f)if(a){if(Me(a,a.siblings()).length===0){const b=a.parent;b&&i(b)&&t.addExplicit(b)}p.push(a)}else return t;a&&t.addExplicit(a);const m=nt([...r.elements,...n.descendingSiblings()]);for(const b of m)t.addConnections(Me(b,p,"directed"));f&&(t.addConnections(wt(p)),t.addExplicit(p));for(const b of p)t.addConnections(Me(b,m,"directed"));return t},exclude:({scope:n,memory:e,stage:t,where:r})=>r!==Yt?(t.exclude(we([...e.elements],r)),t):n?(t.exclude([n,...n.descendants()]),t):At.empty(e.scope).stageExclude(t.expression)};function Wr(n,e,t){switch(!0){case An(n):return e==="include"?Wr(n.custom.expr,e,t):t.stage;case In(n):{const r=ct(n.where.condition),i=we(r);return Wr(n.where.expr,e,{...t,where:r,filterWhere:i})}case gt(n):return Mu[e]({...t,expr:n})??t.stage;case Ke(n):return Ru[e]({...t,expr:n})??t.stage;case Oe(n):return Ku[e]({...t,expr:n})??t.stage;case Rt(n):case jt(n):return zu[e]({...t,expr:n})??t.stage;default:Be(n)}}function Fr(n,e,t){switch(!0){case lr(n):return e==="include"?Fr(n.customRelation.relation,e,t):t.stage;case dr(n):{const r=ct(n.where.condition),i=p=>new Set(we([...p],r)),a=p=>J(p,xe(f=>new $e(f.source,f.target,i(f.relations))),we(f=>f.nonEmpty()));return Fr(n.where.expr,e,{...t,where:r,filterWhere:a})}case ar(n):return Pu[e]({...t,expr:n})??t.stage;case sr(n):return Bu[e]({...t,expr:n})??t.stage;case cr(n):return qu[e]({...t,expr:n})??t.stage;case ur(n):return Wu[e]({...t,expr:n})??t.stage;default:Be(n)}}function jo(n,e,t){const r={model:n,scope:e.scope,where:Yt,filterWhere:ju};for(const i of t){if(Di(i)){const a=vt.enter(e,i);e=jo(n,a,i.groupRules),re(e instanceof vt,"processPredicates must return ActiveGroupMemory"),e=e.leave();continue}if($n(i)){const a="include"in i?"include":"exclude",p=i.include??i.exclude;for(const f of p){let m=a==="include"?e.stageInclude(f):e.stageExclude(f);switch(!0){case Ns(f):m=Wr(f,a,{...r,stage:m,memory:e})??m;break;case Ei(f):m=Fr(f,a,{...r,stage:m,memory:e})??m;break;default:Be(f)}e=m.commit()}}}return Pr.for(e).commit()}function Xu(n,{docUri:e,rules:t,...r}){t=_u(t,n.globals());const i=r.viewOf?n.element(r.viewOf):null;let a=jo(n,At.empty(i),t);a.isEmpty()&&i&&(a=a.update({final:new Set([i])})),a=Vu(a);const p=Tu(a),f=Nu(a.connections);Ki(p,f);const m=ao({nodes:p,edges:f}),b=Go(t,bo(t,m.nodes)),S=wr(t,fr),D=Er(b);return Ir({...r,autoLayout:{direction:S?.direction??"TB",...S?.nodeSep&&{nodeSep:S.nodeSep},...S?.rankSep&&{rankSep:S.rankSep}},edges:$u(t,b,m.edges),nodes:xe(b,G=>(delete G.notation,G.icon==="none"&&delete G.icon,G)),...D.length>0&&{notation:{elements:D}}})}function Vu(n){if(n.groups.length===0)return n;const e=new De(()=>new Set),t=new Map,r=p=>{for(const f of p.ancestors()){const m=t.get(f);if(m)return t.set(p,m),e.get(m).add(p),!0}return!1},i=p=>{for(const f of p.descendants("asc")){const m=t.get(f);if(m)return t.set(p,m),e.get(m).add(p),!0}return!1};if(J(xn([...n.explicitFirstSeenIn.keys()]),We(p=>{if(!r(p)){const f=be(n.explicitFirstSeenIn.get(p));t.set(p,f),e.get(f).add(p)}})),J(xn([...n.lastSeenIn.keys()]),we(p=>!t.has(p)),We(p=>{if(r(p)||i(p))return;const f=be(n.lastSeenIn.get(p));t.set(p,f),e.get(f).add(p)})),e.size===0)return n;let a=n.groups.map(p=>{const f=e.get(p.id);return f?p.update(f):p});return n.update({groups:a})}function Uo(n,e){switch(!0){case Li(n):return ku(e,n);case Oi(n):return Iu(e,n);case tn(n):return Xu(e,n);default:Be(n)}}function Hu(n,e){try{return{isSuccess:!0,view:Uo(n,e)}}catch(t){return{isSuccess:!1,error:t instanceof Error?t:new Error(`Unknown error: ${t}`),view:void 0}}}function Ie(n){return lt(n)?n:n.id}class No{constructor(e,t){this.$model=e,this.$deployments=t;for(const r of xn(Et(t.elements))){const i=this.addElement(r);for(const a of i.tags)this.#u.get(a).add(i);i.isInstance()&&this.#s.get(i.element.id).add(i)}for(const r of Et(t.relations)){const i=this.addRelation(r);for(const a of i.tags)this.#u.get(a).add(i)}}#e=new Map;#t=new Map;#n=new De(()=>new Set);#s=new De(()=>new Set);#i=new Set;#r=new Map;#o=new De(()=>new Set);#c=new De(()=>new Set);#a=new De(()=>new Set);#u=new De(()=>new Set);#d=new Map;element(e){if(e instanceof Gr||e instanceof Cr)return e;const t=Ie(e);return be(this.#e.get(t),`Element ${t} not found`)}findElement(e){return this.#e.get(e)??null}node(e){const t=this.element(e);return re(t.isDeploymentNode(),`Element ${t.id} is not a deployment node`),t}findNode(e){const t=this.findElement(e);return t?(re(t.isDeploymentNode(),`Element ${t?.id} is not a deployment node`),t):null}instance(e){const t=this.element(e);return re(t.isInstance(),`Element ${t.id} is not a deployed instance`),t}findInstance(e){const t=this.findElement(e);return t?(re(t.isInstance(),`Element ${t?.id} is not a deployed instance`),t):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(const e of this.#e.values())e.isDeploymentNode()&&(yield e)}*instances(){for(const e of this.#e.values())e.isInstance()&&(yield e)}*instancesOf(e){const t=Ie(e),r=this.#s.get(t);r&&(yield*r)}deploymentRef(e){if("element"in e){const{id:t,element:r}=e;return tr(this.#d,`${t}@${r}`,()=>new Na(this.instance(t),this.$model.element(r)))}return this.element(e)}relationships(){return this.#r.values()}relationship(e){return be(this.#r.get(e),`DeploymentRelationModel ${e} not found`)}findRelationship(e){return this.#r.get(e)??null}*views(){for(const e of this.$model.views())e.isDeploymentView()&&(yield e)}parent(e){const t=Ie(e);return this.#t.get(t)||null}children(e){const t=Ie(e);return this.#n.get(t)}*siblings(e){const t=Ie(e),r=this.parent(e)?.children()??this.roots();for(const i of r)i.id!==t&&(yield i)}*ancestors(e){let t=lt(e)?e:e.id,r;for(;r=this.#t.get(t);)yield r,t=r.id}*descendants(e,t="desc"){for(const r of this.children(e))t==="asc"?(yield r,yield*this.descendants(r.id)):(yield*this.descendants(r.id),yield r)}*incoming(e,t="all"){const r=Ie(e);for(const i of this.#o.get(r))switch(!0){case t==="all":case(t==="direct"&&i.target.id===r):case(t==="to-descendants"&&i.target.id!==r):yield i;break}}*outgoing(e,t="all"){const r=Ie(e);for(const i of this.#c.get(r))switch(!0){case t==="all":case(t==="direct"&&i.source.id===r):case(t==="from-descendants"&&i.source.id!==r):yield i;break}}addElement(e){if(this.#e.has(e.id))throw new Error(`Element ${e.id} already exists`);const t=_n.isDeploymentNode(e)?new Gr(this,Object.freeze(e)):new Cr(this,Object.freeze(e),this.$model.element(e.element));this.#e.set(t.id,t);const r=ut(t.id);return r?(re(this.#e.has(r),`Parent ${r} of ${t.id} not found`),this.#t.set(t.id,this.node(r)),this.#n.get(r).add(t)):(re(t.isDeploymentNode(),`Root element ${t.id} is not a deployment node`),this.#i.add(t)),t}addRelation(e){if(this.#r.has(e.id))throw new Error(`Relation ${e.id} already exists`);const t=new lo(this,Object.freeze(e));this.#r.set(t.id,t),this.#o.get(t.target.id).add(t),this.#c.get(t.source.id).add(t);const r=t.boundary?.id??null;if(r)for(const i of[r,...pt(r)])this.#a.get(i).add(t);for(const i of pt(t.source.id)){if(i===r)break;this.#c.get(i).add(t)}for(const i of pt(t.target.id)){if(i===r)break;this.#o.get(i).add(t)}return t}}class To{constructor(e,t){this.model=e,this.$relationship=t,this.source=e.element(t.source),this.target=e.element(t.target);const r=ft(this.source.id,this.target.id);this.boundary=r?this.model.element(r):null}source;target;boundary;get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return yt(this.$relationship.title)?null:this.$relationship.title}get technology(){return yt(this.$relationship.technology)?null:this.$relationship.technology}get description(){return yt(this.$relationship.description)?null:this.$relationship.description}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get links(){return this.$relationship.links??[]}*views(){for(const e of this.model.views())e.includesRelation(this.id)&&(yield e)}}class Bo{constructor(e,t,r,i){this.view=e,this.$edge=t,this.source=r,this.target=i}get id(){return this.$edge.id}get parent(){return this.$edge.parent?this.view.node(this.$edge.parent):null}get label(){return this.$edge.label}get description(){return this.$edge.description??null}get technology(){return this.$edge.technology??null}hasParent(){return this.$edge.parent!==null}get tags(){return this.$edge.tags??[]}get stepNumber(){return this.isStep()?ji(this.id):null}get navigateTo(){return this.$edge.navigateTo?this.view.$model.view(this.$edge.navigateTo):null}isStep(){return Ri(this.id)}*relationships(e){for(const t of this.$edge.relations)if(e){const r=this.view.$model.findRelationship(t,e);r&&(yield r)}else yield this.view.$model.relationship(t)}includesRelation(e){return this.$edge.relations.includes(e)}}class Wo{constructor(e,t){this.$view=e,this.$node=t}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return this.$node.description}get technology(){return this.$node.technology}get parent(){return this.$node.parent?this.$view.node(this.$node.parent):null}get element(){const e=it.modelRef(this.$node);return e?this.$view.$model.element(e):null}get deployment(){const e=it.deploymentRef(this.$node);return e?this.$view.$model.deployment.element(e):null}get shape(){return this.$node.shape}get color(){return this.$node.color}get tags(){return this.$node.tags??[]}get links(){return this.$node.links??[]}get navigateTo(){return this.$node.navigateTo?this.$view.$model.view(this.$node.navigateTo):null}*ancestors(){let e=this.parent;for(;e;)yield e,e=e.parent}*children(){for(const e of this.$node.children)yield this.$view.node(e)}*sublings(){const e=this.parent?.children()??this.$view.roots();for(const t of e)t.id!==this.id&&(yield t)}*incoming(e="all"){for(const t of this.$node.inEdges){const r=this.$view.edge(t);switch(!0){case e==="all":case(e==="direct"&&r.target.id===this.id):case(e==="to-descendants"&&r.target.id!==this.id):yield r;break}}}*incomers(e="all"){const t=new Set;for(const r of this.incoming(e))t.has(r.source.id)||(t.add(r.source.id),yield r.source)}*outgoing(e="all"){for(const t of this.$node.outEdges){const r=this.$view.edge(t);switch(!0){case e==="all":case(e==="direct"&&r.source.id===this.id):case(e==="from-descendants"&&r.source.id!==this.id):yield r;break}}}*outgoers(e="all"){const t=new Set;for(const r of this.outgoing(e))t.has(r.target.id)||(t.add(r.target.id),yield r.target)}isDiagramNode(){return"width"in this.$node&&"height"in this.$node}hasChildren(){return this.$node.children.length>0}hasParent(){return this.$node.parent!==null}hasElement(){return it.modelRef(this.$node)!==null}hasDeployment(){return it.deploymentRef(this.$node)!==null}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return it.isNodesGroup(this.$node)}}class Fo{constructor(e,t){this.$model=e,this.$view=t;for(const r of yr(t.nodes,li)){const i=new Wo(this,Object.freeze(r));this.#t.set(r.id,i),r.parent||this.#e.add(i),i.hasDeployment()&&this.#i.add(i.deployment.id),i.hasElement()&&this.#s.add(i.element.id);for(const a of i.tags)tr(this.#o,a,()=>new Set).add(i)}for(const r of t.edges){const i=new Bo(this,Object.freeze(r),this.node(r.source),this.node(r.target));for(const a of i.tags)tr(this.#o,a,()=>new Set).add(i);for(const a of r.relations)this.#r.add(a);this.#n.set(r.id,i)}}#e=new Set;#t=new Map;#n=new Map;#s=new Set;#i=new Set;#r=new Set;#o=new Map;get __(){return this.$view.__??"element"}get id(){return this.$view.id}get title(){return this.$view.title}get tags(){return this.$view.tags??[]}get links(){return this.$view.links??[]}get viewOf(){const e=this.$view;return Mi(e)?this.$model.element(e.viewOf):null}get includedTags(){return[...this.#o.keys()]}roots(){return this.#e.values()}*compounds(){for(const e of this.#t.values())e.hasChildren()&&(yield e)}node(e){const t=Ie(e);return be(this.#t.get(t),`Node ${t} not found in view ${this.$view.id}`)}findNode(e){return this.#t.get(Ie(e))??null}nodes(){return this.#t.values()}edge(e){const t=Ie(e);return be(this.#n.get(t),`Edge ${t} not found in view ${this.$view.id}`)}findEdge(e){return this.#n.get(Ie(e))??null}edges(){return this.#n.values()}*edgesWithRelation(e){for(const t of this.#n.values())t.includesRelation(e)&&(yield t)}*elements(){for(const e of this.#t.values())e.hasElement()&&(yield e)}includesElement(e){return this.#s.has(e)}includesDeployment(e){return this.#i.has(e)}includesRelation(e){return this.#r.has(e)}isComputed(){return!0}isDiagram(){return"bounds"in this.$view}isElementView(){return tn(this.$view)}isDeploymentView(){return Li(this.$view)}isDynamicView(){return Oi(this.$view)}}class St{constructor(e){this.$model=e;for(const r of Et(e.elements)){const i=this.addElement(r);for(const a of i.tags)this.#u.get(a).add(i)}for(const r of Et(e.relations)){const i=this.addRelation(r);for(const a of i.tags)this.#u.get(a).add(i)}this.deployment=new No(this,e.deployments);const t=J(Et(e.views),yr((r,i)=>bn(r.title??"untitled",i.title??"untitled")));for(const r of t){const i=new Fo(this,Object.freeze(r));this.#a.set(r.id,i);for(const a of i.tags)this.#u.get(a).add(i)}}Aux;#e=new Map;#t=new Map;#n=new De(()=>new Set);#s=new Set;#i=new Map;#r=new De(()=>new Set);#o=new De(()=>new Set);#c=new De(()=>new Set);#a=new Map;#u=new De(()=>new Set);deployment;static compute(e){let{views:t,...r}=e;const i=new St({...r,views:{}});return new St({...r,views:Dn(t,a=>Uo(a,i))})}static makeCompute(e){let{views:t,...r}=e;const i=new St(structuredClone({...r,views:{}}));return a=>Hu(a,i)}static create(e){return new St(e)}static fromDump(e){return new St(e)}get type(){return this.$model.__??"computed"}element(e){if(e instanceof xr)return e;const t=Ie(e);return be(this.findElement(t),`Element ${Ie(e)} not found`)}findElement(e){return this.#e.get(e)??null}roots(){return this.#s.values()}elements(){return this.#e.values()}relationships(){return this.#i.values()}relationship(e,t){if(t==="deployment")return this.deployment.relationship(e);let r=this.#i.get(e)??null;return r||t==="model"?be(r,`Model relation ${e} not found`):be(this.deployment.findRelationship(e),`No model/deployment relation ${e} not found`)}findRelationship(e,t){if(t==="deployment")return this.deployment.findRelationship(e);let r=this.#i.get(e)??null;return r||t==="model"?r:this.deployment.findRelationship(e)}views(){return this.#a.values()}view(e){return be(this.#a.get(e),`View ${e} not found`)}findView(e){return be(this.#a.get(e),`View ${e} not found`)}parent(e){const t=Ie(e);return this.#t.get(t)||null}children(e){const t=Ie(e);return this.#n.get(t)}*siblings(e){const t=Ie(e),r=this.#t.get(t),i=r?this.#n.get(r.id).values():this.roots();for(const a of i)a.id!==t&&(yield a)}*ancestors(e){let t=Ie(e),r;for(;r=this.#t.get(t);)yield r,t=r.id}*descendants(e){for(const t of this.children(e))yield t,yield*this.descendants(t.id)}*incoming(e,t="all"){const r=Ie(e);for(const i of this.#r.get(r))switch(!0){case t==="all":case(t==="direct"&&i.target.id===r):case(t==="to-descendants"&&i.target.id!==r):yield i;break}}*outgoing(e,t="all"){const r=Ie(e);for(const i of this.#o.get(r))switch(!0){case t==="all":case(t==="direct"&&i.source.id===r):case(t==="from-descendants"&&i.source.id!==r):yield i;break}}globals(){return{predicates:{...this.$model.globals?.predicates},dynamicPredicates:{...this.$model.globals?.dynamicPredicates},styles:{...this.$model.globals?.styles}}}addElement(e){if(this.#e.has(e.id))throw new Error(`Element ${e.id} already exists`);const t=new xr(this,Object.freeze(structuredClone(e)));this.#e.set(t.id,t);const r=ut(t.id);return r?(re(this.#e.has(r),`Parent ${r} of ${t.id} not found`),this.#t.set(t.id,this.element(r)),this.#n.get(r).add(t)):this.#s.add(t),t}addRelation(e){if(this.#i.has(e.id))throw new Error(`Relation ${e.id} already exists`);const t=new To(this,Object.freeze(structuredClone(e))),{source:r,target:i}=t;this.#i.set(t.id,t),this.#r.get(i.id).add(t),this.#o.get(r.id).add(t);const a=ft(r.id,i.id);if(a)for(const p of[a,...pt(a)])this.#c.get(p).add(t);for(const p of pt(e.source)){if(p===a)break;this.#o.get(p).add(t)}for(const p of pt(e.target)){if(p===a)break;this.#r.get(p).add(t)}return t}}function Ju(n){return n.isInstance()}export{Gr as $,st as A,Wo as B,Mr as C,Or as D,Ii as E,To as F,Dr as G,hr as H,Cr as I,Qt as J,ji as K,Ta as L,be as M,As as N,En as O,Fa as P,tt as Q,ci as R,ut as S,bn as T,No as U,Fo as V,Pa as W,Ai as X,Us as Y,Zt as Z,Vi as _,St as a,Et as a0,qs as a1,Tt as a2,io as a3,tn as a4,er as a5,Mi as a6,_n as a7,en as a8,Ot as a9,ye as aa,ie as ab,Zn as ac,rr as ad,Fs as ae,Si as af,_i as ag,Lr as b,je as c,Mn as d,$e as e,Bt as f,lo as g,Wt as h,it as i,qa as j,pr as k,gr as l,ho as m,Be as n,re as o,Xn as p,Bo as q,Jn as r,bt as s,ft as t,Ft as u,go as v,po as w,di as x,xr as y,Wa as z};