@dbt-tools/web 0.6.2 → 0.6.4
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){var e=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),t=e(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,`defaultMaxListeners`,{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.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},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){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 p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}}))();function n(){let e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(let n in arguments[t])e[n]=arguments[t][n];return e}let r=n;typeof Object.assign==`function`&&(r=Object.assign);function i(e,t,n,r){let i=e._nodes.get(t),a=null;return i&&(a=r===`mixed`?i.out&&i.out[n]||i.undirected&&i.undirected[n]:r===`directed`?i.out&&i.out[n]:i.undirected&&i.undirected[n]),a}function a(e){return typeof e==`object`&&!!e}function o(e){let t;for(t in e)return!1;return!0}function s(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function c(e,t,n){let r={enumerable:!0,configurable:!0};typeof n==`function`?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function l(e){return!(!a(e)||e.attributes&&!Array.isArray(e.attributes))}function u(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function d(){let e=arguments,t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done){t=null;continue}break}while(!0);return r}}}function f(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var p=class extends Error{constructor(e){super(),this.name=`GraphError`,this.message=e}},m=class e extends p{constructor(t){super(t),this.name=`InvalidArgumentsGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}},h=class e extends p{constructor(t){super(t),this.name=`NotFoundGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}},g=class e extends p{constructor(t){super(t),this.name=`UsageGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}};function _(e,t){this.key=e,this.attributes=t,this.clear()}_.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function v(e,t){this.key=e,this.attributes=t,this.clear()}v.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function y(e,t){this.key=e,this.attributes=t,this.clear()}y.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function b(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}b.prototype.attach=function(){let e=`out`,t=`in`;this.undirected&&(e=t=`undirected`);let n=this.source.key,r=this.target.key;this.source[e][r]=this,!(this.undirected&&n===r)&&(this.target[t][n]=this)},b.prototype.attachMulti=function(){let e=`out`,t=`in`,n=this.source.key,r=this.target.key;this.undirected&&(e=t=`undirected`);let i=this.source[e],a=i[r];if(a===void 0){i[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}a.previous=this,this.next=a,i[r]=this,this.target[t][n]=this},b.prototype.detach=function(){let e=this.source.key,t=this.target.key,n=`out`,r=`in`;this.undirected&&(n=r=`undirected`),delete this.source[n][t],delete this.target[r][e]},b.prototype.detachMulti=function(){let e=this.source.key,t=this.target.key,n=`out`,r=`in`;this.undirected&&(n=r=`undirected`),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};function x(e,t,n,r,i,a,o){let s,c,l,u;if(r=``+r,n===0){if(s=e._nodes.get(r),!s)throw new h(`Graph.${t}: could not find the "${r}" node in the graph.`);l=i,u=a}else if(n===3){if(i=``+i,c=e._edges.get(i),!c)throw new h(`Graph.${t}: could not find the "${i}" edge in the graph.`);let n=c.source.key,d=c.target.key;if(r===n)s=c.target;else if(r===d)s=c.source;else throw new h(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${n}, ${d}).`);l=a,u=o}else{if(c=e._edges.get(r),!c)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`);s=n===1?c.source:c.target,l=i,u=a}return[s,l,u]}function S(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=x(this,t,n,e,r,i);return a.attributes[o]}}function C(e,t,n){e.prototype[t]=function(e,r){let[i]=x(this,t,n,e,r);return i.attributes}}function w(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=x(this,t,n,e,r,i);return a.attributes.hasOwnProperty(o)}}function ee(e,t,n){e.prototype[t]=function(e,r,i,a){let[o,s,c]=x(this,t,n,e,r,i,a);return o.attributes[s]=c,this.emit(`nodeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:s}),this}}function te(e,t,n){e.prototype[t]=function(e,r,i,a){let[o,s,c]=x(this,t,n,e,r,i,a);if(typeof c!=`function`)throw new m(`Graph.${t}: updater should be a function.`);let l=o.attributes;return l[s]=c(l[s]),this.emit(`nodeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:s}),this}}function T(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=x(this,t,n,e,r,i);return delete a.attributes[o],this.emit(`nodeAttributesUpdated`,{key:a.key,type:`remove`,attributes:a.attributes,name:o}),this}}function ne(e,t,n){e.prototype[t]=function(e,r,i){let[o,s]=x(this,t,n,e,r,i);if(!a(s))throw new m(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=s,this.emit(`nodeAttributesUpdated`,{key:o.key,type:`replace`,attributes:o.attributes}),this}}function re(e,t,n){e.prototype[t]=function(e,i,o){let[s,c]=x(this,t,n,e,i,o);if(!a(c))throw new m(`Graph.${t}: provided attributes are not a plain object.`);return r(s.attributes,c),this.emit(`nodeAttributesUpdated`,{key:s.key,type:`merge`,attributes:s.attributes,data:c}),this}}function ie(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=x(this,t,n,e,r,i);if(typeof o!=`function`)throw new m(`Graph.${t}: provided updater is not a function.`);return a.attributes=o(a.attributes),this.emit(`nodeAttributesUpdated`,{key:a.key,type:`update`,attributes:a.attributes}),this}}let ae=[{name:e=>`get${e}Attribute`,attacher:S},{name:e=>`get${e}Attributes`,attacher:C},{name:e=>`has${e}Attribute`,attacher:w},{name:e=>`set${e}Attribute`,attacher:ee},{name:e=>`update${e}Attribute`,attacher:te},{name:e=>`remove${e}Attribute`,attacher:T},{name:e=>`replace${e}Attributes`,attacher:ne},{name:e=>`merge${e}Attributes`,attacher:re},{name:e=>`update${e}Attributes`,attacher:ie}];function oe(e){ae.forEach(function({name:t,attacher:n}){n(e,t(`Node`),0),n(e,t(`Source`),1),n(e,t(`Target`),2),n(e,t(`Opposite`),3)})}function se(e,t,n){e.prototype[t]=function(e,r){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: 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.`);let o=``+e,s=``+r;if(r=arguments[2],a=i(this,o,s,n),!a)throw new h(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,a=this._edges.get(e),!a)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return a.attributes[r]}}function ce(e,t,n){e.prototype[t]=function(e){let r;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new g(`Graph.${t}: 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.`);let a=``+e,o=``+arguments[1];if(r=i(this,a,o,n),!r)throw new h(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,r=this._edges.get(e),!r)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return r.attributes}}function le(e,t,n){e.prototype[t]=function(e,r){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: 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.`);let o=``+e,s=``+r;if(r=arguments[2],a=i(this,o,s,n),!a)throw new h(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,a=this._edges.get(e),!a)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return a.attributes.hasOwnProperty(r)}}function ue(e,t,n){e.prototype[t]=function(e,r,a){let o;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new g(`Graph.${t}: 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.`);let s=``+e,c=``+r;if(r=arguments[2],a=arguments[3],o=i(this,s,c,n),!o)throw new h(`Graph.${t}: could not find an edge for the given path ("${s}" - "${c}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,o=this._edges.get(e),!o)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return o.attributes[r]=a,this.emit(`edgeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:r}),this}}function de(e,t,n){e.prototype[t]=function(e,r,a){let o;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new g(`Graph.${t}: 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.`);let s=``+e,c=``+r;if(r=arguments[2],a=arguments[3],o=i(this,s,c,n),!o)throw new h(`Graph.${t}: could not find an edge for the given path ("${s}" - "${c}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,o=this._edges.get(e),!o)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(typeof a!=`function`)throw new m(`Graph.${t}: updater should be a function.`);return o.attributes[r]=a(o.attributes[r]),this.emit(`edgeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:r}),this}}function fe(e,t,n){e.prototype[t]=function(e,r){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: 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.`);let o=``+e,s=``+r;if(r=arguments[2],a=i(this,o,s,n),!a)throw new h(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,a=this._edges.get(e),!a)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return delete a.attributes[r],this.emit(`edgeAttributesUpdated`,{key:a.key,type:`remove`,attributes:a.attributes,name:r}),this}}function pe(e,t,n){e.prototype[t]=function(e,r){let o;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: 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.`);let a=``+e,s=``+r;if(r=arguments[2],o=i(this,a,s,n),!o)throw new h(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,o=this._edges.get(e),!o)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(!a(r))throw new m(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=r,this.emit(`edgeAttributesUpdated`,{key:o.key,type:`replace`,attributes:o.attributes}),this}}function me(e,t,n){e.prototype[t]=function(e,o){let s;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: 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.`);let r=``+e,a=``+o;if(o=arguments[2],s=i(this,r,a,n),!s)throw new h(`Graph.${t}: could not find an edge for the given path ("${r}" - "${a}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,s=this._edges.get(e),!s)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(!a(o))throw new m(`Graph.${t}: provided attributes are not a plain object.`);return r(s.attributes,o),this.emit(`edgeAttributesUpdated`,{key:s.key,type:`merge`,attributes:s.attributes,data:o}),this}}function he(e,t,n){e.prototype[t]=function(e,r){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: 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.`);let o=``+e,s=``+r;if(r=arguments[2],a=i(this,o,s,n),!a)throw new h(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,a=this._edges.get(e),!a)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(typeof r!=`function`)throw new m(`Graph.${t}: provided updater is not a function.`);return a.attributes=r(a.attributes),this.emit(`edgeAttributesUpdated`,{key:a.key,type:`update`,attributes:a.attributes}),this}}let ge=[{name:e=>`get${e}Attribute`,attacher:se},{name:e=>`get${e}Attributes`,attacher:ce},{name:e=>`has${e}Attribute`,attacher:le},{name:e=>`set${e}Attribute`,attacher:ue},{name:e=>`update${e}Attribute`,attacher:de},{name:e=>`remove${e}Attribute`,attacher:fe},{name:e=>`replace${e}Attributes`,attacher:pe},{name:e=>`merge${e}Attributes`,attacher:me},{name:e=>`update${e}Attributes`,attacher:he}];function _e(e){ge.forEach(function({name:t,attacher:n}){n(e,t(`Edge`),`mixed`),n(e,t(`DirectedEdge`),`directed`),n(e,t(`UndirectedEdge`),`undirected`)})}let ve=[{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 ye(e,t,n,r){let i=!1;for(let a in t){if(a===r)continue;let o=t[a];if(i=n(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&i)return o.key}}function be(e,t,n,r){let i,a,o,s=!1;for(let c in t)if(c!==r){i=t[c];do{if(a=i.source,o=i.target,s=n(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),e&&s)return i.key;i=i.next}while(i!==void 0)}}function xe(e,t){let n=Object.keys(e),r=n.length,i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=r)return{done:!0};let o=n[a++];if(o===t){i=void 0;continue}i=e[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function Se(e,t,n,r){let i=t[n];if(!i)return;let a=i.source,o=i.target;if(r(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&e)return i.key}function Ce(e,t,n,r){let i=t[n];if(!i)return;let a=!1;do{if(a=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&a)return i.key;i=i.next}while(i!==void 0)}function we(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let e={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:e}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function Te(e,t){if(e.size===0)return[];if(t===`mixed`||t===e.type)return Array.from(e._edges.keys());let n=t===`undirected`?e.undirectedSize:e.directedSize,r=Array(n),i=t===`undirected`,a=e._edges.values(),o=0,s,c;for(;s=a.next(),s.done!==!0;)c=s.value,c.undirected===i&&(r[o++]=c.key);return r}function Ee(e,t,n,r){if(t.size===0)return;let i=n!==`mixed`&&n!==t.type,a=n===`undirected`,o,s,c=!1,l=t._edges.values();for(;o=l.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;let{key:t,attributes:n,source:l,target:u}=s;if(c=r(t,n,l.key,u.key,l.attributes,u.attributes,s.undirected),e&&c)return t}}function De(e,t){if(e.size===0)return f();let n=t!==`mixed`&&t!==e.type,r=t===`undirected`,i=e._edges.values();return{[Symbol.iterator](){return this},next(){let e,t;for(;;){if(e=i.next(),e.done)return e;if(t=e.value,!(n&&t.undirected!==r))break}return{value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected},done:!1}}}}function Oe(e,t,n,r,i,a){let o=t?be:ye,s;if(n!==`undirected`&&(r!==`out`&&(s=o(e,i.in,a),e&&s)||r!==`in`&&(s=o(e,i.out,a,r?void 0:i.key),e&&s))||n!==`directed`&&(s=o(e,i.undirected,a),e&&s))return s}function ke(e,t,n,r){let i=[];return Oe(!1,e,t,n,r,function(e){i.push(e)}),i}function Ae(e,t,n){let r=f();return e!==`undirected`&&(t!==`out`&&n.in!==void 0&&(r=d(r,xe(n.in))),t!==`in`&&n.out!==void 0&&(r=d(r,xe(n.out,t?void 0:n.key)))),e!==`directed`&&n.undirected!==void 0&&(r=d(r,xe(n.undirected))),r}function je(e,t,n,r,i,a,o){let s=n?Ce:Se,c;if(t!==`undirected`&&(i.in!==void 0&&r!==`out`&&(c=s(e,i.in,a,o),e&&c)||i.out!==void 0&&r!==`in`&&(r||i.key!==a)&&(c=s(e,i.out,a,o),e&&c))||t!==`directed`&&i.undirected!==void 0&&(c=s(e,i.undirected,a,o),e&&c))return c}function Me(e,t,n,r,i){let a=[];return je(!1,e,t,n,r,i,function(e){a.push(e)}),a}function Ne(e,t,n,r){let i=f();return e!==`undirected`&&(n.in!==void 0&&t!==`out`&&r in n.in&&(i=d(i,we(n.in,r))),n.out!==void 0&&t!==`in`&&r in n.out&&(t||n.key!==r)&&(i=d(i,we(n.out,r)))),e!==`directed`&&n.undirected!==void 0&&r in n.undirected&&(i=d(i,we(n.undirected,r))),i}function Pe(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return[];if(!arguments.length)return Te(this,r);if(arguments.length===1){e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new h(`Graph.${n}: could not find the "${e}" node in the graph.`);return ke(this.multi,r===`mixed`?this.type:r,i,t)}if(arguments.length===2){e=``+e,t=``+t;let a=this._nodes.get(e);if(!a)throw new h(`Graph.${n}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.${n}: could not find the "${t}" target node in the graph.`);return Me(r,this.multi,i,a,t)}throw new m(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Fe(e,t){let{name:n,type:r,direction:i}=t,a=`forEach`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t,n){if(!(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)){if(arguments.length===1)return n=e,Ee(!1,this,r,n);if(arguments.length===2){e=``+e,n=t;let o=this._nodes.get(e);if(o===void 0)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);return Oe(!1,this.multi,r===`mixed`?this.type:r,i,o,n)}if(arguments.length===3){e=``+e,t=``+t;let o=this._nodes.get(e);if(!o)throw new h(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.${a}: could not find the "${t}" target node in the graph.`);return je(!1,r,this.multi,i,o,t,n)}throw new m(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let o=`map`+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop(),n;if(e.length===0){let i=0;r!==`directed`&&(i+=this.undirectedSize),r!==`undirected`&&(i+=this.directedSize),n=Array(i);let a=0;e.push((e,r,i,o,s,c,l)=>{n[a++]=t(e,r,i,o,s,c,l)})}else n=[],e.push((e,r,i,a,o,s,c)=>{n.push(t(e,r,i,a,o,s,c))});return this[a].apply(this,e),n};let s=`filter`+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop(),n=[];return e.push((e,r,i,a,o,s,c)=>{t(e,r,i,a,o,s,c)&&n.push(e)}),this[a].apply(this,e),n};let c=`reduce`+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(){let e=Array.prototype.slice.call(arguments);if(e.length<2||e.length>4)throw new m(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${e.length}).`);if(typeof e[e.length-1]==`function`&&typeof e[e.length-2]!=`function`)throw new m(`Graph.${c}: 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.`);let t,n;e.length===2?(t=e[0],n=e[1],e=[]):e.length===3?(t=e[1],n=e[2],e=[e[0]]):e.length===4&&(t=e[2],n=e[3],e=[e[0],e[1]]);let r=n;return e.push((e,n,i,a,o,s,c)=>{r=t(r,e,n,i,a,o,s,c)}),this[a].apply(this,e),r}}function Ie(e,t){let{name:n,type:r,direction:i}=t,a=`find`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t,n){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return!1;if(arguments.length===1)return n=e,Ee(!0,this,r,n);if(arguments.length===2){e=``+e,n=t;let o=this._nodes.get(e);if(o===void 0)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);return Oe(!0,this.multi,r===`mixed`?this.type:r,i,o,n)}if(arguments.length===3){e=``+e,t=``+t;let o=this._nodes.get(e);if(!o)throw new h(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.${a}: could not find the "${t}" target node in the graph.`);return je(!0,r,this.multi,i,o,t,n)}throw new m(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let o=`some`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((e,n,r,i,a,o,s)=>t(e,n,r,i,a,o,s)),!!this[a].apply(this,e)};let s=`every`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((e,n,r,i,a,o,s)=>!t(e,n,r,i,a,o,s)),!this[a].apply(this,e)}}function Le(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+`Entries`;e.prototype[a]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return f();if(!arguments.length)return De(this,r);if(arguments.length===1){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);return Ae(r,i,t)}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.${a}: could not find the "${t}" target node in the graph.`);return Ne(r,i,n,t)}throw new m(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Re(e){ve.forEach(t=>{Pe(e,t),Fe(e,t),Ie(e,t),Le(e,t)})}let ze=[{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 E(){this.A=null,this.B=null}E.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)},E.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function D(e,t,n,r,i){for(let a in r){let o=r[a],s=o.source,c=o.target,l=s===n?c:s;if(t&&t.has(l.key))continue;let u=i(l.key,l.attributes);if(e&&u)return l.key}}function Be(e,t,n,r,i){if(t!==`mixed`){if(t===`undirected`)return D(e,null,r,r.undirected,i);if(typeof n==`string`)return D(e,null,r,r[n],i)}let a=new E,o;if(t!==`undirected`){if(n!==`out`){if(o=D(e,null,r,r.in,i),e&&o)return o;a.wrap(r.in)}if(n!==`in`){if(o=D(e,a,r,r.out,i),e&&o)return o;a.wrap(r.out)}}if(t!==`directed`&&(o=D(e,a,r,r.undirected,i),e&&o))return o}function Ve(e,t,n){if(e!==`mixed`){if(e===`undirected`)return Object.keys(n.undirected);if(typeof t==`string`)return Object.keys(n[t])}let r=[];return Be(!1,e,t,n,function(e){r.push(e)}),r}function O(e,t,n){let r=Object.keys(n),i=r.length,a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return e&&e.wrap(n),{done:!0};let s=n[r[a++]],c=s.source,l=s.target;if(o=c===t?l:c,e&&e.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function He(e,t,n){if(e!==`mixed`){if(e===`undirected`)return O(null,n,n.undirected);if(typeof t==`string`)return O(null,n,n[t])}let r=f(),i=new E;return e!==`undirected`&&(t!==`out`&&(r=d(r,O(i,n,n.in))),t!==`in`&&(r=d(r,O(i,n,n.out)))),e!==`directed`&&(r=d(r,O(i,n,n.undirected))),r}function Ue(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(e){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return[];e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new h(`Graph.${n}: could not find the "${e}" node in the graph.`);return Ve(r===`mixed`?this.type:r,i,t)}}function We(e,t){let{name:n,type:r,direction:i}=t,a=`forEach`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return;e=``+e;let n=this._nodes.get(e);if(n===void 0)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);Be(!1,r===`mixed`?this.type:r,i,n,t)};let o=`map`+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(e,t){let n=[];return this[a](e,(e,r)=>{n.push(t(e,r))}),n};let s=`filter`+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(e,t){let n=[];return this[a](e,(e,r)=>{t(e,r)&&n.push(e)}),n};let c=`reduce`+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(e,t,n){if(arguments.length<3)throw new m(`Graph.${c}: 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.`);let r=n;return this[a](e,(e,n)=>{r=t(r,e,n)}),r}}function Ge(e,t){let{name:n,type:r,direction:i}=t,a=n[0].toUpperCase()+n.slice(1,-1),o=`find`+a;e.prototype[o]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return;e=``+e;let n=this._nodes.get(e);if(n===void 0)throw new h(`Graph.${o}: could not find the "${e}" node in the graph.`);return Be(!0,r===`mixed`?this.type:r,i,n,t)};let s=`some`+a;e.prototype[s]=function(e,t){return!!this[o](e,t)};let c=`every`+a;e.prototype[c]=function(e,t){return!this[o](e,(e,n)=>!t(e,n))}}function Ke(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+`Entries`;e.prototype[a]=function(e){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return f();e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);return He(r===`mixed`?this.type:r,i,t)}}function qe(e){ze.forEach(t=>{Ue(e,t),We(e,t),Ge(e,t),Ke(e,t)})}function k(e,t,n,r,i){let a=r._nodes.values(),o=r.type,s,c,l,u,d,f,p;for(;s=a.next(),s.done!==!0;){let r=!1;if(c=s.value,o!==`undirected`)for(l in u=c.out,u){d=u[l];do{if(f=d.target,r=!0,p=i(c.key,f.key,c.attributes,f.attributes,d.key,d.attributes,d.undirected),e&&p)return d;d=d.next}while(d)}if(o!==`directed`){for(l in u=c.undirected,u)if(!(t&&c.key>l)){d=u[l];do{if(f=d.target,f.key!==l&&(f=d.source),r=!0,p=i(c.key,f.key,c.attributes,f.attributes,d.key,d.attributes,d.undirected),e&&p)return d;d=d.next}while(d)}}if(n&&!r&&(p=i(c.key,null,c.attributes,null,null,null,null),e&&p))return null}}function Je(e,t){let n={key:e};return o(t.attributes)||(n.attributes=r({},t.attributes)),n}function Ye(e,t,n){let i={key:t,source:n.source.key,target:n.target.key};return o(n.attributes)||(i.attributes=r({},n.attributes)),e===`mixed`&&n.undirected&&(i.undirected=!0),i}function Xe(e){if(!a(e))throw new m(`Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.`);if(!(`key`in e))throw new m(`Graph.import: serialized node is missing its key.`);if(`attributes`in e&&(!a(e.attributes)||e.attributes===null))throw new m(`Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.`)}function Ze(e){if(!a(e))throw new m(`Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.`);if(!(`source`in e))throw new m(`Graph.import: serialized edge is missing its source.`);if(!(`target`in e))throw new m(`Graph.import: serialized edge is missing its target.`);if(`attributes`in e&&(!a(e.attributes)||e.attributes===null))throw new m(`Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.`);if(`undirected`in e&&typeof e.undirected!=`boolean`)throw new m(`Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.`)}let Qe=u(),$e=new Set([`directed`,`undirected`,`mixed`]),et=new Set([`domain`,`_events`,`_eventsCount`,`_maxListeners`]),tt=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:`directed`},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:`undirected`},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:`directed`},{name:e=>`${e}UndirectedEdgeWithKey`,type:`undirected`}],nt={allowSelfLoops:!0,multi:!1,type:`mixed`};function rt(e,t,n){if(n&&!a(n))throw new m(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=``+t,n||={},e._nodes.has(t))throw new g(`Graph.addNode: the "${t}" node already exist in the graph.`);let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit(`nodeAdded`,{key:t,attributes:n}),r}function it(e,t,n){let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit(`nodeAdded`,{key:t,attributes:n}),r}function at(e,t,n,r,i,o,s,c){if(!r&&e.type===`undirected`)throw new g(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type===`directed`)throw new g(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(c&&!a(c))throw new m(`Graph.${t}: invalid attributes. Expecting an object but got "${c}"`);if(o=``+o,s=``+s,c||={},!e.allowSelfLoops&&o===s)throw new g(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(o),u=e._nodes.get(s);if(!l)throw new h(`Graph.${t}: source node "${o}" not found.`);if(!u)throw new h(`Graph.${t}: target node "${s}" not found.`);let d={key:null,undirected:r,source:o,target:s,attributes:c};if(n)i=e._edgeKeyGenerator();else if(i=``+i,e._edges.has(i))throw new g(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?l.undirected[s]!==void 0:l.out[s]!==void 0))throw new g(`Graph.${t}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let f=new b(r,i,l,u,c);e._edges.set(i,f);let p=o===s;return r?(l.undirectedDegree++,u.undirectedDegree++,p&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,p&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?f.attachMulti():f.attach(),r?e._undirectedSize++:e._directedSize++,d.key=i,e.emit(`edgeAdded`,d),i}function ot(e,t,n,i,o,s,c,l,u){if(!i&&e.type===`undirected`)throw new g(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(i&&e.type===`directed`)throw new g(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(l){if(u){if(typeof l!=`function`)throw new m(`Graph.${t}: invalid updater function. Expecting a function but got "${l}"`)}else if(!a(l))throw new m(`Graph.${t}: invalid attributes. Expecting an object but got "${l}"`)}s=``+s,c=``+c;let d;if(u&&(d=l,l=void 0),!e.allowSelfLoops&&s===c)throw new g(`Graph.${t}: source & target are the same ("${s}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let f=e._nodes.get(s),p=e._nodes.get(c),h,_;if(!n&&(h=e._edges.get(o),h)){if((h.source.key!==s||h.target.key!==c)&&(!i||h.source.key!==c||h.target.key!==s))throw new g(`Graph.${t}: inconsistency detected when attempting to merge the "${o}" edge with "${s}" source & "${c}" target vs. ("${h.source.key}", "${h.target.key}").`);_=h}if(!_&&!e.multi&&f&&(_=i?f.undirected[c]:f.out[c]),_){let t=[_.key,!1,!1,!1];if(u?!d:!l)return t;if(u){let t=_.attributes;_.attributes=d(t),e.emit(`edgeAttributesUpdated`,{type:`replace`,key:_.key,attributes:_.attributes})}else r(_.attributes,l),e.emit(`edgeAttributesUpdated`,{type:`merge`,key:_.key,attributes:_.attributes,data:l});return t}l||={},u&&d&&(l=d(l));let v={key:null,undirected:i,source:s,target:c,attributes:l};if(n)o=e._edgeKeyGenerator();else if(o=``+o,e._edges.has(o))throw new g(`Graph.${t}: the "${o}" edge already exists in the graph.`);let y=!1,x=!1;f||(f=it(e,s,{}),y=!0,s===c&&(p=f,x=!0)),p||(p=it(e,c,{}),x=!0),h=new b(i,o,f,p,l),e._edges.set(o,h);let S=s===c;return i?(f.undirectedDegree++,p.undirectedDegree++,S&&(f.undirectedLoops++,e._undirectedSelfLoopCount++)):(f.outDegree++,p.inDegree++,S&&(f.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),i?e._undirectedSize++:e._directedSize++,v.key=o,e.emit(`edgeAdded`,v),[o,!0,y,x]}function A(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:i}=t,a=t.undirected,o=n===r;a?(n.undirectedDegree--,r.undirectedDegree--,o&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,o&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),a?e._undirectedSize--:e._directedSize--,e.emit(`edgeDropped`,{key:t.key,attributes:i,source:n.key,target:r.key,undirected:a})}var j=class e extends t.EventEmitter{constructor(e){if(super(),e=r({},nt,e),typeof e.multi!=`boolean`)throw new m(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!$e.has(e.type))throw new m(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!=`boolean`)throw new m(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let t=e.type===`mixed`?_:e.type===`directed`?v:y;s(this,`NodeDataClass`,t);let n=`geid_`+Qe()+`_`,i=0;s(this,`_attributes`,{}),s(this,`_nodes`,new Map),s(this,`_edges`,new Map),s(this,`_directedSize`,0),s(this,`_undirectedSize`,0),s(this,`_directedSelfLoopCount`,0),s(this,`_undirectedSelfLoopCount`,0),s(this,`_edgeKeyGenerator`,()=>{let e;do e=n+ i++;while(this._edges.has(e));return e}),s(this,`_options`,e),et.forEach(e=>s(this,e,this[e])),c(this,`order`,()=>this._nodes.size),c(this,`size`,()=>this._edges.size),c(this,`directedSize`,()=>this._directedSize),c(this,`undirectedSize`,()=>this._undirectedSize),c(this,`selfLoopCount`,()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),c(this,`directedSelfLoopCount`,()=>this._directedSelfLoopCount),c(this,`undirectedSelfLoopCount`,()=>this._undirectedSelfLoopCount),c(this,`multi`,this._options.multi),c(this,`type`,this._options.type),c(this,`allowSelfLoops`,this._options.allowSelfLoops),c(this,`implementation`,()=>`graphology`)}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(``+e)}hasDirectedEdge(e,t){if(this.type===`undirected`)return!1;if(arguments.length===1){let t=``+e,n=this._edges.get(t);return!!n&&!n.undirected}else if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new m(`Graph.hasDirectedEdge: invalid arity (${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.`)}hasUndirectedEdge(e,t){if(this.type===`directed`)return!1;if(arguments.length===1){let t=``+e,n=this._edges.get(t);return!!n&&n.undirected}else if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new m(`Graph.hasDirectedEdge: invalid arity (${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.`)}hasEdge(e,t){if(arguments.length===1){let t=``+e;return this._edges.has(t)}else if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.out!==void 0&&n.out.hasOwnProperty(t)||n.undirected!==void 0&&n.undirected.hasOwnProperty(t):!1}throw new m(`Graph.hasEdge: invalid arity (${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.`)}directedEdge(e,t){if(this.type===`undirected`)return;if(e=``+e,t=``+t,this.multi)throw new g(`Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.`);let n=this._nodes.get(e);if(!n)throw new h(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);let r=n.out&&n.out[t]||void 0;if(r)return r.key}undirectedEdge(e,t){if(this.type===`directed`)return;if(e=``+e,t=``+t,this.multi)throw new g(`Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.`);let n=this._nodes.get(e);if(!n)throw new h(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);let r=n.undirected&&n.undirected[t]||void 0;if(r)return r.key}edge(e,t){if(this.multi)throw new g(`Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.`);e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.edge: could not find the "${t}" target node in the graph.`);let r=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(r)return r.key}areDirectedNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type===`undirected`?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type===`undirected`?!1:t in n.out}areInNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type===`undirected`?!1:t in n.in}areUndirectedNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type===`directed`?!1:t in n.undirected}areNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&(t in n.in||t in n.out)||this.type!==`directed`&&t in n.undirected}areInboundNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.in||this.type!==`directed`&&t in n.undirected}areOutboundNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.out||this.type!==`directed`&&t in n.undirected}inDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree}outDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.outDegree}directedDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree+t.outDegree}undirectedDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type===`directed`?0:t.undirectedDegree}inboundDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.inDegree),n}outboundDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.outDegree),n}degree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`directed`?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.inDegree,r+=t.directedLoops),n-r}outboundDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.outDegree,r+=t.directedLoops),n-r}degreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.inDegree+t.outDegree,r+=t.directedLoops*2),n-r}source(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=``+e,t=``+t;let n=this._edges.get(t);if(!n)throw new h(`Graph.opposite: could not find the "${t}" edge in the graph.`);let r=n.source.key,i=n.target.key;if(e===r)return i;if(e===i)return r;throw new h(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${r}, ${i}).`)}hasExtremity(e,t){e=``+e,t=``+t;let n=this._edges.get(e);if(!n)throw new h(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return rt(this,e,t).key}mergeNode(e,t){if(t&&!a(t))throw new m(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=``+e,t||={};let n=this._nodes.get(e);return n?(t&&(r(n.attributes,t),this.emit(`nodeAttributesUpdated`,{type:`merge`,key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit(`nodeAdded`,{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!=`function`)throw new m(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=``+e;let n=this._nodes.get(e);if(n){if(t){let r=n.attributes;n.attributes=t(r),this.emit(`nodeAttributesUpdated`,{type:`replace`,key:e,attributes:n.attributes})}return[e,!1]}let r=t?t({}):{};return n=new this.NodeDataClass(e,r),this._nodes.set(e,n),this.emit(`nodeAdded`,{key:e,attributes:r}),[e,!0]}dropNode(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!==`undirected`){for(let e in t.out){n=t.out[e];do A(this,n),n=n.next;while(n)}for(let e in t.in){n=t.in[e];do A(this,n),n=n.next;while(n)}}if(this.type!==`directed`)for(let e in t.undirected){n=t.undirected[e];do A(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit(`nodeDropped`,{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){let e=``+arguments[0],n=``+arguments[1];if(t=i(this,e,n,this.type),!t)throw new h(`Graph.dropEdge: could not find the "${e}" -> "${n}" edge in the graph.`)}else if(e=``+e,t=this._edges.get(e),!t)throw new h(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return A(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new g(`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 g(`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.`);e=``+e,t=``+t;let n=i(this,e,t,`directed`);if(!n)throw new h(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return A(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new g(`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 g(`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.`);let n=i(this,e,t,`undirected`);if(!n)throw new h(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return A(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit(`cleared`)}clearEdges(){let e=this._nodes.values(),t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit(`edgesCleared`)}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit(`attributesUpdated`,{type:`set`,attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!=`function`)throw new m(`Graph.updateAttribute: updater should be a function.`);let n=this._attributes[e];return this._attributes[e]=t(n),this.emit(`attributesUpdated`,{type:`set`,attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit(`attributesUpdated`,{type:`remove`,attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!a(e))throw new m(`Graph.replaceAttributes: provided attributes are not a plain object.`);return this._attributes=e,this.emit(`attributesUpdated`,{type:`replace`,attributes:this._attributes}),this}mergeAttributes(e){if(!a(e))throw new m(`Graph.mergeAttributes: provided attributes are not a plain object.`);return r(this._attributes,e),this.emit(`attributesUpdated`,{type:`merge`,attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!=`function`)throw new m(`Graph.updateAttributes: provided updater is not a function.`);return this._attributes=e(this._attributes),this.emit(`attributesUpdated`,{type:`update`,attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!=`function`)throw new m(`Graph.updateEachNodeAttributes: expecting an updater function.`);if(t&&!l(t))throw new m(`Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}`);let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,i.attributes=e(i.key,i.attributes);this.emit(`eachNodeAttributesUpdated`,{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!=`function`)throw new m(`Graph.updateEachEdgeAttributes: expecting an updater function.`);if(t&&!l(t))throw new m(`Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}`);let n=this._edges.values(),r,i,a,o;for(;r=n.next(),r.done!==!0;)i=r.value,a=i.source,o=i.target,i.attributes=e(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected);this.emit(`eachEdgeAttributesUpdated`,{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!=`function`)throw new m(`Graph.forEachAdjacencyEntry: expecting a callback.`);k(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!=`function`)throw new m(`Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.`);k(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!=`function`)throw new m(`Graph.forEachAssymetricAdjacencyEntry: expecting a callback.`);k(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!=`function`)throw new m(`Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.`);k(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!=`function`)throw new m(`Graph.forEachNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)r=n.value,e(r.key,r.attributes)}findNode(e){if(typeof e!=`function`)throw new m(`Graph.findNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,e(r.key,r.attributes))return r.key}mapNodes(e){if(typeof e!=`function`)throw new m(`Graph.mapNode: expecting a callback.`);let t=this._nodes.values(),n,r,i=Array(this.order),a=0;for(;n=t.next(),n.done!==!0;)r=n.value,i[a++]=e(r.key,r.attributes);return i}someNode(e){if(typeof e!=`function`)throw new m(`Graph.someNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,e(r.key,r.attributes))return!0;return!1}everyNode(e){if(typeof e!=`function`)throw new m(`Graph.everyNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,!e(r.key,r.attributes))return!1;return!0}filterNodes(e){if(typeof e!=`function`)throw new m(`Graph.filterNodes: expecting a callback.`);let t=this._nodes.values(),n,r,i=[];for(;n=t.next(),n.done!==!0;)r=n.value,e(r.key,r.attributes)&&i.push(r.key);return i}reduceNodes(e,t){if(typeof e!=`function`)throw new m(`Graph.reduceNodes: expecting a callback.`);if(arguments.length<2)throw new m(`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.`);let n=t,r=this._nodes.values(),i,a;for(;i=r.next(),i.done!==!0;)a=i.value,n=e(n,a.key,a.attributes);return n}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let t=e.next();if(t.done)return t;let n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}}}export(){let e=Array(this._nodes.size),t=0;this._nodes.forEach((n,r)=>{e[t++]=Je(r,n)});let n=Array(this._edges.size);return t=0,this._edges.forEach((e,r)=>{n[t++]=Ye(this.type,r,e)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(t,n=!1){if(t instanceof e)return t.forEachNode((e,t)=>{n?this.mergeNode(e,t):this.addNode(e,t)}),t.forEachEdge((e,t,r,i,a,o,s)=>{n?s?this.mergeUndirectedEdgeWithKey(e,r,i,t):this.mergeDirectedEdgeWithKey(e,r,i,t):s?this.addUndirectedEdgeWithKey(e,r,i,t):this.addDirectedEdgeWithKey(e,r,i,t)}),this;if(!a(t))throw new m(`Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.`);if(t.attributes){if(!a(t.attributes))throw new m(`Graph.import: invalid attributes. Expecting a plain object.`);n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,o,s,c;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new m(`Graph.import: invalid nodes. Expecting an array.`);for(r=0,i=o.length;r<i;r++){s=o[r],Xe(s);let{key:e,attributes:t}=s;n?this.mergeNode(e,t):this.addNode(e,t)}}if(t.edges){let e=!1;if(this.type===`undirected`&&(e=!0),o=t.edges,!Array.isArray(o))throw new m(`Graph.import: invalid edges. Expecting an array.`);for(r=0,i=o.length;r<i;r++){c=o[r],Ze(c);let{source:t,target:i,attributes:a,undirected:s=e}=c,l;`key`in c?(l=n?s?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:s?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,l.call(this,c.key,t,i,a)):(l=n?s?this.mergeUndirectedEdge:this.mergeDirectedEdge:s?this.addUndirectedEdge:this.addDirectedEdge,l.call(this,t,i,a))}}return this}nullCopy(t){let n=new e(r({},this._options,t));return n.replaceAttributes(r({},this.getAttributes())),n}emptyCopy(e){let t=this.nullCopy(e);return this._nodes.forEach((e,n)=>{let i=r({},e.attributes);e=new t.NodeDataClass(n,i),t._nodes.set(n,e)}),t}copy(e){if(e||={},typeof e.type==`string`&&e.type!==this.type&&e.type!==`mixed`)throw new g(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi==`boolean`&&e.multi!==this.multi&&e.multi!==!0)throw new g(`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 e.allowSelfLoops==`boolean`&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new g(`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.`);let t=this.emptyCopy(e),n=this._edges.values(),i,a;for(;i=n.next(),i.done!==!0;)a=i.value,at(t,`copy`,!1,a.undirected,a.key,a.source.key,a.target.key,r({},a.attributes));return t}toJSON(){return this.export()}toString(){return`[object Graph]`}inspect(){let e={};this._nodes.forEach((t,n)=>{e[n]=t.attributes});let t={},n={};this._edges.forEach((e,r)=>{let i=e.undirected?`--`:`->`,a=``,o=e.source.key,s=e.target.key,c;e.undirected&&o>s&&(c=o,o=s,s=c);let l=`(${o})${i}(${s})`;r.startsWith(`geid_`)?this.multi&&(n[l]===void 0?n[l]=0:n[l]++,a+=`${n[l]}. `):a+=`[${r}]: `,a+=l,t[a]=e.attributes});let r={};for(let e in this)this.hasOwnProperty(e)&&!et.has(e)&&typeof this[e]!=`function`&&typeof e!=`symbol`&&(r[e]=this[e]);return r.attributes=this._attributes,r.nodes=e,r.edges=t,s(r,`constructor`,this.constructor),r}};typeof Symbol<`u`&&(j.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=j.prototype.inspect),tt.forEach(e=>{[`add`,`merge`,`update`].forEach(t=>{let n=e.name(t),r=t===`add`?at:ot;e.generateKey?j.prototype[n]=function(i,a,o){return r(this,n,!0,(e.type||this.type)===`undirected`,null,i,a,o,t===`update`)}:j.prototype[n]=function(i,a,o,s){return r(this,n,!1,(e.type||this.type)===`undirected`,i,a,o,s,t===`update`)}})}),oe(j),_e(j),Re(j),qe(j);var M=class extends j{constructor(e){let t=r({type:`directed`},e);if(`multi`in t&&t.multi!==!1)throw new m(`DirectedGraph.from: inconsistent indication that the graph should be multi in given options!`);if(t.type!==`directed`)throw new m(`DirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},st=class extends j{constructor(e){let t=r({type:`undirected`},e);if(`multi`in t&&t.multi!==!1)throw new m(`UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!`);if(t.type!==`undirected`)throw new m(`UndirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},ct=class extends j{constructor(e){let t=r({multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new m(`MultiGraph.from: inconsistent indication that the graph should be simple in given options!`);super(t)}},lt=class extends j{constructor(e){let t=r({type:`directed`,multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new m(`MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!`);if(t.type!==`directed`)throw new m(`MultiDirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},ut=class extends j{constructor(e){let t=r({type:`undirected`,multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new m(`MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!`);if(t.type!==`undirected`)throw new m(`MultiUndirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}};function N(e){e.from=function(t,n){let i=new e(r({},t.options,n));return i.import(t),i}}N(j),N(M),N(st),N(ct),N(lt),N(ut),j.Graph=j,j.DirectedGraph=M,j.UndirectedGraph=st,j.MultiGraph=ct,j.MultiDirectedGraph=lt,j.MultiUndirectedGraph=ut,j.InvalidArgumentsGraphError=m,j.NotFoundGraphError=h,j.UsageGraphError=g;var dt=e(((e,t)=>{t.exports=function(e){return typeof e==`object`&&!!e&&typeof e.addUndirectedEdgeWithKey==`function`&&typeof e.dropNode==`function`&&typeof e.multi==`boolean`}})),ft=e(((e,t)=>{let n=dt();t.exports=function(e){if(!n(e))throw Error(`graphology-dag/has-cycle: the given graph is not a valid graphology instance.`);if(e.size===0)return!1;if(e.selfLoopCount!==0)return!0;let t={},r=[];function i(e){let n=t[e];if(n===void 0)r.push(e);else if(n===0)return!0;return!1}return e.someNode(n=>{if(t[n]===1)return!1;for(r.push(n);r.length!==0;){let n=r[r.length-1],a=t[n];if(a!==0){if(t[n]=0,e.someOutboundNeighbor(n,i))return!0}else a===0&&(r.pop(),t[n]=1)}return!1})}})),pt=e(((e,t)=>{let n=dt();t.exports=function(e,t,r){if(!n(e))throw 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;let i=e.outNeighbors(r);function a(e){i.push(e)}for(;i.length!==0;){let n=i.pop();if(n===t)return!0;e.forEachOutNeighbor(n,a)}return!1}})),mt=e((e=>{e.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<`u`,e.SYMBOL_SUPPORT=typeof Symbol<`u`})),ht=e(((e,t)=>{var n=mt(),r=n.ARRAY_BUFFER_SUPPORT,i=n.SYMBOL_SUPPORT;t.exports=function(e,t){var n,a,o,s,c;if(!e)throw Error(`obliterator/forEach: invalid iterable.`);if(typeof t!=`function`)throw Error(`obliterator/forEach: expecting a callback.`);if(Array.isArray(e)||r&&ArrayBuffer.isView(e)||typeof e==`string`||e.toString()===`[object Arguments]`){for(o=0,s=e.length;o<s;o++)t(e[o],o);return}if(typeof e.forEach==`function`){e.forEach(t);return}if(i&&Symbol.iterator in e&&typeof e.next!=`function`&&(e=e[Symbol.iterator]()),typeof e.next==`function`){for(n=e,o=0;c=n.next(),c.done!==!0;)t(c.value,o),o++;return}for(a in e)e.hasOwnProperty(a)&&t(e[a],a)}})),gt=e((e=>{var t=2**8-1,n=2**16-1,r=2**32-1,i=2**7-1,a=2**15-1,o=2**31-1;e.getPointerArray=function(e){var i=e-1;if(i<=t)return Uint8Array;if(i<=n)return Uint16Array;if(i<=r)return Uint32Array;throw Error(`mnemonist: Pointer Array of size > 4294967295 is not supported.`)},e.getSignedPointerArray=function(e){var t=e-1;return t<=i?Int8Array:t<=a?Int16Array:t<=o?Int32Array:Float64Array},e.getNumberType=function(e){return e===(e|0)?Math.sign(e)===-1?e<=127&&e>=-128?Int8Array:e<=32767&&e>=-32768?Int16Array:Int32Array:e<=255?Uint8Array:e<=65535?Uint16Array:Uint32Array:Float64Array};var s={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};e.getMinimalRepresentation=function(t,n){var r=null,i=0,a,o,c,l,u;for(l=0,u=t.length;l<u;l++)c=n?n(t[l]):t[l],o=e.getNumberType(c),a=s[o.name],a>i&&(i=a,r=o);return r},e.isTypedArray=function(e){return typeof ArrayBuffer<`u`&&ArrayBuffer.isView(e)},e.concat=function(){var e=0,t,n,r;for(t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=new arguments[0].constructor(e);for(t=0,n=0;t<r;t++)i.set(arguments[t],n),n+=arguments[t].length;return i},e.indices=function(t){for(var n=new(e.getPointerArray(t))(t),r=0;r<t;r++)n[r]=r;return n}})),_t=e((e=>{var t=ht(),n=gt();function r(e){return Array.isArray(e)||n.isTypedArray(e)}function i(e){if(typeof e.length==`number`)return e.length;if(typeof e.size==`number`)return e.size}function a(e){var n=i(e),r=typeof n==`number`?Array(n):[],a=0;return t(e,function(e){r[a++]=e}),r}function o(e){var r=i(e),a=typeof r==`number`?n.getPointerArray(r):Array,o=typeof r==`number`?Array(r):[],s=typeof r==`number`?new a(r):[],c=0;return t(e,function(e){o[c]=e,s[c]=c++}),[o,s]}e.isArrayLike=r,e.guessLength=i,e.toArray=a,e.toArrayWithIndices=o})),vt=e(((e,t)=>{function n(e){if(typeof e!=`function`)throw Error(`obliterator/iterator: expecting a function!`);this.next=e}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(){return new n(function(){return{done:!0}})},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&&typeof e.next==`function`},t.exports=n})),yt=e(((e,t)=>{var n=_t(),r=vt();function i(e,t){if(arguments.length<2)throw Error(`mnemonist/fixed-deque: expecting an Array class and a capacity.`);if(typeof t!=`number`||t<=0)throw Error("mnemonist/fixed-deque: `capacity` should be a positive number.");this.ArrayClass=e,this.capacity=t,this.items=new e(this.capacity),this.clear()}i.prototype.clear=function(){this.start=0,this.size=0},i.prototype.push=function(e){if(this.size===this.capacity)throw Error(`mnemonist/fixed-deque.push: deque capacity (`+this.capacity+`) exceeded!`);var t=this.start+this.size;return t>=this.capacity&&(t-=this.capacity),this.items[t]=e,++this.size},i.prototype.unshift=function(e){if(this.size===this.capacity)throw Error(`mnemonist/fixed-deque.unshift: deque capacity (`+this.capacity+`) exceeded!`);var t=this.start-1;return this.start===0&&(t=this.capacity-1),this.items[t]=e,this.start=t,++this.size},i.prototype.pop=function(){if(this.size!==0){this.size--;var e=this.start+this.size;return e>=this.capacity&&(e-=this.capacity),this.items[e]}},i.prototype.shift=function(){if(this.size!==0){var e=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[e]}},i.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]},i.prototype.peekLast=function(){if(this.size!==0){var e=this.start+this.size-1;return e>=this.capacity&&(e-=this.capacity),this.items[e]}},i.prototype.get=function(e){if(!(this.size===0||e>=this.capacity))return e=this.start+e,e>=this.capacity&&(e-=this.capacity),this.items[e]},i.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=this.capacity,r=this.size,i=this.start,a=0;a<r;)e.call(t,this.items[i],a,this),i++,a++,i===n&&(i=0)},i.prototype.toArray=function(){var e=this.start+this.size;if(e<this.capacity)return this.items.slice(this.start,e);for(var t=new this.ArrayClass(this.size),n=this.capacity,r=this.size,i=this.start,a=0;a<r;)t[a]=this.items[i],i++,a++,i===n&&(i=0);return t},i.prototype.values=function(){var e=this.items,t=this.capacity,n=this.size,i=this.start,a=0;return new r(function(){if(a>=n)return{done:!0};var r=e[i];return i++,a++,i===t&&(i=0),{value:r,done:!1}})},i.prototype.entries=function(){var e=this.items,t=this.capacity,n=this.size,i=this.start,a=0;return new r(function(){if(a>=n)return{done:!0};var r=e[i];return i++,i===t&&(i=0),{value:[a++,r],done:!1}})},typeof Symbol<`u`&&(i.prototype[Symbol.iterator]=i.prototype.values),i.prototype.inspect=function(){var e=this.toArray();return e.type=this.ArrayClass.name,e.capacity=this.capacity,Object.defineProperty(e,`constructor`,{value:i,enumerable:!1}),e},typeof Symbol<`u`&&(i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=i.prototype.inspect),i.from=function(e,t,r){if(arguments.length<3&&(r=n.guessLength(e),typeof r!=`number`))throw Error(`mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.`);var a=new i(t,r);if(n.isArrayLike(e)){var o,s;for(o=0,s=e.length;o<s;o++)a.items[o]=e[o];return a.size=s,a}return n.forEach(e,function(e){a.push(e)}),a},t.exports=i})),bt=e((e=>{let t=dt(),n=yt();function r(e,t){let n=0;return e.forEachInNeighbor(t,()=>{n++}),n}function i(e,i){if(!t(e))throw Error(`graphology-dag/topological-sort: the given graph is not a valid graphology instance.`);if(e.type===`undirected`||e.undirectedSize!==0)throw Error(`graphology-dag/topological-sort: cannot work if graph is not directed.`);if(e.order===0)return;let a=new n(Array,e.order),o={},s=0;e.forEachNode((t,n)=>{let i=e.multi?r(e,t):e.inDegree(t);i===0?a.push([t,n,0]):(o[t]=i,s+=i)});let c=0;function l(e,t){let n=--o[e];s--,n===0&&a.push([e,t,c+1]),o[e]=n}for(;a.size!==0;){let[t,n,r]=a.shift();c=r,i(t,n,r),e.forEachOutNeighbor(t,l)}if(s!==0)throw Error(`graphology-dag/topological-sort: given graph is not acyclic.`)}function a(e){if(!t(e))throw Error(`graphology-dag/topological-sort: the given graph is not a valid graphology instance.`);let n=Array(e.order),r=0;return i(e,e=>{n[r++]=e}),n}function o(e,n){if(!t(e))throw Error(`graphology-dag/topological-generations: the given graph is not a valid graphology instance.`);if(e.order===0)return;let r=0,a=[];i(e,(e,t,i)=>{i>r&&(n(a),r=i,a=[]),a.push(e)}),n(a)}function s(e){if(!t(e))throw Error(`graphology-dag/topological-generations: the given graph is not a valid graphology instance.`);let n=[];return o(e,e=>{n.push(e)}),n}e.topologicalSort=a,e.forEachNodeInTopologicalOrder=i,e.topologicalGenerations=s,e.forEachTopologicalGeneration=o})),xt=e((e=>{e.hasCycle=ft(),e.willCreateCycle=pt();let t=bt();e.forEachNodeInTopologicalOrder=t.forEachNodeInTopologicalOrder,e.topologicalSort=t.topologicalSort,e.topologicalGenerations=t.topologicalGenerations,e.forEachTopologicalGeneration=t.forEachTopologicalGeneration}))();function P(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return Object.getOwnPropertyDescriptor(e,t)?.value}function St(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Ct(e){return Object.fromEntries(e)}function F(e,t,n=1){let r=e.get(t)??0;e.set(t,r+n)}function wt(e){let t=e.metadata;if(!t||!t.dbt_schema_version)return null;let n=t.dbt_schema_version.match(/\/manifest\/v(\d+)\.json$/);return n?parseInt(n[1],10):null}function Tt(e){return e.metadata?.dbt_version||null}function Et(e){let t=wt(e);return t===null?!1:t>=10}function Dt(e){return{schema_version:wt(e),dbt_version:Tt(e),is_supported:Et(e)}}function Ot(e){return e.metrics}function kt(e){return e.semantic_models}function At(e){return e.unit_tests}var jt=class{constructor(e){if(this.relationMap=new Map,!Et(e)){let t=Dt(e);throw Error(`Unsupported dbt version. Schema version: ${t.schema_version||`unknown`}, dbt version: ${t.dbt_version||`unknown`}. Requires dbt 1.10+ (manifest schema v10+)`)}this.graph=new M,this.buildGraph(e)}buildGraph(e){this.addNodes(e),this.addEdges(e)}registerRelationName(e,t){t&&this.relationMap.set(t.toLowerCase(),e)}optionalString(e){return typeof e==`string`&&e!==``?e:void 0}optionalStringArray(e){return Array.isArray(e)?e:void 0}baseNodeAttributes(e,t){return{unique_id:e,name:this.optionalString(t.name)??e,package_name:this.optionalString(t.package_name)??``,path:this.optionalString(t.path),original_file_path:this.optionalString(t.original_file_path),tags:this.optionalStringArray(t.tags),description:this.optionalString(t.description)}}addManifestEntries(e,t,n){if(e)for(let[r,i]of Object.entries(e)){let e=i;this.graph.addNode(r,t(r,e)),n!=null&&this.registerRelationName(r,P(e,n))}}readMaterialized(e){let t=e?.materialized;return typeof t==`string`&&t.trim()!==``?t:void 0}metricArrayStrings(e,t){if(Array.isArray(e))return e.map(e=>P(e,t)).filter(e=>typeof e==`string`)}buildNodeEntryAttributes(e,t){let n=this.extractResourceType(this.optionalString(t.resource_type)??`model`),r=t.config,i=this.readMaterialized(r);return{...this.baseNodeAttributes(e,t),resource_type:n,patch_path:this.optionalString(t.patch_path),database:this.optionalString(t.database),schema:this.optionalString(t.schema),compiled_code:this.optionalString(t.compiled_code),raw_code:this.optionalString(t.raw_code)??this.optionalString(t.raw_sql),...i==null?{}:{materialized:i}}}buildSourceEntryAttributes(e,t){return{...this.baseNodeAttributes(e,t),resource_type:`source`}}buildMacroEntryAttributes(e,t){return{...this.baseNodeAttributes(e,t),resource_type:`macro`,raw_code:this.optionalString(t.macro_sql)}}buildExposureEntryAttributes(e,t){return{...this.baseNodeAttributes(e,t),resource_type:`exposure`}}buildMetricEntryAttributes(e,t){let n=t.type_params,r=t.filter,i=t.depends_on,a=t.tags,o=typeof a==`string`?[a]:this.optionalStringArray(a);return{...this.baseNodeAttributes(e,t),resource_type:`metric`,label:this.optionalString(t.label),metric_type:this.optionalString(t.type),metric_expression:this.optionalString(n?.expr),metric_measure:this.optionalString(n?.measure?.name),metric_input_measures:this.metricArrayStrings(n?.input_measures,`name`),metric_input_metrics:this.metricArrayStrings(n?.metrics,`name`),metric_time_granularity:this.optionalString(t.time_granularity),metric_filters:this.metricArrayStrings(r?.where_filters,`where_sql_template`),metric_source_reference:i?.nodes?.[0]??void 0,tags:o}}traverseNeighbors(e,t){if(!this.graph.hasNode(e))return[];let n=[],r=new Set,i=[],a=0,o=(e,a)=>{for(let o of t.getNeighbors(e))r.has(o)||(r.add(o),n.push(t.includeParents?{nodeId:o,depth:a,parentId:e}:{nodeId:o,depth:a}),(t.maxDepth===void 0||a<t.maxDepth)&&i.push({id:o,depth:a}))};for(o(e,1);a<i.length;){let{id:e,depth:t}=i[a++];o(e,t+1)}return n}addNodes(e){this.addNodeEntries(e.nodes),this.addSourceEntries(e.sources),this.addMacroEntries(e.macros),this.addExposureEntries(e.exposures),this.addMetricEntries(Ot(e)),this.addSemanticModelEntries(kt(e)),this.addUnitTestEntries(At(e))}addNodeEntries(e){this.addManifestEntries(e,(e,t)=>this.buildNodeEntryAttributes(e,t),`relation_name`)}addSourceEntries(e){this.addManifestEntries(e,(e,t)=>this.buildSourceEntryAttributes(e,t),`relation_name`)}addMacroEntries(e){this.addManifestEntries(e,(e,t)=>this.buildMacroEntryAttributes(e,t))}addExposureEntries(e){this.addManifestEntries(e,(e,t)=>this.buildExposureEntryAttributes(e,t))}addMetricEntries(e){this.addManifestEntries(e,(e,t)=>this.buildMetricEntryAttributes(e,t))}addSemanticModelEntries(e){if(e)for(let[t,n]of Object.entries(e)){let e=n;this.graph.addNode(t,{unique_id:t,resource_type:`semantic_model`,name:e.name||t,package_name:e.package_name||``,path:e.path||void 0,original_file_path:e.original_file_path||void 0,description:e.description||void 0,label:e.label||void 0,semantic_model_reference:e.model||void 0,semantic_model_default_time_dimension:e.defaults?.agg_time_dimension||void 0,semantic_model_entities:Array.isArray(e.entities)?e.entities.map(e=>e.name).filter(e=>typeof e==`string`):void 0,semantic_model_measures:Array.isArray(e.measures)?e.measures.map(e=>e.name).filter(e=>typeof e==`string`):void 0,semantic_model_dimensions:Array.isArray(e.dimensions)?e.dimensions.map(e=>e.name).filter(e=>typeof e==`string`):void 0})}}addUnitTestEntries(e){if(e)for(let[t,n]of Object.entries(e)){let e=n;this.graph.addNode(t,{unique_id:t,resource_type:`unit_test`,name:e.name||t,package_name:e.package_name||``})}}addEdges(e){e.parent_map&&this.addEdgesFromParentMap(e.parent_map),this.addEdgesFromNodeDependsOn(e.nodes),this.addEdgesFromExposureDependsOn(e.exposures),this.addEdgesFromMetricDependsOn(Ot(e))}addEdgesFromParentMap(e){for(let[t,n]of Object.entries(e))if(this.graph.hasNode(t))for(let e of n)this.graph.hasNode(e)&&!this.graph.hasEdge(e,t)&&this.graph.addEdge(e,t,{dependency_type:this.inferDependencyType(e)})}addEdgesFromDependsOn(e,t){if(t.nodes)for(let n of t.nodes)this.graph.hasNode(n)&&!this.graph.hasEdge(n,e)&&this.graph.addEdge(n,e,{dependency_type:`node`});if(t.macros)for(let n of t.macros)this.graph.hasNode(n)&&!this.graph.hasEdge(n,e)&&this.graph.addEdge(n,e,{dependency_type:`macro`})}addEdgesFromNodeDependsOn(e){if(e)for(let[t,n]of Object.entries(e)){let e=n.depends_on;e&&this.addEdgesFromDependsOn(t,e)}}addEdgesFromExposureDependsOn(e){if(e)for(let[t,n]of Object.entries(e)){let e=n.depends_on;e?.nodes&&this.addEdgesFromDependsOn(t,e)}}addEdgesFromMetricDependsOn(e){if(e)for(let[t,n]of Object.entries(e)){let e=n.depends_on;e?.nodes&&this.addEdgesFromDependsOn(t,e)}}extractResourceType(e){let t=e.toLowerCase();return[`model`,`source`,`seed`,`snapshot`,`test`,`analysis`,`macro`,`exposure`,`metric`,`semantic_model`,`unit_test`,`function`].includes(t)?t:`model`}inferDependencyType(e){return e.startsWith(`macro.`)?`macro`:e.startsWith(`source.`)?`source`:`node`}getGraph(){return this.graph}getSummary(){let e=new Map,t=0;this.graph.forEachNode((n,r)=>{t++,F(e,r.resource_type||`unknown`)});let n=(0,xt.hasCycle)(this.graph);return{total_nodes:t,nodes_by_type:Ct(e),total_edges:this.graph.size,has_cycles:n}}getUpstream(e,t){return this.traverseNeighbors(e,{maxDepth:t,getNeighbors:e=>this.graph.inboundNeighbors(e),includeParents:!1}).map(({nodeId:e,depth:t})=>({nodeId:e,depth:t}))}getDownstream(e,t){return this.traverseNeighbors(e,{maxDepth:t,getNeighbors:e=>this.graph.outboundNeighbors(e),includeParents:!1}).map(({nodeId:e,depth:t})=>({nodeId:e,depth:t}))}getUpstreamWithParents(e,t){return this.traverseNeighbors(e,{maxDepth:t,getNeighbors:e=>this.graph.inboundNeighbors(e),includeParents:!0}).map(({nodeId:t,depth:n,parentId:r})=>({nodeId:t,depth:n,parentId:r??e}))}getUpstreamBuildOrder(e,t){let n=this.getUpstream(e,t);if(n.length===0)return[];let r=new Set(n.map(e=>e.nodeId)),i=new Map(n.map(e=>[e.nodeId,e.depth])),a=new M;for(let e of r)a.addNode(e,this.graph.getNodeAttributes(e));return this.graph.forEachEdge((e,t,n,i)=>{r.has(n)&&r.has(i)&&(a.hasEdge(n,i)||a.addEdge(n,i,t))}),(0,xt.topologicalSort)(a).map(e=>({nodeId:e,depth:i.get(e)??0}))}getDownstreamWithParents(e,t){return this.traverseNeighbors(e,{maxDepth:t,getNeighbors:e=>this.graph.outboundNeighbors(e),includeParents:!0}).map(({nodeId:t,depth:n,parentId:r})=>({nodeId:t,depth:n,parentId:r??e}))}addFieldNodes(e){if(e.nodes){for(let[t,n]of Object.entries(e.nodes))if(this.graph.hasNode(t)){let e=n.columns;this.processCatalogColumns(t,e)}}if(e.sources){for(let[t,n]of Object.entries(e.sources))if(this.graph.hasNode(t)){let e=n.columns;this.processCatalogColumns(t,e)}}}processCatalogColumns(e,t){if(!t)return;let n=this.graph.getNodeAttributes(e);for(let[r,i]of Object.entries(t)){let t=`${e}#${r}`,a=i,o=a?.comment??a?.description;this.graph.hasNode(t)||(this.graph.addNode(t,{unique_id:t,resource_type:`field`,name:r,package_name:n.package_name,parent_id:e,description:o}),this.graph.addEdge(e,t,{dependency_type:`internal`}))}}addFieldEdges(e,t){if(this.graph.hasNode(e))for(let[n,r]of Object.entries(t)){let t=`${e}#${n}`;this.ensureFieldNode(e,n);for(let e of r){let n=this.resolveRelationToUniqueId(e.sourceTable);if(!n)continue;let r=`${n}#${e.sourceColumn}`;this.ensureFieldNode(n,e.sourceColumn),this.graph.hasEdge(r,t)||this.graph.addEdge(r,t,{dependency_type:`field`})}}}ensureFieldNode(e,t){let n=`${e}#${t}`;if(!this.graph.hasNode(n)){let r=this.graph.getNodeAttributes(e);this.graph.addNode(n,{unique_id:n,resource_type:`field`,name:t,package_name:r.package_name,parent_id:e}),this.graph.addEdge(e,n,{dependency_type:`internal`})}return n}tryResolveRelationName(e){return this.resolveRelationToUniqueId(e)}resolveRelationToUniqueId(e){let t=e.toLowerCase();if(this.relationMap.has(t))return this.relationMap.get(t);let n=t.replace(/["`]/g,``);if(this.relationMap.has(n))return this.relationMap.get(n);for(let[e,t]of this.relationMap.entries()){let r=e.replace(/["`]/g,``);if(r.endsWith(`.${n}`)||r===n)return t}}buildSubgraph(e,t,n,r){if(!this.graph.hasNode(e))throw Error(`Focus node not found in manifest: ${e}`);let i=new Set([e]);if(t===`upstream`||t===`both`)for(let{nodeId:t}of this.getUpstream(e,n))i.add(t);if(t===`downstream`||t===`both`)for(let{nodeId:t}of this.getDownstream(e,n))i.add(t);let a=new M;for(let t of i){if(!this.graph.hasNode(t))continue;let n=this.graph.getNodeAttributes(t);t!==e&&r&&!r.has(n.resource_type.toLowerCase())||a.addNode(t,n)}return this.graph.forEachEdge((e,t,n,r)=>{a.hasNode(n)&&a.hasNode(r)&&(a.hasEdge(n,r)||a.addEdge(n,r,t))}),a}};function I(e,t){let n=P(e,t);if(typeof n==`number`&&Number.isFinite(n))return n;if(typeof n==`string`&&n.trim()!==``){let e=Number(n);if(Number.isFinite(e))return e}}function L(e,t){let n=P(e,t);if(typeof n==`string`&&n.trim()!==``)return n}function R(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function z(e){return e===null?`null`:typeof e==`string`?e===``?`""`:e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?`[${e.map(e=>z(e)).join(`, `)}]`:R(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${z(P(e,t))}`).join(`,`)}}`:String(e)}function Mt(e,t){return typeof t==`number`&&Number.isFinite(t)?{key:e,label:e,kind:`number`,displayValue:t.toLocaleString(),isScalar:!0,sortValue:t}:typeof t==`string`?{key:e,label:e,kind:`string`,displayValue:t===``?`""`:t,isScalar:!0,sortValue:t}:typeof t==`boolean`?{key:e,label:e,kind:`boolean`,displayValue:t?`true`:`false`,isScalar:!0,sortValue:+!!t}:t===null?{key:e,label:e,kind:`null`,displayValue:`null`,isScalar:!1}:Array.isArray(t)?{key:e,label:e,kind:`array`,displayValue:z(t),isScalar:!1}:{key:e,label:e,kind:`object`,displayValue:z(t),isScalar:!1}}function Nt(e,t){if(!R(t))return[Mt(e,t)];let n=Object.keys(t).sort();return n.length===0?[Mt(e,t)]:n.map(n=>Mt(`${e}.${n}`,P(t,n)))}function Pt(e){return e.bytesProcessed!==void 0||e.bytesBilled!==void 0||e.slotMs!==void 0||e.rowsAffected!==void 0||e.adapterCode!==void 0||e.adapterMessage!==void 0||e.queryId!==void 0||e.projectId!==void 0||e.location!==void 0||e.rowsInserted!==void 0||e.rowsDeleted!==void 0||e.rowsUpdated!==void 0||e.rowsDuplicated!==void 0}function Ft(e){return R(e)}function It(e){if(typeof e!=`string`)return e;let t=e.trim();if(t===``||t===`null`)return null;let n=t[0];if(n!==`{`&&n!==`[`)return e;try{return JSON.parse(t)}catch{return e}}function Lt(e){return R(e)?Object.keys(e).sort().flatMap(t=>Nt(t,P(e,t))):[]}function Rt(e,t,n,r){for(let{metricKey:i,totalKey:a}of t){let t=P(e,i);typeof t==`number`&&(F(n,a,t),r.set(a,!0))}}function zt(e,t,n,r){let i={nodesWithAdapterData:e};for(let{totalKey:e}of t){if(!r.get(e))continue;let t=n.get(e);t!==void 0&&St(i,e,t)}return i}function Bt(e){let t=[{metricKey:`bytesProcessed`,totalKey:`totalBytesProcessed`},{metricKey:`bytesBilled`,totalKey:`totalBytesBilled`},{metricKey:`slotMs`,totalKey:`totalSlotMs`},{metricKey:`rowsAffected`,totalKey:`totalRowsAffected`},{metricKey:`rowsInserted`,totalKey:`totalRowsInserted`},{metricKey:`rowsUpdated`,totalKey:`totalRowsUpdated`},{metricKey:`rowsDeleted`,totalKey:`totalRowsDeleted`},{metricKey:`rowsDuplicated`,totalKey:`totalRowsDuplicated`}],n=0,r=new Map,i=new Map;for(let{totalKey:e}of t)r.set(e,0),i.set(e,!1);for(let a of e)a==null||!Pt(a)||(n+=1,Rt(a,t,r,i));if(n!==0)return zt(n,t,r,i)}function Vt(e){if(!R(e))return{};let t=I(e,`bytes_processed`),n=I(e,`bytes_billed`),r=I(e,`slot_ms`),i=I(e,`rows_affected`),a=L(e,`code`),o=L(e,`_message`),s=L(e,`query_id`)??L(e,`job_id`),c=L(e,`project_id`),l=L(e,`location`);return{...t===void 0?{}:{bytesProcessed:t},...n===void 0?{}:{bytesBilled:n},...r===void 0?{}:{slotMs:r},...i===void 0?{}:{rowsAffected:i},...a===void 0?{}:{adapterCode:a},...o===void 0?{}:{adapterMessage:o},...s===void 0?{}:{queryId:s},...c===void 0?{}:{projectId:c},...l===void 0?{}:{location:l}}}function B(e,t){if(!R(e))return{rawKeys:[]};let n=Object.keys(e).filter(e=>typeof e==`string`);return{...Vt(e),...t,rawKeys:n}}let Ht={name:`generic`,parse(e){return B(e,{})}},Ut={name:`athena`,parse(e){if(!R(e))return{rawKeys:[]};let t=I(e,`data_scanned_in_bytes`);return B(e,{...t===void 0?{}:{bytesProcessed:t}})},canParse(e){return R(e)?`data_scanned_in_bytes`in e:!1}},Wt={name:`bigquery`,parse(e){if(!R(e))return{rawKeys:[]};let t=I(e,`bytes_processed`),n=I(e,`bytes_billed`),r=I(e,`slot_ms`),i=L(e,`project_id`),a=L(e,`location`),o=L(e,`query_id`)??L(e,`job_id`);return B(e,{...t===void 0?{}:{bytesProcessed:t},...n===void 0?{}:{bytesBilled:n},...r===void 0?{}:{slotMs:r},...o===void 0?{}:{queryId:o},...i===void 0?{}:{projectId:i},...a===void 0?{}:{location:a}})},canParse(e){return R(e)?`bytes_processed`in e||`bytes_billed`in e||`slot_ms`in e||`job_id`in e||`location`in e:!1}},Gt={name:`postgres`,parse(e){return B(e,{})}},Kt={name:`redshift`,parse(e){return B(e,{})}},qt={name:`snowflake`,parse(e){if(!R(e))return{rawKeys:[]};let t=I(e,`rows_inserted`),n=I(e,`rows_deleted`),r=I(e,`rows_updated`),i=I(e,`rows_duplicates`);return B(e,{...t===void 0?{}:{rowsInserted:t},...n===void 0?{}:{rowsDeleted:n},...r===void 0?{}:{rowsUpdated:r},...i===void 0?{}:{rowsDuplicated:i}})},canParse(e){return R(e)?`rows_inserted`in e||`rows_deleted`in e||`rows_updated`in e||`rows_duplicates`in e:!1}},Jt=new Map([[`athena`,Ut],[`bigquery`,Wt],[`postgres`,Gt],[`redshift`,Kt],[`snowflake`,qt],[`spark`,{name:`spark`,parse(e){return B(e,{})}}]]),Yt=[Wt,qt,Ut],Xt=new class{selectParser(e,t){if(e&&typeof e==`string`){let n=e.toLowerCase().trim(),r=Jt.get(n);if(r&&(!r.canParse||r.canParse(t)))return r}for(let e of Yt)if(e.canParse&&e.canParse(t))return e;return Ht}};function Zt(e,t){let n=It(e),r=t?.adapterType;return Xt.selectParser(r,n).parse(n)}function Qt(e,t){if(!e.results||!Array.isArray(e.results))return[];let n=e.results,r=e=>{let t=e.timing||[];return t.find(e=>e.name===`execute`)||t.find(e=>e.name===`compile`)||t[0]},i=e=>typeof e==`string`&&e.trim()!==``?e.trim():void 0,a=e=>{let n=Zt(e,{adapterType:t});return{adapterMetrics:n,includeAdapter:n.rawKeys.length>0||Pt(n),adapterResponseFields:Lt(e),includeAdapterFields:Ft(e)}};return n.map(e=>{let t=r(e),{adapterMetrics:n,includeAdapter:o,adapterResponseFields:s,includeAdapterFields:c}=a(It(e.adapter_response)),l=i(e.message);return{unique_id:e.unique_id||``,status:e.status||`unknown`,execution_time:e.execution_time||0,started_at:t?.started_at??void 0,completed_at:t?.completed_at??void 0,thread_id:e.thread_id??void 0,...l==null?{}:{message:l},...o?{adapterMetrics:n}:{},...c?{adapterResponseFields:s}:{}}})}var $t=class{constructor(e,t,n){this.runResults=e,this.graph=t,this.adapterType=n}getSummary(){let e=this.getNodeExecutions(),t=new Map,n=0;for(let r of e)F(t,r.status||`unknown`),n+=r.execution_time||0;let r=this.calculateCriticalPath(e);return{total_execution_time:n,total_nodes:e.length,nodes_by_status:Ct(t),critical_path:r,node_executions:e}}getNodeExecutions(){return Qt(this.runResults,this.adapterType)}calculateCriticalPath(e){let t=new Map;for(let n of e)t.set(n.unique_id,n);let n=[],r=this.graph.getGraph();if(r.forEachNode(e=>{r.outboundNeighbors(e).length===0&&t.has(e)&&n.push(e)}),n.length===0)return;let i=[],a=0;for(let e of n){let n=this.findLongestPathToRoot(e,t),r=this.calculatePathTime(n,t);r>a&&(a=r,i=n)}if(i.length!==0)return{path:i,total_time:a}}findLongestPathToRoot(e,t){let n=this.graph.getGraph(),r=new Set,i=[],a=(e,o)=>{if(r.has(e))return;r.add(e);let s=[...o,e];s.length>i.length&&(i=s);let c=n.inboundNeighbors(e);for(let e of c)t.has(e)&&a(e,s);r.delete(e)};return a(e,[]),i.reverse()}calculatePathTime(e,t){let n=0;for(let r of e){let e=t.get(r);e&&(n+=e.execution_time||0)}return n}getRunStartedAt(){let e=this.getNodeExecutions().map(e=>e.started_at?new Date(e.started_at).getTime():null).filter(e=>e!==null);return e.length===0?null:Math.min(...e)}parseTimingInterval(e){if(!e)return null;let t=e.started_at,n=e.completed_at;if(!t||!n)return null;let r=new Date(t).getTime(),i=new Date(n).getTime();return Number.isNaN(r)||Number.isNaN(i)?null:{start:r,end:i}}wallClockFromResult(e){let t=e.timing||[],n=t.find(e=>e.name===`execute`),r=t.find(e=>e.name===`compile`),i=this.parseTimingInterval(r),a=this.parseTimingInterval(n),o=[],s=[];return i&&(o.push(i.start),s.push(i.end)),a&&(o.push(a.start),s.push(a.end)),o.length===0?null:{wallStart:Math.min(...o),wallEnd:Math.max(...s),compile:i,execute:a}}getGanttData(){if(!this.runResults.results||!Array.isArray(this.runResults.results))return[];let e=this.graph.getGraph(),t=[];for(let n of this.runResults.results){let r=n.unique_id||``;if(!r)continue;let i=this.wallClockFromResult(n);if(!i)continue;let a=(e.hasNode(r)?e.getNodeAttributes(r):void 0)?.name||r,o=n.status||`unknown`;t.push({unique_id:r,name:a,status:o,wall:i})}if(t.length===0)return[];let n=Math.min(...t.map(e=>e.wall.wallStart));return t.map(e=>{let{wall:t}=e,r=e=>e-n;return{unique_id:e.unique_id,name:e.name,start:r(t.wallStart),end:r(t.wallEnd),duration:t.wallEnd-t.wallStart,status:e.status,compileStart:t.compile?r(t.compile.start):null,compileEnd:t.compile?r(t.compile.end):null,executeStart:t.execute?r(t.execute.start):null,executeEnd:t.execute?r(t.execute.end):null}})}};function en(e,t){let n=t.split(`*`);if(n.length===1)return e===t;let r=0,i=!0;for(let t of n){let n=e.indexOf(t,r);if(n===-1||i&&n!==0)return!1;i=!1,r=n+t.length}let a=n[n.length-1];return a===``||e.endsWith(a)}function tn(e,t){return t instanceof RegExp?t.test(e):en(e,t)}new Map([`bytes_processed`,`bytes_billed`,`slot_ms`,`rows_affected`,`rows_inserted`,`rows_updated`,`rows_deleted`,`rows_duplicated`].map(e=>[`${e}_desc`,e]));function nn(e,t){let n=e.adapterMetrics;return n==null?!1:[n.queryId,n.adapterCode,n.adapterMessage,n.projectId,n.location].some(e=>e?.toLowerCase().includes(t)===!0)}function rn(e,t){let n=[...e];if(t.status!==void 0){let e=typeof t.status==`string`?[t.status]:t.status,r=new Set(e.map(e=>e.toLowerCase()));n=n.filter(e=>r.has((e.status||`unknown`).toLowerCase()))}if(t.min_execution_time!==void 0&&(n=n.filter(e=>(e.execution_time??0)>=t.min_execution_time)),t.max_execution_time!==void 0&&(n=n.filter(e=>(e.execution_time??0)<=t.max_execution_time)),t.unique_id_pattern!==void 0&&(n=n.filter(e=>tn(e.unique_id,t.unique_id_pattern))),t.has_adapter_key!==void 0&&(n=n.filter(e=>e.adapterMetrics?.rawKeys.includes(t.has_adapter_key)===!0)),t.adapter_text!==void 0&&t.adapter_text.trim()!==``){let e=t.adapter_text.toLowerCase();n=n.filter(t=>nn(t,e))}return n}function an(e,t){return[...e].sort((e,n)=>{switch(t){case`execution_time_asc`:return(e.execution_time??0)-(n.execution_time??0);case`execution_time_desc`:return(n.execution_time??0)-(e.execution_time??0);case`unique_id`:return e.unique_id.localeCompare(n.unique_id);default:return 0}})}function on(e,t){let n=rn(e,t);return t.sort&&(n=an(n,t.sort)),t.limit!==void 0&&t.limit>=0&&(n=n.slice(0,t.limit)),n}function sn(e,t){if(!t)return;let n=t.getGraph();if(n.hasNode(e))return n.getNodeAttributes(e)?.name||void 0}function cn(e,t){let n=e.reduce((e,t)=>e+(t.execution_time??0),0),r;return r=t.mode===`top_n`?on(e,{sort:`execution_time_desc`,limit:t.top}):on(e,{min_execution_time:t.min_seconds,sort:`execution_time_desc`}),{nodes:r.map((e,r)=>{let i=e.execution_time??0,a=n>0?i/n*100:0;return{unique_id:e.unique_id,name:sn(e.unique_id,t.graph),execution_time:i,rank:r+1,pct_of_total:Math.round(a*10)/10,status:e.status||`unknown`}}),total_execution_time:n,criteria_used:t.mode===`top_n`?`top_n`:`threshold`}}function ln(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r+=1)n|=e.charCodeAt(r)^t.charCodeAt(r);return n===0}let un=new Map([[`seed`,`seed`],[`snapshot`,`snapshot`],[`test`,`test`],[`unit_test`,`test`],[`operation`,`operation`]]);function dn(e){switch(e){case`table`:return`table`;case`view`:return`view`;case`incremental`:return`incremental`;case`ephemeral`:return`ephemeral`;case`materialized_view`:case`materializedview`:return`materialized_view`;default:return}}function fn(e){return e.trim().toLowerCase()||`unknown`}function pn(e){if(e==null||typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t===``?null:t.replace(/[\s-]+/g,`_`)}function mn(e,t){let n=fn(e),r=pn(t),i=un.get(n);if(i!==void 0)return{kind:i};if(n.length===0||ln(n,`model`))return typeof r==`string`?hn(r,t):{kind:`unknown`};if(typeof r==`string`){let e=dn(r);return e===void 0?{kind:`unknown`,raw:t.trim()}:{kind:e,raw:void 0}}return{kind:`unknown`}}function hn(e,t){let n=dn(e);return n===void 0?{kind:`unknown`,raw:t.trim()}:{kind:n}}function gn(e,t){if(fn(t)===`source`)return{persisted:!0,createsRelation:!1,compiledIntoParent:!1};switch(e){case`ephemeral`:return{persisted:!1,createsRelation:!1,compiledIntoParent:!0};case`table`:case`view`:case`incremental`:case`materialized_view`:return{persisted:!0,createsRelation:!0,compiledIntoParent:!1};case`seed`:case`snapshot`:return{persisted:!0,createsRelation:!0,compiledIntoParent:!1};case`test`:case`operation`:return{persisted:!1,createsRelation:!1,compiledIntoParent:!1};default:return{persisted:!1,createsRelation:!1,compiledIntoParent:!1}}}function _n(e){if(e==null)return;let t=e.config;return typeof t==`object`&&t?t:void 0}function vn(e,t,n){return e==null?`derived`:t||n||typeof e.relation_name==`string`&&e.relation_name.length>0?`manifest`:`derived`}function yn(e){let t=e?.unique_key;return t==null?{uniqueKey:void 0,hasUniqueKeyField:!1}:typeof t==`string`||Array.isArray(t)&&t.every(e=>typeof e==`string`)?{uniqueKey:t,hasUniqueKeyField:!0}:{uniqueKey:void 0,hasUniqueKeyField:!0}}function bn(e,t){if(e==null)return{hasAnyIncrementalHint:t};let n=typeof e.incremental_strategy==`string`?e.incremental_strategy:void 0,r=typeof e.on_schema_change==`string`?e.on_schema_change:void 0,i=typeof e.full_refresh==`boolean`?e.full_refresh:void 0;return{incrementalStrategy:n,onSchemaChange:r,fullRefreshCapable:i,hasAnyIncrementalHint:n!=null||r!=null||i!=null||t}}function xn(e){let t=e=>typeof e==`string`&&e.trim()!==``?e:void 0,n=(e,n,r,i,a)=>({...e==null?{}:{relationName:e},...t(n)==null?{}:{adapterType:t(n)},...a.incrementalStrategy==null?{}:{incrementalStrategy:a.incrementalStrategy},...r==null?{}:{uniqueKey:r},...a.onSchemaChange==null?{}:{onSchemaChange:a.onSchemaChange},...a.fullRefreshCapable==null?{}:{fullRefreshCapable:a.fullRefreshCapable},...t(i)==null?{}:{rawMaterialization:t(i)}}),{resourceType:r,adapterType:i}=e,a=e.manifestEntry??null,o=_n(a),s=typeof o?.materialized==`string`?o.materialized:null,c=typeof e.materialized==`string`&&e.materialized.trim()!==``?e.materialized:null,{kind:l,raw:u}=mn(r,c??s),{uniqueKey:d,hasUniqueKeyField:f}=yn(o),p=bn(o,f),m=t(a?.relation_name),h=s!=null&&String(s).trim()!==``,g=c!=null&&c.trim()!==``;return{resourceType:r,materialization:l,...gn(l,r),...n(m,i,d,u,p),materializationSource:vn(a,h||g,p.hasAnyIncrementalHint)}}let Sn=[`model`,`source`,`test`,`metric`,`semantic_model`,`exposure`,`seed`,`snapshot`,`unit_test`,`analysis`,`macro`];function V(){return performance.now()}function H(e){let t=e?.trim().toLowerCase();return t?[`success`,`pass`,`passed`].includes(t)?`positive`:[`warn`,`warning`].includes(t)?`warning`:[`error`,`errors`,`fail`,`failed`,`failure`,`failures`,`errored`,`run error`,`runtime error`,`compile error`,`database error`].includes(t)?`danger`:[`skipped`,`no op`].includes(t)?`skipped`:`neutral`:`neutral`}function U(e){return e?e.split(/[\s_-]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1).toLowerCase()).join(` `):`Unknown`}function W(e){let t=e.split(`.`);return t.length<2?``:t[1]??``}function G(e){let t=e.split(`.`)[0]??``;return new Set([`model`,`test`,`unit_test`,`seed`,`snapshot`,`source`,`source_freshness`,`exposure`,`metric`,`semantic_model`,`analysis`,`macro`]).has(t)?t:`operation`}function Cn(e){return e.split(`_`).map(e=>e[0].toUpperCase()+e.slice(1)).join(` `)}function K(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function wn(e){let t=typeof e.metric_measure==`string`?e.metric_measure:null,n=K(e.metric_input_measures);return{kind:`metric`,label:typeof e.label==`string`?e.label:null,description:typeof e.description==`string`?e.description:null,metricType:typeof e.metric_type==`string`?e.metric_type:null,expression:typeof e.metric_expression==`string`?e.metric_expression:null,sourceReference:typeof e.metric_source_reference==`string`?e.metric_source_reference:typeof e.metric_measure==`string`?e.metric_measure:null,filters:K(e.metric_filters),timeGranularity:typeof e.metric_time_granularity==`string`?e.metric_time_granularity:null,measures:n.length>0?n:t==null?[]:[t],metrics:K(e.metric_input_metrics)}}function Tn(e){return{kind:`semantic_model`,label:typeof e.label==`string`?e.label:null,description:typeof e.description==`string`?e.description:null,sourceReference:typeof e.semantic_model_reference==`string`?e.semantic_model_reference:null,defaultTimeDimension:typeof e.semantic_model_default_time_dimension==`string`?e.semantic_model_default_time_dimension:null,entities:K(e.semantic_model_entities),measures:K(e.semantic_model_measures),dimensions:K(e.semantic_model_dimensions)}}function En(e,t){return e===`metric`?wn(t):e===`semantic_model`?Tn(t):null}function Dn(e,t){let n=Sn.indexOf(e),r=Sn.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r}function On(e,t){let n=Dn(e.resourceType,t.resourceType);return n===0?e.name.localeCompare(t.name):n}function kn(e){let t=e.metadata;return typeof t==`object`&&t&&`project_name`in t&&typeof t.project_name==`string`&&t.project_name!==``?t.project_name:null}let An=new Set([`test`,`unit_test`,`macro`,`operation`,`sql_operation`]),jn=new Set([`elementary`]);function Mn(e,t){let n=(t.hasNode(e.unique_id)?t.getNodeAttributes(e.unique_id):void 0)?.package_name;return typeof n==`string`&&n.length>0?n:W(e.unique_id)}function Nn(e,t){let n=(t.hasNode(e.unique_id)?t.getNodeAttributes(e.unique_id):void 0)?.resource_type;return typeof n==`string`&&n.length>0?n:G(e.unique_id)}function Pn(e,t){if(e.length===0)return null;let n=new Map;for(let r of e){let e=Nn(r,t);if(An.has(e))continue;let i=Mn(r,t);i.length>0&&!jn.has(i)&&F(n,i)}return[...n.entries()].sort((e,t)=>{let n=t[1]-e[1];return n===0?e[0].localeCompare(t[0]):n})[0]?.[0]??null}function Fn(e,t,n){let r=0;for(let i of e){let e=Nn(i,t);An.has(e)||Mn(i,t)===n&&r++}return r}function In(e,t,n){let r=kn(e),i=Pn(t,n);return r==null||Fn(t,n,r)===0&&i!=null?i:r}function Ln(e){let t=e.metadata!=null&&typeof e.metadata==`object`?e.metadata:null;return typeof t?.invocation_id==`string`?t.invocation_id:null}function Rn(e){let t=e.metadata;return typeof t==`object`&&t&&`adapter_type`in t&&typeof t.adapter_type==`string`&&t.adapter_type!==``?t.adapter_type:null}function zn(e){let t=new Map;for(let n of e){let e=t.get(n.resourceType)??[];e.push(n),t.set(n.resourceType,e)}return[...t.entries()].sort(([e],[t])=>Dn(e,t)).map(([e,t])=>({resourceType:e,label:Cn(e),count:t.length,attentionCount:t.filter(e=>e.statusTone===`danger`||e.statusTone===`warning`).length,resources:t}))}function Bn(e,t){let n=new Map;for(let e of t){let t=U(e.status);n.set(t,(n.get(t)??0)+(e.execution_time??0))}return Object.entries(e.nodes_by_status).map(([t,r])=>({status:U(t),count:r,duration:n.get(U(t))??0,share:e.total_nodes>0?r/e.total_nodes:0,tone:H(t)})).sort((e,t)=>t.count-e.count)}function Vn(e,t){let n={};for(let r of t)St(n,r,e.hasNode(r)?{inbound:[...e.inboundNeighbors(r)],outbound:[...e.outboundNeighbors(r)]}:{inbound:[],outbound:[]});return n}function Hn(e){let t=new Map;for(let n of e){let e=n.threadId??`unknown`,r=t.get(e)??{count:0,totalExecutionTime:0};r.count+=1,r.totalExecutionTime+=n.executionTime,t.set(e,r)}return[...t.entries()].map(([e,t])=>({threadId:e,count:t.count,totalExecutionTime:t.totalExecutionTime})).sort((e,t)=>t.totalExecutionTime-e.totalExecutionTime)}let Un=new Set([`test`,`unit_test`]);function Wn(e){let t=new Map,n=e=>{if(!(typeof e!=`object`||!e))for(let[n,r]of Object.entries(e))typeof r==`object`&&r&&t.set(n,r)};if(n(e.nodes),n(e.sources),n(e.unit_tests),e.disabled!=null&&typeof e.disabled==`object`){for(let[n,r]of Object.entries(e.disabled))if(Array.isArray(r))for(let e of r)typeof e==`object`&&e&&t.set(n,e)}return t}function Gn(e,t,n){return t.hasNode(e)?t.getNodeAttributes(e):n.get(e)}function Kn(e,t,n){for(let r of e){let e=Gn(r,t,n),i=String(e?.resource_type??G(r));if(i!==`test`&&i!==`unit_test`&&i!==``)return r}return null}function qn(e,t,n,r){let i=e.getUpstream(r),a=i.filter(e=>e.depth===1),o=Kn((a.length>0?a:i).map(e=>e.nodeId),t,n);if(o!=null)return o;let s=n.get(r),c=typeof s?.attached_node==`string`?s.attached_node:null;if(c!=null)return c;let l=s?.depends_on;if(Array.isArray(l?.nodes)){let e=Kn(l.nodes.filter(e=>typeof e==`string`),t,n);if(e!=null)return e}return null}function Jn(e){return typeof e?.original_file_path==`string`?e.original_file_path:typeof e?.path==`string`?e.path:null}function Yn(e,t,n,r){let i=n.get(e)??null;return xn({resourceType:typeof t?.resource_type==`string`&&t.resource_type!==``?t.resource_type:G(e),materialized:typeof t?.materialized==`string`&&t.materialized.trim()!==``?t.materialized:null,manifestEntry:i,adapterType:r??null})}function Xn(e,t,n,r,i){let a=Gn(e.unique_id,n,r),o=typeof a?.resource_type==`string`&&a.resource_type!==``?a.resource_type:G(e.unique_id),s=o===`test`||o===`unit_test`?qn(t,n,r,e.unique_id):null,c=typeof a?.package_name==`string`&&a.package_name.length>0?a.package_name:W(e.unique_id),l=typeof a?.materialized==`string`&&a.materialized.trim()!==``?a.materialized:null,u=Yn(e.unique_id,a,r,i);return{...e,resourceType:o,packageName:c,path:Jn(a),parentId:s,materialized:l,semantics:u}}function Zn(e){let t=e?.trim().toLowerCase();return t?[`error`,`fail`,`failed`,`run error`].includes(t)?3:[`warn`,`warning`].includes(t)?2:+!![`success`,`pass`,`passed`].includes(t):0}function Qn(e){let t=e[0]?.status??`unknown`,n=Zn(t);for(let r of e.slice(1)){let e=Zn(r.status);e>n&&(n=e,t=r.status)}return t}function q(e,t){let n=e.start-t.start;if(n!==0)return n;let r=t.duration-e.duration;return r===0?e.name.localeCompare(t.name):r}function $n(e,t,n,r){let i=(e,n)=>{if(n.resourceType!==`test`&&n.resourceType!==`unit_test`||n.parentId==null||!t.hasNode(n.parentId))return;let r=t.getNodeAttributes(n.parentId);if(String(r?.resource_type??``)!==`source`)return;let i=e.get(n.parentId)??[];i.push(n),e.set(n.parentId,i)},a=(e,i)=>{let a=t.getNodeAttributes(e),o=[...i].sort(q),s=Math.min(...o.map(e=>e.start)),c=Math.max(...o.map(e=>e.end)),l=Yn(e,a,n,r);return{unique_id:e,name:typeof a?.name==`string`&&a.name.length>0?a.name:e,start:s,end:c,duration:Math.max(0,c-s),status:Qn(o),resourceType:`source`,packageName:typeof a?.package_name==`string`&&a.package_name.length>0?a.package_name:W(e),path:Jn(a),parentId:null,compileStart:null,compileEnd:null,executeStart:null,executeEnd:null,materialized:null,semantics:l}},o=new Set(e.map(e=>e.unique_id)),s=new Map;for(let t of e)i(s,t);let c=[];for(let[e,t]of s.entries())o.has(e)||t.length===0||c.push(a(e,t));return c.sort(q)}function er(e,t,n,r,i){let a=new Set(e.map(e=>e.unique_id)),o=new Map(e.map(e=>[e.unique_id,e])),s=[];return t.forEachNode((e,c)=>{if(String(c.resource_type??``)!==`source`||a.has(e))return;let l=typeof c.package_name==`string`&&c.package_name.length>0?c.package_name:W(e);if(n!=null&&l!==n)return;let u=[];for(let n of t.outboundNeighbors(e)){let e=o.get(n);e!=null&&(Un.has(e.resourceType)||u.push(e))}if(u.length===0)return;let d=[...u].sort(q),f=Math.min(...d.map(e=>e.start)),p=Math.max(...d.map(e=>e.end)),m=Yn(e,c,r,i);s.push({unique_id:e,name:typeof c.name==`string`&&c.name.length>0?c.name:e,start:f,end:p,duration:Math.max(0,p-f),status:Qn(d),resourceType:`source`,packageName:l,path:Jn(c),parentId:null,compileStart:null,compileEnd:null,executeStart:null,executeEnd:null,materialized:null,semantics:m})}),s.sort(q)}function tr(e){let t=e.column_name;return typeof t!=`string`||t.trim()===``?null:t.trim()}function nr(e,t){let n=e.attached_node;if(typeof n!=`string`)return null;let r=t.getGraph();if(!r.hasNode(n))return null;let i=r.getNodeAttributes(n);return i==null||typeof i.name!=`string`||i.name===``?null:i.name}function rr(e,t){let n=e.depends_on;if(!Array.isArray(n?.nodes))return null;let r=t.getGraph();for(let e of n.nodes){if(typeof e!=`string`||!r.hasNode(e))continue;let t=r.getNodeAttributes(e),n=String(t?.resource_type??G(e));if(!(n===`test`||n===`unit_test`)&&t!=null&&typeof t.name==`string`&&t.name!==``)return t.name}return null}function ir(e,t){if(e==null)return null;let n=tr(e),r=nr(e,t)??rr(e,t);return r!=null&&n!=null?`${r}.${n}`:r??n??null}function J(e,t){let n=P(e,t);return typeof n==`string`?n:null}function ar(e,t){let n=Array.isArray(t.tags)?t.tags.filter(e=>typeof e==`string`):void 0;return{uniqueId:e,name:String(t.name||e),resourceType:String(t.resource_type||`unknown`),packageName:String(t.package_name||``),...n===void 0?{}:{tags:n},path:J(t,`path`),originalFilePath:J(t,`original_file_path`),patchPath:J(t,`patch_path`),database:J(t,`database`),schema:J(t,`schema`),description:J(t,`description`)}}function Y(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function or(e){let t=new Map;if(e==null)return t;for(let n of[`nodes`,`sources`]){let r=n===`nodes`?e.nodes:n===`sources`?e.sources:void 0;if(!(typeof r!=`object`||!r))for(let[e,n]of Object.entries(r))typeof n==`object`&&n&&t.set(e,n)}return t}function sr(e){if(e==null)return null;let t=e.columns!=null&&typeof e.columns==`object`?e.columns:void 0,n=e.metadata!=null&&typeof e.metadata==`object`?e.metadata:void 0,r=e.stats!=null&&typeof e.stats==`object`?e.stats:void 0;return{columnCount:t==null?0:Object.keys(t).length,tableType:typeof n?.type==`string`?n.type:typeof n?.table_type==`string`?n.table_type:null,bytes:Y(r?.bytes)??Y(r?.num_bytes)??Y(r?.size),rowCount:Y(r?.row_count)??Y(r?.num_rows)??Y(r?.rows)}}function cr(e){let t=new Map,n=e?.results;if(!Array.isArray(n))return t;for(let e of n){if(typeof e!=`object`||!e)continue;let n=e,r=n.unique_id;typeof r==`string`&&r.length>0&&t.set(r,n)}return t}function lr(e){if(typeof e!=`object`||!e)return null;let t=typeof e.count==`number`?e.count:null,n=typeof e.period==`string`?e.period:null;return t==null||n==null?null:`${t} ${n}`}function ur(e,t){if(e!==`source`||t==null)return null;let n=t.criteria!=null&&typeof t.criteria==`object`?t.criteria:void 0,r=typeof t.status==`string`&&t.status.trim()!==``?t.status:void 0;return{status:r==null?`Unknown`:U(r),statusTone:H(r),maxLoadedAt:typeof t.max_loaded_at==`string`?t.max_loaded_at:null,snapshottedAt:typeof t.snapshotted_at==`string`?t.snapshotted_at:null,ageSeconds:Y(t.max_loaded_at_time_ago_in_s),criteria:n==null?null:{warnAfter:lr(n.warn_after),errorAfter:lr(n.error_after),filter:typeof n.filter==`string`?n.filter:null},error:typeof t.error==`string`?t.error:typeof t.message==`string`?t.message:null}}function dr(e,t,n){let r=e=>{let n=t.getNodeAttributes(e.nodeId);return{uniqueId:e.nodeId,name:String(n?.name||e.nodeId),resourceType:String(n?.resource_type||`unknown`),depth:e.depth}},i=e.getUpstream(n,1),a=e.getDownstream(n,1);return{upstreamCount:i.length,downstreamCount:a.length,upstream:i.map(r),downstream:a.map(r)}}function fr(e,t,n,r,i,a,o,s){let c=(e,t,n)=>e?{[t]:n}:{},l=ar(e,t),{resourceType:u}=l,d=J(t,`materialized`),f=xn({resourceType:u,materialized:d!=null&&d.trim()!==``?d:null,manifestEntry:a.get(e)??null,adapterType:o??null}),p=u===`test`||u===`unit_test`?ir(r,i):null,m=n?.message,h=typeof m==`string`&&m.trim()!==``?m.trim():null,g=typeof n?.execution_time==`number`?n.execution_time:null,_=typeof n?.thread_id==`string`?n.thread_id:null,v=sr(s.catalogEntry),y=ur(u,s.sourcesEntry);return{...l,compiledCode:null,rawCode:null,definition:En(u,t),status:n?.status?U(n.status):null,statusTone:H(n?.status),executionTime:g,threadId:_,semantics:f,...c(p!=null,`testAttachedTarget`,p),...c(h!=null,`runResultMessage`,h),...c(n?.adapterMetrics!=null,`adapterMetrics`,n?.adapterMetrics),...c(n?.adapterResponseFields!=null,`adapterResponseFields`,n?.adapterResponseFields),...c(v!=null,`catalogStats`,v),...c(y!=null,`sourceFreshness`,y)}}function pr(e,t,n,r,i){let a=[],o={},s=e.getGraph(),c=or(i.catalogJson),l=cr(i.sourcesJson);return s.forEachNode((i,u)=>{let d=t.get(i),f=n.get(i);a.push(fr(i,u,d,f,e,n,r,{catalogEntry:c.get(i),sourcesEntry:l.get(i)})),St(o,i,dr(e,s,i))}),a.sort(On),{resources:a,dependencyIndex:o}}var mr=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),hr=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.parseManifestV1=a,e.parseManifestV2=o,e.parseManifestV3=s,e.parseManifestV4=c,e.parseManifestV5=l,e.parseManifestV6=u,e.parseManifestV7=d,e.parseManifestV8=f,e.parseManifestV9=p,e.parseManifestV10=m,e.parseManifestV11=h,e.parseManifestV12=g,e.parseManifest=v,n(mr(),e);let r=`Not a manifest.json`;function i(e){if(!e)return null;let t=e.match(/\/manifest\/v(\d+)\.json$/);return t?parseInt(t[1],10):null}function a(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v1`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v1.json`))throw Error(`Not a manifest.json v1`);return e}function o(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v2`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v2.json`))throw Error(`Not a manifest.json v2`);return e}function s(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v3`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v3.json`))throw Error(`Not a manifest.json v3`);return e}function c(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v4`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v4.json`))throw Error(`Not a manifest.json v4`);return e}function l(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v5`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v5.json`))throw Error(`Not a manifest.json v5`);return e}function u(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v6`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v6.json`))throw Error(`Not a manifest.json v6`);return e}function d(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v7`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v7.json`))throw Error(`Not a manifest.json v7`);return e}function f(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v8`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v8.json`))throw Error(`Not a manifest.json v8`);return e}function p(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v9`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v9.json`))throw Error(`Not a manifest.json v9`);return e}function m(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v10`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v10.json`))throw Error(`Not a manifest.json v10`);return e}function h(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v11`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v11.json`))throw Error(`Not a manifest.json v11`);return e}function g(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v12`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v12.json`))throw Error(`Not a manifest.json v12`);return e}let _=[a,o,s,c,l,u,d,f,p,m,h,g];function v(e){let t=e.metadata;if(!t)throw Error(r);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v`))throw Error(r);let a=i(n);if(a===null)throw Error(r);let o=_[a-1];if(!o)throw Error(`Unsupported manifest version: ${a}`);return o(e)}})),gr=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),_r=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.parseRunResultsV1=a,e.parseRunResultsV2=o,e.parseRunResultsV3=s,e.parseRunResultsV4=c,e.parseRunResultsV5=l,e.parseRunResultsV6=u,e.parseRunResults=f,n(gr(),e);let r=`Not a run-results.json`;function i(e){if(!e)return null;let t=e.match(/\/run-results\/v(\d+)\.json$/);return t?parseInt(t[1],10):null}function a(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v1`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v1.json`))throw Error(`Not a run-results.json v1`);return e}function o(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v2`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v2.json`))throw Error(`Not a run-results.json v2`);return e}function s(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v3`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v3.json`))throw Error(`Not a run-results.json v3`);return e}function c(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v4`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v4.json`))throw Error(`Not a run-results.json v4`);return e}function l(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v5`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v5.json`))throw Error(`Not a run-results.json v5`);return e}function u(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v6`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v6.json`))throw Error(`Not a run-results.json v6`);return e}let d=[a,o,s,c,l,u];function f(e){let t=e.metadata;if(!t)throw Error(r);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v`))throw Error(r);let a=i(n);if(a===null)throw Error(r);let o=d[a-1];if(!o)throw Error(`Unsupported run-results version: ${a}`);return o(e)}})),vr=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),yr=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.parseCatalogV1=a,e.parseCatalog=o,n(vr(),e);let r=`Not a catalog.json`;function i(e){if(!e)return null;let t=e.match(/\/catalog\/v(\d+)\.json$/);return t?parseInt(t[1],10):null}function a(e){let t=e.metadata;if(!t)throw Error(`Not a catalog.json v1`);let n=t.dbt_schema_version;if(!n||!n.includes(`/catalog/v1.json`))throw Error(`Not a catalog.json v1`);return e}function o(e){let t=e.metadata;if(!t)throw Error(r);let n=t.dbt_schema_version;if(!n||!n.includes(`/catalog/v`))throw Error(r);let o=i(n);if(o===null)throw Error(r);switch(o){case 1:return a(e);default:throw Error(`Unsupported catalog version: ${o}`)}}})),br=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),xr=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.parseSourcesV1=a,e.parseSourcesV2=o,e.parseSourcesV3=s,e.parseSources=c,n(br(),e);let r=`Not a sources.json`;function i(e){if(!e)return null;let t=e.match(/\/sources\/v(\d+)\.json$/);return t?parseInt(t[1],10):null}function a(e){let t=e.metadata;if(!t)throw Error(`Not a sources.json v1`);let n=t.dbt_schema_version;if(!n||!n.includes(`/sources/v1.json`))throw Error(`Not a sources.json v1`);return e}function o(e){let t=e.metadata;if(!t)throw Error(`Not a sources.json v2`);let n=t.dbt_schema_version;if(!n||!n.includes(`/sources/v2.json`))throw Error(`Not a sources.json v2`);return e}function s(e){let t=e.metadata;if(!t)throw Error(`Not a sources.json v3`);let n=t.dbt_schema_version;if(!n||!n.includes(`/sources/v3.json`))throw Error(`Not a sources.json v3`);return e}function c(e){let t=e.metadata;if(!t)throw Error(r);let n=t.dbt_schema_version;if(!n||!n.includes(`/sources/v`))throw Error(r);let c=i(n);if(c===null)throw Error(r);switch(c){case 1:return a(e);case 2:return o(e);case 3:return s(e);default:throw Error(`Unsupported sources version: ${c}`)}}}));function Sr(){return{total_execution_time:0,total_nodes:0,nodes_by_status:{},node_executions:[]}}function Cr(e){let{manifestJson:t,runResultsJson:n,catalogJson:r,sourcesJson:i,manifest:a,runResults:o}=e,s=V(),c=new jt(a),l=Rn(t),u=o==null?null:new $t(o,c,l),d=V()-s,f=V(),p=u?.getSummary()??Sr(),m=Wn(t),h=u?.getGanttData()??[],g=u?.getNodeExecutions()??[],_=g.map(e=>e.started_at?new Date(e.started_at).getTime():null).filter(e=>e!==null),v=_.length>0?Math.min(..._):null,y=p.node_executions.length===0?void 0:cn(p.node_executions,{mode:`top_n`,top:5,graph:c}),b=c.getSummary(),x=new Map(h.map(e=>[e.unique_id,e])),S=new Map(g.map(e=>[e.unique_id,e])),C=c.getGraph(),{resources:w,dependencyIndex:ee}=pr(c,S,m,l,{catalogJson:r,sourcesJson:i}),te=In(t,g,C),T=h.map(e=>Xn(e,c,C,m,l)),ne=$n(T,C,m,l),re=er([...T,...ne],C,te,m,l),ie=[...T,...ne,...re].sort(q),ae=Vn(C,ie.map(e=>e.unique_id)),oe=new Map(w.map(e=>[e.uniqueId,e.semantics])),se=g.map(e=>{let t=C.hasNode(e.unique_id)?C.getNodeAttributes(e.unique_id):void 0,n=x.get(e.unique_id),r=oe.get(e.unique_id);return{uniqueId:e.unique_id,name:String(t?.name||e.unique_id),resourceType:String(t?.resource_type||G(e.unique_id)),packageName:(()=>{let n=t?.package_name;return typeof n==`string`&&n.length>0?n:W(e.unique_id)})(),path:typeof t?.original_file_path==`string`?t.original_file_path:typeof t?.path==`string`?t.path:null,status:U(e.status),statusTone:H(e.status),executionTime:e.execution_time??0,threadId:typeof e.thread_id==`string`?e.thread_id:null,start:n?.start??null,end:n?.end??null,...e.adapterMetrics==null?{}:{adapterMetrics:e.adapterMetrics},...e.adapterResponseFields==null?{}:{adapterResponseFields:e.adapterResponseFields},...r==null?{}:{semantics:r}}}).sort((e,t)=>t.executionTime-e.executionTime),ce=Bt(g.map(e=>e.adapterMetrics)),le=zn(w),ue=Bn(p,g),de=Hn(se),fe=w.find(e=>e.resourceType===`model`)?.uniqueId??w[0]?.uniqueId??null;return{analysis:{summary:p,projectName:te,warehouseType:l,runStartedAt:v,ganttData:ie,bottlenecks:y,graphSummary:{totalNodes:b.total_nodes,totalEdges:b.total_edges,hasCycles:b.has_cycles,nodesByType:b.nodes_by_type},resources:w,resourceGroups:le,executions:se,statusBreakdown:ue,threadStats:de,dependencyIndex:ee,timelineAdjacency:ae,selectedResourceId:fe,invocationId:n==null?null:Ln(n),...ce==null?{}:{adapterTotals:ce}},timings:{graphBuildMs:d,snapshotBuildMs:V()-f},graph:c}}function wr(e){let t=e.split(/\s+/).filter(Boolean),n=[],r,i,a,o;for(let e of t)e.startsWith(`type:`)?r=e.slice(5):e.startsWith(`package:`)?i=e.slice(8):e.startsWith(`tag:`)?a=e.slice(4):e.startsWith(`path:`)?o=e.slice(5):e.startsWith(`owner:`)||e.startsWith(`source:`)?n.push(e.slice(e.indexOf(`:`)+1)):n.push(e);return{terms:n,type:r,package:i,tag:a,path:o}}function Tr(e,t,n,r,i){if(e.resource_type===`field`||t&&!t.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean).includes(e.resource_type.toLowerCase())||n&&(e.package_name||``)!==n)return!1;if(r){let t=r.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean),n=(e.tags||[]).map(e=>e.toLowerCase());if(!t.some(e=>n.includes(e)))return!1}return!(i&&!(e.path||``).includes(i))}var Er=hr(),Dr=_r(),Or=yr(),kr=xr();let X={accent:`#635BFF`,text:`#171C28`,textSoft:`#6B7385`,bg:`#F6F7FB`,bgSoft:`#FFFFFF`,borderDefault:`#D7DCE7`,borderSubtle:`#E6E9F0`,slate:`#64748B`,rose:`#C0352B`,mint:`#0F8A4B`,amber:`#A56315`},Z={accent:`#8A7CFF`,text:`#F3F6FC`,textSoft:`#98A3BC`,bg:`#0D1120`,bgSoft:`#151A2E`,borderDefault:`#313A58`,borderSubtle:`#262E47`,slate:`#8690AA`,rose:`#FF8D86`,mint:`#59D38C`,amber:`#F5B95C`};X.mint,X.rose,X.slate,X.rose,X.mint,X.rose,X.amber,X.slate,Z.mint,Z.rose,Z.slate,Z.rose,Z.mint,Z.rose,Z.amber,Z.slate,X.text,X.textSoft,X.slate,X.accent,Z.text,Z.textSoft,Z.slate,Z.accent;let Ar=new Set([`model`,`seed`,`snapshot`,`source`,`source_freshness`,`test`,`unit_test`,`metric`,`semantic_model`]),jr=new Set([`test`,`unit_test`]);[...Ar].filter(e=>!jr.has(e)).sort((e,t)=>e.localeCompare(t));function Mr(e,t){if(!t)return!0;let n=t.trim().toLowerCase();if(!n)return!0;let r=wr(n);if(!Tr({unique_id:e.uniqueId,resource_type:e.resourceType,name:e.name,package_name:e.packageName,tags:e.tags,path:e.path??``},r.type,r.package,r.tag,r.path))return!1;let i=[e.name,e.resourceType,e.packageName,...e.tags??[],e.path??``,e.originalFilePath??``,e.patchPath??``,e.uniqueId].map(e=>e.toLowerCase());return r.terms.every(e=>i.some(t=>t.includes(e.toLowerCase())))}function Nr(e){let t=e.origin;if(t===``||t===`null`)return!0;try{return t===globalThis.location.origin}catch{return!1}}function Q(){return performance.now()}let $=null,Pr=null,Fr=`No analysis loaded`;function Ir(e,t){return{type:`analysis-error`,protocolVersion:4,requestId:e,message:t}}function Lr(e,t){return{type:`resource-code-error`,protocolVersion:4,requestId:e,message:t}}function Rr(e,t){return{type:`search-resources-error`,protocolVersion:4,requestId:e,message:t}}function zr(e){let t=new TextDecoder().decode(e);return JSON.parse(t)}function Br(e){return e==null?void 0:zr(e)}function Vr(e,t){let n=e.getGraph();if(!n.hasNode(t))return{compiledCode:null,rawCode:null};let r=n.getNodeAttributes(t);return{compiledCode:typeof r.compiled_code==`string`?r.compiled_code:null,rawCode:typeof r.raw_code==`string`?r.raw_code:typeof r.raw_sql==`string`?r.raw_sql:null}}function Hr(e){if(e.protocolVersion!==4)return Rr(e.requestId,`Unsupported protocol version: ${e.protocolVersion}`);if(!Pr)return Rr(e.requestId,Fr);let t=Pr.filter(t=>Mr(t,e.query)).slice(0,8);return{type:`search-resources-ready`,protocolVersion:4,requestId:e.requestId,resources:t}}function Ur(e){if(e.protocolVersion!==4)return Lr(e.requestId,`Unsupported protocol version: ${e.protocolVersion}`);if(!$)return Lr(e.requestId,Fr);let{compiledCode:t,rawCode:n}=Vr($,e.uniqueId);return{type:`resource-code-ready`,protocolVersion:4,requestId:e.requestId,compiledCode:t,rawCode:n}}async function Wr(e){if(e.protocolVersion!==4)return Ir(e.requestId,`Unsupported protocol version: ${e.protocolVersion}`);try{$=null,Pr=null;let t=Q(),n=Q(),r=zr(e.artifactBuffers.manifestBytes),i=Br(e.artifactBuffers.runResultsBytes),a=Br(e.artifactBuffers.catalogBytes),o=Br(e.artifactBuffers.sourcesBytes),s=Q()-n,c=Q(),l=(0,Er.parseManifest)(r),u=i==null?void 0:(0,Dr.parseRunResults)(i),d=a==null?void 0:(0,Or.parseCatalog)(a),f=o==null?void 0:(0,kr.parseSources)(o),p=Q()-c,{analysis:m,timings:h,graph:g}=Cr({manifestJson:r,runResultsJson:i,catalogJson:a,sourcesJson:o,manifest:l,runResults:u,catalog:d,sources:f});$=g,Pr=m.resources;let _={decodeMs:s,parseMs:p,graphBuildMs:h.graphBuildMs,snapshotBuildMs:h.snapshotBuildMs,totalWorkerMs:Q()-t};return{type:`analysis-ready`,protocolVersion:4,requestId:e.requestId,analysis:m,timings:_}}catch(t){return Ir(e.requestId,t instanceof Error?t.message:`Failed to analyze artifacts`)}}function Gr(e){return e.type===`get-resource-code`?Promise.resolve(Ur(e)):e.type===`search-resources`?Promise.resolve(Hr(e)):Wr(e)}typeof self<`u`&&(self.onmessage=e=>{Nr(e)&&Gr(e.data).then(e=>{self.postMessage(e)})})})();
|
|
1
|
+
(function(){var e=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),t=e(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,`defaultMaxListeners`,{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.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},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){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 p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}}))();function n(){let e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(let n in arguments[t])e[n]=arguments[t][n];return e}let r=n;typeof Object.assign==`function`&&(r=Object.assign);function i(e,t,n,r){let i=e._nodes.get(t),a=null;return i&&(a=r===`mixed`?i.out&&i.out[n]||i.undirected&&i.undirected[n]:r===`directed`?i.out&&i.out[n]:i.undirected&&i.undirected[n]),a}function a(e){return typeof e==`object`&&!!e}function o(e){let t;for(t in e)return!1;return!0}function s(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function c(e,t,n){let r={enumerable:!0,configurable:!0};typeof n==`function`?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function l(e){return!(!a(e)||e.attributes&&!Array.isArray(e.attributes))}function u(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function d(){let e=arguments,t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done){t=null;continue}break}while(!0);return r}}}function f(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var p=class extends Error{constructor(e){super(),this.name=`GraphError`,this.message=e}},m=class e extends p{constructor(t){super(t),this.name=`InvalidArgumentsGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}},h=class e extends p{constructor(t){super(t),this.name=`NotFoundGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}},g=class e extends p{constructor(t){super(t),this.name=`UsageGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}};function _(e,t){this.key=e,this.attributes=t,this.clear()}_.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function v(e,t){this.key=e,this.attributes=t,this.clear()}v.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function y(e,t){this.key=e,this.attributes=t,this.clear()}y.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function b(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}b.prototype.attach=function(){let e=`out`,t=`in`;this.undirected&&(e=t=`undirected`);let n=this.source.key,r=this.target.key;this.source[e][r]=this,!(this.undirected&&n===r)&&(this.target[t][n]=this)},b.prototype.attachMulti=function(){let e=`out`,t=`in`,n=this.source.key,r=this.target.key;this.undirected&&(e=t=`undirected`);let i=this.source[e],a=i[r];if(a===void 0){i[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}a.previous=this,this.next=a,i[r]=this,this.target[t][n]=this},b.prototype.detach=function(){let e=this.source.key,t=this.target.key,n=`out`,r=`in`;this.undirected&&(n=r=`undirected`),delete this.source[n][t],delete this.target[r][e]},b.prototype.detachMulti=function(){let e=this.source.key,t=this.target.key,n=`out`,r=`in`;this.undirected&&(n=r=`undirected`),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};function x(e,t,n,r,i,a,o){let s,c,l,u;if(r=``+r,n===0){if(s=e._nodes.get(r),!s)throw new h(`Graph.${t}: could not find the "${r}" node in the graph.`);l=i,u=a}else if(n===3){if(i=``+i,c=e._edges.get(i),!c)throw new h(`Graph.${t}: could not find the "${i}" edge in the graph.`);let n=c.source.key,d=c.target.key;if(r===n)s=c.target;else if(r===d)s=c.source;else throw new h(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${n}, ${d}).`);l=a,u=o}else{if(c=e._edges.get(r),!c)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`);s=n===1?c.source:c.target,l=i,u=a}return[s,l,u]}function S(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=x(this,t,n,e,r,i);return a.attributes[o]}}function C(e,t,n){e.prototype[t]=function(e,r){let[i]=x(this,t,n,e,r);return i.attributes}}function w(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=x(this,t,n,e,r,i);return a.attributes.hasOwnProperty(o)}}function ee(e,t,n){e.prototype[t]=function(e,r,i,a){let[o,s,c]=x(this,t,n,e,r,i,a);return o.attributes[s]=c,this.emit(`nodeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:s}),this}}function te(e,t,n){e.prototype[t]=function(e,r,i,a){let[o,s,c]=x(this,t,n,e,r,i,a);if(typeof c!=`function`)throw new m(`Graph.${t}: updater should be a function.`);let l=o.attributes;return l[s]=c(l[s]),this.emit(`nodeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:s}),this}}function T(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=x(this,t,n,e,r,i);return delete a.attributes[o],this.emit(`nodeAttributesUpdated`,{key:a.key,type:`remove`,attributes:a.attributes,name:o}),this}}function ne(e,t,n){e.prototype[t]=function(e,r,i){let[o,s]=x(this,t,n,e,r,i);if(!a(s))throw new m(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=s,this.emit(`nodeAttributesUpdated`,{key:o.key,type:`replace`,attributes:o.attributes}),this}}function re(e,t,n){e.prototype[t]=function(e,i,o){let[s,c]=x(this,t,n,e,i,o);if(!a(c))throw new m(`Graph.${t}: provided attributes are not a plain object.`);return r(s.attributes,c),this.emit(`nodeAttributesUpdated`,{key:s.key,type:`merge`,attributes:s.attributes,data:c}),this}}function ie(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=x(this,t,n,e,r,i);if(typeof o!=`function`)throw new m(`Graph.${t}: provided updater is not a function.`);return a.attributes=o(a.attributes),this.emit(`nodeAttributesUpdated`,{key:a.key,type:`update`,attributes:a.attributes}),this}}let ae=[{name:e=>`get${e}Attribute`,attacher:S},{name:e=>`get${e}Attributes`,attacher:C},{name:e=>`has${e}Attribute`,attacher:w},{name:e=>`set${e}Attribute`,attacher:ee},{name:e=>`update${e}Attribute`,attacher:te},{name:e=>`remove${e}Attribute`,attacher:T},{name:e=>`replace${e}Attributes`,attacher:ne},{name:e=>`merge${e}Attributes`,attacher:re},{name:e=>`update${e}Attributes`,attacher:ie}];function oe(e){ae.forEach(function({name:t,attacher:n}){n(e,t(`Node`),0),n(e,t(`Source`),1),n(e,t(`Target`),2),n(e,t(`Opposite`),3)})}function se(e,t,n){e.prototype[t]=function(e,r){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: 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.`);let o=``+e,s=``+r;if(r=arguments[2],a=i(this,o,s,n),!a)throw new h(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,a=this._edges.get(e),!a)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return a.attributes[r]}}function ce(e,t,n){e.prototype[t]=function(e){let r;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new g(`Graph.${t}: 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.`);let a=``+e,o=``+arguments[1];if(r=i(this,a,o,n),!r)throw new h(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,r=this._edges.get(e),!r)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return r.attributes}}function le(e,t,n){e.prototype[t]=function(e,r){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: 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.`);let o=``+e,s=``+r;if(r=arguments[2],a=i(this,o,s,n),!a)throw new h(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,a=this._edges.get(e),!a)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return a.attributes.hasOwnProperty(r)}}function ue(e,t,n){e.prototype[t]=function(e,r,a){let o;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new g(`Graph.${t}: 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.`);let s=``+e,c=``+r;if(r=arguments[2],a=arguments[3],o=i(this,s,c,n),!o)throw new h(`Graph.${t}: could not find an edge for the given path ("${s}" - "${c}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,o=this._edges.get(e),!o)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return o.attributes[r]=a,this.emit(`edgeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:r}),this}}function de(e,t,n){e.prototype[t]=function(e,r,a){let o;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new g(`Graph.${t}: 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.`);let s=``+e,c=``+r;if(r=arguments[2],a=arguments[3],o=i(this,s,c,n),!o)throw new h(`Graph.${t}: could not find an edge for the given path ("${s}" - "${c}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,o=this._edges.get(e),!o)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(typeof a!=`function`)throw new m(`Graph.${t}: updater should be a function.`);return o.attributes[r]=a(o.attributes[r]),this.emit(`edgeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:r}),this}}function fe(e,t,n){e.prototype[t]=function(e,r){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: 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.`);let o=``+e,s=``+r;if(r=arguments[2],a=i(this,o,s,n),!a)throw new h(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,a=this._edges.get(e),!a)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return delete a.attributes[r],this.emit(`edgeAttributesUpdated`,{key:a.key,type:`remove`,attributes:a.attributes,name:r}),this}}function pe(e,t,n){e.prototype[t]=function(e,r){let o;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: 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.`);let a=``+e,s=``+r;if(r=arguments[2],o=i(this,a,s,n),!o)throw new h(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,o=this._edges.get(e),!o)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(!a(r))throw new m(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=r,this.emit(`edgeAttributesUpdated`,{key:o.key,type:`replace`,attributes:o.attributes}),this}}function me(e,t,n){e.prototype[t]=function(e,o){let s;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: 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.`);let r=``+e,a=``+o;if(o=arguments[2],s=i(this,r,a,n),!s)throw new h(`Graph.${t}: could not find an edge for the given path ("${r}" - "${a}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,s=this._edges.get(e),!s)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(!a(o))throw new m(`Graph.${t}: provided attributes are not a plain object.`);return r(s.attributes,o),this.emit(`edgeAttributesUpdated`,{key:s.key,type:`merge`,attributes:s.attributes,data:o}),this}}function he(e,t,n){e.prototype[t]=function(e,r){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: 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.`);let o=``+e,s=``+r;if(r=arguments[2],a=i(this,o,s,n),!a)throw new h(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: 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(e=``+e,a=this._edges.get(e),!a)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(typeof r!=`function`)throw new m(`Graph.${t}: provided updater is not a function.`);return a.attributes=r(a.attributes),this.emit(`edgeAttributesUpdated`,{key:a.key,type:`update`,attributes:a.attributes}),this}}let ge=[{name:e=>`get${e}Attribute`,attacher:se},{name:e=>`get${e}Attributes`,attacher:ce},{name:e=>`has${e}Attribute`,attacher:le},{name:e=>`set${e}Attribute`,attacher:ue},{name:e=>`update${e}Attribute`,attacher:de},{name:e=>`remove${e}Attribute`,attacher:fe},{name:e=>`replace${e}Attributes`,attacher:pe},{name:e=>`merge${e}Attributes`,attacher:me},{name:e=>`update${e}Attributes`,attacher:he}];function _e(e){ge.forEach(function({name:t,attacher:n}){n(e,t(`Edge`),`mixed`),n(e,t(`DirectedEdge`),`directed`),n(e,t(`UndirectedEdge`),`undirected`)})}let ve=[{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 ye(e,t,n,r){let i=!1;for(let a in t){if(a===r)continue;let o=t[a];if(i=n(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&i)return o.key}}function be(e,t,n,r){let i,a,o,s=!1;for(let c in t)if(c!==r){i=t[c];do{if(a=i.source,o=i.target,s=n(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),e&&s)return i.key;i=i.next}while(i!==void 0)}}function xe(e,t){let n=Object.keys(e),r=n.length,i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=r)return{done:!0};let o=n[a++];if(o===t){i=void 0;continue}i=e[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function Se(e,t,n,r){let i=t[n];if(!i)return;let a=i.source,o=i.target;if(r(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&e)return i.key}function Ce(e,t,n,r){let i=t[n];if(!i)return;let a=!1;do{if(a=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&a)return i.key;i=i.next}while(i!==void 0)}function we(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let e={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:e}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function Te(e,t){if(e.size===0)return[];if(t===`mixed`||t===e.type)return Array.from(e._edges.keys());let n=t===`undirected`?e.undirectedSize:e.directedSize,r=Array(n),i=t===`undirected`,a=e._edges.values(),o=0,s,c;for(;s=a.next(),s.done!==!0;)c=s.value,c.undirected===i&&(r[o++]=c.key);return r}function Ee(e,t,n,r){if(t.size===0)return;let i=n!==`mixed`&&n!==t.type,a=n===`undirected`,o,s,c=!1,l=t._edges.values();for(;o=l.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;let{key:t,attributes:n,source:l,target:u}=s;if(c=r(t,n,l.key,u.key,l.attributes,u.attributes,s.undirected),e&&c)return t}}function De(e,t){if(e.size===0)return f();let n=t!==`mixed`&&t!==e.type,r=t===`undirected`,i=e._edges.values();return{[Symbol.iterator](){return this},next(){let e,t;for(;;){if(e=i.next(),e.done)return e;if(t=e.value,!(n&&t.undirected!==r))break}return{value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected},done:!1}}}}function Oe(e,t,n,r,i,a){let o=t?be:ye,s;if(n!==`undirected`&&(r!==`out`&&(s=o(e,i.in,a),e&&s)||r!==`in`&&(s=o(e,i.out,a,r?void 0:i.key),e&&s))||n!==`directed`&&(s=o(e,i.undirected,a),e&&s))return s}function ke(e,t,n,r){let i=[];return Oe(!1,e,t,n,r,function(e){i.push(e)}),i}function Ae(e,t,n){let r=f();return e!==`undirected`&&(t!==`out`&&n.in!==void 0&&(r=d(r,xe(n.in))),t!==`in`&&n.out!==void 0&&(r=d(r,xe(n.out,t?void 0:n.key)))),e!==`directed`&&n.undirected!==void 0&&(r=d(r,xe(n.undirected))),r}function je(e,t,n,r,i,a,o){let s=n?Ce:Se,c;if(t!==`undirected`&&(i.in!==void 0&&r!==`out`&&(c=s(e,i.in,a,o),e&&c)||i.out!==void 0&&r!==`in`&&(r||i.key!==a)&&(c=s(e,i.out,a,o),e&&c))||t!==`directed`&&i.undirected!==void 0&&(c=s(e,i.undirected,a,o),e&&c))return c}function Me(e,t,n,r,i){let a=[];return je(!1,e,t,n,r,i,function(e){a.push(e)}),a}function Ne(e,t,n,r){let i=f();return e!==`undirected`&&(n.in!==void 0&&t!==`out`&&r in n.in&&(i=d(i,we(n.in,r))),n.out!==void 0&&t!==`in`&&r in n.out&&(t||n.key!==r)&&(i=d(i,we(n.out,r)))),e!==`directed`&&n.undirected!==void 0&&r in n.undirected&&(i=d(i,we(n.undirected,r))),i}function Pe(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return[];if(!arguments.length)return Te(this,r);if(arguments.length===1){e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new h(`Graph.${n}: could not find the "${e}" node in the graph.`);return ke(this.multi,r===`mixed`?this.type:r,i,t)}if(arguments.length===2){e=``+e,t=``+t;let a=this._nodes.get(e);if(!a)throw new h(`Graph.${n}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.${n}: could not find the "${t}" target node in the graph.`);return Me(r,this.multi,i,a,t)}throw new m(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Fe(e,t){let{name:n,type:r,direction:i}=t,a=`forEach`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t,n){if(!(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)){if(arguments.length===1)return n=e,Ee(!1,this,r,n);if(arguments.length===2){e=``+e,n=t;let o=this._nodes.get(e);if(o===void 0)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);return Oe(!1,this.multi,r===`mixed`?this.type:r,i,o,n)}if(arguments.length===3){e=``+e,t=``+t;let o=this._nodes.get(e);if(!o)throw new h(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.${a}: could not find the "${t}" target node in the graph.`);return je(!1,r,this.multi,i,o,t,n)}throw new m(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let o=`map`+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop(),n;if(e.length===0){let i=0;r!==`directed`&&(i+=this.undirectedSize),r!==`undirected`&&(i+=this.directedSize),n=Array(i);let a=0;e.push((e,r,i,o,s,c,l)=>{n[a++]=t(e,r,i,o,s,c,l)})}else n=[],e.push((e,r,i,a,o,s,c)=>{n.push(t(e,r,i,a,o,s,c))});return this[a].apply(this,e),n};let s=`filter`+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop(),n=[];return e.push((e,r,i,a,o,s,c)=>{t(e,r,i,a,o,s,c)&&n.push(e)}),this[a].apply(this,e),n};let c=`reduce`+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(){let e=Array.prototype.slice.call(arguments);if(e.length<2||e.length>4)throw new m(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${e.length}).`);if(typeof e[e.length-1]==`function`&&typeof e[e.length-2]!=`function`)throw new m(`Graph.${c}: 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.`);let t,n;e.length===2?(t=e[0],n=e[1],e=[]):e.length===3?(t=e[1],n=e[2],e=[e[0]]):e.length===4&&(t=e[2],n=e[3],e=[e[0],e[1]]);let r=n;return e.push((e,n,i,a,o,s,c)=>{r=t(r,e,n,i,a,o,s,c)}),this[a].apply(this,e),r}}function Ie(e,t){let{name:n,type:r,direction:i}=t,a=`find`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t,n){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return!1;if(arguments.length===1)return n=e,Ee(!0,this,r,n);if(arguments.length===2){e=``+e,n=t;let o=this._nodes.get(e);if(o===void 0)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);return Oe(!0,this.multi,r===`mixed`?this.type:r,i,o,n)}if(arguments.length===3){e=``+e,t=``+t;let o=this._nodes.get(e);if(!o)throw new h(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.${a}: could not find the "${t}" target node in the graph.`);return je(!0,r,this.multi,i,o,t,n)}throw new m(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let o=`some`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((e,n,r,i,a,o,s)=>t(e,n,r,i,a,o,s)),!!this[a].apply(this,e)};let s=`every`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((e,n,r,i,a,o,s)=>!t(e,n,r,i,a,o,s)),!this[a].apply(this,e)}}function Le(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+`Entries`;e.prototype[a]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return f();if(!arguments.length)return De(this,r);if(arguments.length===1){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);return Ae(r,i,t)}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.${a}: could not find the "${t}" target node in the graph.`);return Ne(r,i,n,t)}throw new m(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Re(e){ve.forEach(t=>{Pe(e,t),Fe(e,t),Ie(e,t),Le(e,t)})}let ze=[{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 E(){this.A=null,this.B=null}E.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)},E.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function D(e,t,n,r,i){for(let a in r){let o=r[a],s=o.source,c=o.target,l=s===n?c:s;if(t&&t.has(l.key))continue;let u=i(l.key,l.attributes);if(e&&u)return l.key}}function Be(e,t,n,r,i){if(t!==`mixed`){if(t===`undirected`)return D(e,null,r,r.undirected,i);if(typeof n==`string`)return D(e,null,r,r[n],i)}let a=new E,o;if(t!==`undirected`){if(n!==`out`){if(o=D(e,null,r,r.in,i),e&&o)return o;a.wrap(r.in)}if(n!==`in`){if(o=D(e,a,r,r.out,i),e&&o)return o;a.wrap(r.out)}}if(t!==`directed`&&(o=D(e,a,r,r.undirected,i),e&&o))return o}function Ve(e,t,n){if(e!==`mixed`){if(e===`undirected`)return Object.keys(n.undirected);if(typeof t==`string`)return Object.keys(n[t])}let r=[];return Be(!1,e,t,n,function(e){r.push(e)}),r}function O(e,t,n){let r=Object.keys(n),i=r.length,a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return e&&e.wrap(n),{done:!0};let s=n[r[a++]],c=s.source,l=s.target;if(o=c===t?l:c,e&&e.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function He(e,t,n){if(e!==`mixed`){if(e===`undirected`)return O(null,n,n.undirected);if(typeof t==`string`)return O(null,n,n[t])}let r=f(),i=new E;return e!==`undirected`&&(t!==`out`&&(r=d(r,O(i,n,n.in))),t!==`in`&&(r=d(r,O(i,n,n.out)))),e!==`directed`&&(r=d(r,O(i,n,n.undirected))),r}function Ue(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(e){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return[];e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new h(`Graph.${n}: could not find the "${e}" node in the graph.`);return Ve(r===`mixed`?this.type:r,i,t)}}function We(e,t){let{name:n,type:r,direction:i}=t,a=`forEach`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return;e=``+e;let n=this._nodes.get(e);if(n===void 0)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);Be(!1,r===`mixed`?this.type:r,i,n,t)};let o=`map`+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(e,t){let n=[];return this[a](e,(e,r)=>{n.push(t(e,r))}),n};let s=`filter`+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(e,t){let n=[];return this[a](e,(e,r)=>{t(e,r)&&n.push(e)}),n};let c=`reduce`+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(e,t,n){if(arguments.length<3)throw new m(`Graph.${c}: 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.`);let r=n;return this[a](e,(e,n)=>{r=t(r,e,n)}),r}}function Ge(e,t){let{name:n,type:r,direction:i}=t,a=n[0].toUpperCase()+n.slice(1,-1),o=`find`+a;e.prototype[o]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return;e=``+e;let n=this._nodes.get(e);if(n===void 0)throw new h(`Graph.${o}: could not find the "${e}" node in the graph.`);return Be(!0,r===`mixed`?this.type:r,i,n,t)};let s=`some`+a;e.prototype[s]=function(e,t){return!!this[o](e,t)};let c=`every`+a;e.prototype[c]=function(e,t){return!this[o](e,(e,n)=>!t(e,n))}}function Ke(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+`Entries`;e.prototype[a]=function(e){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return f();e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);return He(r===`mixed`?this.type:r,i,t)}}function qe(e){ze.forEach(t=>{Ue(e,t),We(e,t),Ge(e,t),Ke(e,t)})}function k(e,t,n,r,i){let a=r._nodes.values(),o=r.type,s,c,l,u,d,f,p;for(;s=a.next(),s.done!==!0;){let r=!1;if(c=s.value,o!==`undirected`)for(l in u=c.out,u){d=u[l];do{if(f=d.target,r=!0,p=i(c.key,f.key,c.attributes,f.attributes,d.key,d.attributes,d.undirected),e&&p)return d;d=d.next}while(d)}if(o!==`directed`){for(l in u=c.undirected,u)if(!(t&&c.key>l)){d=u[l];do{if(f=d.target,f.key!==l&&(f=d.source),r=!0,p=i(c.key,f.key,c.attributes,f.attributes,d.key,d.attributes,d.undirected),e&&p)return d;d=d.next}while(d)}}if(n&&!r&&(p=i(c.key,null,c.attributes,null,null,null,null),e&&p))return null}}function Je(e,t){let n={key:e};return o(t.attributes)||(n.attributes=r({},t.attributes)),n}function Ye(e,t,n){let i={key:t,source:n.source.key,target:n.target.key};return o(n.attributes)||(i.attributes=r({},n.attributes)),e===`mixed`&&n.undirected&&(i.undirected=!0),i}function Xe(e){if(!a(e))throw new m(`Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.`);if(!(`key`in e))throw new m(`Graph.import: serialized node is missing its key.`);if(`attributes`in e&&(!a(e.attributes)||e.attributes===null))throw new m(`Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.`)}function Ze(e){if(!a(e))throw new m(`Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.`);if(!(`source`in e))throw new m(`Graph.import: serialized edge is missing its source.`);if(!(`target`in e))throw new m(`Graph.import: serialized edge is missing its target.`);if(`attributes`in e&&(!a(e.attributes)||e.attributes===null))throw new m(`Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.`);if(`undirected`in e&&typeof e.undirected!=`boolean`)throw new m(`Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.`)}let Qe=u(),$e=new Set([`directed`,`undirected`,`mixed`]),et=new Set([`domain`,`_events`,`_eventsCount`,`_maxListeners`]),tt=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:`directed`},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:`undirected`},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:`directed`},{name:e=>`${e}UndirectedEdgeWithKey`,type:`undirected`}],nt={allowSelfLoops:!0,multi:!1,type:`mixed`};function rt(e,t,n){if(n&&!a(n))throw new m(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=``+t,n||={},e._nodes.has(t))throw new g(`Graph.addNode: the "${t}" node already exist in the graph.`);let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit(`nodeAdded`,{key:t,attributes:n}),r}function it(e,t,n){let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit(`nodeAdded`,{key:t,attributes:n}),r}function at(e,t,n,r,i,o,s,c){if(!r&&e.type===`undirected`)throw new g(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type===`directed`)throw new g(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(c&&!a(c))throw new m(`Graph.${t}: invalid attributes. Expecting an object but got "${c}"`);if(o=``+o,s=``+s,c||={},!e.allowSelfLoops&&o===s)throw new g(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(o),u=e._nodes.get(s);if(!l)throw new h(`Graph.${t}: source node "${o}" not found.`);if(!u)throw new h(`Graph.${t}: target node "${s}" not found.`);let d={key:null,undirected:r,source:o,target:s,attributes:c};if(n)i=e._edgeKeyGenerator();else if(i=``+i,e._edges.has(i))throw new g(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?l.undirected[s]!==void 0:l.out[s]!==void 0))throw new g(`Graph.${t}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let f=new b(r,i,l,u,c);e._edges.set(i,f);let p=o===s;return r?(l.undirectedDegree++,u.undirectedDegree++,p&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,p&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?f.attachMulti():f.attach(),r?e._undirectedSize++:e._directedSize++,d.key=i,e.emit(`edgeAdded`,d),i}function ot(e,t,n,i,o,s,c,l,u){if(!i&&e.type===`undirected`)throw new g(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(i&&e.type===`directed`)throw new g(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(l){if(u){if(typeof l!=`function`)throw new m(`Graph.${t}: invalid updater function. Expecting a function but got "${l}"`)}else if(!a(l))throw new m(`Graph.${t}: invalid attributes. Expecting an object but got "${l}"`)}s=``+s,c=``+c;let d;if(u&&(d=l,l=void 0),!e.allowSelfLoops&&s===c)throw new g(`Graph.${t}: source & target are the same ("${s}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let f=e._nodes.get(s),p=e._nodes.get(c),h,_;if(!n&&(h=e._edges.get(o),h)){if((h.source.key!==s||h.target.key!==c)&&(!i||h.source.key!==c||h.target.key!==s))throw new g(`Graph.${t}: inconsistency detected when attempting to merge the "${o}" edge with "${s}" source & "${c}" target vs. ("${h.source.key}", "${h.target.key}").`);_=h}if(!_&&!e.multi&&f&&(_=i?f.undirected[c]:f.out[c]),_){let t=[_.key,!1,!1,!1];if(u?!d:!l)return t;if(u){let t=_.attributes;_.attributes=d(t),e.emit(`edgeAttributesUpdated`,{type:`replace`,key:_.key,attributes:_.attributes})}else r(_.attributes,l),e.emit(`edgeAttributesUpdated`,{type:`merge`,key:_.key,attributes:_.attributes,data:l});return t}l||={},u&&d&&(l=d(l));let v={key:null,undirected:i,source:s,target:c,attributes:l};if(n)o=e._edgeKeyGenerator();else if(o=``+o,e._edges.has(o))throw new g(`Graph.${t}: the "${o}" edge already exists in the graph.`);let y=!1,x=!1;f||(f=it(e,s,{}),y=!0,s===c&&(p=f,x=!0)),p||(p=it(e,c,{}),x=!0),h=new b(i,o,f,p,l),e._edges.set(o,h);let S=s===c;return i?(f.undirectedDegree++,p.undirectedDegree++,S&&(f.undirectedLoops++,e._undirectedSelfLoopCount++)):(f.outDegree++,p.inDegree++,S&&(f.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),i?e._undirectedSize++:e._directedSize++,v.key=o,e.emit(`edgeAdded`,v),[o,!0,y,x]}function A(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:i}=t,a=t.undirected,o=n===r;a?(n.undirectedDegree--,r.undirectedDegree--,o&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,o&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),a?e._undirectedSize--:e._directedSize--,e.emit(`edgeDropped`,{key:t.key,attributes:i,source:n.key,target:r.key,undirected:a})}var j=class e extends t.EventEmitter{constructor(e){if(super(),e=r({},nt,e),typeof e.multi!=`boolean`)throw new m(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!$e.has(e.type))throw new m(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!=`boolean`)throw new m(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let t=e.type===`mixed`?_:e.type===`directed`?v:y;s(this,`NodeDataClass`,t);let n=`geid_`+Qe()+`_`,i=0;s(this,`_attributes`,{}),s(this,`_nodes`,new Map),s(this,`_edges`,new Map),s(this,`_directedSize`,0),s(this,`_undirectedSize`,0),s(this,`_directedSelfLoopCount`,0),s(this,`_undirectedSelfLoopCount`,0),s(this,`_edgeKeyGenerator`,()=>{let e;do e=n+ i++;while(this._edges.has(e));return e}),s(this,`_options`,e),et.forEach(e=>s(this,e,this[e])),c(this,`order`,()=>this._nodes.size),c(this,`size`,()=>this._edges.size),c(this,`directedSize`,()=>this._directedSize),c(this,`undirectedSize`,()=>this._undirectedSize),c(this,`selfLoopCount`,()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),c(this,`directedSelfLoopCount`,()=>this._directedSelfLoopCount),c(this,`undirectedSelfLoopCount`,()=>this._undirectedSelfLoopCount),c(this,`multi`,this._options.multi),c(this,`type`,this._options.type),c(this,`allowSelfLoops`,this._options.allowSelfLoops),c(this,`implementation`,()=>`graphology`)}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(``+e)}hasDirectedEdge(e,t){if(this.type===`undirected`)return!1;if(arguments.length===1){let t=``+e,n=this._edges.get(t);return!!n&&!n.undirected}else if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new m(`Graph.hasDirectedEdge: invalid arity (${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.`)}hasUndirectedEdge(e,t){if(this.type===`directed`)return!1;if(arguments.length===1){let t=``+e,n=this._edges.get(t);return!!n&&n.undirected}else if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new m(`Graph.hasDirectedEdge: invalid arity (${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.`)}hasEdge(e,t){if(arguments.length===1){let t=``+e;return this._edges.has(t)}else if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.out!==void 0&&n.out.hasOwnProperty(t)||n.undirected!==void 0&&n.undirected.hasOwnProperty(t):!1}throw new m(`Graph.hasEdge: invalid arity (${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.`)}directedEdge(e,t){if(this.type===`undirected`)return;if(e=``+e,t=``+t,this.multi)throw new g(`Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.`);let n=this._nodes.get(e);if(!n)throw new h(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);let r=n.out&&n.out[t]||void 0;if(r)return r.key}undirectedEdge(e,t){if(this.type===`directed`)return;if(e=``+e,t=``+t,this.multi)throw new g(`Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.`);let n=this._nodes.get(e);if(!n)throw new h(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);let r=n.undirected&&n.undirected[t]||void 0;if(r)return r.key}edge(e,t){if(this.multi)throw new g(`Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.`);e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.edge: could not find the "${t}" target node in the graph.`);let r=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(r)return r.key}areDirectedNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type===`undirected`?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type===`undirected`?!1:t in n.out}areInNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type===`undirected`?!1:t in n.in}areUndirectedNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type===`directed`?!1:t in n.undirected}areNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&(t in n.in||t in n.out)||this.type!==`directed`&&t in n.undirected}areInboundNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.in||this.type!==`directed`&&t in n.undirected}areOutboundNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.out||this.type!==`directed`&&t in n.undirected}inDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree}outDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.outDegree}directedDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree+t.outDegree}undirectedDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type===`directed`?0:t.undirectedDegree}inboundDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.inDegree),n}outboundDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.outDegree),n}degree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`directed`?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.inDegree,r+=t.directedLoops),n-r}outboundDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.outDegree,r+=t.directedLoops),n-r}degreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.inDegree+t.outDegree,r+=t.directedLoops*2),n-r}source(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=``+e,t=``+t;let n=this._edges.get(t);if(!n)throw new h(`Graph.opposite: could not find the "${t}" edge in the graph.`);let r=n.source.key,i=n.target.key;if(e===r)return i;if(e===i)return r;throw new h(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${r}, ${i}).`)}hasExtremity(e,t){e=``+e,t=``+t;let n=this._edges.get(e);if(!n)throw new h(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return rt(this,e,t).key}mergeNode(e,t){if(t&&!a(t))throw new m(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=``+e,t||={};let n=this._nodes.get(e);return n?(t&&(r(n.attributes,t),this.emit(`nodeAttributesUpdated`,{type:`merge`,key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit(`nodeAdded`,{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!=`function`)throw new m(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=``+e;let n=this._nodes.get(e);if(n){if(t){let r=n.attributes;n.attributes=t(r),this.emit(`nodeAttributesUpdated`,{type:`replace`,key:e,attributes:n.attributes})}return[e,!1]}let r=t?t({}):{};return n=new this.NodeDataClass(e,r),this._nodes.set(e,n),this.emit(`nodeAdded`,{key:e,attributes:r}),[e,!0]}dropNode(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!==`undirected`){for(let e in t.out){n=t.out[e];do A(this,n),n=n.next;while(n)}for(let e in t.in){n=t.in[e];do A(this,n),n=n.next;while(n)}}if(this.type!==`directed`)for(let e in t.undirected){n=t.undirected[e];do A(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit(`nodeDropped`,{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){let e=``+arguments[0],n=``+arguments[1];if(t=i(this,e,n,this.type),!t)throw new h(`Graph.dropEdge: could not find the "${e}" -> "${n}" edge in the graph.`)}else if(e=``+e,t=this._edges.get(e),!t)throw new h(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return A(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new g(`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 g(`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.`);e=``+e,t=``+t;let n=i(this,e,t,`directed`);if(!n)throw new h(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return A(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new g(`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 g(`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.`);let n=i(this,e,t,`undirected`);if(!n)throw new h(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return A(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit(`cleared`)}clearEdges(){let e=this._nodes.values(),t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit(`edgesCleared`)}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit(`attributesUpdated`,{type:`set`,attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!=`function`)throw new m(`Graph.updateAttribute: updater should be a function.`);let n=this._attributes[e];return this._attributes[e]=t(n),this.emit(`attributesUpdated`,{type:`set`,attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit(`attributesUpdated`,{type:`remove`,attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!a(e))throw new m(`Graph.replaceAttributes: provided attributes are not a plain object.`);return this._attributes=e,this.emit(`attributesUpdated`,{type:`replace`,attributes:this._attributes}),this}mergeAttributes(e){if(!a(e))throw new m(`Graph.mergeAttributes: provided attributes are not a plain object.`);return r(this._attributes,e),this.emit(`attributesUpdated`,{type:`merge`,attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!=`function`)throw new m(`Graph.updateAttributes: provided updater is not a function.`);return this._attributes=e(this._attributes),this.emit(`attributesUpdated`,{type:`update`,attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!=`function`)throw new m(`Graph.updateEachNodeAttributes: expecting an updater function.`);if(t&&!l(t))throw new m(`Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}`);let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,i.attributes=e(i.key,i.attributes);this.emit(`eachNodeAttributesUpdated`,{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!=`function`)throw new m(`Graph.updateEachEdgeAttributes: expecting an updater function.`);if(t&&!l(t))throw new m(`Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}`);let n=this._edges.values(),r,i,a,o;for(;r=n.next(),r.done!==!0;)i=r.value,a=i.source,o=i.target,i.attributes=e(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected);this.emit(`eachEdgeAttributesUpdated`,{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!=`function`)throw new m(`Graph.forEachAdjacencyEntry: expecting a callback.`);k(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!=`function`)throw new m(`Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.`);k(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!=`function`)throw new m(`Graph.forEachAssymetricAdjacencyEntry: expecting a callback.`);k(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!=`function`)throw new m(`Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.`);k(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!=`function`)throw new m(`Graph.forEachNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)r=n.value,e(r.key,r.attributes)}findNode(e){if(typeof e!=`function`)throw new m(`Graph.findNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,e(r.key,r.attributes))return r.key}mapNodes(e){if(typeof e!=`function`)throw new m(`Graph.mapNode: expecting a callback.`);let t=this._nodes.values(),n,r,i=Array(this.order),a=0;for(;n=t.next(),n.done!==!0;)r=n.value,i[a++]=e(r.key,r.attributes);return i}someNode(e){if(typeof e!=`function`)throw new m(`Graph.someNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,e(r.key,r.attributes))return!0;return!1}everyNode(e){if(typeof e!=`function`)throw new m(`Graph.everyNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,!e(r.key,r.attributes))return!1;return!0}filterNodes(e){if(typeof e!=`function`)throw new m(`Graph.filterNodes: expecting a callback.`);let t=this._nodes.values(),n,r,i=[];for(;n=t.next(),n.done!==!0;)r=n.value,e(r.key,r.attributes)&&i.push(r.key);return i}reduceNodes(e,t){if(typeof e!=`function`)throw new m(`Graph.reduceNodes: expecting a callback.`);if(arguments.length<2)throw new m(`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.`);let n=t,r=this._nodes.values(),i,a;for(;i=r.next(),i.done!==!0;)a=i.value,n=e(n,a.key,a.attributes);return n}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let t=e.next();if(t.done)return t;let n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}}}export(){let e=Array(this._nodes.size),t=0;this._nodes.forEach((n,r)=>{e[t++]=Je(r,n)});let n=Array(this._edges.size);return t=0,this._edges.forEach((e,r)=>{n[t++]=Ye(this.type,r,e)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(t,n=!1){if(t instanceof e)return t.forEachNode((e,t)=>{n?this.mergeNode(e,t):this.addNode(e,t)}),t.forEachEdge((e,t,r,i,a,o,s)=>{n?s?this.mergeUndirectedEdgeWithKey(e,r,i,t):this.mergeDirectedEdgeWithKey(e,r,i,t):s?this.addUndirectedEdgeWithKey(e,r,i,t):this.addDirectedEdgeWithKey(e,r,i,t)}),this;if(!a(t))throw new m(`Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.`);if(t.attributes){if(!a(t.attributes))throw new m(`Graph.import: invalid attributes. Expecting a plain object.`);n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,o,s,c;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new m(`Graph.import: invalid nodes. Expecting an array.`);for(r=0,i=o.length;r<i;r++){s=o[r],Xe(s);let{key:e,attributes:t}=s;n?this.mergeNode(e,t):this.addNode(e,t)}}if(t.edges){let e=!1;if(this.type===`undirected`&&(e=!0),o=t.edges,!Array.isArray(o))throw new m(`Graph.import: invalid edges. Expecting an array.`);for(r=0,i=o.length;r<i;r++){c=o[r],Ze(c);let{source:t,target:i,attributes:a,undirected:s=e}=c,l;`key`in c?(l=n?s?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:s?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,l.call(this,c.key,t,i,a)):(l=n?s?this.mergeUndirectedEdge:this.mergeDirectedEdge:s?this.addUndirectedEdge:this.addDirectedEdge,l.call(this,t,i,a))}}return this}nullCopy(t){let n=new e(r({},this._options,t));return n.replaceAttributes(r({},this.getAttributes())),n}emptyCopy(e){let t=this.nullCopy(e);return this._nodes.forEach((e,n)=>{let i=r({},e.attributes);e=new t.NodeDataClass(n,i),t._nodes.set(n,e)}),t}copy(e){if(e||={},typeof e.type==`string`&&e.type!==this.type&&e.type!==`mixed`)throw new g(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi==`boolean`&&e.multi!==this.multi&&e.multi!==!0)throw new g(`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 e.allowSelfLoops==`boolean`&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new g(`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.`);let t=this.emptyCopy(e),n=this._edges.values(),i,a;for(;i=n.next(),i.done!==!0;)a=i.value,at(t,`copy`,!1,a.undirected,a.key,a.source.key,a.target.key,r({},a.attributes));return t}toJSON(){return this.export()}toString(){return`[object Graph]`}inspect(){let e={};this._nodes.forEach((t,n)=>{e[n]=t.attributes});let t={},n={};this._edges.forEach((e,r)=>{let i=e.undirected?`--`:`->`,a=``,o=e.source.key,s=e.target.key,c;e.undirected&&o>s&&(c=o,o=s,s=c);let l=`(${o})${i}(${s})`;r.startsWith(`geid_`)?this.multi&&(n[l]===void 0?n[l]=0:n[l]++,a+=`${n[l]}. `):a+=`[${r}]: `,a+=l,t[a]=e.attributes});let r={};for(let e in this)this.hasOwnProperty(e)&&!et.has(e)&&typeof this[e]!=`function`&&typeof e!=`symbol`&&(r[e]=this[e]);return r.attributes=this._attributes,r.nodes=e,r.edges=t,s(r,`constructor`,this.constructor),r}};typeof Symbol<`u`&&(j.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=j.prototype.inspect),tt.forEach(e=>{[`add`,`merge`,`update`].forEach(t=>{let n=e.name(t),r=t===`add`?at:ot;e.generateKey?j.prototype[n]=function(i,a,o){return r(this,n,!0,(e.type||this.type)===`undirected`,null,i,a,o,t===`update`)}:j.prototype[n]=function(i,a,o,s){return r(this,n,!1,(e.type||this.type)===`undirected`,i,a,o,s,t===`update`)}})}),oe(j),_e(j),Re(j),qe(j);var M=class extends j{constructor(e){let t=r({type:`directed`},e);if(`multi`in t&&t.multi!==!1)throw new m(`DirectedGraph.from: inconsistent indication that the graph should be multi in given options!`);if(t.type!==`directed`)throw new m(`DirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},st=class extends j{constructor(e){let t=r({type:`undirected`},e);if(`multi`in t&&t.multi!==!1)throw new m(`UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!`);if(t.type!==`undirected`)throw new m(`UndirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},ct=class extends j{constructor(e){let t=r({multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new m(`MultiGraph.from: inconsistent indication that the graph should be simple in given options!`);super(t)}},lt=class extends j{constructor(e){let t=r({type:`directed`,multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new m(`MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!`);if(t.type!==`directed`)throw new m(`MultiDirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},ut=class extends j{constructor(e){let t=r({type:`undirected`,multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new m(`MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!`);if(t.type!==`undirected`)throw new m(`MultiUndirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}};function N(e){e.from=function(t,n){let i=new e(r({},t.options,n));return i.import(t),i}}N(j),N(M),N(st),N(ct),N(lt),N(ut),j.Graph=j,j.DirectedGraph=M,j.UndirectedGraph=st,j.MultiGraph=ct,j.MultiDirectedGraph=lt,j.MultiUndirectedGraph=ut,j.InvalidArgumentsGraphError=m,j.NotFoundGraphError=h,j.UsageGraphError=g;var dt=e(((e,t)=>{t.exports=function(e){return typeof e==`object`&&!!e&&typeof e.addUndirectedEdgeWithKey==`function`&&typeof e.dropNode==`function`&&typeof e.multi==`boolean`}})),ft=e(((e,t)=>{let n=dt();t.exports=function(e){if(!n(e))throw Error(`graphology-dag/has-cycle: the given graph is not a valid graphology instance.`);if(e.size===0)return!1;if(e.selfLoopCount!==0)return!0;let t={},r=[];function i(e){let n=t[e];if(n===void 0)r.push(e);else if(n===0)return!0;return!1}return e.someNode(n=>{if(t[n]===1)return!1;for(r.push(n);r.length!==0;){let n=r[r.length-1],a=t[n];if(a!==0){if(t[n]=0,e.someOutboundNeighbor(n,i))return!0}else a===0&&(r.pop(),t[n]=1)}return!1})}})),pt=e(((e,t)=>{let n=dt();t.exports=function(e,t,r){if(!n(e))throw 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;let i=e.outNeighbors(r);function a(e){i.push(e)}for(;i.length!==0;){let n=i.pop();if(n===t)return!0;e.forEachOutNeighbor(n,a)}return!1}})),mt=e((e=>{e.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<`u`,e.SYMBOL_SUPPORT=typeof Symbol<`u`})),ht=e(((e,t)=>{var n=mt(),r=n.ARRAY_BUFFER_SUPPORT,i=n.SYMBOL_SUPPORT;t.exports=function(e,t){var n,a,o,s,c;if(!e)throw Error(`obliterator/forEach: invalid iterable.`);if(typeof t!=`function`)throw Error(`obliterator/forEach: expecting a callback.`);if(Array.isArray(e)||r&&ArrayBuffer.isView(e)||typeof e==`string`||e.toString()===`[object Arguments]`){for(o=0,s=e.length;o<s;o++)t(e[o],o);return}if(typeof e.forEach==`function`){e.forEach(t);return}if(i&&Symbol.iterator in e&&typeof e.next!=`function`&&(e=e[Symbol.iterator]()),typeof e.next==`function`){for(n=e,o=0;c=n.next(),c.done!==!0;)t(c.value,o),o++;return}for(a in e)e.hasOwnProperty(a)&&t(e[a],a)}})),gt=e((e=>{var t=2**8-1,n=2**16-1,r=2**32-1,i=2**7-1,a=2**15-1,o=2**31-1;e.getPointerArray=function(e){var i=e-1;if(i<=t)return Uint8Array;if(i<=n)return Uint16Array;if(i<=r)return Uint32Array;throw Error(`mnemonist: Pointer Array of size > 4294967295 is not supported.`)},e.getSignedPointerArray=function(e){var t=e-1;return t<=i?Int8Array:t<=a?Int16Array:t<=o?Int32Array:Float64Array},e.getNumberType=function(e){return e===(e|0)?Math.sign(e)===-1?e<=127&&e>=-128?Int8Array:e<=32767&&e>=-32768?Int16Array:Int32Array:e<=255?Uint8Array:e<=65535?Uint16Array:Uint32Array:Float64Array};var s={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};e.getMinimalRepresentation=function(t,n){var r=null,i=0,a,o,c,l,u;for(l=0,u=t.length;l<u;l++)c=n?n(t[l]):t[l],o=e.getNumberType(c),a=s[o.name],a>i&&(i=a,r=o);return r},e.isTypedArray=function(e){return typeof ArrayBuffer<`u`&&ArrayBuffer.isView(e)},e.concat=function(){var e=0,t,n,r;for(t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=new arguments[0].constructor(e);for(t=0,n=0;t<r;t++)i.set(arguments[t],n),n+=arguments[t].length;return i},e.indices=function(t){for(var n=new(e.getPointerArray(t))(t),r=0;r<t;r++)n[r]=r;return n}})),_t=e((e=>{var t=ht(),n=gt();function r(e){return Array.isArray(e)||n.isTypedArray(e)}function i(e){if(typeof e.length==`number`)return e.length;if(typeof e.size==`number`)return e.size}function a(e){var n=i(e),r=typeof n==`number`?Array(n):[],a=0;return t(e,function(e){r[a++]=e}),r}function o(e){var r=i(e),a=typeof r==`number`?n.getPointerArray(r):Array,o=typeof r==`number`?Array(r):[],s=typeof r==`number`?new a(r):[],c=0;return t(e,function(e){o[c]=e,s[c]=c++}),[o,s]}e.isArrayLike=r,e.guessLength=i,e.toArray=a,e.toArrayWithIndices=o})),vt=e(((e,t)=>{function n(e){if(typeof e!=`function`)throw Error(`obliterator/iterator: expecting a function!`);this.next=e}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(){return new n(function(){return{done:!0}})},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&&typeof e.next==`function`},t.exports=n})),yt=e(((e,t)=>{var n=_t(),r=vt();function i(e,t){if(arguments.length<2)throw Error(`mnemonist/fixed-deque: expecting an Array class and a capacity.`);if(typeof t!=`number`||t<=0)throw Error("mnemonist/fixed-deque: `capacity` should be a positive number.");this.ArrayClass=e,this.capacity=t,this.items=new e(this.capacity),this.clear()}i.prototype.clear=function(){this.start=0,this.size=0},i.prototype.push=function(e){if(this.size===this.capacity)throw Error(`mnemonist/fixed-deque.push: deque capacity (`+this.capacity+`) exceeded!`);var t=this.start+this.size;return t>=this.capacity&&(t-=this.capacity),this.items[t]=e,++this.size},i.prototype.unshift=function(e){if(this.size===this.capacity)throw Error(`mnemonist/fixed-deque.unshift: deque capacity (`+this.capacity+`) exceeded!`);var t=this.start-1;return this.start===0&&(t=this.capacity-1),this.items[t]=e,this.start=t,++this.size},i.prototype.pop=function(){if(this.size!==0){this.size--;var e=this.start+this.size;return e>=this.capacity&&(e-=this.capacity),this.items[e]}},i.prototype.shift=function(){if(this.size!==0){var e=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[e]}},i.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]},i.prototype.peekLast=function(){if(this.size!==0){var e=this.start+this.size-1;return e>=this.capacity&&(e-=this.capacity),this.items[e]}},i.prototype.get=function(e){if(!(this.size===0||e>=this.capacity))return e=this.start+e,e>=this.capacity&&(e-=this.capacity),this.items[e]},i.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=this.capacity,r=this.size,i=this.start,a=0;a<r;)e.call(t,this.items[i],a,this),i++,a++,i===n&&(i=0)},i.prototype.toArray=function(){var e=this.start+this.size;if(e<this.capacity)return this.items.slice(this.start,e);for(var t=new this.ArrayClass(this.size),n=this.capacity,r=this.size,i=this.start,a=0;a<r;)t[a]=this.items[i],i++,a++,i===n&&(i=0);return t},i.prototype.values=function(){var e=this.items,t=this.capacity,n=this.size,i=this.start,a=0;return new r(function(){if(a>=n)return{done:!0};var r=e[i];return i++,a++,i===t&&(i=0),{value:r,done:!1}})},i.prototype.entries=function(){var e=this.items,t=this.capacity,n=this.size,i=this.start,a=0;return new r(function(){if(a>=n)return{done:!0};var r=e[i];return i++,i===t&&(i=0),{value:[a++,r],done:!1}})},typeof Symbol<`u`&&(i.prototype[Symbol.iterator]=i.prototype.values),i.prototype.inspect=function(){var e=this.toArray();return e.type=this.ArrayClass.name,e.capacity=this.capacity,Object.defineProperty(e,`constructor`,{value:i,enumerable:!1}),e},typeof Symbol<`u`&&(i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=i.prototype.inspect),i.from=function(e,t,r){if(arguments.length<3&&(r=n.guessLength(e),typeof r!=`number`))throw Error(`mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.`);var a=new i(t,r);if(n.isArrayLike(e)){var o,s;for(o=0,s=e.length;o<s;o++)a.items[o]=e[o];return a.size=s,a}return n.forEach(e,function(e){a.push(e)}),a},t.exports=i})),bt=e((e=>{let t=dt(),n=yt();function r(e,t){let n=0;return e.forEachInNeighbor(t,()=>{n++}),n}function i(e,i){if(!t(e))throw Error(`graphology-dag/topological-sort: the given graph is not a valid graphology instance.`);if(e.type===`undirected`||e.undirectedSize!==0)throw Error(`graphology-dag/topological-sort: cannot work if graph is not directed.`);if(e.order===0)return;let a=new n(Array,e.order),o={},s=0;e.forEachNode((t,n)=>{let i=e.multi?r(e,t):e.inDegree(t);i===0?a.push([t,n,0]):(o[t]=i,s+=i)});let c=0;function l(e,t){let n=--o[e];s--,n===0&&a.push([e,t,c+1]),o[e]=n}for(;a.size!==0;){let[t,n,r]=a.shift();c=r,i(t,n,r),e.forEachOutNeighbor(t,l)}if(s!==0)throw Error(`graphology-dag/topological-sort: given graph is not acyclic.`)}function a(e){if(!t(e))throw Error(`graphology-dag/topological-sort: the given graph is not a valid graphology instance.`);let n=Array(e.order),r=0;return i(e,e=>{n[r++]=e}),n}function o(e,n){if(!t(e))throw Error(`graphology-dag/topological-generations: the given graph is not a valid graphology instance.`);if(e.order===0)return;let r=0,a=[];i(e,(e,t,i)=>{i>r&&(n(a),r=i,a=[]),a.push(e)}),n(a)}function s(e){if(!t(e))throw Error(`graphology-dag/topological-generations: the given graph is not a valid graphology instance.`);let n=[];return o(e,e=>{n.push(e)}),n}e.topologicalSort=a,e.forEachNodeInTopologicalOrder=i,e.topologicalGenerations=s,e.forEachTopologicalGeneration=o})),xt=e((e=>{e.hasCycle=ft(),e.willCreateCycle=pt();let t=bt();e.forEachNodeInTopologicalOrder=t.forEachNodeInTopologicalOrder,e.topologicalSort=t.topologicalSort,e.topologicalGenerations=t.topologicalGenerations,e.forEachTopologicalGeneration=t.forEachTopologicalGeneration}))();function P(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return Object.getOwnPropertyDescriptor(e,t)?.value}function St(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Ct(e){return Object.fromEntries(e)}function F(e,t,n=1){let r=e.get(t)??0;e.set(t,r+n)}function wt(e){let t=e.metadata;if(!t||!t.dbt_schema_version)return null;let n=t.dbt_schema_version.match(/\/manifest\/v(\d+)\.json$/);return n?parseInt(n[1],10):null}function Tt(e){return e.metadata?.dbt_version||null}function Et(e){let t=wt(e);return t===null?!1:t>=10}function Dt(e){return{schema_version:wt(e),dbt_version:Tt(e),is_supported:Et(e)}}function Ot(e){return e.metrics}function kt(e){return e.semantic_models}function At(e){return e.unit_tests}var jt=class{constructor(e){if(this.relationMap=new Map,!Et(e)){let t=Dt(e);throw Error(`Unsupported dbt version. Schema version: ${t.schema_version||`unknown`}, dbt version: ${t.dbt_version||`unknown`}. Requires dbt 1.10+ (manifest schema v10+)`)}this.graph=new M,this.buildGraph(e)}buildGraph(e){this.addNodes(e),this.addEdges(e)}registerRelationName(e,t){t&&this.relationMap.set(t.toLowerCase(),e)}optionalString(e){return typeof e==`string`&&e!==``?e:void 0}optionalStringArray(e){return Array.isArray(e)?e:void 0}baseNodeAttributes(e,t){return{unique_id:e,name:this.optionalString(t.name)??e,package_name:this.optionalString(t.package_name)??``,path:this.optionalString(t.path),original_file_path:this.optionalString(t.original_file_path),tags:this.optionalStringArray(t.tags),description:this.optionalString(t.description)}}addManifestEntries(e,t,n){if(e)for(let[r,i]of Object.entries(e)){let e=i;this.graph.addNode(r,t(r,e)),n!=null&&this.registerRelationName(r,P(e,n))}}readMaterialized(e){let t=e?.materialized;return typeof t==`string`&&t.trim()!==``?t:void 0}metricArrayStrings(e,t){if(Array.isArray(e))return e.map(e=>P(e,t)).filter(e=>typeof e==`string`)}buildNodeEntryAttributes(e,t){let n=this.extractResourceType(this.optionalString(t.resource_type)??`model`),r=t.config,i=this.readMaterialized(r);return{...this.baseNodeAttributes(e,t),resource_type:n,patch_path:this.optionalString(t.patch_path),database:this.optionalString(t.database),schema:this.optionalString(t.schema),compiled_code:this.optionalString(t.compiled_code),raw_code:this.optionalString(t.raw_code)??this.optionalString(t.raw_sql),...i==null?{}:{materialized:i}}}buildSourceEntryAttributes(e,t){return{...this.baseNodeAttributes(e,t),resource_type:`source`}}buildMacroEntryAttributes(e,t){return{...this.baseNodeAttributes(e,t),resource_type:`macro`,raw_code:this.optionalString(t.macro_sql)}}buildExposureEntryAttributes(e,t){return{...this.baseNodeAttributes(e,t),resource_type:`exposure`}}buildMetricEntryAttributes(e,t){let n=t.type_params,r=t.filter,i=t.depends_on,a=t.tags,o=typeof a==`string`?[a]:this.optionalStringArray(a);return{...this.baseNodeAttributes(e,t),resource_type:`metric`,label:this.optionalString(t.label),metric_type:this.optionalString(t.type),metric_expression:this.optionalString(n?.expr),metric_measure:this.optionalString(n?.measure?.name),metric_input_measures:this.metricArrayStrings(n?.input_measures,`name`),metric_input_metrics:this.metricArrayStrings(n?.metrics,`name`),metric_time_granularity:this.optionalString(t.time_granularity),metric_filters:this.metricArrayStrings(r?.where_filters,`where_sql_template`),metric_source_reference:i?.nodes?.[0]??void 0,tags:o}}traverseNeighbors(e,t){if(!this.graph.hasNode(e))return[];let n=[],r=new Set,i=[],a=0,o=(e,a)=>{for(let o of t.getNeighbors(e))r.has(o)||(r.add(o),n.push(t.includeParents?{nodeId:o,depth:a,parentId:e}:{nodeId:o,depth:a}),(t.maxDepth===void 0||a<t.maxDepth)&&i.push({id:o,depth:a}))};for(o(e,1);a<i.length;){let{id:e,depth:t}=i[a++];o(e,t+1)}return n}addNodes(e){this.addNodeEntries(e.nodes),this.addSourceEntries(e.sources),this.addMacroEntries(e.macros),this.addExposureEntries(e.exposures),this.addMetricEntries(Ot(e)),this.addSemanticModelEntries(kt(e)),this.addUnitTestEntries(At(e))}addNodeEntries(e){this.addManifestEntries(e,(e,t)=>this.buildNodeEntryAttributes(e,t),`relation_name`)}addSourceEntries(e){this.addManifestEntries(e,(e,t)=>this.buildSourceEntryAttributes(e,t),`relation_name`)}addMacroEntries(e){this.addManifestEntries(e,(e,t)=>this.buildMacroEntryAttributes(e,t))}addExposureEntries(e){this.addManifestEntries(e,(e,t)=>this.buildExposureEntryAttributes(e,t))}addMetricEntries(e){this.addManifestEntries(e,(e,t)=>this.buildMetricEntryAttributes(e,t))}addSemanticModelEntries(e){if(e)for(let[t,n]of Object.entries(e)){let e=n;this.graph.addNode(t,{unique_id:t,resource_type:`semantic_model`,name:e.name||t,package_name:e.package_name||``,path:e.path||void 0,original_file_path:e.original_file_path||void 0,description:e.description||void 0,label:e.label||void 0,semantic_model_reference:e.model||void 0,semantic_model_default_time_dimension:e.defaults?.agg_time_dimension||void 0,semantic_model_entities:Array.isArray(e.entities)?e.entities.map(e=>e.name).filter(e=>typeof e==`string`):void 0,semantic_model_measures:Array.isArray(e.measures)?e.measures.map(e=>e.name).filter(e=>typeof e==`string`):void 0,semantic_model_dimensions:Array.isArray(e.dimensions)?e.dimensions.map(e=>e.name).filter(e=>typeof e==`string`):void 0})}}addUnitTestEntries(e){if(e)for(let[t,n]of Object.entries(e)){let e=n;this.graph.addNode(t,{unique_id:t,resource_type:`unit_test`,name:e.name||t,package_name:e.package_name||``})}}addEdges(e){e.parent_map&&this.addEdgesFromParentMap(e.parent_map),this.addEdgesFromNodeDependsOn(e.nodes),this.addEdgesFromExposureDependsOn(e.exposures),this.addEdgesFromMetricDependsOn(Ot(e))}addEdgesFromParentMap(e){for(let[t,n]of Object.entries(e))if(this.graph.hasNode(t))for(let e of n)this.graph.hasNode(e)&&!this.graph.hasEdge(e,t)&&this.graph.addEdge(e,t,{dependency_type:this.inferDependencyType(e)})}addEdgesFromDependsOn(e,t){if(t.nodes)for(let n of t.nodes)this.graph.hasNode(n)&&!this.graph.hasEdge(n,e)&&this.graph.addEdge(n,e,{dependency_type:`node`});if(t.macros)for(let n of t.macros)this.graph.hasNode(n)&&!this.graph.hasEdge(n,e)&&this.graph.addEdge(n,e,{dependency_type:`macro`})}addEdgesFromNodeDependsOn(e){if(e)for(let[t,n]of Object.entries(e)){let e=n.depends_on;e&&this.addEdgesFromDependsOn(t,e)}}addEdgesFromExposureDependsOn(e){if(e)for(let[t,n]of Object.entries(e)){let e=n.depends_on;e?.nodes&&this.addEdgesFromDependsOn(t,e)}}addEdgesFromMetricDependsOn(e){if(e)for(let[t,n]of Object.entries(e)){let e=n.depends_on;e?.nodes&&this.addEdgesFromDependsOn(t,e)}}extractResourceType(e){let t=e.toLowerCase();return[`model`,`source`,`seed`,`snapshot`,`test`,`analysis`,`macro`,`exposure`,`metric`,`semantic_model`,`unit_test`,`function`].includes(t)?t:`model`}inferDependencyType(e){return e.startsWith(`macro.`)?`macro`:e.startsWith(`source.`)?`source`:`node`}getGraph(){return this.graph}getSummary(){let e=new Map,t=0;this.graph.forEachNode((n,r)=>{t++,F(e,r.resource_type||`unknown`)});let n=(0,xt.hasCycle)(this.graph);return{total_nodes:t,nodes_by_type:Ct(e),total_edges:this.graph.size,has_cycles:n}}getUpstream(e,t){return this.traverseNeighbors(e,{maxDepth:t,getNeighbors:e=>this.graph.inboundNeighbors(e),includeParents:!1}).map(({nodeId:e,depth:t})=>({nodeId:e,depth:t}))}getDownstream(e,t){return this.traverseNeighbors(e,{maxDepth:t,getNeighbors:e=>this.graph.outboundNeighbors(e),includeParents:!1}).map(({nodeId:e,depth:t})=>({nodeId:e,depth:t}))}getUpstreamWithParents(e,t){return this.traverseNeighbors(e,{maxDepth:t,getNeighbors:e=>this.graph.inboundNeighbors(e),includeParents:!0}).map(({nodeId:t,depth:n,parentId:r})=>({nodeId:t,depth:n,parentId:r??e}))}getUpstreamBuildOrder(e,t){let n=this.getUpstream(e,t);if(n.length===0)return[];let r=new Set(n.map(e=>e.nodeId)),i=new Map(n.map(e=>[e.nodeId,e.depth])),a=new M;for(let e of r)a.addNode(e,this.graph.getNodeAttributes(e));return this.graph.forEachEdge((e,t,n,i)=>{r.has(n)&&r.has(i)&&(a.hasEdge(n,i)||a.addEdge(n,i,t))}),(0,xt.topologicalSort)(a).map(e=>({nodeId:e,depth:i.get(e)??0}))}getDownstreamWithParents(e,t){return this.traverseNeighbors(e,{maxDepth:t,getNeighbors:e=>this.graph.outboundNeighbors(e),includeParents:!0}).map(({nodeId:t,depth:n,parentId:r})=>({nodeId:t,depth:n,parentId:r??e}))}addFieldNodes(e){if(e.nodes){for(let[t,n]of Object.entries(e.nodes))if(this.graph.hasNode(t)){let e=n.columns;this.processCatalogColumns(t,e)}}if(e.sources){for(let[t,n]of Object.entries(e.sources))if(this.graph.hasNode(t)){let e=n.columns;this.processCatalogColumns(t,e)}}}processCatalogColumns(e,t){if(!t)return;let n=this.graph.getNodeAttributes(e);for(let[r,i]of Object.entries(t)){let t=`${e}#${r}`,a=i,o=a?.comment??a?.description;this.graph.hasNode(t)||(this.graph.addNode(t,{unique_id:t,resource_type:`field`,name:r,package_name:n.package_name,parent_id:e,description:o}),this.graph.addEdge(e,t,{dependency_type:`internal`}))}}addFieldEdges(e,t){if(this.graph.hasNode(e))for(let[n,r]of Object.entries(t)){let t=`${e}#${n}`;this.ensureFieldNode(e,n);for(let e of r){let n=this.resolveRelationToUniqueId(e.sourceTable);if(!n)continue;let r=`${n}#${e.sourceColumn}`;this.ensureFieldNode(n,e.sourceColumn),this.graph.hasEdge(r,t)||this.graph.addEdge(r,t,{dependency_type:`field`})}}}ensureFieldNode(e,t){let n=`${e}#${t}`;if(!this.graph.hasNode(n)){let r=this.graph.getNodeAttributes(e);this.graph.addNode(n,{unique_id:n,resource_type:`field`,name:t,package_name:r.package_name,parent_id:e}),this.graph.addEdge(e,n,{dependency_type:`internal`})}return n}tryResolveRelationName(e){return this.resolveRelationToUniqueId(e)}resolveRelationToUniqueId(e){let t=e.toLowerCase();if(this.relationMap.has(t))return this.relationMap.get(t);let n=t.replace(/["`]/g,``);if(this.relationMap.has(n))return this.relationMap.get(n);for(let[e,t]of this.relationMap.entries()){let r=e.replace(/["`]/g,``);if(r.endsWith(`.${n}`)||r===n)return t}}buildSubgraph(e,t,n,r){if(!this.graph.hasNode(e))throw Error(`Focus node not found in manifest: ${e}`);let i=new Set([e]);if(t===`upstream`||t===`both`)for(let{nodeId:t}of this.getUpstream(e,n))i.add(t);if(t===`downstream`||t===`both`)for(let{nodeId:t}of this.getDownstream(e,n))i.add(t);let a=new M;for(let t of i){if(!this.graph.hasNode(t))continue;let n=this.graph.getNodeAttributes(t);t!==e&&r&&!r.has(n.resource_type.toLowerCase())||a.addNode(t,n)}return this.graph.forEachEdge((e,t,n,r)=>{a.hasNode(n)&&a.hasNode(r)&&(a.hasEdge(n,r)||a.addEdge(n,r,t))}),a}};function I(e,t){let n=P(e,t);if(typeof n==`number`&&Number.isFinite(n))return n;if(typeof n==`string`&&n.trim()!==``){let e=Number(n);if(Number.isFinite(e))return e}}function L(e,t){let n=P(e,t);if(typeof n==`string`&&n.trim()!==``)return n}function R(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function z(e){return e===null?`null`:typeof e==`string`?e===``?`""`:e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?`[${e.map(e=>z(e)).join(`, `)}]`:R(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${z(P(e,t))}`).join(`,`)}}`:String(e)}function Mt(e,t){return typeof t==`number`&&Number.isFinite(t)?{key:e,label:e,kind:`number`,displayValue:t.toLocaleString(),isScalar:!0,sortValue:t}:typeof t==`string`?{key:e,label:e,kind:`string`,displayValue:t===``?`""`:t,isScalar:!0,sortValue:t}:typeof t==`boolean`?{key:e,label:e,kind:`boolean`,displayValue:t?`true`:`false`,isScalar:!0,sortValue:+!!t}:t===null?{key:e,label:e,kind:`null`,displayValue:`null`,isScalar:!1}:Array.isArray(t)?{key:e,label:e,kind:`array`,displayValue:z(t),isScalar:!1}:{key:e,label:e,kind:`object`,displayValue:z(t),isScalar:!1}}function Nt(e,t){if(!R(t))return[Mt(e,t)];let n=Object.keys(t).sort();return n.length===0?[Mt(e,t)]:n.map(n=>Mt(`${e}.${n}`,P(t,n)))}function Pt(e){return e.bytesProcessed!==void 0||e.bytesBilled!==void 0||e.slotMs!==void 0||e.rowsAffected!==void 0||e.adapterCode!==void 0||e.adapterMessage!==void 0||e.queryId!==void 0||e.projectId!==void 0||e.location!==void 0||e.rowsInserted!==void 0||e.rowsDeleted!==void 0||e.rowsUpdated!==void 0||e.rowsDuplicated!==void 0}function Ft(e){return R(e)}function It(e){if(typeof e!=`string`)return e;let t=e.trim();if(t===``||t===`null`)return null;let n=t[0];if(n!==`{`&&n!==`[`)return e;try{return JSON.parse(t)}catch{return e}}function Lt(e){return R(e)?Object.keys(e).sort().flatMap(t=>Nt(t,P(e,t))):[]}function Rt(e,t,n,r){for(let{metricKey:i,totalKey:a}of t){let t=P(e,i);typeof t==`number`&&(F(n,a,t),r.set(a,!0))}}function zt(e,t,n,r){let i={nodesWithAdapterData:e};for(let{totalKey:e}of t){if(!r.get(e))continue;let t=n.get(e);t!==void 0&&St(i,e,t)}return i}function Bt(e){let t=[{metricKey:`bytesProcessed`,totalKey:`totalBytesProcessed`},{metricKey:`bytesBilled`,totalKey:`totalBytesBilled`},{metricKey:`slotMs`,totalKey:`totalSlotMs`},{metricKey:`rowsAffected`,totalKey:`totalRowsAffected`},{metricKey:`rowsInserted`,totalKey:`totalRowsInserted`},{metricKey:`rowsUpdated`,totalKey:`totalRowsUpdated`},{metricKey:`rowsDeleted`,totalKey:`totalRowsDeleted`},{metricKey:`rowsDuplicated`,totalKey:`totalRowsDuplicated`}],n=0,r=new Map,i=new Map;for(let{totalKey:e}of t)r.set(e,0),i.set(e,!1);for(let a of e)a==null||!Pt(a)||(n+=1,Rt(a,t,r,i));if(n!==0)return zt(n,t,r,i)}function Vt(e){if(!R(e))return{};let t=I(e,`bytes_processed`),n=I(e,`bytes_billed`),r=I(e,`slot_ms`),i=I(e,`rows_affected`),a=L(e,`code`),o=L(e,`_message`),s=L(e,`query_id`)??L(e,`job_id`),c=L(e,`project_id`),l=L(e,`location`);return{...t===void 0?{}:{bytesProcessed:t},...n===void 0?{}:{bytesBilled:n},...r===void 0?{}:{slotMs:r},...i===void 0?{}:{rowsAffected:i},...a===void 0?{}:{adapterCode:a},...o===void 0?{}:{adapterMessage:o},...s===void 0?{}:{queryId:s},...c===void 0?{}:{projectId:c},...l===void 0?{}:{location:l}}}function B(e,t){if(!R(e))return{rawKeys:[]};let n=Object.keys(e).filter(e=>typeof e==`string`);return{...Vt(e),...t,rawKeys:n}}let Ht={name:`generic`,parse(e){return B(e,{})}},Ut={name:`athena`,parse(e){if(!R(e))return{rawKeys:[]};let t=I(e,`data_scanned_in_bytes`);return B(e,{...t===void 0?{}:{bytesProcessed:t}})},canParse(e){return R(e)?`data_scanned_in_bytes`in e:!1}},Wt={name:`bigquery`,parse(e){if(!R(e))return{rawKeys:[]};let t=I(e,`bytes_processed`),n=I(e,`bytes_billed`),r=I(e,`slot_ms`),i=L(e,`project_id`),a=L(e,`location`),o=L(e,`query_id`)??L(e,`job_id`);return B(e,{...t===void 0?{}:{bytesProcessed:t},...n===void 0?{}:{bytesBilled:n},...r===void 0?{}:{slotMs:r},...o===void 0?{}:{queryId:o},...i===void 0?{}:{projectId:i},...a===void 0?{}:{location:a}})},canParse(e){return R(e)?`bytes_processed`in e||`bytes_billed`in e||`slot_ms`in e||`job_id`in e||`location`in e:!1}},Gt={name:`postgres`,parse(e){return B(e,{})}},Kt={name:`redshift`,parse(e){return B(e,{})}},qt={name:`snowflake`,parse(e){if(!R(e))return{rawKeys:[]};let t=I(e,`rows_inserted`),n=I(e,`rows_deleted`),r=I(e,`rows_updated`),i=I(e,`rows_duplicates`);return B(e,{...t===void 0?{}:{rowsInserted:t},...n===void 0?{}:{rowsDeleted:n},...r===void 0?{}:{rowsUpdated:r},...i===void 0?{}:{rowsDuplicated:i}})},canParse(e){return R(e)?`rows_inserted`in e||`rows_deleted`in e||`rows_updated`in e||`rows_duplicates`in e:!1}},Jt=new Map([[`athena`,Ut],[`bigquery`,Wt],[`postgres`,Gt],[`redshift`,Kt],[`snowflake`,qt],[`spark`,{name:`spark`,parse(e){return B(e,{})}}]]),Yt=[Wt,qt,Ut],Xt=new class{selectParser(e,t){if(e&&typeof e==`string`){let n=e.toLowerCase().trim(),r=Jt.get(n);if(r&&(!r.canParse||r.canParse(t)))return r}for(let e of Yt)if(e.canParse&&e.canParse(t))return e;return Ht}};function Zt(e,t){let n=It(e),r=t?.adapterType;return Xt.selectParser(r,n).parse(n)}function Qt(e,t){if(!e.results||!Array.isArray(e.results))return[];let n=e.results,r=e=>{let t=e.timing||[];return t.find(e=>e.name===`execute`)||t.find(e=>e.name===`compile`)||t[0]},i=e=>typeof e==`string`&&e.trim()!==``?e.trim():void 0,a=e=>{let n=Zt(e,{adapterType:t});return{adapterMetrics:n,includeAdapter:n.rawKeys.length>0||Pt(n),adapterResponseFields:Lt(e),includeAdapterFields:Ft(e)}};return n.map(e=>{let t=r(e),{adapterMetrics:n,includeAdapter:o,adapterResponseFields:s,includeAdapterFields:c}=a(It(e.adapter_response)),l=i(e.message);return{unique_id:e.unique_id||``,status:e.status||`unknown`,execution_time:e.execution_time||0,started_at:t?.started_at??void 0,completed_at:t?.completed_at??void 0,thread_id:e.thread_id??void 0,...l==null?{}:{message:l},...o?{adapterMetrics:n}:{},...c?{adapterResponseFields:s}:{}}})}var $t=class{constructor(e,t,n){this.runResults=e,this.graph=t,this.adapterType=n}getSummary(){let e=this.getNodeExecutions(),t=new Map,n=0;for(let r of e)F(t,r.status||`unknown`),n+=r.execution_time||0;let r=this.calculateCriticalPath(e);return{total_execution_time:n,total_nodes:e.length,nodes_by_status:Ct(t),critical_path:r,node_executions:e}}getNodeExecutions(){return Qt(this.runResults,this.adapterType)}calculateCriticalPath(e){let t=new Map;for(let n of e)t.set(n.unique_id,n);let n=[],r=this.graph.getGraph();if(r.forEachNode(e=>{r.outboundNeighbors(e).length===0&&t.has(e)&&n.push(e)}),n.length===0)return;let i=[],a=0;for(let e of n){let n=this.findLongestPathToRoot(e,t),r=this.calculatePathTime(n,t);r>a&&(a=r,i=n)}if(i.length!==0)return{path:i,total_time:a}}findLongestPathToRoot(e,t){let n=this.graph.getGraph(),r=new Set,i=[],a=(e,o)=>{if(r.has(e))return;r.add(e);let s=[...o,e];s.length>i.length&&(i=s);let c=n.inboundNeighbors(e);for(let e of c)t.has(e)&&a(e,s);r.delete(e)};return a(e,[]),i.reverse()}calculatePathTime(e,t){let n=0;for(let r of e){let e=t.get(r);e&&(n+=e.execution_time||0)}return n}getRunStartedAt(){let e=this.getNodeExecutions().map(e=>e.started_at?new Date(e.started_at).getTime():null).filter(e=>e!==null);return e.length===0?null:Math.min(...e)}parseTimingInterval(e){if(!e)return null;let t=e.started_at,n=e.completed_at;if(!t||!n)return null;let r=new Date(t).getTime(),i=new Date(n).getTime();return Number.isNaN(r)||Number.isNaN(i)?null:{start:r,end:i}}wallClockFromResult(e){let t=e.timing||[],n=t.find(e=>e.name===`execute`),r=t.find(e=>e.name===`compile`),i=this.parseTimingInterval(r),a=this.parseTimingInterval(n),o=[],s=[];return i&&(o.push(i.start),s.push(i.end)),a&&(o.push(a.start),s.push(a.end)),o.length===0?null:{wallStart:Math.min(...o),wallEnd:Math.max(...s),compile:i,execute:a}}getGanttData(){if(!this.runResults.results||!Array.isArray(this.runResults.results))return[];let e=this.graph.getGraph(),t=[];for(let n of this.runResults.results){let r=n.unique_id||``;if(!r)continue;let i=this.wallClockFromResult(n);if(!i)continue;let a=(e.hasNode(r)?e.getNodeAttributes(r):void 0)?.name||r,o=n.status||`unknown`;t.push({unique_id:r,name:a,status:o,wall:i})}if(t.length===0)return[];let n=Math.min(...t.map(e=>e.wall.wallStart));return t.map(e=>{let{wall:t}=e,r=e=>e-n;return{unique_id:e.unique_id,name:e.name,start:r(t.wallStart),end:r(t.wallEnd),duration:t.wallEnd-t.wallStart,status:e.status,compileStart:t.compile?r(t.compile.start):null,compileEnd:t.compile?r(t.compile.end):null,executeStart:t.execute?r(t.execute.start):null,executeEnd:t.execute?r(t.execute.end):null}})}};function en(e,t){let n=t.split(`*`);if(n.length===1)return e===t;let r=0,i=!0;for(let t of n){let n=e.indexOf(t,r);if(n===-1||i&&n!==0)return!1;i=!1,r=n+t.length}let a=n[n.length-1];return a===``||e.endsWith(a)}function tn(e,t){return t instanceof RegExp?t.test(e):en(e,t)}new Map([`bytes_processed`,`bytes_billed`,`slot_ms`,`rows_affected`,`rows_inserted`,`rows_updated`,`rows_deleted`,`rows_duplicated`].map(e=>[`${e}_desc`,e]));function nn(e,t){let n=e.adapterMetrics;return n==null?!1:[n.queryId,n.adapterCode,n.adapterMessage,n.projectId,n.location].some(e=>e?.toLowerCase().includes(t)===!0)}function rn(e,t){let n=[...e];if(t.status!==void 0){let e=typeof t.status==`string`?[t.status]:t.status,r=new Set(e.map(e=>e.toLowerCase()));n=n.filter(e=>r.has((e.status||`unknown`).toLowerCase()))}if(t.min_execution_time!==void 0&&(n=n.filter(e=>(e.execution_time??0)>=t.min_execution_time)),t.max_execution_time!==void 0&&(n=n.filter(e=>(e.execution_time??0)<=t.max_execution_time)),t.unique_id_pattern!==void 0&&(n=n.filter(e=>tn(e.unique_id,t.unique_id_pattern))),t.has_adapter_key!==void 0&&(n=n.filter(e=>e.adapterMetrics?.rawKeys.includes(t.has_adapter_key)===!0)),t.adapter_text!==void 0&&t.adapter_text.trim()!==``){let e=t.adapter_text.toLowerCase();n=n.filter(t=>nn(t,e))}return n}function an(e,t){return[...e].sort((e,n)=>{switch(t){case`execution_time_asc`:return(e.execution_time??0)-(n.execution_time??0);case`execution_time_desc`:return(n.execution_time??0)-(e.execution_time??0);case`unique_id`:return e.unique_id.localeCompare(n.unique_id);default:return 0}})}function on(e,t){let n=rn(e,t);return t.sort&&(n=an(n,t.sort)),t.limit!==void 0&&t.limit>=0&&(n=n.slice(0,t.limit)),n}function sn(e,t){if(!t)return;let n=t.getGraph();if(n.hasNode(e))return n.getNodeAttributes(e)?.name||void 0}function cn(e,t){let n=e.reduce((e,t)=>e+(t.execution_time??0),0),r;return r=t.mode===`top_n`?on(e,{sort:`execution_time_desc`,limit:t.top}):on(e,{min_execution_time:t.min_seconds,sort:`execution_time_desc`}),{nodes:r.map((e,r)=>{let i=e.execution_time??0,a=n>0?i/n*100:0;return{unique_id:e.unique_id,name:sn(e.unique_id,t.graph),execution_time:i,rank:r+1,pct_of_total:Math.round(a*10)/10,status:e.status||`unknown`}}),total_execution_time:n,criteria_used:t.mode===`top_n`?`top_n`:`threshold`}}function ln(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r+=1)n|=e.charCodeAt(r)^t.charCodeAt(r);return n===0}let un=new Map([[`seed`,`seed`],[`snapshot`,`snapshot`],[`test`,`test`],[`unit_test`,`test`],[`operation`,`operation`]]);function dn(e){switch(e){case`table`:return`table`;case`view`:return`view`;case`incremental`:return`incremental`;case`ephemeral`:return`ephemeral`;case`materialized_view`:case`materializedview`:return`materialized_view`;default:return}}function fn(e){return e.trim().toLowerCase()||`unknown`}function pn(e){if(e==null||typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t===``?null:t.replace(/[\s-]+/g,`_`)}function mn(e,t){let n=fn(e),r=pn(t),i=un.get(n);if(i!==void 0)return{kind:i};if(n.length===0||ln(n,`model`))return typeof r==`string`?hn(r,t):{kind:`unknown`};if(typeof r==`string`){let e=dn(r);return e===void 0?{kind:`unknown`,raw:t.trim()}:{kind:e,raw:void 0}}return{kind:`unknown`}}function hn(e,t){let n=dn(e);return n===void 0?{kind:`unknown`,raw:t.trim()}:{kind:n}}function gn(e,t){if(fn(t)===`source`)return{persisted:!0,createsRelation:!1,compiledIntoParent:!1};switch(e){case`ephemeral`:return{persisted:!1,createsRelation:!1,compiledIntoParent:!0};case`table`:case`view`:case`incremental`:case`materialized_view`:return{persisted:!0,createsRelation:!0,compiledIntoParent:!1};case`seed`:case`snapshot`:return{persisted:!0,createsRelation:!0,compiledIntoParent:!1};case`test`:case`operation`:return{persisted:!1,createsRelation:!1,compiledIntoParent:!1};default:return{persisted:!1,createsRelation:!1,compiledIntoParent:!1}}}function _n(e){if(e==null)return;let t=e.config;return typeof t==`object`&&t?t:void 0}function vn(e,t,n){return e==null?`derived`:t||n||typeof e.relation_name==`string`&&e.relation_name.length>0?`manifest`:`derived`}function yn(e){let t=e?.unique_key;return t==null?{uniqueKey:void 0,hasUniqueKeyField:!1}:typeof t==`string`||Array.isArray(t)&&t.every(e=>typeof e==`string`)?{uniqueKey:t,hasUniqueKeyField:!0}:{uniqueKey:void 0,hasUniqueKeyField:!0}}function bn(e,t){if(e==null)return{hasAnyIncrementalHint:t};let n=typeof e.incremental_strategy==`string`?e.incremental_strategy:void 0,r=typeof e.on_schema_change==`string`?e.on_schema_change:void 0,i=typeof e.full_refresh==`boolean`?e.full_refresh:void 0;return{incrementalStrategy:n,onSchemaChange:r,fullRefreshCapable:i,hasAnyIncrementalHint:n!=null||r!=null||i!=null||t}}function xn(e){let t=e=>typeof e==`string`&&e.trim()!==``?e:void 0,n=(e,n,r,i,a)=>({...e==null?{}:{relationName:e},...t(n)==null?{}:{adapterType:t(n)},...a.incrementalStrategy==null?{}:{incrementalStrategy:a.incrementalStrategy},...r==null?{}:{uniqueKey:r},...a.onSchemaChange==null?{}:{onSchemaChange:a.onSchemaChange},...a.fullRefreshCapable==null?{}:{fullRefreshCapable:a.fullRefreshCapable},...t(i)==null?{}:{rawMaterialization:t(i)}}),{resourceType:r,adapterType:i}=e,a=e.manifestEntry??null,o=_n(a),s=typeof o?.materialized==`string`?o.materialized:null,c=typeof e.materialized==`string`&&e.materialized.trim()!==``?e.materialized:null,{kind:l,raw:u}=mn(r,c??s),{uniqueKey:d,hasUniqueKeyField:f}=yn(o),p=bn(o,f),m=t(a?.relation_name),h=s!=null&&String(s).trim()!==``,g=c!=null&&c.trim()!==``;return{resourceType:r,materialization:l,...gn(l,r),...n(m,i,d,u,p),materializationSource:vn(a,h||g,p.hasAnyIncrementalHint)}}let Sn=[`model`,`source`,`test`,`metric`,`semantic_model`,`exposure`,`seed`,`snapshot`,`unit_test`,`analysis`,`macro`];function V(){return performance.now()}function H(e){let t=e?.trim().toLowerCase();return t?[`success`,`pass`,`passed`].includes(t)?`positive`:[`warn`,`warning`].includes(t)?`warning`:[`error`,`errors`,`fail`,`failed`,`failure`,`failures`,`errored`,`run error`,`runtime error`,`compile error`,`database error`].includes(t)?`danger`:[`skipped`,`no op`].includes(t)?`skipped`:`neutral`:`neutral`}function U(e){return e?e.split(/[\s_-]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1).toLowerCase()).join(` `):`Unknown`}function W(e){let t=e.split(`.`);return t.length<2?``:t[1]??``}function G(e){let t=e.split(`.`)[0]??``;return new Set([`model`,`test`,`unit_test`,`seed`,`snapshot`,`source`,`source_freshness`,`exposure`,`metric`,`semantic_model`,`analysis`,`macro`]).has(t)?t:`operation`}function Cn(e){return e.split(`_`).map(e=>e[0].toUpperCase()+e.slice(1)).join(` `)}function K(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function wn(e){let t=typeof e.metric_measure==`string`?e.metric_measure:null,n=K(e.metric_input_measures);return{kind:`metric`,label:typeof e.label==`string`?e.label:null,description:typeof e.description==`string`?e.description:null,metricType:typeof e.metric_type==`string`?e.metric_type:null,expression:typeof e.metric_expression==`string`?e.metric_expression:null,sourceReference:typeof e.metric_source_reference==`string`?e.metric_source_reference:typeof e.metric_measure==`string`?e.metric_measure:null,filters:K(e.metric_filters),timeGranularity:typeof e.metric_time_granularity==`string`?e.metric_time_granularity:null,measures:n.length>0?n:t==null?[]:[t],metrics:K(e.metric_input_metrics)}}function Tn(e){return{kind:`semantic_model`,label:typeof e.label==`string`?e.label:null,description:typeof e.description==`string`?e.description:null,sourceReference:typeof e.semantic_model_reference==`string`?e.semantic_model_reference:null,defaultTimeDimension:typeof e.semantic_model_default_time_dimension==`string`?e.semantic_model_default_time_dimension:null,entities:K(e.semantic_model_entities),measures:K(e.semantic_model_measures),dimensions:K(e.semantic_model_dimensions)}}function En(e,t){return e===`metric`?wn(t):e===`semantic_model`?Tn(t):null}function Dn(e,t){let n=Sn.indexOf(e),r=Sn.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r}function On(e,t){let n=Dn(e.resourceType,t.resourceType);return n===0?e.name.localeCompare(t.name):n}function kn(e){let t=e.metadata;return typeof t==`object`&&t&&`project_name`in t&&typeof t.project_name==`string`&&t.project_name!==``?t.project_name:null}let An=new Set([`test`,`unit_test`,`macro`,`operation`,`sql_operation`]),jn=new Set([`elementary`]);function Mn(e,t){let n=(t.hasNode(e.unique_id)?t.getNodeAttributes(e.unique_id):void 0)?.package_name;return typeof n==`string`&&n.length>0?n:W(e.unique_id)}function Nn(e,t){let n=(t.hasNode(e.unique_id)?t.getNodeAttributes(e.unique_id):void 0)?.resource_type;return typeof n==`string`&&n.length>0?n:G(e.unique_id)}function Pn(e,t){if(e.length===0)return null;let n=new Map;for(let r of e){let e=Nn(r,t);if(An.has(e))continue;let i=Mn(r,t);i.length>0&&!jn.has(i)&&F(n,i)}return[...n.entries()].sort((e,t)=>{let n=t[1]-e[1];return n===0?e[0].localeCompare(t[0]):n})[0]?.[0]??null}function Fn(e,t,n){let r=0;for(let i of e){let e=Nn(i,t);An.has(e)||Mn(i,t)===n&&r++}return r}function In(e,t,n){let r=kn(e),i=Pn(t,n);return r==null||Fn(t,n,r)===0&&i!=null?i:r}function Ln(e){let t=e.metadata!=null&&typeof e.metadata==`object`?e.metadata:null;return typeof t?.invocation_id==`string`?t.invocation_id:null}function Rn(e){let t=e.metadata;return typeof t==`object`&&t&&`adapter_type`in t&&typeof t.adapter_type==`string`&&t.adapter_type!==``?t.adapter_type:null}function zn(e){let t=new Map;for(let n of e){let e=t.get(n.resourceType)??[];e.push(n),t.set(n.resourceType,e)}return[...t.entries()].sort(([e],[t])=>Dn(e,t)).map(([e,t])=>({resourceType:e,label:Cn(e),count:t.length,attentionCount:t.filter(e=>e.statusTone===`danger`||e.statusTone===`warning`).length,resources:t}))}function Bn(e,t){let n=new Map;for(let e of t){let t=U(e.status);n.set(t,(n.get(t)??0)+(e.execution_time??0))}return Object.entries(e.nodes_by_status).map(([t,r])=>({status:U(t),count:r,duration:n.get(U(t))??0,share:e.total_nodes>0?r/e.total_nodes:0,tone:H(t)})).sort((e,t)=>t.count-e.count)}function Vn(e,t){let n={};for(let r of t)St(n,r,e.hasNode(r)?{inbound:[...e.inboundNeighbors(r)],outbound:[...e.outboundNeighbors(r)]}:{inbound:[],outbound:[]});return n}function Hn(e){let t=new Map;for(let n of e){let e=n.threadId??`unknown`,r=t.get(e)??{count:0,totalExecutionTime:0};r.count+=1,r.totalExecutionTime+=n.executionTime,t.set(e,r)}return[...t.entries()].map(([e,t])=>({threadId:e,count:t.count,totalExecutionTime:t.totalExecutionTime})).sort((e,t)=>t.totalExecutionTime-e.totalExecutionTime)}let Un=new Set([`test`,`unit_test`]);function Wn(e){let t=new Map,n=e=>{if(!(typeof e!=`object`||!e))for(let[n,r]of Object.entries(e))typeof r==`object`&&r&&t.set(n,r)};if(n(e.nodes),n(e.sources),n(e.unit_tests),e.disabled!=null&&typeof e.disabled==`object`){for(let[n,r]of Object.entries(e.disabled))if(Array.isArray(r))for(let e of r)typeof e==`object`&&e&&t.set(n,e)}return t}function Gn(e,t,n){return t.hasNode(e)?t.getNodeAttributes(e):n.get(e)}function Kn(e,t,n){for(let r of e){let e=Gn(r,t,n),i=String(e?.resource_type??G(r));if(i!==`test`&&i!==`unit_test`&&i!==``)return r}return null}function qn(e,t,n,r){let i=e.getUpstream(r),a=i.filter(e=>e.depth===1),o=Kn((a.length>0?a:i).map(e=>e.nodeId),t,n);if(o!=null)return o;let s=n.get(r),c=typeof s?.attached_node==`string`?s.attached_node:null;if(c!=null)return c;let l=s?.depends_on;if(Array.isArray(l?.nodes)){let e=Kn(l.nodes.filter(e=>typeof e==`string`),t,n);if(e!=null)return e}return null}function Jn(e){return typeof e?.original_file_path==`string`?e.original_file_path:typeof e?.path==`string`?e.path:null}function Yn(e,t,n,r){let i=n.get(e)??null;return xn({resourceType:typeof t?.resource_type==`string`&&t.resource_type!==``?t.resource_type:G(e),materialized:typeof t?.materialized==`string`&&t.materialized.trim()!==``?t.materialized:null,manifestEntry:i,adapterType:r??null})}function Xn(e,t,n,r,i){let a=Gn(e.unique_id,n,r),o=typeof a?.resource_type==`string`&&a.resource_type!==``?a.resource_type:G(e.unique_id),s=o===`test`||o===`unit_test`?qn(t,n,r,e.unique_id):null,c=typeof a?.package_name==`string`&&a.package_name.length>0?a.package_name:W(e.unique_id),l=typeof a?.materialized==`string`&&a.materialized.trim()!==``?a.materialized:null,u=Yn(e.unique_id,a,r,i);return{...e,resourceType:o,packageName:c,path:Jn(a),parentId:s,materialized:l,semantics:u}}function Zn(e){let t=e?.trim().toLowerCase();return t?[`error`,`fail`,`failed`,`run error`].includes(t)?3:[`warn`,`warning`].includes(t)?2:+!![`success`,`pass`,`passed`].includes(t):0}function Qn(e){let t=e[0]?.status??`unknown`,n=Zn(t);for(let r of e.slice(1)){let e=Zn(r.status);e>n&&(n=e,t=r.status)}return t}function q(e,t){let n=e.start-t.start;if(n!==0)return n;let r=t.duration-e.duration;return r===0?e.name.localeCompare(t.name):r}function $n(e,t,n,r){let i=(e,n)=>{if(n.resourceType!==`test`&&n.resourceType!==`unit_test`||n.parentId==null||!t.hasNode(n.parentId))return;let r=t.getNodeAttributes(n.parentId);if(String(r?.resource_type??``)!==`source`)return;let i=e.get(n.parentId)??[];i.push(n),e.set(n.parentId,i)},a=(e,i)=>{let a=t.getNodeAttributes(e),o=[...i].sort(q),s=Math.min(...o.map(e=>e.start)),c=Math.max(...o.map(e=>e.end)),l=Yn(e,a,n,r);return{unique_id:e,name:typeof a?.name==`string`&&a.name.length>0?a.name:e,start:s,end:c,duration:Math.max(0,c-s),status:Qn(o),resourceType:`source`,packageName:typeof a?.package_name==`string`&&a.package_name.length>0?a.package_name:W(e),path:Jn(a),parentId:null,compileStart:null,compileEnd:null,executeStart:null,executeEnd:null,materialized:null,semantics:l}},o=new Set(e.map(e=>e.unique_id)),s=new Map;for(let t of e)i(s,t);let c=[];for(let[e,t]of s.entries())o.has(e)||t.length===0||c.push(a(e,t));return c.sort(q)}function er(e,t,n,r,i){let a=new Set(e.map(e=>e.unique_id)),o=new Map(e.map(e=>[e.unique_id,e])),s=[];return t.forEachNode((e,c)=>{if(String(c.resource_type??``)!==`source`||a.has(e))return;let l=typeof c.package_name==`string`&&c.package_name.length>0?c.package_name:W(e);if(n!=null&&l!==n)return;let u=[];for(let n of t.outboundNeighbors(e)){let e=o.get(n);e!=null&&(Un.has(e.resourceType)||u.push(e))}if(u.length===0)return;let d=[...u].sort(q),f=Math.min(...d.map(e=>e.start)),p=Math.max(...d.map(e=>e.end)),m=Yn(e,c,r,i);s.push({unique_id:e,name:typeof c.name==`string`&&c.name.length>0?c.name:e,start:f,end:p,duration:Math.max(0,p-f),status:Qn(d),resourceType:`source`,packageName:l,path:Jn(c),parentId:null,compileStart:null,compileEnd:null,executeStart:null,executeEnd:null,materialized:null,semantics:m})}),s.sort(q)}function tr(e){let t=e.column_name;return typeof t!=`string`||t.trim()===``?null:t.trim()}function nr(e,t){let n=e.attached_node;if(typeof n!=`string`)return null;let r=t.getGraph();if(!r.hasNode(n))return null;let i=r.getNodeAttributes(n);return i==null||typeof i.name!=`string`||i.name===``?null:i.name}function rr(e,t){let n=e.depends_on;if(!Array.isArray(n?.nodes))return null;let r=t.getGraph();for(let e of n.nodes){if(typeof e!=`string`||!r.hasNode(e))continue;let t=r.getNodeAttributes(e),n=String(t?.resource_type??G(e));if(!(n===`test`||n===`unit_test`)&&t!=null&&typeof t.name==`string`&&t.name!==``)return t.name}return null}function ir(e,t){if(e==null)return null;let n=tr(e),r=nr(e,t)??rr(e,t);return r!=null&&n!=null?`${r}.${n}`:r??n??null}function J(e,t){let n=P(e,t);return typeof n==`string`?n:null}function ar(e,t){let n=Array.isArray(t.tags)?t.tags.filter(e=>typeof e==`string`):void 0;return{uniqueId:e,name:String(t.name||e),resourceType:String(t.resource_type||`unknown`),packageName:String(t.package_name||``),...n===void 0?{}:{tags:n},path:J(t,`path`),originalFilePath:J(t,`original_file_path`),patchPath:J(t,`patch_path`),database:J(t,`database`),schema:J(t,`schema`),description:J(t,`description`)}}function Y(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function or(e){let t=new Map;if(e==null)return t;for(let n of[`nodes`,`sources`]){let r=n===`nodes`?e.nodes:n===`sources`?e.sources:void 0;if(!(typeof r!=`object`||!r))for(let[e,n]of Object.entries(r))typeof n==`object`&&n&&t.set(e,n)}return t}function sr(e){if(e==null)return null;let t=e.columns!=null&&typeof e.columns==`object`?e.columns:void 0,n=e.metadata!=null&&typeof e.metadata==`object`?e.metadata:void 0,r=e.stats!=null&&typeof e.stats==`object`?e.stats:void 0;return{columnCount:t==null?0:Object.keys(t).length,tableType:typeof n?.type==`string`?n.type:typeof n?.table_type==`string`?n.table_type:null,bytes:Y(r?.bytes)??Y(r?.num_bytes)??Y(r?.size),rowCount:Y(r?.row_count)??Y(r?.num_rows)??Y(r?.rows)}}function cr(e){let t=new Map,n=e?.results;if(!Array.isArray(n))return t;for(let e of n){if(typeof e!=`object`||!e)continue;let n=e,r=n.unique_id;typeof r==`string`&&r.length>0&&t.set(r,n)}return t}function lr(e){if(typeof e!=`object`||!e)return null;let t=typeof e.count==`number`?e.count:null,n=typeof e.period==`string`?e.period:null;return t==null||n==null?null:`${t} ${n}`}function ur(e,t){if(e!==`source`||t==null)return null;let n=t.criteria!=null&&typeof t.criteria==`object`?t.criteria:void 0,r=typeof t.status==`string`&&t.status.trim()!==``?t.status:void 0;return{status:r==null?`Unknown`:U(r),statusTone:H(r),maxLoadedAt:typeof t.max_loaded_at==`string`?t.max_loaded_at:null,snapshottedAt:typeof t.snapshotted_at==`string`?t.snapshotted_at:null,ageSeconds:Y(t.max_loaded_at_time_ago_in_s),criteria:n==null?null:{warnAfter:lr(n.warn_after),errorAfter:lr(n.error_after),filter:typeof n.filter==`string`?n.filter:null},error:typeof t.error==`string`?t.error:typeof t.message==`string`?t.message:null}}function dr(e,t,n){let r=e=>{let n=t.getNodeAttributes(e.nodeId);return{uniqueId:e.nodeId,name:String(n?.name||e.nodeId),resourceType:String(n?.resource_type||`unknown`),depth:e.depth}},i=e.getUpstream(n,1),a=e.getDownstream(n,1);return{upstreamCount:i.length,downstreamCount:a.length,upstream:i.map(r),downstream:a.map(r)}}function fr(e,t,n,r,i,a,o,s){let c=(e,t,n)=>e?{[t]:n}:{},l=ar(e,t),{resourceType:u}=l,d=J(t,`materialized`),f=xn({resourceType:u,materialized:d!=null&&d.trim()!==``?d:null,manifestEntry:a.get(e)??null,adapterType:o??null}),p=u===`test`||u===`unit_test`?ir(r,i):null,m=n?.message,h=typeof m==`string`&&m.trim()!==``?m.trim():null,g=typeof n?.execution_time==`number`?n.execution_time:null,_=typeof n?.thread_id==`string`?n.thread_id:null,v=sr(s.catalogEntry),y=ur(u,s.sourcesEntry);return{...l,compiledCode:null,rawCode:null,definition:En(u,t),status:n?.status?U(n.status):null,statusTone:H(n?.status),executionTime:g,threadId:_,semantics:f,...c(p!=null,`testAttachedTarget`,p),...c(h!=null,`runResultMessage`,h),...c(n?.adapterMetrics!=null,`adapterMetrics`,n?.adapterMetrics),...c(n?.adapterResponseFields!=null,`adapterResponseFields`,n?.adapterResponseFields),...c(v!=null,`catalogStats`,v),...c(y!=null,`sourceFreshness`,y)}}function pr(e,t,n,r,i){let a=[],o={},s=e.getGraph(),c=or(i.catalogJson),l=cr(i.sourcesJson);return s.forEachNode((i,u)=>{let d=t.get(i),f=n.get(i);a.push(fr(i,u,d,f,e,n,r,{catalogEntry:c.get(i),sourcesEntry:l.get(i)})),St(o,i,dr(e,s,i))}),a.sort(On),{resources:a,dependencyIndex:o}}var mr=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),hr=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.parseManifestV1=a,e.parseManifestV2=o,e.parseManifestV3=s,e.parseManifestV4=c,e.parseManifestV5=l,e.parseManifestV6=u,e.parseManifestV7=d,e.parseManifestV8=f,e.parseManifestV9=p,e.parseManifestV10=m,e.parseManifestV11=h,e.parseManifestV12=g,e.parseManifest=v,n(mr(),e);let r=`Not a manifest.json`;function i(e){if(!e)return null;let t=e.match(/\/manifest\/v(\d+)\.json$/);return t?parseInt(t[1],10):null}function a(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v1`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v1.json`))throw Error(`Not a manifest.json v1`);return e}function o(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v2`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v2.json`))throw Error(`Not a manifest.json v2`);return e}function s(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v3`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v3.json`))throw Error(`Not a manifest.json v3`);return e}function c(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v4`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v4.json`))throw Error(`Not a manifest.json v4`);return e}function l(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v5`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v5.json`))throw Error(`Not a manifest.json v5`);return e}function u(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v6`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v6.json`))throw Error(`Not a manifest.json v6`);return e}function d(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v7`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v7.json`))throw Error(`Not a manifest.json v7`);return e}function f(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v8`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v8.json`))throw Error(`Not a manifest.json v8`);return e}function p(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v9`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v9.json`))throw Error(`Not a manifest.json v9`);return e}function m(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v10`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v10.json`))throw Error(`Not a manifest.json v10`);return e}function h(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v11`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v11.json`))throw Error(`Not a manifest.json v11`);return e}function g(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v12`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v12.json`))throw Error(`Not a manifest.json v12`);return e}let _=[a,o,s,c,l,u,d,f,p,m,h,g];function v(e){let t=e.metadata;if(!t)throw Error(r);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v`))throw Error(r);let a=i(n);if(a===null)throw Error(r);let o=_[a-1];if(!o)throw Error(`Unsupported manifest version: ${a}`);return o(e)}})),gr=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),_r=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.parseRunResultsV1=a,e.parseRunResultsV2=o,e.parseRunResultsV3=s,e.parseRunResultsV4=c,e.parseRunResultsV5=l,e.parseRunResultsV6=u,e.parseRunResults=f,n(gr(),e);let r=`Not a run-results.json`;function i(e){if(!e)return null;let t=e.match(/\/run-results\/v(\d+)\.json$/);return t?parseInt(t[1],10):null}function a(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v1`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v1.json`))throw Error(`Not a run-results.json v1`);return e}function o(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v2`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v2.json`))throw Error(`Not a run-results.json v2`);return e}function s(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v3`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v3.json`))throw Error(`Not a run-results.json v3`);return e}function c(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v4`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v4.json`))throw Error(`Not a run-results.json v4`);return e}function l(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v5`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v5.json`))throw Error(`Not a run-results.json v5`);return e}function u(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v6`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v6.json`))throw Error(`Not a run-results.json v6`);return e}let d=[a,o,s,c,l,u];function f(e){let t=e.metadata;if(!t)throw Error(r);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v`))throw Error(r);let a=i(n);if(a===null)throw Error(r);let o=d[a-1];if(!o)throw Error(`Unsupported run-results version: ${a}`);return o(e)}})),vr=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),yr=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.parseCatalogV1=a,e.parseCatalog=o,n(vr(),e);let r=`Not a catalog.json`;function i(e){if(!e)return null;let t=e.match(/\/catalog\/v(\d+)\.json$/);return t?parseInt(t[1],10):null}function a(e){let t=e.metadata;if(!t)throw Error(`Not a catalog.json v1`);let n=t.dbt_schema_version;if(!n||!n.includes(`/catalog/v1.json`))throw Error(`Not a catalog.json v1`);return e}function o(e){let t=e.metadata;if(!t)throw Error(r);let n=t.dbt_schema_version;if(!n||!n.includes(`/catalog/v`))throw Error(r);let o=i(n);if(o===null)throw Error(r);switch(o){case 1:return a(e);default:throw Error(`Unsupported catalog version: ${o}`)}}})),br=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),xr=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.parseSourcesV1=a,e.parseSourcesV2=o,e.parseSourcesV3=s,e.parseSources=c,n(br(),e);let r=`Not a sources.json`;function i(e){if(!e)return null;let t=e.match(/\/sources\/v(\d+)\.json$/);return t?parseInt(t[1],10):null}function a(e){let t=e.metadata;if(!t)throw Error(`Not a sources.json v1`);let n=t.dbt_schema_version;if(!n||!n.includes(`/sources/v1.json`))throw Error(`Not a sources.json v1`);return e}function o(e){let t=e.metadata;if(!t)throw Error(`Not a sources.json v2`);let n=t.dbt_schema_version;if(!n||!n.includes(`/sources/v2.json`))throw Error(`Not a sources.json v2`);return e}function s(e){let t=e.metadata;if(!t)throw Error(`Not a sources.json v3`);let n=t.dbt_schema_version;if(!n||!n.includes(`/sources/v3.json`))throw Error(`Not a sources.json v3`);return e}function c(e){let t=e.metadata;if(!t)throw Error(r);let n=t.dbt_schema_version;if(!n||!n.includes(`/sources/v`))throw Error(r);let c=i(n);if(c===null)throw Error(r);switch(c){case 1:return a(e);case 2:return o(e);case 3:return s(e);default:throw Error(`Unsupported sources version: ${c}`)}}}));function Sr(){return{total_execution_time:0,total_nodes:0,nodes_by_status:{},node_executions:[]}}function Cr(e){let{manifestJson:t,runResultsJson:n,catalogJson:r,sourcesJson:i,manifest:a,runResults:o}=e,s=V(),c=new jt(a),l=Rn(t),u=o==null?null:new $t(o,c,l),d=V()-s,f=V(),p=u?.getSummary()??Sr(),m=Wn(t),h=u?.getGanttData()??[],g=u?.getNodeExecutions()??[],_=g.map(e=>e.started_at?new Date(e.started_at).getTime():null).filter(e=>e!==null),v=_.length>0?Math.min(..._):null,y=p.node_executions.length===0?void 0:cn(p.node_executions,{mode:`top_n`,top:5,graph:c}),b=c.getSummary(),x=new Map(h.map(e=>[e.unique_id,e])),S=new Map(g.map(e=>[e.unique_id,e])),C=c.getGraph(),{resources:w,dependencyIndex:ee}=pr(c,S,m,l,{catalogJson:r,sourcesJson:i}),te=In(t,g,C),T=h.map(e=>Xn(e,c,C,m,l)),ne=$n(T,C,m,l),re=er([...T,...ne],C,te,m,l),ie=[...T,...ne,...re].sort(q),ae=Vn(C,ie.map(e=>e.unique_id)),oe=new Map(w.map(e=>[e.uniqueId,e.semantics])),se=g.map(e=>{let t=C.hasNode(e.unique_id)?C.getNodeAttributes(e.unique_id):void 0,n=x.get(e.unique_id),r=oe.get(e.unique_id);return{uniqueId:e.unique_id,name:String(t?.name||e.unique_id),resourceType:String(t?.resource_type||G(e.unique_id)),packageName:(()=>{let n=t?.package_name;return typeof n==`string`&&n.length>0?n:W(e.unique_id)})(),path:typeof t?.original_file_path==`string`?t.original_file_path:typeof t?.path==`string`?t.path:null,status:U(e.status),statusTone:H(e.status),executionTime:e.execution_time??0,threadId:typeof e.thread_id==`string`?e.thread_id:null,start:n?.start??null,end:n?.end??null,...e.adapterMetrics==null?{}:{adapterMetrics:e.adapterMetrics},...e.adapterResponseFields==null?{}:{adapterResponseFields:e.adapterResponseFields},...r==null?{}:{semantics:r}}}).sort((e,t)=>t.executionTime-e.executionTime),ce=Bt(g.map(e=>e.adapterMetrics)),le=zn(w),ue=Bn(p,g),de=Hn(se),fe=w.find(e=>e.resourceType===`model`)?.uniqueId??w[0]?.uniqueId??null;return{analysis:{summary:p,projectName:te,warehouseType:l,runStartedAt:v,ganttData:ie,bottlenecks:y,graphSummary:{totalNodes:b.total_nodes,totalEdges:b.total_edges,hasCycles:b.has_cycles,nodesByType:b.nodes_by_type},resources:w,resourceGroups:le,executions:se,statusBreakdown:ue,threadStats:de,dependencyIndex:ee,timelineAdjacency:ae,selectedResourceId:fe,invocationId:n==null?null:Ln(n),...ce==null?{}:{adapterTotals:ce}},timings:{graphBuildMs:d,snapshotBuildMs:V()-f},graph:c}}function wr(e){let t=e.split(/\s+/).filter(Boolean),n=[],r,i,a,o;for(let e of t)e.startsWith(`type:`)?r=e.slice(5):e.startsWith(`package:`)?i=e.slice(8):e.startsWith(`tag:`)?a=e.slice(4):e.startsWith(`path:`)?o=e.slice(5):e.startsWith(`owner:`)||e.startsWith(`source:`)?n.push(e.slice(e.indexOf(`:`)+1)):n.push(e);return{terms:n,type:r,package:i,tag:a,path:o}}function Tr(e,t,n,r,i){if(e.resource_type===`field`||t&&!t.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean).includes(e.resource_type.toLowerCase())||n&&(e.package_name||``)!==n)return!1;if(r){let t=r.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean),n=(e.tags||[]).map(e=>e.toLowerCase());if(!t.some(e=>n.includes(e)))return!1}return!(i&&!(e.path||``).includes(i))}var Er=hr(),Dr=_r(),Or=yr(),kr=xr();let X={accent:`#635BFF`,text:`#171C28`,textSoft:`#6B7385`,bg:`#F6F7FB`,bgSoft:`#FFFFFF`,borderDefault:`#D7DCE7`,borderSubtle:`#E6E9F0`,slate:`#64748B`,rose:`#C0352B`,mint:`#0F8A4B`,amber:`#A56315`},Z={accent:`#8A7CFF`,text:`#F3F6FC`,textSoft:`#98A3BC`,bg:`#0D1120`,bgSoft:`#151A2E`,borderDefault:`#313A58`,borderSubtle:`#262E47`,slate:`#8690AA`,rose:`#FF8D86`,mint:`#59D38C`,amber:`#F5B95C`};X.mint,X.rose,X.slate,X.rose,X.mint,X.rose,X.amber,X.slate,Z.mint,Z.rose,Z.slate,Z.rose,Z.mint,Z.rose,Z.amber,Z.slate,X.text,X.textSoft,X.slate,X.accent,Z.text,Z.textSoft,Z.slate,Z.accent;let Ar=new Set([`model`,`seed`,`snapshot`,`source`,`source_freshness`,`test`,`unit_test`,`metric`,`semantic_model`]),jr=new Set([`test`,`unit_test`]);[...Ar].filter(e=>!jr.has(e)).sort((e,t)=>e.localeCompare(t));function Mr(e,t){if(!t)return!0;let n=t.trim().toLowerCase();if(!n)return!0;let r=wr(n);if(!Tr({unique_id:e.uniqueId,resource_type:e.resourceType,name:e.name,package_name:e.packageName,tags:e.tags,path:e.path??``},r.type,r.package,r.tag,r.path))return!1;let i=[e.name,e.resourceType,e.packageName,...e.tags??[],e.path??``,e.originalFilePath??``,e.patchPath??``,e.uniqueId].map(e=>e.toLowerCase());return r.terms.every(e=>i.some(t=>t.includes(e.toLowerCase())))}function Nr(e){let t=e.origin;if(t===``||t===`null`)return!0;try{return t===globalThis.location.origin}catch{return!1}}function Q(){return performance.now()}let $=null,Pr=null,Fr=0,Ir=`No analysis loaded`;function Lr(e,t){return{type:`analysis-error`,protocolVersion:4,requestId:e,message:t}}function Rr(e,t){return{type:`resource-code-error`,protocolVersion:4,requestId:e,message:t}}function zr(e,t){return{type:`search-resources-error`,protocolVersion:4,requestId:e,message:t}}function Br(e){let t=new TextDecoder().decode(e);return JSON.parse(t)}function Vr(e){return e==null?void 0:Br(e)}function Hr(e,t){let n=e.getGraph();if(!n.hasNode(t))return{compiledCode:null,rawCode:null};let r=n.getNodeAttributes(t);return{compiledCode:typeof r.compiled_code==`string`?r.compiled_code:null,rawCode:typeof r.raw_code==`string`?r.raw_code:typeof r.raw_sql==`string`?r.raw_sql:null}}function Ur(e){if(e.protocolVersion!==4)return zr(e.requestId,`Unsupported protocol version: ${e.protocolVersion}`);if(!Pr)return zr(e.requestId,Ir);let t=Pr.filter(t=>Mr(t,e.query)).slice(0,8);return{type:`search-resources-ready`,protocolVersion:4,requestId:e.requestId,resources:t}}function Wr(e){if(e.protocolVersion!==4)return Rr(e.requestId,`Unsupported protocol version: ${e.protocolVersion}`);if(!$)return Rr(e.requestId,Ir);let{compiledCode:t,rawCode:n}=Hr($,e.uniqueId);return{type:`resource-code-ready`,protocolVersion:4,requestId:e.requestId,compiledCode:t,rawCode:n}}async function Gr(e){if(e.protocolVersion!==4)return Lr(e.requestId,`Unsupported protocol version: ${e.protocolVersion}`);let t=++Fr;try{let n=Q(),r=Q(),i=Br(e.artifactBuffers.manifestBytes),a=Vr(e.artifactBuffers.runResultsBytes),o=Vr(e.artifactBuffers.catalogBytes),s=Vr(e.artifactBuffers.sourcesBytes),c=Q()-r,l=Q(),u=(0,Er.parseManifest)(i),d=a==null?void 0:(0,Dr.parseRunResults)(a),f=o==null?void 0:(0,Or.parseCatalog)(o),p=s==null?void 0:(0,kr.parseSources)(s),m=Q()-l,{analysis:h,timings:g,graph:_}=Cr({manifestJson:i,runResultsJson:a,catalogJson:o,sourcesJson:s,manifest:u,runResults:d,catalog:f,sources:p});t===Fr&&($=_,Pr=h.resources);let v={decodeMs:c,parseMs:m,graphBuildMs:g.graphBuildMs,snapshotBuildMs:g.snapshotBuildMs,totalWorkerMs:Q()-n};return{type:`analysis-ready`,protocolVersion:4,requestId:e.requestId,analysis:h,timings:v}}catch(t){return Lr(e.requestId,t instanceof Error?t.message:`Failed to analyze artifacts`)}}function Kr(e){return e.type===`get-resource-code`?Promise.resolve(Wr(e)):e.type===`search-resources`?Promise.resolve(Ur(e)):Gr(e)}function qr(e){return typeof e==`object`&&!!e&&e.type===`invalidate-pending-loads`}typeof self<`u`&&(self.onmessage=e=>{if(Nr(e)){if(qr(e.data)){Fr+=1;return}Kr(e.data).then(e=>{self.postMessage(e)})}})})();
|