pi-weave 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/index.ts +5 -0
- package/src/core/vault.ts +105 -14
- package/src/web/client/api.ts +21 -1
- package/src/web/client/dist/app.js +48 -42
- package/src/web/client/graph/column.model.ts +5 -3
- package/src/web/client/note/note.model.ts +22 -3
- package/src/web/client/shell/Columns.tsx +2 -1
- package/src/web/client/shell/Shell.tsx +1 -0
- package/src/web/client/shell/theme.ts +6 -0
- package/src/web/client/tree/Tree.tsx +46 -4
- package/src/web/client/tree/tree.model.ts +23 -0
- package/src/web/server/routes.ts +63 -2
- package/src/web/shared/wire.ts +6 -0
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
* sigma@3.0.3 — MIT
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
"use strict";(()=>{var pf=Object.create;var Ua=Object.defineProperty;var gf=Object.getOwnPropertyDescriptor;var mf=Object.getOwnPropertyNames;var vf=Object.getPrototypeOf,yf=Object.prototype.hasOwnProperty;var Ha=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var wf=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of mf(e))!yf.call(t,i)&&i!==n&&Ua(t,i,{get:()=>e[i],enumerable:!(r=gf(e,i))||r.enumerable});return t};var on=(t,e,n)=>(n=t!=null?pf(vf(t)):{},wf(e||!t||!t.__esModule?Ua(n,"default",{value:t,enumerable:!0}):n,t));var ur=Ha((ix,Bi)=>{"use strict";var $t=typeof Reflect=="object"?Reflect:null,Qs=$t&&typeof $t.apply=="function"?$t.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},sr;$t&&typeof $t.ownKeys=="function"?sr=$t.ownKeys:Object.getOwnPropertySymbols?sr=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:sr=function(e){return Object.getOwnPropertyNames(e)};function kp(t){console&&console.warn&&console.warn(t)}var el=Number.isNaN||function(e){return e!==e};function W(){W.init.call(this)}Bi.exports=W;Bi.exports.once=Ap;W.EventEmitter=W;W.prototype._events=void 0;W.prototype._eventsCount=0;W.prototype._maxListeners=void 0;var Js=10;function lr(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(W,"defaultMaxListeners",{enumerable:!0,get:function(){return Js},set:function(t){if(typeof t!="number"||t<0||el(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Js=t}});W.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};W.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||el(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function tl(t){return t._maxListeners===void 0?W.defaultMaxListeners:t._maxListeners}W.prototype.getMaxListeners=function(){return tl(this)};W.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var a;if(n.length>0&&(a=n[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=o[e];if(l===void 0)return!1;if(typeof l=="function")Qs(l,this,n);else for(var u=l.length,c=al(l,u),r=0;r<u;++r)Qs(c[r],this,n);return!0};function nl(t,e,n,r){var i,o,a;if(lr(n),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),a=o[e]),a===void 0)a=o[e]=n,++t._eventsCount;else if(typeof a=="function"?a=o[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),i=tl(t),i>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,kp(s)}return t}W.prototype.addListener=function(e,n){return nl(this,e,n,!1)};W.prototype.on=W.prototype.addListener;W.prototype.prependListener=function(e,n){return nl(this,e,n,!0)};function Ep(){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 rl(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=Ep.bind(r);return i.listener=n,r.wrapFn=i,i}W.prototype.once=function(e,n){return lr(n),this.on(e,rl(this,e,n)),this};W.prototype.prependOnceListener=function(e,n){return lr(n),this.prependListener(e,rl(this,e,n)),this};W.prototype.removeListener=function(e,n){var r,i,o,a,s;if(lr(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(o=-1,a=r.length-1;a>=0;a--)if(r[a]===n||r[a].listener===n){s=r[a].listener,o=a;break}if(o<0)return this;o===0?r.shift():Sp(r,o),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,s||n)}return this};W.prototype.off=W.prototype.removeListener;W.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var o=Object.keys(r),a;for(i=0;i<o.length;++i)a=o[i],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=r[e],typeof n=="function")this.removeListener(e,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(e,n[i]);return this};function il(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?Tp(i):al(i,i.length)}W.prototype.listeners=function(e){return il(this,e,!0)};W.prototype.rawListeners=function(e){return il(this,e,!1)};W.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):ol.call(t,e)};W.prototype.listenerCount=ol;function ol(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}W.prototype.eventNames=function(){return this._eventsCount>0?sr(this._events):[]};function al(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function Sp(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Tp(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function Ap(t,e){return new Promise(function(n,r){function i(a){t.removeListener(e,o),r(a)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),n([].slice.call(arguments))}sl(t,e,o,{once:!0}),e!=="error"&&Rp(t,i,{once:!0})})}function Rp(t,e,n){typeof t.on=="function"&&sl(t,"error",e,n)}function sl(t,e,n,r){if(typeof t.on=="function")r.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){r.once&&t.removeEventListener(e,i),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var Wi=Ha((sx,ul)=>{"use strict";ul.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var Jn,B,ja,bf,at,Ba,qa,Ya,vi,jn,an,Xa,bi,yi,wi,xf,Xn={},Zn=[],_f=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,er=Array.isArray;function Xe(t,e){for(var n in e)t[n]=e[n];return t}function xi(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function kf(t,e,n){var r,i,o,a={};for(o in e)o=="key"?r=e[o]:o=="ref"?i=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?Jn.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)a[o]===void 0&&(a[o]=t.defaultProps[o]);return qn(t,a,r,i,null)}function qn(t,e,n,r,i){var o={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++ja,__i:-1,__u:0};return i==null&&B.vnode!=null&&B.vnode(o),o}function st(t){return t.children}function Yn(t,e){this.props=t,this.context=e}function vt(t,e){if(e==null)return t.__?vt(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?vt(t):null}function Ef(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,r=[],i=[],o=Xe({},e);o.__v=e.__v+1,B.vnode&&B.vnode(o),_i(t.__P,o,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,r,n??vt(e),!!(32&e.__u),i),o.__v=e.__v,o.__.__k[o.__i]=o,ts(r,o,i),e.__e=e.__=null,o.__e!=n&&Za(o)}}function Za(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(e){if(e!=null&&e.__e!=null)return t.__e=t.__c.base=e.__e}),Za(t)}function Wa(t){(!t.__d&&(t.__d=!0)&&at.push(t)&&!Qn.__r++||Ba!=B.debounceRendering)&&((Ba=B.debounceRendering)||qa)(Qn)}function Qn(){try{for(var t,e=1;at.length;)at.length>e&&at.sort(Ya),t=at.shift(),e=at.length,Ef(t)}finally{at.length=Qn.__r=0}}function Qa(t,e,n,r,i,o,a,s,l,u,c){var h,d,f,g,m,v,y=r&&r.__k||Zn,w=e.length;for(l=Sf(n,e,y,l,w),h=0;h<w;h++)(f=n.__k[h])!=null&&(d=f.__i!=-1&&y[f.__i]||Xn,f.__i=h,v=_i(t,f,d,i,o,a,s,l,u,c),g=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&ki(d.ref,null,f),c.push(f.ref,f.__c||g,f)),m==null&&g!=null&&(m=g),4&f.__u?(l=Ja(f,l,t),d.__e&&(d.__e=null)):typeof f.type=="function"&&v!==void 0?l=v:g&&(l=g.nextSibling),f.__u&=-7);return n.__e=m,l}function Sf(t,e,n,r,i){var o,a,s,l,u,c=n.length,h=c,d=0;for(t.__k=new Array(i),o=0;o<i;o++)(a=e[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=t.__k[o]=qn(null,a,null,null,null):er(a)?a=t.__k[o]=qn(st,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[o]=qn(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[o]=a,l=o+d,a.__=t,a.__b=t.__b+1,s=null,(u=a.__i=Tf(a,n,l,h))!=-1&&(h--,(s=n[u])&&(s.__u|=2)),s==null||s.__v==null?(u==-1&&(i>c?d--:i<c&&d++),typeof a.type!="function"&&(a.__u|=4)):u!=l&&(u==l-1?d--:u==l+1?d++:(u>l?d--:d++,a.__u|=4))):t.__k[o]=null;if(h)for(o=0;o<c;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=vt(s)),rs(s,s));return r}function Ja(t,e,n){var r,i;if(typeof t.type=="function"){for(r=t.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=t,e=Ja(r[i],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=vt(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Tf(t,e,n,r){var i,o,a,s=t.key,l=t.type,u=e[n],c=u!=null&&(2&u.__u)==0;if(u===null&&s==null||c&&s==u.key&&l==u.type)return n;if(r>(c?1:0)){for(i=n-1,o=n+1;i>=0||o<e.length;)if((u=e[a=i>=0?i--:o++])!=null&&(2&u.__u)==0&&s==u.key&&l==u.type)return a}return-1}function Ka(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||_f.test(e)?n:n+"px"}function Vn(t,e,n,r,i){var o,a;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||Ka(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||Ka(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(Xa,"$1")),a=e.toLowerCase(),e=a in t||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n[an]=r[an]:(n[an]=bi,t.addEventListener(e,o?wi:yi,o)):t.removeEventListener(e,o?wi:yi,o);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function Va(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[jn]==null)e[jn]=bi++;else if(e[jn]<n[an])return;return n(B.event?B.event(e):e)}}}function _i(t,e,n,r,i,o,a,s,l,u){var c,h,d,f,g,m,v,y,w,k,_,L,R,D,z,F,G=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=e.__e=n.__e]),(c=B.__b)&&c(e);e:if(typeof G=="function"){h=a.length;try{if(w=e.props,k=G.prototype&&G.prototype.render,_=(c=G.contextType)&&r[c.__c],L=c?_?_.props.value:c.__:r,n.__c?y=(d=e.__c=n.__c).__=d.__E:(k?e.__c=d=new G(w,L):(e.__c=d=new Yn(w,L),d.constructor=G,d.render=Rf),_&&_.sub(d),d.state||(d.state={}),d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),k&&d.__s==null&&(d.__s=d.state),k&&G.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=Xe({},d.__s)),Xe(d.__s,G.getDerivedStateFromProps(w,d.__s))),g=d.props,m=d.state,d.__v=e,f)k&&G.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),k&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(k&&G.getDerivedStateFromProps==null&&w!==g&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(w,L),e.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(w,d.__s,L)===!1){e.__v!=n.__v&&(d.props=w,d.state=d.__s,d.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(U){U&&(U.__=e)}),Zn.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=vt(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(w,d.__s,L),k&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(g,m,v)})}if(d.context=L,d.props=w,d.__P=t,d.__e=!1,R=B.__r,D=0,k)d.state=d.__s,d.__d=!1,R&&R(e),c=d.render(d.props,d.state,d.context),Zn.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,R&&R(e),c=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++D<25);d.state=d.__s,d.getChildContext!=null&&(r=Xe(Xe({},r),d.getChildContext())),k&&!f&&d.getSnapshotBeforeUpdate!=null&&(v=d.getSnapshotBeforeUpdate(g,m)),z=c!=null&&c.type===st&&c.key==null?ns(c.props.children):c,s=Qa(t,er(z)?z:[z],e,n,r,i,o,a,s,l,u),d.base=e.__e,e.__u&=-161,d.__h.length&&a.push(d),y&&(d.__E=d.__=null)}catch(U){if(a.length=h,e.__v=null,l||o!=null){if(U.then){for(e.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o!=null&&(o[o.indexOf(s)]=null),e.__e=s}else if(o!=null)for(F=o.length;F--;)xi(o[F])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),U.then||es(e),B.__e(U,e,n)}}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):s=e.__e=Af(n.__e,e,n,r,i,o,a,l,u);return(c=B.diffed)&&c(e),128&e.__u?void 0:s}function es(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(es))}function ts(t,e,n){for(var r=0;r<n.length;r++)ki(n[r],n[++r],n[++r]);B.__c&&B.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){B.__e(o,i.__v)}})}function ns(t){return typeof t!="object"||t==null||t.__b>0?t:er(t)?t.map(ns):t.constructor!==void 0?null:Xe({},t)}function Af(t,e,n,r,i,o,a,s,l){var u,c,h,d,f,g,m,v=n.props||Xn,y=e.props,w=e.type;if(w=="svg"?i="http://www.w3.org/2000/svg":w=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((f=o[u])&&"setAttribute"in f==!!w&&(w?f.localName==w:f.nodeType==3)){t=f,o[u]=null;break}}if(t==null){if(w==null)return document.createTextNode(y);t=document.createElementNS(i,w,y.is&&y),s&&(B.__m&&B.__m(e,o),s=!1),o=null}if(w==null)v===y||s&&t.data==y||(t.data=y);else{if(o=w=="textarea"&&y.defaultValue!=null?null:o&&Jn.call(t.childNodes),!s&&o!=null)for(v={},u=0;u<t.attributes.length;u++)v[(f=t.attributes[u]).name]=f.value;for(u in v)f=v[u],u=="dangerouslySetInnerHTML"?h=f:u=="children"||u in y||u=="value"&&"defaultValue"in y||u=="checked"&&"defaultChecked"in y||Vn(t,u,null,f,i);for(u in y)f=y[u],u=="children"?d=f:u=="dangerouslySetInnerHTML"?c=f:u=="value"?g=f:u=="checked"?m=f:s&&typeof f!="function"||v[u]===f||Vn(t,u,f,v[u],i);if(c)s||h&&(c.__html==h.__html||c.__html==t.innerHTML)||(t.innerHTML=c.__html),e.__k=[];else if(h&&(t.innerHTML=""),Qa(e.type=="template"?t.content:t,er(d)?d:[d],e,n,r,w=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&vt(n,0),s,l),o!=null)for(u=o.length;u--;)xi(o[u]);s&&w!="textarea"||(u="value",w=="progress"&&g==null?t.removeAttribute("value"):g!=null&&(g!==t[u]||w=="progress"&&!g||w=="option"&&g!=v[u])&&Vn(t,u,g,v[u],i),u="checked",m!=null&&m!=t[u]&&Vn(t,u,m,v[u],i))}return t}function ki(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){B.__e(i,n)}}function rs(t,e,n){var r,i;if(B.unmount&&B.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||ki(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){B.__e(o,e)}r.base=r.__P=r.__n=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&rs(r[i],e,n||typeof t.type!="function");n||xi(t.__e),t.__c=t.__=t.__e=void 0}function Rf(t,e,n){return this.constructor(t,n)}function is(t,e,n){var r,i,o,a;e==document&&(e=document.documentElement),B.__&&B.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,o=[],a=[],_i(e,t=(!r&&n||e).__k=kf(st,null,[t]),i||Xn,Xn,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?Jn.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,a),ts(o,t,a),t.props.children=null}Jn=Zn.slice,B={__e:function(t,e,n,r){for(var i,o,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),a=i.__d),a)return i.__E=i}catch(s){t=s}throw t}},ja=0,bf=function(t){return t!=null&&t.constructor===void 0},Yn.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Xe({},this.state),typeof t=="function"&&(t=t(Xe({},n),this.props)),t&&Xe(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),Wa(this))},Yn.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Wa(this))},Yn.prototype.render=st,at=[],qa=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ya=function(t,e){return t.__v.__b-e.__v.__b},Qn.__r=0,vi=Math.random().toString(8),jn="__d"+vi,an="__a"+vi,Xa=/(PointerCapture)$|Capture$/i,bi=0,yi=Va(!1),wi=Va(!0),xf=0;var os="weave-bootstrap";var Ei={cwd:""};function Cf(t){return typeof t!="object"||t===null?!1:typeof t.cwd=="string"}function as(t){if(t===null||t.trim()==="")return Ei;let e;try{e=JSON.parse(t)}catch{return Ei}return Cf(e)?e:Ei}var Ot,te,Si,ss,sn=0,gs=[],re=B,ls=re.__b,us=re.__r,cs=re.diffed,ds=re.__c,hs=re.unmount,fs=re.__;function nr(t,e){re.__h&&re.__h(te,t,sn||e),sn=0;var n=te.__H||(te.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function oe(t){return sn=1,Nf(vs,t)}function Nf(t,e,n){var r=nr(Ot++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):vs(void 0,e),function(s){var l=r.__N?r.__N[0]:r.__[0],u=r.t(l,s);l!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=te,!te.__f)){var i=function(s,l,u){if(!r.__c.__H)return!0;var c=!1,h=r.__c.props!==s;if(r.__c.__H.__.some(function(f){if(f.__N){c=!0;var g=f.__[0];f.__=f.__N,f.__N=void 0,g!==f.__[0]&&(h=!0)}}),o){var d=o.call(this,s,l,u);return c?d||h:d}return!c||h};te.__f=!0;var o=te.shouldComponentUpdate,a=te.componentWillUpdate;te.componentWillUpdate=function(s,l,u){if(this.__e){var c=o;o=void 0,i(s,l,u),o=c}a&&a.call(this,s,l,u)},te.shouldComponentUpdate=i}return r.__N||r.__}function ie(t,e){var n=nr(Ot++,3);!re.__s&&Ai(n.__H,e)&&(n.__=t,n.u=e,te.__H.__h.push(n))}function ln(t,e){var n=nr(Ot++,4);!re.__s&&Ai(n.__H,e)&&(n.__=t,n.u=e,te.__h.push(n))}function ee(t){return sn=5,qe(function(){return{current:t}},[])}function qe(t,e){var n=nr(Ot++,7);return Ai(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function ms(t,e){return sn=8,qe(function(){return t},e)}function Lf(){for(var t;t=gs.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(tr),e.__h.some(Ti),e.__h=[]}catch(n){e.__h=[],re.__e(n,t.__v)}}}re.__b=function(t){te=null,ls&&ls(t)},re.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),fs&&fs(t,e)},re.__r=function(t){us&&us(t),Ot=0;var e=(te=t.__c).__H;e&&(Si===te?(e.__h=[],te.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(tr),e.__h.some(Ti),e.__h=[],Ot=0)),Si=te},re.diffed=function(t){cs&&cs(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(gs.push(e)!==1&&ss===re.requestAnimationFrame||((ss=re.requestAnimationFrame)||Pf)(Lf)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Si=te=null},re.__c=function(t,e){e.some(function(n){try{n.__h.some(tr),n.__h=n.__h.filter(function(r){return!r.__||Ti(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],re.__e(r,n.__v)}}),ds&&ds(t,e)},re.unmount=function(t){hs&&hs(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(r){try{tr(r)}catch(i){e=i}}),n.__H=void 0,e&&re.__e(e,n.__v))};var ps=typeof requestAnimationFrame=="function";function Pf(t){var e,n=function(){clearTimeout(r),ps&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);ps&&(e=requestAnimationFrame(n))}function tr(t){var e=te,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),te=e}function Ti(t){var e=te;t.__c=t.__(),te=e}function Ai(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function vs(t,e){return typeof e=="function"?e(t):e}var rr=(t,e)=>fetch(t,{...e?.method===void 0?{}:{method:e.method},...e?.headers===void 0?{}:{headers:e.headers},...e?.body===void 0?{}:{body:e.body},...e?.signal===void 0?{}:{signal:e.signal},credentials:"same-origin"});function Ri(t,e=!1){return{ok:!0,data:t,cached:e}}function Ze(t,e,n){return{ok:!1,kind:t,status:e,message:n}}function ys(t){return t===403?"auth":t===404?"missing":"server"}function ws(t){return t===403?"not authorised — this workspace session has ended":t===404?"not found":`server error (${t})`}async function Ci(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return Ze("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return Ze(ys(i.status),i.status,ws(i.status));let o;try{o=await i.json()}catch{return Ze("malformed",i.status,"response was not valid JSON")}return n(o)?Ri(o):Ze("malformed",i.status,"response did not match the expected shape")}function lt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Df(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function If(t){if(!lt(t)||typeof t.stamp!="string")return!1;let e=t.model;return!lt(e)||!Array.isArray(e.nodes)||!Array.isArray(e.edges)?!1:lt(t.tags)&<(t.dangling)}function Gf(t){if(!lt(t))return!1;for(let e of["slug","title","body","created","updated","source"])if(typeof t[e]!="string")return!1;return Df(t.tags)}function Mf(t){return lt(t)&&Gf(t.note)}function Of(t){return lt(t)&&typeof t.query=="string"&&Array.isArray(t.hits)}function Ff(t){return lt(t)&&typeof t.opened=="boolean"}async function bs(t,e=null){let n=e===null?void 0:{"if-none-match":`"${e.stamp}"`},r;try{r=await t("/api/graph",n===void 0?{}:{headers:n})}catch(o){return Ze("network",0,o instanceof Error?o.message:"network request failed")}if(r.status===304)return e===null?Ze("malformed",304,"server sent 304 for an unconditional request"):Ri(e,!0);if(!r.ok)return Ze(ys(r.status),r.status,ws(r.status));let i;try{i=await r.json()}catch{return Ze("malformed",r.status,"response was not valid JSON")}return If(i)?Ri(i):Ze("malformed",r.status,"response did not match the expected shape")}function xs(t,e){return Ci(t,`/api/note/${encodeURIComponent(e)}`,Mf)}function _s(t,e,n){return Ci(t,`/api/search?q=${encodeURIComponent(e)}`,Of,n===void 0?void 0:{signal:n})}function ks(t,e){return Ci(t,"/api/open",Ff,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:e})})}var Es="(prefers-color-scheme: light)";function ir(t){return t==null||typeof t.matchMedia!="function"?"dark":t.matchMedia(Es).matches?"light":"dark"}function Ss(t,e){if(typeof t.matchMedia!="function")return()=>{};let n=t.matchMedia(Es);if(typeof n.addEventListener!="function")return()=>{};let r=()=>e(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}function zf(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function wt(t){var e=zf(t,"string");return typeof e=="symbol"?e:e+""}function le(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ts(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,wt(r.key),r)}}function ue(t,e,n){return e&&Ts(t.prototype,e),n&&Ts(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function yt(t){return yt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},yt(t)}function As(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(As=function(){return!!t})()}function $f(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Uf(t,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return $f(t)}function be(t,e,n){return e=yt(e),Uf(t,As()?Reflect.construct(e,n||[],yt(t).constructor):e.apply(t,n))}function Ni(t,e){return Ni=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Ni(t,e)}function xe(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Ni(t,e)}function Hf(t){if(Array.isArray(t))return t}function Bf(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function or(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Ii(t,e){if(t){if(typeof t=="string")return or(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?or(t,e):void 0}}function Wf(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
22
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
21
|
+
"use strict";(()=>{var Cf=Object.create;var Ka=Object.defineProperty;var Nf=Object.getOwnPropertyDescriptor;var Lf=Object.getOwnPropertyNames;var Df=Object.getPrototypeOf,Pf=Object.prototype.hasOwnProperty;var Va=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var If=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Lf(e))!Pf.call(t,i)&&i!==n&&Ka(t,i,{get:()=>e[i],enumerable:!(r=Nf(e,i))||r.enumerable});return t};var an=(t,e,n)=>(n=t!=null?Cf(Df(t)):{},If(e||!t||!t.__esModule?Ka(n,"default",{value:t,enumerable:!0}):n,t));var dr=Va((yx,Vi)=>{"use strict";var Ut=typeof Reflect=="object"?Reflect:null,ll=Ut&&typeof Ut.apply=="function"?Ut.apply:function(e,n,r){return Function.prototype.apply.call(e,n,r)},ur;Ut&&typeof Ut.ownKeys=="function"?ur=Ut.ownKeys:Object.getOwnPropertySymbols?ur=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ur=function(e){return Object.getOwnPropertyNames(e)};function zp(t){console&&console.warn&&console.warn(t)}var cl=Number.isNaN||function(e){return e!==e};function W(){W.init.call(this)}Vi.exports=W;Vi.exports.once=Bp;W.EventEmitter=W;W.prototype._events=void 0;W.prototype._eventsCount=0;W.prototype._maxListeners=void 0;var ul=10;function cr(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(W,"defaultMaxListeners",{enumerable:!0,get:function(){return ul},set:function(t){if(typeof t!="number"||t<0||cl(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ul=t}});W.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};W.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||cl(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function dl(t){return t._maxListeners===void 0?W.defaultMaxListeners:t._maxListeners}W.prototype.getMaxListeners=function(){return dl(this)};W.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var a;if(n.length>0&&(a=n[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=o[e];if(l===void 0)return!1;if(typeof l=="function")ll(l,this,n);else for(var u=l.length,c=ml(l,u),r=0;r<u;++r)ll(c[r],this,n);return!0};function hl(t,e,n,r){var i,o,a;if(cr(n),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),a=o[e]),a===void 0)a=o[e]=n,++t._eventsCount;else if(typeof a=="function"?a=o[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),i=dl(t),i>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,zp(s)}return t}W.prototype.addListener=function(e,n){return hl(this,e,n,!1)};W.prototype.on=W.prototype.addListener;W.prototype.prependListener=function(e,n){return hl(this,e,n,!0)};function $p(){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 fl(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=$p.bind(r);return i.listener=n,r.wrapFn=i,i}W.prototype.once=function(e,n){return cr(n),this.on(e,fl(this,e,n)),this};W.prototype.prependOnceListener=function(e,n){return cr(n),this.prependListener(e,fl(this,e,n)),this};W.prototype.removeListener=function(e,n){var r,i,o,a,s;if(cr(n),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||n));else if(typeof r!="function"){for(o=-1,a=r.length-1;a>=0;a--)if(r[a]===n||r[a].listener===n){s=r[a].listener,o=a;break}if(o<0)return this;o===0?r.shift():Up(r,o),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,s||n)}return this};W.prototype.off=W.prototype.removeListener;W.prototype.removeAllListeners=function(e){var n,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var o=Object.keys(r),a;for(i=0;i<o.length;++i)a=o[i],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=r[e],typeof n=="function")this.removeListener(e,n);else if(n!==void 0)for(i=n.length-1;i>=0;i--)this.removeListener(e,n[i]);return this};function pl(t,e,n){var r=t._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?n?[i.listener||i]:[i]:n?Hp(i):ml(i,i.length)}W.prototype.listeners=function(e){return pl(this,e,!0)};W.prototype.rawListeners=function(e){return pl(this,e,!1)};W.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):gl.call(t,e)};W.prototype.listenerCount=gl;function gl(t){var e=this._events;if(e!==void 0){var n=e[t];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}W.prototype.eventNames=function(){return this._eventsCount>0?ur(this._events):[]};function ml(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}function Up(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Hp(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}function Bp(t,e){return new Promise(function(n,r){function i(a){t.removeListener(e,o),r(a)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),n([].slice.call(arguments))}vl(t,e,o,{once:!0}),e!=="error"&&Wp(t,i,{once:!0})})}function Wp(t,e,n){typeof t.on=="function"&&vl(t,"error",e,n)}function vl(t,e,n,r){if(typeof t.on=="function")r.once?t.once(e,n):t.on(e,n);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){r.once&&t.removeEventListener(e,i),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var ji=Va((xx,wl)=>{"use strict";wl.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var tr,B,Za,Gf,ct,ja,Qa,Ja,bi,Yn,sn,es,ki,xi,_i,Mf,Qn={},Jn=[],Of=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,nr=Array.isArray;function Qe(t,e){for(var n in e)t[n]=e[n];return t}function Ei(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Ff(t,e,n){var r,i,o,a={};for(o in e)o=="key"?r=e[o]:o=="ref"?i=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?tr.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(o in t.defaultProps)a[o]===void 0&&(a[o]=t.defaultProps[o]);return Xn(t,a,r,i,null)}function Xn(t,e,n,r,i){var o={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Za,__i:-1,__u:0};return i==null&&B.vnode!=null&&B.vnode(o),o}function qe(t){return t.children}function Zn(t,e){this.props=t,this.context=e}function yt(t,e){if(e==null)return t.__?yt(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?yt(t):null}function zf(t){if(t.__P&&t.__d){var e=t.__v,n=e.__e,r=[],i=[],o=Qe({},e);o.__v=e.__v+1,B.vnode&&B.vnode(o),Si(t.__P,o,e,t.__n,t.__P.namespaceURI,32&e.__u?[n]:null,r,n??yt(e),!!(32&e.__u),i),o.__v=e.__v,o.__.__k[o.__i]=o,os(r,o,i),e.__e=e.__=null,o.__e!=n&&ts(o)}}function ts(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(e){if(e!=null&&e.__e!=null)return t.__e=t.__c.base=e.__e}),ts(t)}function qa(t){(!t.__d&&(t.__d=!0)&&ct.push(t)&&!er.__r++||ja!=B.debounceRendering)&&((ja=B.debounceRendering)||Qa)(er)}function er(){try{for(var t,e=1;ct.length;)ct.length>e&&ct.sort(Ja),t=ct.shift(),e=ct.length,zf(t)}finally{ct.length=er.__r=0}}function ns(t,e,n,r,i,o,a,s,l,u,c){var h,d,f,p,m,v,y=r&&r.__k||Jn,w=e.length;for(l=$f(n,e,y,l,w),h=0;h<w;h++)(f=n.__k[h])!=null&&(d=f.__i!=-1&&y[f.__i]||Qn,f.__i=h,v=Si(t,f,d,i,o,a,s,l,u,c),p=f.__e,f.ref&&d.ref!=f.ref&&(d.ref&&Ti(d.ref,null,f),c.push(f.ref,f.__c||p,f)),m==null&&p!=null&&(m=p),4&f.__u?(l=rs(f,l,t),d.__e&&(d.__e=null)):typeof f.type=="function"&&v!==void 0?l=v:p&&(l=p.nextSibling),f.__u&=-7);return n.__e=m,l}function $f(t,e,n,r,i){var o,a,s,l,u,c=n.length,h=c,d=0;for(t.__k=new Array(i),o=0;o<i;o++)(a=e[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=t.__k[o]=Xn(null,a,null,null,null):nr(a)?a=t.__k[o]=Xn(qe,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[o]=Xn(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[o]=a,l=o+d,a.__=t,a.__b=t.__b+1,s=null,(u=a.__i=Uf(a,n,l,h))!=-1&&(h--,(s=n[u])&&(s.__u|=2)),s==null||s.__v==null?(u==-1&&(i>c?d--:i<c&&d++),typeof a.type!="function"&&(a.__u|=4)):u!=l&&(u==l-1?d--:u==l+1?d++:(u>l?d--:d++,a.__u|=4))):t.__k[o]=null;if(h)for(o=0;o<c;o++)(s=n[o])!=null&&(2&s.__u)==0&&(s.__e==r&&(r=yt(s)),ss(s,s));return r}function rs(t,e,n){var r,i;if(typeof t.type=="function"){for(r=t.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=t,e=rs(r[i],e,n));return e}t.__e!=e&&(e&&t.type&&!e.parentNode&&(e=yt(t)),e=n.insertBefore(t.__e,e||null));do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Uf(t,e,n,r){var i,o,a,s=t.key,l=t.type,u=e[n],c=u!=null&&(2&u.__u)==0;if(u===null&&s==null||c&&s==u.key&&l==u.type)return n;if(r>(c?1:0)){for(i=n-1,o=n+1;i>=0||o<e.length;)if((u=e[a=i>=0?i--:o++])!=null&&(2&u.__u)==0&&s==u.key&&l==u.type)return a}return-1}function Ya(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||Of.test(e)?n:n+"px"}function qn(t,e,n,r,i){var o,a;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof r=="string"&&(t.style.cssText=r=""),r)for(e in r)n&&e in n||Ya(t.style,e,"");if(n)for(e in n)r&&n[e]==r[e]||Ya(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(es,"$1")),a=e.toLowerCase(),e=a in t||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=n,n?r?n[sn]=r[sn]:(n[sn]=ki,t.addEventListener(e,o?_i:xi,o)):t.removeEventListener(e,o?_i:xi,o);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function Xa(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e[Yn]==null)e[Yn]=ki++;else if(e[Yn]<n[sn])return;return n(B.event?B.event(e):e)}}}function Si(t,e,n,r,i,o,a,s,l,u){var c,h,d,f,p,m,v,y,w,k,_,L,R,P,z,F,G=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[s=e.__e=n.__e]),(c=B.__b)&&c(e);e:if(typeof G=="function"){h=a.length;try{if(w=e.props,k=G.prototype&&G.prototype.render,_=(c=G.contextType)&&r[c.__c],L=c?_?_.props.value:c.__:r,n.__c?y=(d=e.__c=n.__c).__=d.__E:(k?e.__c=d=new G(w,L):(e.__c=d=new Zn(w,L),d.constructor=G,d.render=Bf),_&&_.sub(d),d.state||(d.state={}),d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),k&&d.__s==null&&(d.__s=d.state),k&&G.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=Qe({},d.__s)),Qe(d.__s,G.getDerivedStateFromProps(w,d.__s))),p=d.props,m=d.state,d.__v=e,f)k&&G.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),k&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(k&&G.getDerivedStateFromProps==null&&w!==p&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(w,L),e.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(w,d.__s,L)===!1){e.__v!=n.__v&&(d.props=w,d.state=d.__s,d.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(U){U&&(U.__=e)}),Jn.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),s=yt(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(w,d.__s,L),k&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(p,m,v)})}if(d.context=L,d.props=w,d.__P=t,d.__e=!1,R=B.__r,P=0,k)d.state=d.__s,d.__d=!1,R&&R(e),c=d.render(d.props,d.state,d.context),Jn.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,R&&R(e),c=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++P<25);d.state=d.__s,d.getChildContext!=null&&(r=Qe(Qe({},r),d.getChildContext())),k&&!f&&d.getSnapshotBeforeUpdate!=null&&(v=d.getSnapshotBeforeUpdate(p,m)),z=c!=null&&c.type===qe&&c.key==null?as(c.props.children):c,s=ns(t,nr(z)?z:[z],e,n,r,i,o,a,s,l,u),d.base=e.__e,e.__u&=-161,d.__h.length&&a.push(d),y&&(d.__E=d.__=null)}catch(U){if(a.length=h,e.__v=null,l||o!=null){if(U.then){for(e.__u|=l?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;o!=null&&(o[o.indexOf(s)]=null),e.__e=s}else if(o!=null)for(F=o.length;F--;)Ei(o[F])}else e.__e=n.__e;e.__k==null&&(e.__k=n.__k||[]),U.then||is(e),B.__e(U,e,n)}}else o==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):s=e.__e=Hf(n.__e,e,n,r,i,o,a,l,u);return(c=B.diffed)&&c(e),128&e.__u?void 0:s}function is(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(is))}function os(t,e,n){for(var r=0;r<n.length;r++)Ti(n[r],n[++r],n[++r]);B.__c&&B.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(o){o.call(i)})}catch(o){B.__e(o,i.__v)}})}function as(t){return typeof t!="object"||t==null||t.__b>0?t:nr(t)?t.map(as):t.constructor!==void 0?null:Qe({},t)}function Hf(t,e,n,r,i,o,a,s,l){var u,c,h,d,f,p,m,v=n.props||Qn,y=e.props,w=e.type;if(w=="svg"?i="http://www.w3.org/2000/svg":w=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((f=o[u])&&"setAttribute"in f==!!w&&(w?f.localName==w:f.nodeType==3)){t=f,o[u]=null;break}}if(t==null){if(w==null)return document.createTextNode(y);t=document.createElementNS(i,w,y.is&&y),s&&(B.__m&&B.__m(e,o),s=!1),o=null}if(w==null)v===y||s&&t.data==y||(t.data=y);else{if(o=w=="textarea"&&y.defaultValue!=null?null:o&&tr.call(t.childNodes),!s&&o!=null)for(v={},u=0;u<t.attributes.length;u++)v[(f=t.attributes[u]).name]=f.value;for(u in v)f=v[u],u=="dangerouslySetInnerHTML"?h=f:u=="children"||u in y||u=="value"&&"defaultValue"in y||u=="checked"&&"defaultChecked"in y||qn(t,u,null,f,i);for(u in y)f=y[u],u=="children"?d=f:u=="dangerouslySetInnerHTML"?c=f:u=="value"?p=f:u=="checked"?m=f:s&&typeof f!="function"||v[u]===f||qn(t,u,f,v[u],i);if(c)s||h&&(c.__html==h.__html||c.__html==t.innerHTML)||(t.innerHTML=c.__html),e.__k=[];else if(h&&(t.innerHTML=""),ns(e.type=="template"?t.content:t,nr(d)?d:[d],e,n,r,w=="foreignObject"?"http://www.w3.org/1999/xhtml":i,o,a,o?o[0]:n.__k&&yt(n,0),s,l),o!=null)for(u=o.length;u--;)Ei(o[u]);s&&w!="textarea"||(u="value",w=="progress"&&p==null?t.removeAttribute("value"):p!=null&&(p!==t[u]||w=="progress"&&!p||w=="option"&&p!=v[u])&&qn(t,u,p,v[u],i),u="checked",m!=null&&m!=t[u]&&qn(t,u,m,v[u],i))}return t}function Ti(t,e,n){try{if(typeof t=="function"){var r=typeof t.__u=="function";r&&t.__u(),r&&e==null||(t.__u=t(e))}else t.current=e}catch(i){B.__e(i,n)}}function ss(t,e,n){var r,i;if(B.unmount&&B.unmount(t),(r=t.ref)&&(r.current&&r.current!=t.__e||Ti(r,null,e)),(r=t.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){B.__e(o,e)}r.base=r.__P=r.__n=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&ss(r[i],e,n||typeof t.type!="function");n||Ei(t.__e),t.__c=t.__=t.__e=void 0}function Bf(t,e,n){return this.constructor(t,n)}function ls(t,e,n){var r,i,o,a;e==document&&(e=document.documentElement),B.__&&B.__(t,e),i=(r=typeof n=="function")?null:n&&n.__k||e.__k,o=[],a=[],Si(e,t=(!r&&n||e).__k=Ff(qe,null,[t]),i||Qn,Qn,e.namespaceURI,!r&&n?[n]:i?null:e.firstChild?tr.call(e.childNodes):null,o,!r&&n?n:i?i.__e:e.firstChild,r,a),os(o,t,a),t.props.children=null}tr=Jn.slice,B={__e:function(t,e,n,r){for(var i,o,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&o.getDerivedStateFromError!=null&&(i.setState(o.getDerivedStateFromError(t)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,r||{}),a=i.__d),a)return i.__E=i}catch(s){t=s}throw t}},Za=0,Gf=function(t){return t!=null&&t.constructor===void 0},Zn.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Qe({},this.state),typeof t=="function"&&(t=t(Qe({},n),this.props)),t&&Qe(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),qa(this))},Zn.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),qa(this))},Zn.prototype.render=qe,ct=[],Qa=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ja=function(t,e){return t.__v.__b-e.__v.__b},er.__r=0,bi=Math.random().toString(8),Yn="__d"+bi,sn="__a"+bi,es=/(PointerCapture)$|Capture$/i,ki=0,xi=Xa(!1),_i=Xa(!0),Mf=0;var us="weave-bootstrap";var Ai={cwd:""};function Wf(t){return typeof t!="object"||t===null?!1:typeof t.cwd=="string"}function cs(t){if(t===null||t.trim()==="")return Ai;let e;try{e=JSON.parse(t)}catch{return Ai}return Wf(e)?e:Ai}var Ft,te,Ri,ds,ln=0,ws=[],ie=B,hs=ie.__b,fs=ie.__r,ps=ie.diffed,gs=ie.__c,ms=ie.unmount,vs=ie.__;function ir(t,e){ie.__h&&ie.__h(te,t,ln||e),ln=0;var n=te.__H||(te.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function ne(t){return ln=1,Kf(xs,t)}function Kf(t,e,n){var r=ir(Ft++,2);if(r.t=t,!r.__c&&(r.__=[n?n(e):xs(void 0,e),function(s){var l=r.__N?r.__N[0]:r.__[0],u=r.t(l,s);l!==u&&(r.__N=[u,r.__[1]],r.__c.setState({}))}],r.__c=te,!te.__f)){var i=function(s,l,u){if(!r.__c.__H)return!0;var c=!1,h=r.__c.props!==s;if(r.__c.__H.__.some(function(f){if(f.__N){c=!0;var p=f.__[0];f.__=f.__N,f.__N=void 0,p!==f.__[0]&&(h=!0)}}),o){var d=o.call(this,s,l,u);return c?d||h:d}return!c||h};te.__f=!0;var o=te.shouldComponentUpdate,a=te.componentWillUpdate;te.componentWillUpdate=function(s,l,u){if(this.__e){var c=o;o=void 0,i(s,l,u),o=c}a&&a.call(this,s,l,u)},te.shouldComponentUpdate=i}return r.__N||r.__}function oe(t,e){var n=ir(Ft++,3);!ie.__s&&Ni(n.__H,e)&&(n.__=t,n.u=e,te.__H.__h.push(n))}function un(t,e){var n=ir(Ft++,4);!ie.__s&&Ni(n.__H,e)&&(n.__=t,n.u=e,te.__h.push(n))}function ee(t){return ln=5,Ye(function(){return{current:t}},[])}function Ye(t,e){var n=ir(Ft++,7);return Ni(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function bs(t,e){return ln=8,Ye(function(){return t},e)}function Vf(){for(var t;t=ws.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(rr),e.__h.some(Ci),e.__h=[]}catch(n){e.__h=[],ie.__e(n,t.__v)}}}ie.__b=function(t){te=null,hs&&hs(t)},ie.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),vs&&vs(t,e)},ie.__r=function(t){fs&&fs(t),Ft=0;var e=(te=t.__c).__H;e&&(Ri===te?(e.__h=[],te.__h=[],e.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.some(rr),e.__h.some(Ci),e.__h=[],Ft=0)),Ri=te},ie.diffed=function(t){ps&&ps(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(ws.push(e)!==1&&ds===ie.requestAnimationFrame||((ds=ie.requestAnimationFrame)||jf)(Vf)),e.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Ri=te=null},ie.__c=function(t,e){e.some(function(n){try{n.__h.some(rr),n.__h=n.__h.filter(function(r){return!r.__||Ci(r)})}catch(r){e.some(function(i){i.__h&&(i.__h=[])}),e=[],ie.__e(r,n.__v)}}),gs&&gs(t,e)},ie.unmount=function(t){ms&&ms(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.some(function(r){try{rr(r)}catch(i){e=i}}),n.__H=void 0,e&&ie.__e(e,n.__v))};var ys=typeof requestAnimationFrame=="function";function jf(t){var e,n=function(){clearTimeout(r),ys&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,35);ys&&(e=requestAnimationFrame(n))}function rr(t){var e=te,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),te=e}function Ci(t){var e=te;t.__c=t.__(),te=e}function Ni(t,e){return!t||t.length!==e.length||e.some(function(n,r){return n!==t[r]})}function xs(t,e){return typeof e=="function"?e(t):e}var Xe=(t,e)=>fetch(t,{...e?.method===void 0?{}:{method:e.method},...e?.headers===void 0?{}:{headers:e.headers},...e?.body===void 0?{}:{body:e.body},...e?.signal===void 0?{}:{signal:e.signal},credentials:"same-origin"});function Li(t,e=!1){return{ok:!0,data:t,cached:e}}function Je(t,e,n){return{ok:!1,kind:t,status:e,message:n}}function _s(t){return t===403?"auth":t===404?"missing":"server"}function ks(t){return t===403?"not authorised — this workspace session has ended":t===404?"not found":`server error (${t})`}async function or(t,e,n,r){let i;try{i=await t(e,r)}catch(a){return Je("network",0,a instanceof Error?a.message:"network request failed")}if(!i.ok)return Je(_s(i.status),i.status,ks(i.status));let o;try{o=await i.json()}catch{return Je("malformed",i.status,"response was not valid JSON")}return n(o)?Li(o):Je("malformed",i.status,"response did not match the expected shape")}function et(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function qf(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function Yf(t){if(!et(t)||typeof t.stamp!="string")return!1;let e=t.model;return!et(e)||!Array.isArray(e.nodes)||!Array.isArray(e.edges)?!1:et(t.tags)&&et(t.dangling)}function Xf(t){if(!et(t))return!1;for(let e of["slug","title","body","created","updated","source"])if(typeof t[e]!="string")return!1;return qf(t.tags)}function Zf(t){return et(t)&&Xf(t.note)}function Qf(t){return et(t)&&typeof t.query=="string"&&Array.isArray(t.hits)}function Jf(t){return et(t)&&typeof t.opened=="boolean"}function ep(t){return et(t)&&t.ok===!0&&(t.id===void 0||typeof t.id=="string")}async function Es(t,e=null){let n=e===null?void 0:{"if-none-match":`"${e.stamp}"`},r;try{r=await t("/api/graph",n===void 0?{}:{headers:n})}catch(o){return Je("network",0,o instanceof Error?o.message:"network request failed")}if(r.status===304)return e===null?Je("malformed",304,"server sent 304 for an unconditional request"):Li(e,!0);if(!r.ok)return Je(_s(r.status),r.status,ks(r.status));let i;try{i=await r.json()}catch{return Je("malformed",r.status,"response was not valid JSON")}return Yf(i)?Li(i):Je("malformed",r.status,"response did not match the expected shape")}function Ss(t,e){return or(t,`/api/note/${encodeURIComponent(e)}`,Zf)}function Ts(t,e,n){return or(t,`/api/search?q=${encodeURIComponent(e)}`,Qf,n===void 0?void 0:{signal:n})}function As(t,e){return or(t,"/api/open",Jf,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({slug:e})})}function cn(t,e,n,r){return or(t,e,ep,{method:n,...r===void 0?{}:{headers:{"content-type":"application/json"},body:JSON.stringify(r)}})}var Di=(t,e="")=>`/api/note/${encodeURIComponent(t)}${e}`,Rs=(t,e="")=>`/api/folder/${t.split("/").map(encodeURIComponent).join("/")}${e}`,Cs=(t,e,n)=>cn(t,Di(e,"/rename"),"POST",{name:n}),Ns=(t,e,n)=>cn(t,Di(e,"/move"),"POST",{folder:n}),Ls=(t,e)=>cn(t,Di(e),"DELETE"),Ds=(t,e,n)=>cn(t,Rs(e,"/rename"),"POST",{name:n}),Ps=(t,e)=>cn(t,Rs(e),"DELETE");var Is="(prefers-color-scheme: light)";function ar(t){return t==null||typeof t.matchMedia!="function"?"dark":t.matchMedia(Is).matches?"light":"dark"}function Gs(t,e){if(typeof t.matchMedia!="function")return()=>{};let n=t.matchMedia(Is);if(typeof n.addEventListener!="function")return()=>{};let r=()=>e(n.matches?"light":"dark");return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}function tp(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function bt(t){var e=tp(t,"string");return typeof e=="symbol"?e:e+""}function le(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ms(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,bt(r.key),r)}}function ue(t,e,n){return e&&Ms(t.prototype,e),n&&Ms(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function wt(t){return wt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},wt(t)}function Os(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Os=function(){return!!t})()}function np(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function rp(t,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return np(t)}function be(t,e,n){return e=wt(e),rp(t,Os()?Reflect.construct(e,n||[],wt(t).constructor):e.apply(t,n))}function Pi(t,e){return Pi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Pi(t,e)}function xe(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Pi(t,e)}function ip(t){if(Array.isArray(t))return t}function op(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,e===0){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function sr(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Oi(t,e){if(t){if(typeof t=="string")return sr(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?sr(t,e):void 0}}function ap(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
22
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dt(t,e){return ip(t)||op(t,e)||Oi(t,e)||ap()}var Ii={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"};var Fs=new Int8Array(4),Gi=new Int32Array(Fs.buffer,0,1),sp=new Float32Array(Fs.buffer,0,1),lp=/^\s*rgba?\s*\(/,up=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function cp(t){var e=0,n=0,r=0,i=1;if(t[0]==="#")t.length===4?(e=parseInt(t.charAt(1)+t.charAt(1),16),n=parseInt(t.charAt(2)+t.charAt(2),16),r=parseInt(t.charAt(3)+t.charAt(3),16)):(e=parseInt(t.charAt(1)+t.charAt(2),16),n=parseInt(t.charAt(3)+t.charAt(4),16),r=parseInt(t.charAt(5)+t.charAt(6),16)),t.length===9&&(i=parseInt(t.charAt(7)+t.charAt(8),16)/255);else if(lp.test(t)){var o=t.match(up);o&&(e=+o[1],n=+o[2],r=+o[3],o[4]&&(i=+o[4]))}return{r:e,g:n,b:r,a:i}}var zt={};for(dn in Ii)zt[dn]=$t(Ii[dn]),zt[Ii[dn]]=zt[dn];var dn;function zs(t,e,n,r,i){return Gi[0]=r<<24|n<<16|e<<8|t,i&&(Gi[0]=Gi[0]&4278190079),sp[0]}function $t(t){if(t=t.toLowerCase(),typeof zt[t]<"u")return zt[t];var e=cp(t),n=e.r,r=e.g,i=e.b,o=e.a;o=o*255|0;var a=zs(n,r,i,o,!0);return zt[t]=a,a}var Mi={};function Fi(t){if(typeof Mi[t]<"u")return Mi[t];var e=(t&16711680)>>>16,n=(t&65280)>>>8,r=t&255,i=255,o=zs(e,n,r,i,!0);return Mi[t]=o,o}function zi(t,e,n,r){return n+(e<<8)+(t<<16)}function $i(t,e,n,r,i,o){var a=Math.floor(n/o*i),s=Math.floor(t.drawingBufferHeight/o-r/o*i),l=new Uint8Array(4);t.bindFramebuffer(t.FRAMEBUFFER,e),t.readPixels(a,s,1,1,t.RGBA,t.UNSIGNED_BYTE,l);var u=dt(l,4),c=u[0],h=u[1],d=u[2],f=u[3];return[c,h,d,f]}function S(t,e,n){return(e=bt(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $s(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function D(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$s(Object(n),!0).forEach(function(r){S(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$s(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function dp(t,e){for(;!{}.hasOwnProperty.call(t,e)&&(t=wt(t))!==null;);return t}function Bi(){return Bi=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=dp(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},Bi.apply(null,arguments)}function js(t,e,n,r){var i=Bi(wt(1&r?t.prototype:t),e,n);return 2&r&&typeof i=="function"?function(o){return i.apply(n,o)}:i}function hp(t){return t.normalized?1:t.size}function Ui(t){var e=0;return t.forEach(function(n){return e+=hp(n)}),e}function qs(t,e,n){var r=t==="VERTEX"?e.VERTEX_SHADER:e.FRAGMENT_SHADER,i=e.createShader(r);if(i===null)throw new Error("loadShader: error while creating the shader");e.shaderSource(i,n),e.compileShader(i);var o=e.getShaderParameter(i,e.COMPILE_STATUS);if(!o){var a=e.getShaderInfoLog(i);throw e.deleteShader(i),new Error(`loadShader: error while compiling the shader:
|
|
23
23
|
`.concat(a,`
|
|
24
|
-
`).concat(n))}return i}function
|
|
25
|
-
`,
|
|
24
|
+
`).concat(n))}return i}function fp(t,e){return qs("VERTEX",t,e)}function pp(t,e){return qs("FRAGMENT",t,e)}function gp(t,e){var n=t.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var r,i;for(r=0,i=e.length;r<i;r++)t.attachShader(n,e[r]);t.linkProgram(n);var o=t.getProgramParameter(n,t.LINK_STATUS);if(!o){var a=t.getProgramInfoLog(n);throw t.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(a))}return n}function Us(t){var e=t.gl,n=t.buffer,r=t.program,i=t.vertexShader,o=t.fragmentShader;e.deleteShader(i),e.deleteShader(o),e.deleteProgram(r),e.deleteBuffer(n)}var Hs=`#define PICKING_MODE
|
|
25
|
+
`,mp=S(S(S(S(S(S(S(S({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4);var Ys=(function(){function t(e,n,r){le(this,t),S(this,"array",new Float32Array),S(this,"constantArray",new Float32Array),S(this,"capacity",0),S(this,"verticesCount",0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in i?i.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in i,this.ATTRIBUTES_ITEMS_COUNT=Ui(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo("normal",e,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",e,Hs+i.VERTEX_SHADER_SOURCE,Hs+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=Ui(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*o);for(var a=0;a<this.CONSTANT_DATA.length;a++){var s=this.CONSTANT_DATA[a];if(s.length!==o)throw new Error("Program: error while getting constant data (one vector has ".concat(s.length," items instead of ").concat(o,")"));for(var l=0;l<s.length;l++)this.constantArray[a*o+l]=s[l]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return ue(t,[{key:"kill",value:function(){Us(this.normalProgram),this.pickProgram&&(Us(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(n,r,i,o,a){var s=this.getDefinition(),l=r.createBuffer();if(l===null)throw new Error("Program: error while creating the WebGL buffer.");var u=fp(r,i),c=pp(r,o),h=gp(r,[u,c]),d={};s.UNIFORMS.forEach(function(m){var v=r.getUniformLocation(h,m);v&&(d[m]=v)});var f={};s.ATTRIBUTES.forEach(function(m){f[m.name]=r.getAttribLocation(h,m.name)});var p;if("CONSTANT_ATTRIBUTES"in s&&(s.CONSTANT_ATTRIBUTES.forEach(function(m){f[m.name]=r.getAttribLocation(h,m.name)}),p=r.createBuffer(),p===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:h,gl:r,frameBuffer:a,buffer:l,constantBuffer:p||{},uniformLocations:d,attributeLocations:f,isPicking:n==="pick",vertexShader:u,fragmentShader:c}}},{key:"bindProgram",value:function(n){var r=this,i=0,o=n.gl,a=n.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,n.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,n.buffer),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,a),i=0,this.ATTRIBUTES.forEach(function(s){return i+=r.bindAttribute(s,n,i)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(n){var r=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!1)}),this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!0)})):this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n)})}},{key:"bindAttribute",value:function(n,r,i,o){var a=mp[n.type];if(typeof a!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(n.type,'"'));var s=r.attributeLocations[n.name],l=r.gl;if(s!==-1){l.enableVertexAttribArray(s);var u=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:Ui(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(l.vertexAttribPointer(s,n.size,n.type,n.normalized||!1,u,i),this.isInstanced&&o)if(l instanceof WebGL2RenderingContext)l.vertexAttribDivisor(s,1);else{var c=l.getExtension("ANGLE_instanced_arrays");c&&c.vertexAttribDivisorANGLE(s,1)}}return n.size*a}},{key:"unbindAttribute",value:function(n,r,i){var o=r.attributeLocations[n.name],a=r.gl;if(o!==-1&&(a.disableVertexAttribArray(o),this.isInstanced&&i))if(a instanceof WebGL2RenderingContext)a.vertexAttribDivisor(o,0);else{var s=a.getExtension("ANGLE_instanced_arrays");s&&s.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(n){n!==this.capacity&&(this.capacity=n,this.verticesCount=this.VERTICES*n,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(n,r){var i=r.gl,o=r.program;i.enable(i.BLEND),i.useProgram(o),this.setUniforms(n,r),this.drawWebGL(this.METHOD,r)}},{key:"render",value:function(n){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,n.width*n.pixelRatio/n.downSizingRatio,n.height*n.pixelRatio/n.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(D(D({},n),{},{pixelRatio:n.pixelRatio/n.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,n.width*n.pixelRatio,n.height*n.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(n,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(n,r){var i=r.gl,o=r.frameBuffer;if(i.bindFramebuffer(i.FRAMEBUFFER,o),!this.isInstanced)i.drawArrays(n,0,this.verticesCount);else if(i instanceof WebGL2RenderingContext)i.drawArraysInstanced(n,0,this.VERTICES,this.capacity);else{var a=i.getExtension("ANGLE_instanced_arrays");a&&a.drawArraysInstancedANGLE(n,0,this.VERTICES,this.capacity)}}}])})();var vp=(function(t){function e(){return le(this,e),be(this,e,arguments)}return xe(e,t),ue(e,[{key:"kill",value:function(){js(e,"kill",this,3)([])}},{key:"process",value:function(r,i,o){var a=i*this.STRIDE;if(o.hidden){for(var s=a+this.STRIDE;a<s;a++)this.array[a]=0;return}return this.processVisibleItem(Fi(r),a,o)}}])})(Ys);var Wi=(function(t){function e(){var n;le(this,e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=be(this,e,[].concat(i)),S(n,"drawLabel",void 0),n}return xe(e,t),ue(e,[{key:"kill",value:function(){js(e,"kill",this,3)([])}},{key:"process",value:function(r,i,o,a,s){var l=i*this.STRIDE;if(s.hidden||o.hidden||a.hidden){for(var u=l+this.STRIDE;l<u;l++)this.array[l]=0;return}return this.processVisibleItem(Fi(r),l,o,a,s)}}])})(Ys);function yp(t,e){return(function(){function n(r,i,o){le(this,n),S(this,"drawLabel",e),this.programs=t.map(function(a){return new a(r,i,o)})}return ue(n,[{key:"reallocate",value:function(i){this.programs.forEach(function(o){return o.reallocate(i)})}},{key:"process",value:function(i,o,a,s,l){this.programs.forEach(function(u){return u.process(i,o,a,s,l)})}},{key:"render",value:function(i){this.programs.forEach(function(o){return o.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function Xs(t,e,n,r,i){var o=i.edgeLabelSize,a=i.edgeLabelFont,s=i.edgeLabelWeight,l=i.edgeLabelColor.attribute?e[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,u=e.label;if(u){t.fillStyle=l,t.font="".concat(s," ").concat(o,"px ").concat(a);var c=n.size,h=r.size,d=n.x,f=n.y,p=r.x,m=r.y,v=(d+p)/2,y=(f+m)/2,w=p-d,k=m-f,_=Math.sqrt(w*w+k*k);if(!(_<c+h)){d+=w*c/_,f+=k*c/_,p-=w*h/_,m-=k*h/_,v=(d+p)/2,y=(f+m)/2,w=p-d,k=m-f,_=Math.sqrt(w*w+k*k);var L=t.measureText(u).width;if(L>_){var R="…";for(u=u+R,L=t.measureText(u).width;L>_&&u.length>1;)u=u.slice(0,-2)+R,L=t.measureText(u).width;if(u.length<4)return}var P;w>0?k>0?P=Math.acos(w/_):P=Math.asin(k/_):k>0?P=Math.acos(w/_)+Math.PI:P=Math.asin(w/_)+Math.PI/2,t.save(),t.translate(v,y),t.rotate(P),t.fillText(u,-L/2,e.size/2+o),t.restore()}}}function Ki(t,e,n){if(e.label){var r=n.labelSize,i=n.labelFont,o=n.labelWeight,a=n.labelColor.attribute?e[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;t.fillStyle=a,t.font="".concat(o," ").concat(r,"px ").concat(i),t.fillText(e.label,e.x+e.size+3,e.y+r/3)}}function Zs(t,e,n){var r=n.labelSize,i=n.labelFont,o=n.labelWeight;t.font="".concat(o," ").concat(r,"px ").concat(i),t.fillStyle="#FFF",t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=8,t.shadowColor="#000";var a=2;if(typeof e.label=="string"){var s=t.measureText(e.label).width,l=Math.round(s+5),u=Math.round(r+2*a),c=Math.max(e.size,r/2)+a,h=Math.asin(u/2/c),d=Math.sqrt(Math.abs(Math.pow(c,2)-Math.pow(u/2,2)));t.beginPath(),t.moveTo(e.x+d,e.y+u/2),t.lineTo(e.x+c+l,e.y+u/2),t.lineTo(e.x+c+l,e.y-u/2),t.lineTo(e.x+d,e.y-u/2),t.arc(e.x,e.y,c,h,-h),t.closePath(),t.fill()}else t.beginPath(),t.arc(e.x,e.y,e.size+a,0,Math.PI*2),t.closePath(),t.fill();t.shadowOffsetX=0,t.shadowOffsetY=0,t.shadowBlur=0,Ki(t,e,n)}var wp=`
|
|
26
26
|
precision highp float;
|
|
27
27
|
|
|
28
28
|
varying vec4 v_color;
|
|
@@ -54,7 +54,7 @@ void main(void) {
|
|
|
54
54
|
gl_FragColor = mix(v_color, transparent, t);
|
|
55
55
|
#endif
|
|
56
56
|
}
|
|
57
|
-
`,
|
|
57
|
+
`,bp=wp,xp=`
|
|
58
58
|
attribute vec4 a_id;
|
|
59
59
|
attribute vec4 a_color;
|
|
60
60
|
attribute vec2 a_position;
|
|
@@ -95,7 +95,7 @@ void main() {
|
|
|
95
95
|
|
|
96
96
|
v_color.a *= bias;
|
|
97
97
|
}
|
|
98
|
-
`,
|
|
98
|
+
`,_p=xp,Qs=WebGLRenderingContext,Bs=Qs.UNSIGNED_BYTE,Hi=Qs.FLOAT,kp=["u_sizeRatio","u_correctionRatio","u_matrix"],fn=(function(t){function e(){return le(this,e),be(this,e,arguments)}return xe(e,t),ue(e,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:_p,FRAGMENT_SHADER_SOURCE:bp,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:kp,ATTRIBUTES:[{name:"a_position",size:2,type:Hi},{name:"a_size",size:1,type:Hi},{name:"a_color",size:4,type:Bs,normalized:!0},{name:"a_id",size:4,type:Bs,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Hi}],CONSTANT_DATA:[[e.ANGLE_1],[e.ANGLE_2],[e.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var a=this.array,s=$t(o.color);a[i++]=o.x,a[i++]=o.y,a[i++]=o.size,a[i++]=s,a[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_sizeRatio,l=a.u_correctionRatio,u=a.u_matrix;o.uniform1f(l,r.correctionRatio),o.uniform1f(s,r.sizeRatio),o.uniformMatrix3fv(u,!1,r.matrix)}}])})(vp);S(fn,"ANGLE_1",0);S(fn,"ANGLE_2",2*Math.PI/3);S(fn,"ANGLE_3",4*Math.PI/3);var Ep=`
|
|
99
99
|
precision mediump float;
|
|
100
100
|
|
|
101
101
|
varying vec4 v_color;
|
|
@@ -103,7 +103,7 @@ varying vec4 v_color;
|
|
|
103
103
|
void main(void) {
|
|
104
104
|
gl_FragColor = v_color;
|
|
105
105
|
}
|
|
106
|
-
`,
|
|
106
|
+
`,Sp=Ep,Tp=`
|
|
107
107
|
attribute vec2 a_position;
|
|
108
108
|
attribute vec2 a_normal;
|
|
109
109
|
attribute float a_radius;
|
|
@@ -169,7 +169,7 @@ void main() {
|
|
|
169
169
|
|
|
170
170
|
v_color.a *= bias;
|
|
171
171
|
}
|
|
172
|
-
`,
|
|
172
|
+
`,Ap=Tp,Js=WebGLRenderingContext,Ws=Js.UNSIGNED_BYTE,lr=Js.FLOAT,Rp=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],el={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function tl(t){var e=D(D({},el),t||{});return(function(n){function r(){return le(this,r),be(this,r,arguments)}return xe(r,n),ue(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Ap,FRAGMENT_SHADER_SOURCE:Sp,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Rp,ATTRIBUTES:[{name:"a_position",size:2,type:lr},{name:"a_normal",size:2,type:lr},{name:"a_radius",size:1,type:lr},{name:"a_color",size:4,type:Ws,normalized:!0},{name:"a_id",size:4,type:Ws,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:lr}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){if(e.extremity==="source"){var c=[l,s];s=c[0],l=c[1]}var h=u.size||1,d=l.size||1,f=s.x,p=s.y,m=l.x,v=l.y,y=$t(u.color),w=m-f,k=v-p,_=w*w+k*k,L=0,R=0;_&&(_=1/Math.sqrt(_),L=-k*_*h,R=w*_*h);var P=this.array;P[a++]=m,P[a++]=v,P[a++]=-L,P[a++]=-R,P[a++]=d,P[a++]=y,P[a++]=o}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,c=l.u_sizeRatio,h=l.u_correctionRatio,d=l.u_minEdgeThickness,f=l.u_lengthToThicknessRatio,p=l.u_widenessToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.sizeRatio),s.uniform1f(h,o.correctionRatio),s.uniform1f(d,o.minEdgeThickness),s.uniform1f(f,e.lengthToThicknessRatio),s.uniform1f(p,e.widenessToThicknessRatio)}}])})(Wi)}var gx=tl();var Cp=`
|
|
173
173
|
precision mediump float;
|
|
174
174
|
|
|
175
175
|
varying vec4 v_color;
|
|
@@ -195,7 +195,7 @@ void main(void) {
|
|
|
195
195
|
gl_FragColor = mix(v_color, transparent, t);
|
|
196
196
|
#endif
|
|
197
197
|
}
|
|
198
|
-
`,
|
|
198
|
+
`,nl=Cp,Np=`
|
|
199
199
|
attribute vec4 a_id;
|
|
200
200
|
attribute vec4 a_color;
|
|
201
201
|
attribute vec2 a_normal;
|
|
@@ -263,7 +263,7 @@ void main() {
|
|
|
263
263
|
|
|
264
264
|
v_color.a *= bias;
|
|
265
265
|
}
|
|
266
|
-
`,
|
|
266
|
+
`,Lp=Np,rl=WebGLRenderingContext,Ks=rl.UNSIGNED_BYTE,xt=rl.FLOAT,Dp=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],Pp={lengthToThicknessRatio:el.lengthToThicknessRatio};function il(t){var e=D(D({},Pp),t||{});return(function(n){function r(){return le(this,r),be(this,r,arguments)}return xe(r,n),ue(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Lp,FRAGMENT_SHADER_SOURCE:nl,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Dp,ATTRIBUTES:[{name:"a_positionStart",size:2,type:xt},{name:"a_positionEnd",size:2,type:xt},{name:"a_normal",size:2,type:xt},{name:"a_color",size:4,type:Ks,normalized:!0},{name:"a_id",size:4,type:Ks,normalized:!0},{name:"a_radius",size:1,type:xt}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:xt},{name:"a_normalCoef",size:1,type:xt},{name:"a_radiusCoef",size:1,type:xt}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,a,s,l,u){var c=u.size||1,h=s.x,d=s.y,f=l.x,p=l.y,m=$t(u.color),v=f-h,y=p-d,w=l.size||1,k=v*v+y*y,_=0,L=0;k&&(k=1/Math.sqrt(k),_=-y*k*c,L=v*k*c);var R=this.array;R[a++]=h,R[a++]=d,R[a++]=f,R[a++]=p,R[a++]=_,R[a++]=L,R[a++]=m,R[a++]=o,R[a++]=w}},{key:"setUniforms",value:function(o,a){var s=a.gl,l=a.uniformLocations,u=l.u_matrix,c=l.u_zoomRatio,h=l.u_feather,d=l.u_pixelRatio,f=l.u_correctionRatio,p=l.u_sizeRatio,m=l.u_minEdgeThickness,v=l.u_lengthToThicknessRatio;s.uniformMatrix3fv(u,!1,o.matrix),s.uniform1f(c,o.zoomRatio),s.uniform1f(p,o.sizeRatio),s.uniform1f(f,o.correctionRatio),s.uniform1f(d,o.pixelRatio),s.uniform1f(h,o.antiAliasingFeather),s.uniform1f(m,o.minEdgeThickness),s.uniform1f(v,e.lengthToThicknessRatio)}}])})(Wi)}var mx=il();function Ip(t){return yp([il(t),tl(t)])}var Gp=Ip(),ol=Gp,Mp=`
|
|
267
267
|
attribute vec4 a_id;
|
|
268
268
|
attribute vec4 a_color;
|
|
269
269
|
attribute vec2 a_normal;
|
|
@@ -328,41 +328,41 @@ void main() {
|
|
|
328
328
|
|
|
329
329
|
v_color.a *= bias;
|
|
330
330
|
}
|
|
331
|
-
`,xp=bp,Xs=WebGLRenderingContext,Ms=Xs.UNSIGNED_BYTE,cn=Xs.FLOAT,_p=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],Zs=(function(t){function e(){return le(this,e),be(this,e,arguments)}return xe(e,t),ue(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:xp,FRAGMENT_SHADER_SOURCE:Vs,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:_p,ATTRIBUTES:[{name:"a_positionStart",size:2,type:cn},{name:"a_positionEnd",size:2,type:cn},{name:"a_normal",size:2,type:cn},{name:"a_color",size:4,type:Ms,normalized:!0},{name:"a_id",size:4,type:Ms,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:cn},{name:"a_normalCoef",size:1,type:cn}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,o,a,s){var l=s.size||1,u=o.x,c=o.y,h=a.x,d=a.y,f=zt(s.color),g=h-u,m=d-c,v=g*g+m*m,y=0,w=0;v&&(v=1/Math.sqrt(v),y=-m*v*l,w=g*v*l);var k=this.array;k[i++]=u,k[i++]=c,k[i++]=h,k[i++]=d,k[i++]=y,k[i++]=w,k[i++]=f,k[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix,l=a.u_zoomRatio,u=a.u_feather,c=a.u_pixelRatio,h=a.u_correctionRatio,d=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,r.matrix),o.uniform1f(l,r.zoomRatio),o.uniform1f(d,r.sizeRatio),o.uniform1f(h,r.correctionRatio),o.uniform1f(c,r.pixelRatio),o.uniform1f(u,r.antiAliasingFeather),o.uniform1f(f,r.minEdgeThickness)}}])})(Ui);var ll=on(ur()),cr=(function(t){function e(){var n;return le(this,e),n=be(this,e),n.rawEmitter=n,n}return xe(e,t),ue(e)})(ll.EventEmitter);var hl=on(Wi());var Cp=function(e){return e},Np=function(e){return e*e},Lp=function(e){return e*(2-e)},Pp=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},Dp=function(e){return e*e*e},Ip=function(e){return--e*e*e+1},Gp=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},fl={linear:Cp,quadraticIn:Np,quadraticOut:Lp,quadraticInOut:Pp,cubicIn:Dp,cubicOut:Ip,cubicInOut:Gp},pl={easing:"quadraticInOut",duration:150};function Ne(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function dr(t,e,n){return t[0]=e,t[4]=typeof n=="number"?n:e,t}function cl(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[3]=-n,t[4]=r,t}function dl(t,e,n){return t[6]=e,t[7]=n,t}function ct(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=e[0],d=e[1],f=e[2],g=e[3],m=e[4],v=e[5],y=e[6],w=e[7],k=e[8];return t[0]=h*n+d*o+f*l,t[1]=h*r+d*a+f*u,t[2]=h*i+d*s+f*c,t[3]=g*n+m*o+v*l,t[4]=g*r+m*a+v*u,t[5]=g*i+m*s+v*c,t[6]=y*n+w*o+k*l,t[7]=y*r+w*a+k*u,t[8]=y*i+w*s+k*c,t}function hr(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=t[0],i=t[1],o=t[3],a=t[4],s=t[6],l=t[7],u=e.x,c=e.y;return{x:u*r+c*o+s*n,y:u*i+c*a+l*n}}function Mp(t,e){var n=t.height/t.width,r=e.height/e.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function Ut(t,e,n,r,i){var o=t.angle,a=t.ratio,s=t.x,l=t.y,u=e.width,c=e.height,h=Ne(),d=Math.min(u,c)-2*r,f=Mp(e,n);return i?(ct(h,dl(Ne(),s,l)),ct(h,dr(Ne(),a)),ct(h,cl(Ne(),o)),ct(h,dr(Ne(),u/d/2/f,c/d/2/f))):(ct(h,dr(Ne(),2*(d/u)*f,2*(d/c)*f)),ct(h,cl(Ne(),-o)),ct(h,dr(Ne(),1/a)),ct(h,dl(Ne(),-s,-l))),h}function gl(t,e,n){var r=hr(t,{x:Math.cos(e.angle),y:Math.sin(e.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function ml(t){if(!t.order)return{x:[0,1],y:[0,1]};var e=1/0,n=-1/0,r=1/0,i=-1/0;return t.forEachNode(function(o,a){var s=a.x,l=a.y;s<e&&(e=s),s>n&&(n=s),l<r&&(r=l),l>i&&(i=l)}),{x:[e,n],y:[r,i]}}function vl(t){if(!(0,hl.default)(t))throw new Error("Sigma: invalid graph instance.");t.forEachNode(function(e,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(e," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function yl(t,e,n){var r=document.createElement(t);if(e)for(var i in e)r.style[i]=e[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function Ki(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Vi(t,e,n){return n.sort(function(r,i){var o=e(r)||0,a=e(i)||0;return o<a?-1:o>a?1:0})}function ji(t){var e=ut(t.x,2),n=e[0],r=e[1],i=ut(t.y,2),o=i[0],a=i[1],s=Math.max(r-n,a-o),l=(r+n)/2,u=(a+o)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(l)&&(l=0),isNaN(u)&&(u=0);var c=function(d){return{x:.5+(d.x-l)/s,y:.5+(d.y-u)/s}};return c.applyTo=function(h){h.x=.5+(h.x-l)/s,h.y=.5+(h.y-u)/s},c.inverse=function(h){return{x:l+s*(h.x-.5),y:u+s*(h.y-.5)}},c.ratio=s,c}function fr(t){"@babel/helpers - typeof";return fr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fr(t)}function qi(t,e){var n=e.size;if(n!==0){var r=t.length;t.length+=n;var i=0;e.forEach(function(o){t[r+i]=o,i++})}}function pr(t){t=t||{};for(var e=0,n=arguments.length<=1?0:arguments.length-1;e<n;e++){var r=e+1<1||arguments.length<=e+1?void 0:arguments[e+1];r&&Object.assign(t,r)}return t}var gr={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:$s,defaultDrawNodeLabel:Hi,defaultDrawNodeHover:Us,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},Op={circle:dn},Fp={arrow:Ys,line:Zs};function mr(t){if(typeof t.labelDensity!="number"||t.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var e=t.minCameraRatio,n=t.maxCameraRatio;if(typeof e=="number"&&typeof n=="number"&&n<e)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function wl(t){var e=pr({},gr,t);return e.nodeProgramClasses=pr({},Op,e.nodeProgramClasses),e.edgeProgramClasses=pr({},Fp,e.edgeProgramClasses),e}var xx=on(ur()),_x=on(Wi()),vr=1.5,bl=(function(t){function e(){var n;return le(this,e),n=be(this,e),S(n,"x",.5),S(n,"y",.5),S(n,"angle",0),S(n,"ratio",1),S(n,"minRatio",null),S(n,"maxRatio",null),S(n,"enabledZooming",!0),S(n,"enabledPanning",!0),S(n,"enabledRotation",!0),S(n,"clean",null),S(n,"nextFrame",null),S(n,"previousState",null),S(n,"enabled",!0),n.previousState=n.getState(),n}return xe(e,t),ue(e,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(r){return this.x===r.x&&this.y===r.y&&this.ratio===r.ratio&&this.angle===r.angle}},{key:"getPreviousState",value:function(){var r=this.previousState;return r?{x:r.x,y:r.y,angle:r.angle,ratio:r.ratio}:null}},{key:"getBoundedRatio",value:function(r){var i=r;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(r){var i={};return this.enabledPanning&&typeof r.x=="number"&&(i.x=r.x),this.enabledPanning&&typeof r.y=="number"&&(i.y=r.y),this.enabledZooming&&typeof r.ratio=="number"&&(i.ratio=this.getBoundedRatio(r.ratio)),this.enabledRotation&&typeof r.angle=="number"&&(i.angle=r.angle),this.clean?this.clean(P(P({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(r){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(r);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(r){return this.setState(r(this.getState())),this}},{key:"animate",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if(!a)return new Promise(function(f){return i.animate(r,o,f)});if(this.enabled){var s=P(P({},pl),o),l=this.validateState(r),u=typeof s.easing=="function"?s.easing:fl[s.easing],c=Date.now(),h=this.getState(),d=function(){var g=(Date.now()-c)/s.duration;if(g>=1){i.nextFrame=null,i.setState(l),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var m=u(g),v={};typeof l.x=="number"&&(v.x=h.x+(l.x-h.x)*m),typeof l.y=="number"&&(v.y=h.y+(l.y-h.y)*m),i.enabledRotation&&typeof l.angle=="number"&&(v.angle=h.angle+(l.angle-h.angle)*m),typeof l.ratio=="number"&&(v.ratio=h.ratio+(l.ratio-h.ratio)*m),i.setState(v),i.nextFrame=requestAnimationFrame(d)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(d)):d(),this.animationCallback=a}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||vr)},r):this.animate({ratio:this.ratio/vr})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||vr)},r):this.animate({ratio:this.ratio*vr})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return e.from(this.getState())}}],[{key:"from",value:function(r){var i=new e;return i.setState(r)}}])})(cr);function Me(t,e){var n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}function Qe(t,e){var n=P(P({},Me(t,e)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:t});return n}function hn(t){var e="x"in t?t:P(P({},t.touches[0]||t.previousTouches[0]),{},{original:t.original,sigmaDefaultPrevented:t.sigmaDefaultPrevented,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0,e.sigmaDefaultPrevented=!0}});return e}function zp(t,e){return P(P({},Qe(t,e)),{},{delta:Tl(t)})}var $p=2;function yr(t){for(var e=[],n=0,r=Math.min(t.length,$p);n<r;n++)e.push(t[n]);return e}function fn(t,e,n){var r={touches:yr(t.touches).map(function(i){return Me(i,n)}),previousTouches:e.map(function(i){return Me(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:t};return r}function Tl(t){if(typeof t.deltaY<"u")return t.deltaY*-3/360;if(typeof t.detail<"u")return t.detail/-9;throw new Error("Captor: could not extract delta from event.")}var Al=(function(t){function e(n,r){var i;return le(this,e),i=be(this,e),i.container=n,i.renderer=r,i}return xe(e,t),ue(e)})(cr),Up=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],Hp=Up.reduce(function(t,e){return P(P({},t),{},S({},e,gr[e]))},{}),Bp=(function(t){function e(n,r){var i;return le(this,e),i=be(this,e,[n,r]),S(i,"enabled",!0),S(i,"draggedEvents",0),S(i,"downStartTime",null),S(i,"lastMouseX",null),S(i,"lastMouseY",null),S(i,"isMouseDown",!1),S(i,"isMoving",!1),S(i,"movingTimeout",null),S(i,"startCameraState",null),S(i,"clicks",0),S(i,"doubleClickTimeout",null),S(i,"currentWheelDirection",0),S(i,"settings",Hp),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),n.addEventListener("click",i.handleClick,{capture:!1}),n.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),n.addEventListener("mousedown",i.handleDown,{capture:!1}),n.addEventListener("wheel",i.handleWheel,{capture:!1}),n.addEventListener("mouseleave",i.handleLeave,{capture:!1}),n.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return xe(e,t),ue(e,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("click",this.handleClick),r.removeEventListener("contextmenu",this.handleRightClick),r.removeEventListener("mousedown",this.handleDown),r.removeEventListener("wheel",this.handleWheel),r.removeEventListener("mouseleave",this.handleLeave),r.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(r){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(r);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",Qe(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",Qe(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=Qe(r,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var o=this.renderer.getCamera(),a=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(Me(r,this.container),a),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(r){if(this.enabled){if(r.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=Me(r,this.container),o=i.x,a=i.y;this.lastMouseX=o,this.lastMouseY=a,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",Qe(r,this.container))}}},{key:"handleUp",value:function(r){var i=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var a=Me(r,this.container),s=a.x,l=a.y,u=o.getState(),c=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:u.x+this.settings.inertiaRatio*(u.x-c.x),y:u.y+this.settings.inertiaRatio*(u.y-c.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==l)&&o.setState({x:u.x,y:u.y}),this.isMoving=!1,setTimeout(function(){var h=i.draggedEvents>0;i.draggedEvents=0,h&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",Qe(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=Qe(r,this.container);if(this.emit("mousemovebody",o),(r.target===this.container||r.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var a=this.renderer.getCamera(),s=Me(r,this.container),l=s.x,u=s.y,c=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),h=this.renderer.viewportToFramedGraph({x:l,y:u}),d=c.x-h.x,f=c.y-h.y,g=a.getState(),m=g.x+d,v=g.y+f;a.setState({x:m,y:v}),this.lastMouseX=l,this.lastMouseY=u,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",Qe(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",Qe(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=Tl(r);if(a){var s=zp(r,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var l=o.getState().ratio,u=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,c=o.getBoundedRatio(l*u),h=a>0?1:-1,d=Date.now();l!==c&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===h&&this.lastWheelTriggerTime&&d-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(Me(r,this.container),c),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=h,this.lastWheelTriggerTime=d))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Al),Wp=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],Kp=Wp.reduce(function(t,e){return P(P({},t),{},S({},e,gr[e]))},{}),Vp=(function(t){function e(n,r){var i;return le(this,e),i=be(this,e,[n,r]),S(i,"enabled",!0),S(i,"isMoving",!1),S(i,"hasMoved",!1),S(i,"touchMode",0),S(i,"startTouchesPositions",[]),S(i,"lastTouches",[]),S(i,"lastTap",null),S(i,"settings",Kp),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),n.addEventListener("touchstart",i.handleStart,{capture:!1}),n.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return xe(e,t),ue(e,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("touchstart",this.handleStart),r.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(r){var i=this;if(this.enabled){r.preventDefault();var o=yr(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return Me(f,i.container)}),this.touchMode===2){var a=ut(this.startTouchesPositions,2),s=a[0],l=s.x,u=s.y,c=a[1],h=c.x,d=c.y;this.startTouchesAngle=Math.atan2(d-u,h-l),this.startTouchesDistance=Math.sqrt(Math.pow(h-l,2)+Math.pow(d-u,2))}this.emit("touchdown",fn(r,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(r){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(r.cancelable&&r.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(r.touches.length===1){this.handleStart(r),r.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),o=i.getState(),a=i.getPreviousState()||{x:0,y:0};i.animate({x:o.x+this.settings.inertiaRatio*(o.x-a.x),y:o.y+this.settings.inertiaRatio*(o.y-a.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",fn(r,this.lastTouches,this.container)),!r.touches.length){var s=Me(this.lastTouches[0],this.container),l=this.startTouchesPositions[0],u=Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2);if(!r.touches.length&&u<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var c=fn(r,this.lastTouches,this.container);if(this.emit("doubletap",c),this.lastTap=null,!c.sigmaDefaultPrevented){var h=this.renderer.getCamera(),d=h.getBoundedRatio(h.getState().ratio/this.settings.doubleClickZoomingRatio);h.animate(this.renderer.getViewportZoomedState(s,d),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=fn(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=yr(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=yr(r.touches),a=o.map(function(We){return Me(We,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=fn(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(We,Jt){var Ce=i.startTouchesPositions[Jt];return Ce&&(We.x!==Ce.x||We.y!==Ce.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var u=this.renderer.getCamera(),c=this.startCameraState,h=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var d=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=d.x,g=d.y,m=this.renderer.viewportToFramedGraph(a[0]),v=m.x,y=m.y;u.setState({x:c.x+f-v,y:c.y+g-y});break}case 2:{var w={x:.5,y:.5,angle:0,ratio:1},k=a[0],_=k.x,L=k.y,R=a[1],D=R.x,z=R.y,F=Math.atan2(z-L,D-_)-this.startTouchesAngle,G=Math.hypot(z-L,D-_)/this.startTouchesDistance,U=u.getBoundedRatio(c.ratio/G);w.ratio=U,w.angle=c.angle+F;var j=this.getDimensions(),Q=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:c}),ge=Math.min(j.width,j.height)-2*h,he=ge/j.width,Be=ge/j.height,Nt=U/ge,De=_-ge/2/he,Ie=L-ge/2/Be,Ge=[De*Math.cos(-w.angle)-Ie*Math.sin(-w.angle),Ie*Math.cos(-w.angle)+De*Math.sin(-w.angle)];De=Ge[0],Ie=Ge[1],w.x=Q.x-De*Nt,w.y=Q.y+Ie*Nt,u.setState(w);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Al);function jp(t){if(Array.isArray(t))return or(t)}function qp(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Yp(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
332
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xl(t){return jp(t)||qp(t)||Ii(t)||Yp()}function Xp(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Yi(t,e){if(t==null)return{};var n,r,i=Xp(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}var _l=(function(){function t(e,n){le(this,t),this.key=e,this.size=n}return ue(t,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),kl=(function(){function t(){le(this,t),S(this,"width",0),S(this,"height",0),S(this,"cellSize",0),S(this,"columns",0),S(this,"rows",0),S(this,"cells",{})}return ue(t,[{key:"resizeAndClear",value:function(n,r){this.width=n.width,this.height=n.height,this.cellSize=r,this.columns=Math.ceil(n.width/r),this.rows=Math.ceil(n.height/r),this.cells={}}},{key:"getIndex",value:function(n){var r=Math.floor(n.x/this.cellSize),i=Math.floor(n.y/this.cellSize);return i*this.columns+r}},{key:"add",value:function(n,r,i){var o=new _l(n,r),a=this.getIndex(i),s=this.cells[a];s||(s=[],this.cells[a]=s),s.push(o)}},{key:"organize",value:function(){for(var n in this.cells){var r=this.cells[n];r.sort(_l.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,o=i/n/n,a=o*r/i,s=Math.ceil(a),l=[];for(var u in this.cells)for(var c=this.cells[u],h=0;h<Math.min(s,c.length);h++)l.push(c[h].key);return l}}])})();function Zp(t){var e=t.graph,n=t.hoveredNode,r=t.highlightedNodes,i=t.displayedNodeLabels,o=[];return e.forEachEdge(function(a,s,l,u){(l===n||u===n||r.has(l)||r.has(u)||i.has(l)&&i.has(u))&&o.push(a)}),o}var El=150,Sl=50,Je=Object.prototype.hasOwnProperty;function Qp(t,e,n){if(!Je.call(n,"x")||!Je.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(e,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return n.color||(n.color=t.defaultNodeColor),!n.label&&n.label!==""&&(n.label=null),n.label!==void 0&&n.label!==null?n.label=""+n.label:n.label=null,n.size||(n.size=2),Je.call(n,"hidden")||(n.hidden=!1),Je.call(n,"highlighted")||(n.highlighted=!1),Je.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultNodeType),n.zIndex||(n.zIndex=0),n}function Jp(t,e,n){return n.color||(n.color=t.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),Je.call(n,"hidden")||(n.hidden=!1),Je.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var eg=(function(t){function e(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(le(this,e),i=be(this,e),S(i,"elements",{}),S(i,"canvasContexts",{}),S(i,"webGLContexts",{}),S(i,"pickingLayers",new Set),S(i,"textures",{}),S(i,"frameBuffers",{}),S(i,"activeListeners",{}),S(i,"labelGrid",new kl),S(i,"nodeDataCache",{}),S(i,"edgeDataCache",{}),S(i,"nodeProgramIndex",{}),S(i,"edgeProgramIndex",{}),S(i,"nodesWithForcedLabels",new Set),S(i,"edgesWithForcedLabels",new Set),S(i,"nodeExtent",{x:[0,1],y:[0,1]}),S(i,"nodeZExtent",[1/0,-1/0]),S(i,"edgeZExtent",[1/0,-1/0]),S(i,"matrix",Ne()),S(i,"invMatrix",Ne()),S(i,"correctionRatio",1),S(i,"customBBox",null),S(i,"normalizationFunction",ji({x:[0,1],y:[0,1]})),S(i,"graphToViewportRatio",1),S(i,"itemIDsIndex",{}),S(i,"nodeIndices",{}),S(i,"edgeIndices",{}),S(i,"width",0),S(i,"height",0),S(i,"pixelRatio",Ki()),S(i,"pickingDownSizingRatio",2*i.pixelRatio),S(i,"displayedNodeLabels",new Set),S(i,"displayedEdgeLabels",new Set),S(i,"highlightedNodes",new Set),S(i,"hoveredNode",null),S(i,"hoveredEdge",null),S(i,"renderFrame",null),S(i,"renderHighlightedNodesFrame",null),S(i,"needToProcess",!1),S(i,"checkEdgesEventsFrame",null),S(i,"nodePrograms",{}),S(i,"nodeHoverPrograms",{}),S(i,"edgePrograms",{}),i.settings=wl(o),mr(i.settings),vl(n),!(r instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=n,i.container=r,i.createWebGLContext("edges",{picking:o.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var a in i.settings.nodeProgramClasses)i.registerNodeProgram(a,i.settings.nodeProgramClasses[a],i.settings.nodeHoverProgramClasses[a]);for(var s in i.settings.edgeProgramClasses)i.registerEdgeProgram(s,i.settings.edgeProgramClasses[s]);return i.camera=new bl,i.bindCameraHandlers(),i.mouseCaptor=new Bp(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new Vp(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return xe(e,t),ue(e,[{key:"registerNodeProgram",value:function(r,i,o){return this.nodePrograms[r]&&this.nodePrograms[r].kill(),this.nodeHoverPrograms[r]&&this.nodeHoverPrograms[r].kill(),this.nodePrograms[r]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[r]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(r,i){return this.edgePrograms[r]&&this.edgePrograms[r].kill(),this.edgePrograms[r]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(r){if(this.nodePrograms[r]){var i=this.nodePrograms,o=i[r],a=Yi(i,[r].map(wt));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],u=Yi(s,[r].map(wt));l.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=Yi(i,[r].map(wt));o.kill(),this.edgePrograms=a}return this}},{key:"resetWebGLTexture",value:function(r){var i=this.webGLContexts[r],o=this.frameBuffers[r],a=this.textures[r];a&&i.deleteTexture(a);var s=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,o),i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,s,0),this.textures[r]=s,this}},{key:"bindCameraHandlers",value:function(){var r=this;return this.activeListeners.camera=function(){r.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(r){var i=r.x,o=r.y,a=Oi(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=Mi.apply(void 0,xl(a)),l=this.itemIDsIndex[s];return l&&l.type==="node"?l.id:null}},{key:"bindEventHandlers",value:function(){var r=this;this.activeListeners.handleResize=function(){r.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var a=hn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}},l=r.getNodeAtPosition(a);if(l&&r.hoveredNode!==l&&!r.nodeDataCache[l].hidden){r.hoveredNode&&r.emit("leaveNode",P(P({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",P(P({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var u=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",P(P({},s),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var c=r.hoveredNode?null:r.getEdgeAtPoint(s.event.x,s.event.y);c!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",P(P({},s),{},{edge:r.hoveredEdge})),c&&r.emit("enterEdge",P(P({},s),{},{edge:c})),r.hoveredEdge=c)}},this.activeListeners.handleMoveBody=function(o){var a=hn(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=hn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",P(P({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",P(P({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",P({},s))},this.activeListeners.handleEnter=function(o){var a=hn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",P({},s))};var i=function(a){return function(s){var l=hn(s),u={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},c=r.getNodeAtPosition(l);if(c)return r.emit("".concat(a,"Node"),P(P({},u),{},{node:c}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),P(P({},u),{},{edge:h}))}return r.emit("".concat(a,"Stage"),u)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var r=this,i=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachNode(function(c){return r.updateNode(c)});var u=!l||l.some(function(c){return o.has(c)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!u,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachEdge(function(c){return r.updateEdge(c)});var u=l&&["zIndex","type"].some(function(c){return l?.includes(c)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!u,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(a){var s=a.key;r.addNode(s),r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(a){var s=a.key;r.removeNode(s),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(a){var s=a.key;r.addEdge(s),r.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(a){var s=a.key;r.removeEdge(s),r.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){r.clearEdgeState(),r.clearEdgeIndices(),r.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){r.clearEdgeState(),r.clearNodeState(),r.clearEdgeIndices(),r.clearNodeIndices(),r.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var r=this.graph;r.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(r,i){var o=Oi(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=Mi.apply(void 0,xl(o)),s=this.itemIDsIndex[a];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var r=this;this.emit("beforeProcess");var i=this.graph,o=this.settings,a=this.getDimensions();if(this.nodeExtent=ml(this.graph),!this.settings.autoRescale){var s=a.width,l=a.height,u=this.nodeExtent,c=u.x,h=u.y;this.nodeExtent={x:[(c[0]+c[1])/2-s/2,(c[0]+c[1])/2+s/2],y:[(h[0]+h[1])/2-l/2,(h[0]+h[1])/2+l/2]}}this.normalizationFunction=ji(this.customBBox||this.nodeExtent);var d=new bl,f=Ut(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var g={},m={},v={},y={},w=1,k=i.nodes(),_=0,L=k.length;_<L;_++){var R=k[_],D=this.nodeDataCache[R],z=i.getNodeAttributes(R);D.x=z.x,D.y=z.y,this.normalizationFunction.applyTo(D),typeof D.label=="string"&&!D.hidden&&this.labelGrid.add(R,D.size,this.framedGraphToViewport(D,{matrix:f})),g[D.type]=(g[D.type]||0)+1}this.labelGrid.organize();for(var F in this.nodePrograms){if(!Je.call(this.nodePrograms,F))throw new Error('Sigma: could not find a suitable program for node type "'.concat(F,'"!'));this.nodePrograms[F].reallocate(g[F]||0),g[F]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(k=Vi(this.nodeZExtent,function(en){return r.nodeDataCache[en].zIndex},k));for(var G=0,U=k.length;G<U;G++){var j=k[G];m[j]=w,y[m[j]]={type:"node",id:j},w++;var Q=this.nodeDataCache[j];this.addNodeToProgram(j,m[j],g[Q.type]++)}for(var ge={},he=i.edges(),Be=0,Nt=he.length;Be<Nt;Be++){var De=he[Be],Ie=this.edgeDataCache[De];ge[Ie.type]=(ge[Ie.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(he=Vi(this.edgeZExtent,function(en){return r.edgeDataCache[en].zIndex},he));for(var Ge in this.edgePrograms){if(!Je.call(this.edgePrograms,Ge))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Ge,'"!'));this.edgePrograms[Ge].reallocate(ge[Ge]||0),ge[Ge]=0}for(var We=0,Jt=he.length;We<Jt;We++){var Ce=he[We];v[Ce]=w,y[v[Ce]]={type:"edge",id:Ce},w++;var q=this.edgeDataCache[Ce];this.addEdgeToProgram(Ce,v[Ce],ge[q.type]++)}return this.itemIDsIndex=y,this.nodeIndices=m,this.edgeIndices=v,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(c){return i.cleanCameraState(c,o.cameraPanBoundaries&&fr(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==o.edgeProgramClasses){for(var a in o.edgeProgramClasses)o.edgeProgramClasses[a]!==r.edgeProgramClasses[a]&&this.registerEdgeProgram(a,o.edgeProgramClasses[a]);for(var s in r.edgeProgramClasses)o.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(r.nodeProgramClasses!==o.nodeProgramClasses||r.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var l in o.nodeProgramClasses)(o.nodeProgramClasses[l]!==r.nodeProgramClasses[l]||o.nodeHoverProgramClasses[l]!==r.nodeHoverProgramClasses[l])&&this.registerNodeProgram(l,o.nodeProgramClasses[l],o.nodeHoverProgramClasses[l]);for(var u in r.nodeProgramClasses)o.nodeProgramClasses[u]||this.unregisterNodeProgram(u)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.tolerance,a=o===void 0?0:o,s=i.boundaries,l=P({},r),u=s||this.nodeExtent,c=ut(u.x,2),h=c[0],d=c[1],f=ut(u.y,2),g=f[0],m=f[1],v=[this.graphToViewport({x:h,y:g},{cameraState:r}),this.graphToViewport({x:d,y:g},{cameraState:r}),this.graphToViewport({x:h,y:m},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r})],y=1/0,w=-1/0,k=1/0,_=-1/0;v.forEach(function(ge){var he=ge.x,Be=ge.y;y=Math.min(y,he),w=Math.max(w,he),k=Math.min(k,Be),_=Math.max(_,Be)});var L=w-y,R=_-k,D=this.getDimensions(),z=D.width,F=D.height,G=0,U=0;if(L>=z?w<z-a?G=w-(z-a):y>a&&(G=y-a):w>z+a?G=w-(z+a):y<-a&&(G=y+a),R>=F?_<F-a?U=_-(F-a):k>a&&(U=k-a):_>F+a?U=_-(F+a):k<-a&&(U=k+a),G||U){var j=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),Q=this.viewportToFramedGraph({x:G,y:U},{cameraState:r});G=Q.x-j.x,U=Q.y-j.y,l.x+=G,l.y+=U}return l}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var r=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(r.ratio,this.settings.labelDensity);qi(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=i.length;a<s;a++){var l=i[a],u=this.nodeDataCache[l];if(!this.displayedNodeLabels.has(l)&&!u.hidden){var c=this.framedGraphToViewport(u),h=c.x,d=c.y,f=this.scaleSize(u.size);if(!(!u.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(h<-El||h>this.width+El||d<-Sl||d>this.height+Sl)){this.displayedNodeLabels.add(l);var g=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[u.type],v=m?.drawLabel||g;v(o,P(P({key:l},u),{},{size:f,x:h,y:d}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var r=this.canvasContexts.edgeLabels;r.clearRect(0,0,this.width,this.height);var i=Zp({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});qi(i,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=i.length;a<s;a++){var l=i[a],u=this.graph.extremities(l),c=this.nodeDataCache[u[0]],h=this.nodeDataCache[u[1]],d=this.edgeDataCache[l];if(!o.has(l)&&!(d.hidden||c.hidden||h.hidden)){var f=this.settings.defaultDrawEdgeLabel,g=this.edgePrograms[d.type],m=g?.drawLabel||f;m(r,P(P({key:l},d),{},{size:this.scaleSize(d.size)}),P(P(P({key:u[0]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),P(P(P({key:u[1]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),this.settings),o.add(l)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(f){var g=r.nodeDataCache[f],m=r.framedGraphToViewport(g),v=m.x,y=m.y,w=r.scaleSize(g.size),k=r.settings.defaultDrawNodeHover,_=r.nodePrograms[g.type],L=_?.drawHover||k;L(i,P(P({key:f},g),{},{size:w,x:v,y}),r.settings)},a=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&a.push(this.hoveredNode),this.highlightedNodes.forEach(function(d){d!==r.hoveredNode&&a.push(d)}),a.forEach(function(d){return o(d)});var s={};a.forEach(function(d){var f=r.nodeDataCache[d].type;s[f]=(s[f]||0)+1});for(var l in this.nodeHoverPrograms)this.nodeHoverPrograms[l].reallocate(s[l]||0),s[l]=0;a.forEach(function(d){var f=r.nodeDataCache[d];r.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var u=this.getRenderParams();for(var c in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[c];h.render(u)}}},{key:"scheduleHighlightedNodesRender",value:function(){var r=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){r.renderHighlightedNodesFrame=null,r.renderHighlightedNodes(),r.renderEdgeLabels()}))}},{key:"render",value:function(){var r=this;this.emit("beforeRender");var i=function(){return r.emit("afterRender"),r};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(v){return r.resetWebGLTexture(v)}),!this.graph.order)return i();var o=this.mouseCaptor,a=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,s=this.camera.getState(),l=this.getDimensions(),u=this.getGraphDimensions(),c=this.getStagePadding();this.matrix=Ut(s,l,u,c),this.invMatrix=Ut(s,l,u,c,!0),this.correctionRatio=gl(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var d in this.nodePrograms){var f=this.nodePrograms[d];f.render(h)}if(!this.settings.hideEdgesOnMove||!a)for(var g in this.edgePrograms){var m=this.edgePrograms[g];m.render(h)}return this.settings.hideLabelsOnMove&&a||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(r){var i=Object.assign({},this.graph.getNodeAttributes(r));this.settings.nodeReducer&&(i=this.settings.nodeReducer(r,i));var o=Qp(this.settings,r,i);this.nodeDataCache[r]=o,this.nodesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(r),this.highlightedNodes.delete(r),o.highlighted&&!o.hidden&&this.highlightedNodes.add(r),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(r){this.addNode(r);var i=this.nodeDataCache[r];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(r){delete this.nodeDataCache[r],delete this.nodeProgramIndex[r],this.highlightedNodes.delete(r),this.hoveredNode===r&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(r)}},{key:"addEdge",value:function(r){var i=Object.assign({},this.graph.getEdgeAttributes(r));this.settings.edgeReducer&&(i=this.settings.edgeReducer(r,i));var o=Jp(this.settings,r,i);this.edgeDataCache[r]=o,this.edgesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(r),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(r){this.addEdge(r)}},{key:"removeEdge",value:function(r){delete this.edgeDataCache[r],delete this.edgeProgramIndex[r],this.hoveredEdge===r&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(r)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new kl,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(r,i,o){var a=this.nodeDataCache[r],s=this.nodePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(a.type,'"!'));s.process(i,o,a),this.nodeProgramIndex[r]=o}},{key:"addEdgeToProgram",value:function(r,i,o){var a=this.edgeDataCache[r],s=this.edgePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(a.type,'"!'));var l=this.graph.extremities(r),u=this.nodeDataCache[l[0]],c=this.nodeDataCache[l[1]];s.process(i,o,u,c,a),this.edgeProgramIndex[r]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var r=this.settings,i=r.stagePadding,o=r.autoRescale;return o&&i||0}},{key:"createLayer",value:function(r,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[r])throw new Error('Sigma: a layer named "'.concat(r,'" already exists'));var a=yl(i,{position:"absolute"},{class:"sigma-".concat(r)});return o.style&&Object.assign(a.style,o.style),this.elements[r]=a,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(a):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(a):this.container.appendChild(a),a}},{key:"createCanvas",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(r,"canvas",i)}},{key:"createCanvasContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(r,i),a={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[r]=o.getContext("2d",a),this}},{key:"createWebGLContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i?.canvas||this.createCanvas(r,i);i.hidden&&o.remove();var a=P({preserveDrawingBuffer:!1,antialias:!1},i),s;s=o.getContext("webgl2",a),s||(s=o.getContext("webgl",a)),s||(s=o.getContext("experimental-webgl",a));var l=s;if(this.webGLContexts[r]=l,l.blendFunc(l.ONE,l.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var u=l.createFramebuffer();if(!u)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=u}return l}},{key:"killLayer",value:function(r){var i=this.elements[r];if(!i)throw new Error("Sigma: cannot kill layer ".concat(r,", which does not exist"));if(this.webGLContexts[r]){var o,a=this.webGLContexts[r];(o=a.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[r]}else this.canvasContexts[r]&&delete this.canvasContexts[r];return i.remove(),delete this.elements[r],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(r){this.unbindCameraHandlers(),this.camera=r,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(r){r!==this.graph&&(this.hoveredNode&&!r.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!r.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=r,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var r=this.customBBox||this.nodeExtent;return{width:r.x[1]-r.x[0]||1,height:r.y[1]-r.y[0]||1}}},{key:"getNodeDisplayData",value:function(r){var i=this.nodeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(r){var i=this.edgeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return P({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=P({},this.settings);return this.settings[r]=i,mr(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(r,i){return this.setSetting(r,i(this.settings[r])),this}},{key:"setSettings",value:function(r){var i=P({},this.settings);return this.settings=P(P({},this.settings),r),mr(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(r){var i=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=Ki(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!r&&i===this.width&&o===this.height)return this;for(var a in this.elements){var s=this.elements[a];s.style.width=this.width+"px",s.style.height=this.height+"px"}for(var l in this.canvasContexts)this.elements[l].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[l].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[l].scale(this.pixelRatio,this.pixelRatio);for(var u in this.webGLContexts){this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px");var c=this.webGLContexts[u];if(c.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(u)){var h=this.textures[u];h&&c.deleteTexture(h)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(r){var i=this,o=r?.skipIndexation!==void 0?r?.skipIndexation:!1,a=r?.schedule!==void 0?r.schedule:!1,s=!r||!r.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(_){return i.addNode(_)}),this.graph.forEachEdge(function(_){return i.addEdge(_)});else{for(var l,u,c=((l=r.partialGraph)===null||l===void 0?void 0:l.nodes)||[],h=0,d=c?.length||0;h<d;h++){var f=c[h];if(this.updateNode(f),o){var g=this.nodeProgramIndex[f];if(g===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],g)}}for(var m=(r==null||(u=r.partialGraph)===null||u===void 0?void 0:u.edges)||[],v=0,y=m.length;v<y;v++){var w=m[v];if(this.updateEdge(w),o){var k=this.edgeProgramIndex[w];if(k===void 0)throw new Error('Sigma: edge "'.concat(w,`" can't be repaint`));this.addEdgeToProgram(w,this.edgeIndices[w],k)}}}return(s||!o)&&(this.needToProcess=!0),a?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var r=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){r.render()})),this}},{key:"scheduleRefresh",value:function(r){return this.refresh(P(P({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var o=this.camera.getState(),a=o.ratio,s=o.angle,l=o.x,u=o.y,c=this.settings,h=c.minCameraRatio,d=c.maxCameraRatio;typeof d=="number"&&(i=Math.min(i,d)),typeof h=="number"&&(i=Math.max(i,h));var f=i/a,g={x:this.width/2,y:this.height/2},m=this.viewportToFramedGraph(r),v=this.viewportToFramedGraph(g);return{angle:s,x:(m.x-v.x)*(1-f)+l,y:(m.y-v.y)*(1-f)+u,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,a=i.matrix?i.matrix:o?Ut(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=hr(a,r);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,a=i.matrix?i.matrix:o?Ut(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=hr(a,{x:r.x/this.width*2-1,y:1-r.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(r,i))}},{key:"graphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(r),i)}},{key:"getGraphToViewportRatio",value:function(){var r={x:0,y:0},i={x:1,y:1},o=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),a=this.graphToViewport(r),s=this.graphToViewport(i),l=Math.sqrt(Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2));return l/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(r){return this.customBBox=r,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var r=this.container;r.firstChild;)r.removeChild(r.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var a in this.edgePrograms)this.edgePrograms[a].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var s in this.elements)this.killLayer(s);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return r/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var r={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(r[i]=this.elements[i]);return r}}])})(cr),Rl=eg;function Cl(t){let e=+this._x.call(null,t),n=+this._y.call(null,t);return Nl(this.cover(e,n),e,n,t)}function Nl(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o=t._root,a={data:r},s=t._x0,l=t._y0,u=t._x1,c=t._y1,h,d,f,g,m,v,y,w;if(!o)return t._root=a,t;for(;o.length;)if((m=e>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d,i=o,!(o=o[y=v<<1|m]))return i[y]=a,t;if(f=+t._x.call(null,o.data),g=+t._y.call(null,o.data),e===f&&n===g)return a.next=o,i?i[y]=a:t._root=a,t;do i=i?i[y]=new Array(4):t._root=new Array(4),(m=e>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d;while((y=v<<1|m)===(w=(g>=d)<<1|f>=h));return i[w]=o,i[y]=a,t}function Ll(t){var e,n,r=t.length,i,o,a=new Array(r),s=new Array(r),l=1/0,u=1/0,c=-1/0,h=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,e=t[n]))||isNaN(o=+this._y.call(null,e))||(a[n]=i,s[n]=o,i<l&&(l=i),i>c&&(c=i),o<u&&(u=o),o>h&&(h=o));if(l>c||u>h)return this;for(this.cover(l,u).cover(c,h),n=0;n<r;++n)Nl(this,a[n],s[n],t[n]);return this}function Pl(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a=i-n||1,s=this._root,l,u;n>t||t>=i||r>e||e>=o;)switch(u=(e<r)<<1|t<n,l=new Array(4),l[u]=s,s=l,a*=2,u){case 0:i=n+a,o=r+a;break;case 1:n=i-a,o=r+a;break;case 2:i=n+a,r=o-a;break;case 3:n=i-a,r=o-a;break}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this}function Dl(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function Il(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function fe(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function Gl(t,e,n){var r,i=this._x0,o=this._y0,a,s,l,u,c=this._x1,h=this._y1,d=[],f=this._root,g,m;for(f&&d.push(new fe(f,i,o,c,h)),n==null?n=1/0:(i=t-n,o=e-n,c=t+n,h=e+n,n*=n);g=d.pop();)if(!(!(f=g.node)||(a=g.x0)>c||(s=g.y0)>h||(l=g.x1)<i||(u=g.y1)<o))if(f.length){var v=(a+l)/2,y=(s+u)/2;d.push(new fe(f[3],v,y,l,u),new fe(f[2],a,y,v,u),new fe(f[1],v,s,l,y),new fe(f[0],a,s,v,y)),(m=(e>=y)<<1|t>=v)&&(g=d[d.length-1],d[d.length-1]=d[d.length-1-m],d[d.length-1-m]=g)}else{var w=t-+this._x.call(null,f.data),k=e-+this._y.call(null,f.data),_=w*w+k*k;if(_<n){var L=Math.sqrt(n=_);i=t-L,o=e-L,c=t+L,h=e+L,r=f.data}}return r}function Ml(t){if(isNaN(c=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t)))return this;var e,n=this._root,r,i,o,a=this._x0,s=this._y0,l=this._x1,u=this._y1,c,h,d,f,g,m,v,y;if(!n)return this;if(n.length)for(;;){if((g=c>=(d=(a+l)/2))?a=d:l=d,(m=h>=(f=(s+u)/2))?s=f:u=f,e=n,!(n=n[v=m<<1|g]))return this;if(!n.length)break;(e[v+1&3]||e[v+2&3]||e[v+3&3])&&(r=e,y=v)}for(;n.data!==t;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):e?(o?e[v]=o:delete e[v],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[y]=n:this._root=n),this):(this._root=o,this)}function Ol(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Fl(){return this._root}function zl(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function $l(t){var e=[],n,r=this._root,i,o,a,s,l;for(r&&e.push(new fe(r,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(r=n.node,o=n.x0,a=n.y0,s=n.x1,l=n.y1)&&r.length){var u=(o+s)/2,c=(a+l)/2;(i=r[3])&&e.push(new fe(i,u,c,s,l)),(i=r[2])&&e.push(new fe(i,o,c,u,l)),(i=r[1])&&e.push(new fe(i,u,a,s,c)),(i=r[0])&&e.push(new fe(i,o,a,u,c))}return this}function Ul(t){var e=[],n=[],r;for(this._root&&e.push(new fe(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var i=r.node;if(i.length){var o,a=r.x0,s=r.y0,l=r.x1,u=r.y1,c=(a+l)/2,h=(s+u)/2;(o=i[0])&&e.push(new fe(o,a,s,c,h)),(o=i[1])&&e.push(new fe(o,c,s,l,h)),(o=i[2])&&e.push(new fe(o,a,h,c,u)),(o=i[3])&&e.push(new fe(o,c,h,l,u))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Hl(t){return t[0]}function Bl(t){return arguments.length?(this._x=t,this):this._x}function Wl(t){return t[1]}function Kl(t){return arguments.length?(this._y=t,this):this._y}function xt(t,e,n){var r=new Xi(e??Hl,n??Wl,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function Xi(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Vl(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var _e=xt.prototype=Xi.prototype;_e.copy=function(){var t=new Xi(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,r;if(!e)return t;if(!e.length)return t._root=Vl(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var i=0;i<4;++i)(r=e.source[i])&&(r.length?n.push({source:r,target:e.target[i]=new Array(4)}):e.target[i]=Vl(r));return t};_e.add=Cl;_e.addAll=Ll;_e.cover=Pl;_e.data=Dl;_e.extent=Il;_e.find=Gl;_e.remove=Ml;_e.removeAll=Ol;_e.root=Fl;_e.size=zl;_e.visit=$l;_e.visitAfter=Ul;_e.x=Bl;_e.y=Kl;function ae(t){return function(){return t}}function Oe(t){return(t()-.5)*1e-6}function tg(t){return t.x+t.vx}function ng(t){return t.y+t.vy}function Zi(t){var e,n,r,i=1,o=1;typeof t!="function"&&(t=ae(t==null?1:+t));function a(){for(var u,c=e.length,h,d,f,g,m,v,y=0;y<o;++y)for(h=xt(e,tg,ng).visitAfter(s),u=0;u<c;++u)d=e[u],m=n[d.index],v=m*m,f=d.x+d.vx,g=d.y+d.vy,h.visit(w);function w(k,_,L,R,D){var z=k.data,F=k.r,G=m+F;if(z){if(z.index>d.index){var U=f-z.x-z.vx,j=g-z.y-z.vy,Q=U*U+j*j;Q<G*G&&(U===0&&(U=Oe(r),Q+=U*U),j===0&&(j=Oe(r),Q+=j*j),Q=(G-(Q=Math.sqrt(Q)))/Q*i,d.vx+=(U*=Q)*(G=(F*=F)/(v+F)),d.vy+=(j*=Q)*G,z.vx-=U*(G=1-G),z.vy-=j*G)}return}return _>f+G||R<f-G||L>g+G||D<g-G}}function s(u){if(u.data)return u.r=n[u.data.index];for(var c=u.r=0;c<4;++c)u[c]&&u[c].r>u.r&&(u.r=u[c].r)}function l(){if(e){var u,c=e.length,h;for(n=new Array(c),u=0;u<c;++u)h=e[u],n[h.index]=+t(h,u,e)}}return a.initialize=function(u,c){e=u,r=c,l()},a.iterations=function(u){return arguments.length?(o=+u,a):o},a.strength=function(u){return arguments.length?(i=+u,a):i},a.radius=function(u){return arguments.length?(t=typeof u=="function"?u:ae(+u),l(),a):t},a}function rg(t){return t.index}function jl(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Qi(t){var e=rg,n=h,r,i=ae(30),o,a,s,l,u,c=1;t==null&&(t=[]);function h(v){return 1/Math.min(s[v.source.index],s[v.target.index])}function d(v){for(var y=0,w=t.length;y<c;++y)for(var k=0,_,L,R,D,z,F,G;k<w;++k)_=t[k],L=_.source,R=_.target,D=R.x+R.vx-L.x-L.vx||Oe(u),z=R.y+R.vy-L.y-L.vy||Oe(u),F=Math.sqrt(D*D+z*z),F=(F-o[k])/F*v*r[k],D*=F,z*=F,R.vx-=D*(G=l[k]),R.vy-=z*G,L.vx+=D*(G=1-G),L.vy+=z*G}function f(){if(a){var v,y=a.length,w=t.length,k=new Map(a.map((L,R)=>[e(L,R,a),L])),_;for(v=0,s=new Array(y);v<w;++v)_=t[v],_.index=v,typeof _.source!="object"&&(_.source=jl(k,_.source)),typeof _.target!="object"&&(_.target=jl(k,_.target)),s[_.source.index]=(s[_.source.index]||0)+1,s[_.target.index]=(s[_.target.index]||0)+1;for(v=0,l=new Array(w);v<w;++v)_=t[v],l[v]=s[_.source.index]/(s[_.source.index]+s[_.target.index]);r=new Array(w),g(),o=new Array(w),m()}}function g(){if(a)for(var v=0,y=t.length;v<y;++v)r[v]=+n(t[v],v,t)}function m(){if(a)for(var v=0,y=t.length;v<y;++v)o[v]=+i(t[v],v,t)}return d.initialize=function(v,y){a=v,u=y,f()},d.links=function(v){return arguments.length?(t=v,f(),d):t},d.id=function(v){return arguments.length?(e=v,d):e},d.iterations=function(v){return arguments.length?(c=+v,d):c},d.strength=function(v){return arguments.length?(n=typeof v=="function"?v:ae(+v),g(),d):n},d.distance=function(v){return arguments.length?(i=typeof v=="function"?v:ae(+v),m(),d):i},d}var ig={value:()=>{}};function Yl(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new wr(n)}function wr(t){this._=t}function og(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}wr.prototype=Yl.prototype={constructor:wr,on:function(t,e){var n=this._,r=og(t+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(t=r[o]).type)&&(i=ag(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<a;)if(i=(t=r[o]).type)n[i]=ql(n[i],t.name,e);else if(e==null)for(i in n)n[i]=ql(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new wr(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};function ag(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function ql(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=ig,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var Ji=Yl;var Ht=0,gn=0,pn=0,Zl=1e3,br,mn,xr=0,_t=0,_r=0,vn=typeof performance=="object"&&performance.now?performance:Date,Ql=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function no(){return _t||(Ql(sg),_t=vn.now()+_r)}function sg(){_t=0}function eo(){this._call=this._time=this._next=null}eo.prototype=kr.prototype={constructor:eo,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?no():+n)+(e==null?0:+e),!this._next&&mn!==this&&(mn?mn._next=this:br=this,mn=this),this._call=t,this._time=n,to()},stop:function(){this._call&&(this._call=null,this._time=1/0,to())}};function kr(t,e,n){var r=new eo;return r.restart(t,e,n),r}function Jl(){no(),++Ht;for(var t=br,e;t;)(e=_t-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Ht}function Xl(){_t=(xr=vn.now())+_r,Ht=gn=0;try{Jl()}finally{Ht=0,ug(),_t=0}}function lg(){var t=vn.now(),e=t-xr;e>Zl&&(_r-=e,xr=t)}function ug(){for(var t,e=br,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:br=n);mn=t,to(r)}function to(t){if(!Ht){gn&&(gn=clearTimeout(gn));var e=t-_t;e>24?(t<1/0&&(gn=setTimeout(Xl,t-vn.now()-_r)),pn&&(pn=clearInterval(pn))):(pn||(xr=vn.now(),pn=setInterval(lg,Zl)),Ht=1,Ql(Xl))}}function eu(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function tu(t){return t.x}function nu(t){return t.y}var cg=10,dg=Math.PI*(3-Math.sqrt(5));function ro(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=kr(h),u=Ji("tick","end"),c=eu();t==null&&(t=[]);function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(m){var v,y=t.length,w;m===void 0&&(m=1);for(var k=0;k<m;++k)for(n+=(o-n)*i,s.forEach(function(_){_(n)}),v=0;v<y;++v)w=t[v],w.fx==null?w.x+=w.vx*=a:(w.x=w.fx,w.vx=0),w.fy==null?w.y+=w.vy*=a:(w.y=w.fy,w.vy=0);return e}function f(){for(var m=0,v=t.length,y;m<v;++m){if(y=t[m],y.index=m,y.fx!=null&&(y.x=y.fx),y.fy!=null&&(y.y=y.fy),isNaN(y.x)||isNaN(y.y)){var w=cg*Math.sqrt(.5+m),k=m*dg;y.x=w*Math.cos(k),y.y=w*Math.sin(k)}(isNaN(y.vx)||isNaN(y.vy))&&(y.vx=y.vy=0)}}function g(m){return m.initialize&&m.initialize(t,c),m}return f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(m){return arguments.length?(t=m,f(),s.forEach(g),e):t},alpha:function(m){return arguments.length?(n=+m,e):n},alphaMin:function(m){return arguments.length?(r=+m,e):r},alphaDecay:function(m){return arguments.length?(i=+m,e):+i},alphaTarget:function(m){return arguments.length?(o=+m,e):o},velocityDecay:function(m){return arguments.length?(a=1-m,e):1-a},randomSource:function(m){return arguments.length?(c=m,s.forEach(g),e):c},force:function(m,v){return arguments.length>1?(v==null?s.delete(m):s.set(m,g(v)),e):s.get(m)},find:function(m,v,y){var w=0,k=t.length,_,L,R,D,z;for(y==null?y=1/0:y*=y,w=0;w<k;++w)D=t[w],_=m-D.x,L=v-D.y,R=_*_+L*L,R<y&&(z=D,y=R);return z},on:function(m,v){return arguments.length>1?(u.on(m,v),e):u.on(m)}}}function io(){var t,e,n,r,i=ae(-30),o,a=1,s=1/0,l=.81;function u(f){var g,m=t.length,v=xt(t,tu,nu).visitAfter(h);for(r=f,g=0;g<m;++g)e=t[g],v.visit(d)}function c(){if(t){var f,g=t.length,m;for(o=new Array(g),f=0;f<g;++f)m=t[f],o[m.index]=+i(m,f,t)}}function h(f){var g=0,m,v,y=0,w,k,_;if(f.length){for(w=k=_=0;_<4;++_)(m=f[_])&&(v=Math.abs(m.value))&&(g+=m.value,y+=v,w+=v*m.x,k+=v*m.y);f.x=w/y,f.y=k/y}else{m=f,m.x=m.data.x,m.y=m.data.y;do g+=o[m.data.index];while(m=m.next)}f.value=g}function d(f,g,m,v){if(!f.value)return!0;var y=f.x-e.x,w=f.y-e.y,k=v-g,_=y*y+w*w;if(k*k/l<_)return _<s&&(y===0&&(y=Oe(n),_+=y*y),w===0&&(w=Oe(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)),e.vx+=y*f.value*r/_,e.vy+=w*f.value*r/_),!0;if(f.length||_>=s)return;(f.data!==e||f.next)&&(y===0&&(y=Oe(n),_+=y*y),w===0&&(w=Oe(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)));do f.data!==e&&(k=o[f.data.index]*r/_,e.vx+=y*k,e.vy+=w*k);while(f=f.next)}return u.initialize=function(f,g){t=f,n=g,c()},u.strength=function(f){return arguments.length?(i=typeof f=="function"?f:ae(+f),c(),u):i},u.distanceMin=function(f){return arguments.length?(a=f*f,u):Math.sqrt(a)},u.distanceMax=function(f){return arguments.length?(s=f*f,u):Math.sqrt(s)},u.theta=function(f){return arguments.length?(l=f*f,u):Math.sqrt(l)},u}function oo(t){var e=ae(.1),n,r,i;typeof t!="function"&&(t=ae(t==null?0:+t));function o(s){for(var l=0,u=n.length,c;l<u;++l)c=n[l],c.vx+=(i[l]-c.x)*r[l]*s}function a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+t(n[s],s,n))?0:+e(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:ae(+s),a(),o):e},o.x=function(s){return arguments.length?(t=typeof s=="function"?s:ae(+s),a(),o):t},o}function ao(t){var e=ae(.1),n,r,i;typeof t!="function"&&(t=ae(t==null?0:+t));function o(s){for(var l=0,u=n.length,c;l<u;++l)c=n[l],c.vy+=(i[l]-c.y)*r[l]*s}function a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+t(n[s],s,n))?0:+e(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:ae(+s),a(),o):e},o.y=function(s){return arguments.length?(t=typeof s=="function"?s:ae(+s),a(),o):t},o}var hg=9,Er=6,Sr=18,fg=32,au=9,Tr=hg+au;function so(t){let e=Number.isFinite(t)&&t>0?t:0,n=Math.min(1,Math.log2(1+e)/Math.log2(1+fg));return Er+(Sr-Er)*n}function lo(t){return t+au}var pg=300,su=1,ru=.001,gg=90,mg=.02,vg=170,yg=.05,wg=-50,iu=.09;function ou(t){return t==="contains"||t==="anchored-at"}function bg(t){let e=Math.trunc(t)>>>0;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function xg(t){let e=[],n=new Set;for(let o of t.nodes)n.has(o.id)||(n.add(o.id),e.push(o.id));let r=[],i=new Set;for(let o of t.edges){if(o.source===o.target||!n.has(o.source)||!n.has(o.target))continue;let a=`${o.source}\0${o.target}\0${o.kind}`;i.has(a)||(i.add(a),r.push(o))}return{ids:e,edges:r}}function uo(t){let e=Qi(t.links).id(n=>n.id).distance(n=>ou(n.kind)?gg:vg).strength(n=>ou(n.kind)?mg:yg).iterations(2);return ro(t.nodes).randomSource(bg(t.seed??su)).force("charge",io().strength(wg)).force("link",e).force("collide",Zi(n=>n.r??Tr).strength(1)).force("x",oo(0).strength(iu)).force("y",ao(0).strength(iu)).stop()}function _g(t,e,n){let r=uo({nodes:t,links:e.map(({source:i,target:o,kind:a})=>({source:i,target:o,kind:a})),seed:n.seed}).alpha(n.warm?.3:1).alphaMin(ru).alphaDecay(n.ticks>0?1-Math.pow(ru,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function lu(t,e={}){let n=Math.max(0,Math.trunc(e.ticks??pg)),{ids:r,edges:i}=xg(t),o=r.map(l=>{let u=e.initial?.get(l),c={id:l,vx:0,vy:0};return u!==void 0&&Number.isFinite(u.x)&&Number.isFinite(u.y)&&(c.x=u.x,c.y=u.y,e.pinWarm===!0&&(c.fx=u.x,c.fy=u.y)),c}),a=new Map;for(let l of i)a.set(l.source,(a.get(l.source)??0)+1),a.set(l.target,(a.get(l.target)??0)+1);for(let l of o)l.r=lo(so(a.get(l.id)??0));o.length>1&&_g(o,i,{ticks:n,seed:e.seed??su,warm:e.initial!==void 0});let s=new Map;for(let l of o)s.set(l.id,{x:Number.isFinite(l.x)?l.x:0,y:Number.isFinite(l.y)?l.y:0});return s}function Te(t){if(t.kind==="external"&&t.detail.url){let e=t.detail.url.replace(/^[a-z]+:\/\//,"").replace(/^[^@\/]+@/,"").replace(/\.git$/,"").replace(/\/+$/,"");if(e)return e}return t.kind==="package"&&t.detail.manifest?`${t.label} (${t.detail.manifest})`:t.label}function kg(t){let e=new Map;for(let l of t.nodes)e.set(l.id,l);let n=new Map,r=new Map,i=new Set;for(let l of t.edges){if(l.kind==="contains"){let u=n.get(l.source);u?u.push(l.target):n.set(l.source,[l.target])}if(l.kind==="contains"||l.kind==="anchored-at"){let u=r.get(l.source);u?u.push(l.target):r.set(l.source,[l.target]),i.add(l.target)}}let o=l=>{if(!l.detail.path)return null;let u=l.detail.path,c=null,h=0,d=n.get("repository")??[];for(let f of d){let g=e.get(f);if(g&&g.kind==="module"&&g.detail.path){let m=g.detail.path;u.startsWith(m+"/")&&m.length>h&&(c=f,h=m.length)}}return c},a=new Map;for(let l of t.nodes){if(l.kind!=="entryPoint")continue;let u=o(l);if(u){let c=a.get(u);c?c.push(l.id):a.set(u,[l.id])}}let s=t.nodes.filter(l=>!i.has(l.id)).map(l=>l.id);return{byId:e,contains:n,tree:r,incoming:i,moduleEntries:a,roots:s}}function du(t){let e=new Set;for(let n of t.edges)(n.kind==="contains"||n.kind==="anchored-at")&&e.add(n.target);return t.nodes.filter(n=>!e.has(n.id)).map(n=>n.id)}function Eg(t){return t==="gitState"||t==="external"||t==="package"||t==="entryPoint"}function uu(t){return t?t.kind==="module"||t.id.startsWith("vfolder:"):!1}function Sg(t,e){return t.slice().sort((n,r)=>{let i=e.get(n),o=e.get(r),a=uu(i),s=uu(o);if(a!==s)return a?-1:1;let l=Te(i),u=Te(o);return l.localeCompare(u)})}function cu(t,e,n){let r=Number(t);return Number.isFinite(r)?{kind:"count",n:r,unit:e,phrasing:n}:{kind:"text",text:n==="attribute"?`${e}=${t}`:`${t} ${e}`}}function Tg(t){switch(t.kind){case"note":return t.detail.updated?{kind:"relTime",iso:t.detail.updated}:null;case"module":return t.detail.files?cu(t.detail.files,"files","attribute"):null;case"gitState":return t.detail.commit?{kind:"commit",sha:t.detail.commit}:null;case"repository":return t.detail.files?cu(t.detail.files,"files","prose"):null;case"package":return t.detail.kind?{kind:"text",text:t.detail.kind}:null;case"entryPoint":return t.detail.summary?{kind:"text",text:"summary"}:null;default:return null}}function co(t,e){let n=kg(t),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=g=>{let y=(i.get(g)??[]).filter(w=>{let k=r.get(w);if(!k||k.kind!=="entryPoint")return!0;for(let[,_]of o)if(_.includes(w))return!1;return!0}).concat(o.get(g)??[]);return y=y.filter(w=>r.has(w)),e.showInternals||(y=y.filter(w=>{let k=r.get(w);return!(k&&Eg(k.kind))})),Sg(y,r)},l=e.provFilter!==null||e.query.length>0,u=g=>!(e.provFilter!==null&&g.provenance!==e.provFilter||e.query.length>0&&!Te(g).toLowerCase().includes(e.query.toLowerCase())),c=new Set,h=g=>{let m=r.get(g),v=!1;for(let w of s(g))h(w)&&(v=!0);let y=u(m)||v;return y&&c.add(g),y};for(let g of a)h(g);let d=[],f=(g,m)=>{if(!c.has(g))return;let v=r.get(g),y=s(g),w=y.filter(_=>c.has(_)),k=l?w.length>0:e.expanded.has(g);if(d.push({id:g,depth:m,hasKids:y.length>0,expanded:k,label:Te(v),kind:v.kind,provenance:v.provenance,meta:Tg(v)}),k)for(let _ of w)f(_,m+1)};for(let g of a)f(g,0);return d}function ho(t){if(!t.nodes.find(i=>i.kind==="vault"))return null;let n=t.nodes.some(i=>i.kind==="note"),r=t.nodes.some(i=>i.kind==="repository");return!n&&!r?"no notes yet — add one with the weave_note tool":null}function yn(t,e){if(!t)return"";let n=Date.parse(t);if(Number.isNaN(n))return"";let r=Math.max(0,Math.floor((e-n)/1e3));if(r<60)return"just now";let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let o=Math.floor(i/60);if(o<24)return`${o}h ago`;let a=Math.floor(o/24);if(a<30)return`${a}d ago`;let s=Math.floor(a/30);return s<12?`${s}mo ago`:`${Math.floor(s/12)}y ago`}var Ag=7;function fo(t,e){if(t===null)return"";switch(t.kind){case"relTime":return yn(t.iso,e);case"count":return t.phrasing==="attribute"?`${t.unit}=${t.n}`:`${t.n} ${t.unit}`;case"commit":return t.sha.slice(0,Ag);case"text":return t.text}}var Rg=["title","description","path","size","slug","source","updated","created","tags","files","languages","branch","commit","uncommitted changes","captured","manifest","kind","url","summarized files","summarized by","summarized at","summary","dangling links","link references","warning","stale","preview","root","notes","state"];function po(t,e){let n=new Map;for(let s of t.nodes)n.set(s.id,s);let r=n.get(e);if(!r)return null;let i=[];for(let s of Rg){let l=r.detail[s];l===void 0||l===""||i.push({id:`meta:${s}`,label:s,value:l})}let o=[];for(let s of t.edges){if(s.source!==e)continue;let l=n.get(s.target);l&&o.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${Te(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let a=[];for(let s of t.edges){if(s.kind!=="links-to"||s.target!==e)continue;let l=n.get(s.source);l&&a.push({id:`backlink:${s.source}`,target:s.source,label:`← ${Te(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:e,label:Te(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function go(t,e){let n=new Set([t]);for(let r of e)r.source===t&&n.add(r.target),r.target===t&&n.add(r.source);return n}var Cg=["contains","anchored-at"];function Ng(t){return Cg.includes(t)}function Ar(t,e){let n=new Map;for(let d of t.nodes)n.set(d.id,d);let r=Lg(t,n),i=du(t),o=new Set,a=d=>{if(!o.has(d)&&(o.add(d),!!e.has(d)))for(let f of r.get(d)??[])a(f)};for(let d of i)a(d);let s=new Map;for(let d of r.keys())s.set(d,Pg(d,r));let l=new Map;for(let d of t.nodes)if(!(!o.has(d.id)||e.has(d.id)))for(let f of s.get(d.id)??[])!o.has(f)&&!l.has(f)&&l.set(f,d.id);for(let d of t.nodes)!o.has(d.id)&&!l.has(d.id)&&o.add(d.id);let u=new Map;for(let[d,f]of r){let g=s.get(d);u.set(d,{children:f,descendants:g,members:g.filter(m=>l.get(m)===d),provenance:Dg(g,n),expanded:e.has(d)})}let c=new Set,h=[];for(let d of t.nodes)o.has(d.id)?h.push(d):c.add(d.id);return{nodes:h,edges:Ig(t.edges,o,l),clusters:u,hidden:c,representative:l,roots:i}}function Lg(t,e){let n=new Map;for(let r of t.edges){if(!Ng(r.kind)||!e.has(r.source)||!e.has(r.target))continue;let i=n.get(r.source);i===void 0?n.set(r.source,[r.target]):i.includes(r.target)||i.push(r.target)}return n}function Pg(t,e){let n=[],r=new Set([t]),i=o=>{for(let a of e.get(o)??[])r.has(a)||(r.add(a),n.push(a),i(a))};return i(t),n}function Dg(t,e){let n={human:0,agent:0,generated:0,none:0};for(let r of t){let i=e.get(r)?.provenance??null;i===null?n.none++:n[i]++}return n}function Ig(t,e,n){let r=a=>e.has(a)?a:n.get(a),i=[],o=new Set;for(let a of t){let s=r(a.source),l=r(a.target);if(s===void 0||l===void 0||s===l)continue;let u=`${s}\0${l}\0${a.kind}`;o.has(u)||(o.add(u),i.push({source:s,target:l,kind:a.kind}))}return i}function mo(t){let e=new Map;for(let n of t){if(n.kind!=="links-to")continue;let r=e.get(n.target);r?r.push(n.source):e.set(n.target,[n.source])}return e}var Bt=[null,"human","agent","generated"];function hu(t=["vault","repository"]){return{expanded:new Set(t),showInternals:!1,provFilter:null,query:""}}function kt(t){return{...t.model,danglingLinks:t.dangling}}function fu(t,e){return t===null?[]:co(kt(t),e)}function wo(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function Mg(t,e){if(t.expanded.has(e))return t;let n=new Set(t.expanded);return n.add(e),{...t,expanded:n}}function Og(t,e){if(!t.expanded.has(e))return t;let n=new Set(t.expanded);return n.delete(e),{...t,expanded:n}}function pu(t,e){return t.query===e?t:{...t,query:e}}function gu(t){let e=Bt.indexOf(t.provFilter),n=Bt[(e+1)%Bt.length]??null;return{...t,provFilter:n}}function mu(t){return{...t,showInternals:!t.showInternals}}function Cr(t,e){return e===null?-1:t.findIndex(n=>n.id===e)}function yo(t,e){return t[e]?.id??null}function vo(t,e,n){if(t.length===0)return null;let r=Cr(t,e),i=r===-1?n>0?-1:t.length:r;return yo(t,Math.min(t.length-1,Math.max(0,i+n)))}function Fg(t,e){let n=Cr(t,e),r=n<=0?void 0:t[n];if(r===void 0)return null;for(let i of t.slice(0,n).reverse())if(i.depth<r.depth)return i.id;return null}var zg={j:"ArrowDown",k:"ArrowUp"};function $g(t){return zg[t]??t}function vu(t,e,n,r,i=!1){let o={state:e,selectedId:n,handled:!1};if(i)return o;let a=h=>({state:e,selectedId:h,handled:!0}),s=$g(r);if(s==="ArrowDown")return a(vo(t,n,1));if(s==="ArrowUp")return a(vo(t,n,-1));if(s==="Home")return a(yo(t,0));if(s==="End")return a(yo(t,t.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return o;let l=Cr(t,n),u=l===-1?void 0:t[l];if(u===void 0||n===null)return o;if(s==="ArrowRight")return u.hasKids?u.expanded?a(vo(t,n,1)):{state:Mg(e,n),selectedId:n,handled:!0}:o;if(u.hasKids&&u.expanded)return{state:Og(e,n),selectedId:n,handled:!0};let c=Fg(t,n);return c===null?o:a(c)}var Ug={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function bo(t){return Ug[t]}var Hg={human:"●",agent:"◐",generated:"○"};function Et(t){return t===null?"":Hg[t]}function Wt(t){return t===null?"":`${t}-authored`}function yu(t){return`weave-row-${t.replace(/[^A-Za-z0-9_-]/g,"-")}`}function Bg(t){let e=t.map(()=>({posinset:1,setsize:1})),n=[],r=i=>{for(let o of n.splice(i+1))for(let[a,s]of o.entries())e[s]={posinset:a+1,setsize:o.length}};for(let[i,o]of t.entries()){r(o.depth);let a=n[o.depth];if(a===void 0){for(a=[];n.length<o.depth;)n.push([]);n.push(a)}a.push(i)}return r(-1),e}function Wg(t,e,n,r={posinset:1,setsize:1}){let i=t.hasKids?t.expanded?"open":"closed":"leaf";return{id:t.id,domId:yu(t.id),posinset:r.posinset,setsize:r.setsize,depth:t.depth,label:t.label,kind:t.kind,kindIcon:bo(t.kind),provenance:t.provenance,provenanceGlyph:Et(t.provenance),provenanceTitle:Wt(t.provenance),twisty:i,hasKids:t.hasKids,expanded:t.expanded,selected:t.id===e,meta:fo(t.meta,n),level:t.depth+1}}function wu(t,e,n){let r=Bg(t);return t.map((i,o)=>Wg(i,e,n,r[o]))}function bu(t,e){return Cr(t,e)===-1?null:yu(e)}function xu(t){return{"--weave-depth":String(Math.max(0,t))}}function Rr(t){return t===null?"all":t}function _u(t){let e=Bt.indexOf(t),n=Bt[(e+1)%Bt.length]??null;return`provenance filter: ${Rr(t)} — click for ${Rr(n)}`}function ku(t){return t?"internals":"knowledge"}function Eu(t){return t?"showing git state, packages, externals and entry points — click to hide":"hiding git state, packages, externals and entry points — click to show"}var Su="filter…",Tu="Vault and repository",Au="Filter the tree",Ru="Filter the tree (/)";function Cu(t,e,n){if(t===null)return"loading…";let r=ho(kt(t));return r!==null?r:e.length>0?null:n.query.length>0||n.provFilter!==null?"nothing matches this filter — clear it to see the whole vault":"nothing to show"}function Nu(t){return t.length===1?"1 row":`${t.length} rows`}var Nr={dark:{accent:"#c6a0f6",success:"#a6da95",warning:"#eed49f",dim:"#a5adcb",text:"#cad3f5",muted:"#939ab7",line:"#494d64",ground:"#24273a"},light:{accent:"#7113ec",success:"#28641b",warning:"#7c4f10",dim:"#56586a",text:"#4c4f69",muted:"#606274",line:"#bcc0cc",ground:"#eff1f5"}},Kg={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},Vg={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function jg(t,e){return Nr[e][Kg[t]]}function Lu(t,e){return Nr[e][Vg[t]]}function qg(t,e){return Yg(t)?xo(Lu(t,e),e,Zg):Lu(t,e)}function Yg(t){return t==="contains"||t==="anchored-at"}var Xg=.85,Zg=.3;function Qg(t,e,n){let r=l=>/^#[0-9a-f]{6}$/.test(l)?[Number.parseInt(l.slice(1,3),16),Number.parseInt(l.slice(3,5),16),Number.parseInt(l.slice(5,7),16)]:null,i=r(t),o=r(e);if(i===null||o===null)return t;let a=Math.min(1,Math.max(0,Number.isFinite(n)?n:0)),s=(l,u)=>Math.round(l+(u-l)*a).toString(16).padStart(2,"0");return`#${s(i[0],o[0])}${s(i[1],o[1])}${s(i[2],o[2])}`}function xo(t,e,n=Xg){return Qg(t,Nr[e].ground,n)}var Jg={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},em=1.6,Pu=32,tm=Pu/2;function nm(t,e=Pu){if(e<=0)return t.length>0?"…":t;if(t.length<=e)return t;let n=e-1,i=t.slice(0,n).lastIndexOf(" "),o=i>=tm?i:n;return`${t.slice(0,o).trimEnd()}…`}function rm(t){let e=Et(t.provenance),n=Te(t);return nm(e===""?n:`${e} ${n}`)}function Du(t){let e=1/0,n=1/0,r=-1/0,i=-1/0,o=0;for(let a of t)!Number.isFinite(a.x)||!Number.isFinite(a.y)||(o++,a.x<e&&(e=a.x),a.x>r&&(r=a.x),a.y<n&&(n=a.y),a.y>i&&(i=a.y));return o===0?null:{x:[e,r],y:[n,i]}}var Iu={nodes:[],edges:[]};function Gu(t){return`${t.source}\0${t.target}\0${t.kind}`}function im(t,e){let n=new Map,r=new Set;for(let i of t){if(i.source===i.target||!e.has(i.source)||!e.has(i.target))continue;let o=Gu(i);r.has(o)||(r.add(o),n.set(i.source,(n.get(i.source)??0)+1),n.set(i.target,(n.get(i.target)??0)+1))}return n}function Mu(t,e,n,r){let i=new Map;for(let c of t){if(i.has(c.id))continue;let h=n.get(c.id);h===void 0||!Number.isFinite(h.x)||!Number.isFinite(h.y)||i.set(c.id,c)}let o=new Set(i.keys()),a=im(e,o),s=[];for(let[c,h]of i){let d=n.get(c),f=so(a.get(c)??0);s.push({id:c,x:d.x,y:d.y,size:f,label:rm(h),color:jg(h.kind,r),kind:h.kind,provenance:h.provenance,zIndex:Math.round(f),type:"circle"})}let l=[],u=new Set;for(let c of e){if(c.source===c.target||!o.has(c.source)||!o.has(c.target))continue;let h=Gu(c);u.has(h)||(u.add(h),l.push({key:h,source:c.source,target:c.target,size:Jg[c.kind],color:qg(c.kind,r),kind:c.kind,zIndex:0,type:"line"}))}return{nodes:s,edges:l}}function Ou(t){return(e,n,r)=>t===null?{}:t.has(e)?{zIndex:n.zIndex+om}:{color:xo(n.color,r),label:null,zIndex:0}}var om=Sr+1;function Fu(t){return(e,n,r)=>t===null?{}:t.has(n.source)&&t.has(n.target)?{zIndex:1,size:n.size*em}:{color:xo(n.color,r)}}var am=(Er+Sr)/2,sm=Tr*4,lm=1;function zu(t){let e=Nr[t];return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:lm,labelGridCellSize:sm,labelRenderedSizeThreshold:am,labelFont:"inherit",labelSize:11,labelColor:{color:e.text},defaultNodeColor:e.dim,defaultEdgeColor:e.line,defaultNodeType:"circle",defaultEdgeType:"line",minEdgeThickness:.6,zIndex:!0,itemSizesReference:"positions",zoomToSizeRatioFunction:n=>n,stagePadding:Tr,allowInvalidContainer:!0}}var Bu=on(ur(),1);function um(){let t=arguments[0];for(let e=1,n=arguments.length;e<n;e++)if(arguments[e])for(let r in arguments[e])t[r]=arguments[e][r];return t}var ce=um;typeof Object.assign=="function"&&(ce=Object.assign);function Pe(t,e,n,r){let i=t._nodes.get(e),o=null;return i&&(r==="mixed"?o=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?o=i.out&&i.out[n]:o=i.undirected&&i.undirected[n]),o}function me(t){return typeof t=="object"&&t!==null}function Wu(t){let e;for(e in t)return!1;return!0}function Le(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Fe(t,e,n){let r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(t,e,r)}function $u(t){return!(!me(t)||t.attributes&&!Array.isArray(t.attributes))}function cm(){let t=Math.floor(Math.random()*256)&255;return()=>t++}function et(){let t=arguments,e=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(e===null){if(n++,n>=t.length)return{done:!0};e=t[n][Symbol.iterator]()}if(r=e.next(),r.done){e=null;continue}break}while(!0);return r}}}function Vt(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var xn=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},N=class t extends xn{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},A=class t extends xn{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},M=class t extends xn{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}};function Ku(t,e){this.key=t,this.attributes=e,this.clear()}Ku.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 Vu(t,e){this.key=t,this.attributes=e,this.clear()}Vu.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function ju(t,e){this.key=t,this.attributes=e,this.clear()}ju.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function jt(t,e,n,r,i){this.key=e,this.attributes=i,this.undirected=t,this.source=n,this.target=r}jt.prototype.attach=function(){let t="out",e="in";this.undirected&&(t=e="undirected");let n=this.source.key,r=this.target.key;this.source[t][r]=this,!(this.undirected&&n===r)&&(this.target[e][n]=this)};jt.prototype.attachMulti=function(){let t="out",e="in",n=this.source.key,r=this.target.key;this.undirected&&(t=e="undirected");let i=this.source[t],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[e][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[e][n]=this};jt.prototype.detach=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][e],delete this.target[r][t]};jt.prototype.detachMulti=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][e],delete this.target[r][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[r][t]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var qu=0,Yu=1,dm=2,Xu=3;function tt(t,e,n,r,i,o,a){let s,l,u,c;if(r=""+r,n===qu){if(s=t._nodes.get(r),!s)throw new A(`Graph.${e}: could not find the "${r}" node in the graph.`);u=i,c=o}else if(n===Xu){if(i=""+i,l=t._edges.get(i),!l)throw new A(`Graph.${e}: could not find the "${i}" edge in the graph.`);let h=l.source.key,d=l.target.key;if(r===h)s=l.target;else if(r===d)s=l.source;else throw new A(`Graph.${e}: the "${r}" node is not attached to the "${i}" edge (${h}, ${d}).`);u=o,c=a}else{if(l=t._edges.get(r),!l)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`);n===Yu?s=l.source:s=l.target,u=i,c=o}return[s,u,c]}function hm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=tt(this,e,n,r,i,o);return a.attributes[s]}}function fm(t,e,n){t.prototype[e]=function(r,i){let[o]=tt(this,e,n,r,i);return o.attributes}}function pm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=tt(this,e,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function gm(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=tt(this,e,n,r,i,o,a);return s.attributes[l]=u,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function mm(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=tt(this,e,n,r,i,o,a);if(typeof u!="function")throw new N(`Graph.${e}: updater should be a function.`);let c=s.attributes,h=u(c[l]);return c[l]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function vm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=tt(this,e,n,r,i,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function ym(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=tt(this,e,n,r,i,o);if(!me(s))throw new N(`Graph.${e}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function wm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=tt(this,e,n,r,i,o);if(!me(s))throw new N(`Graph.${e}: provided attributes are not a plain object.`);return ce(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function bm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=tt(this,e,n,r,i,o);if(typeof s!="function")throw new N(`Graph.${e}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}var xm=[{name:t=>`get${t}Attribute`,attacher:hm},{name:t=>`get${t}Attributes`,attacher:fm},{name:t=>`has${t}Attribute`,attacher:pm},{name:t=>`set${t}Attribute`,attacher:gm},{name:t=>`update${t}Attribute`,attacher:mm},{name:t=>`remove${t}Attribute`,attacher:vm},{name:t=>`replace${t}Attributes`,attacher:ym},{name:t=>`merge${t}Attributes`,attacher:wm},{name:t=>`update${t}Attributes`,attacher:bm}];function _m(t){xm.forEach(function({name:e,attacher:n}){n(t,e("Node"),qu),n(t,e("Source"),Yu),n(t,e("Target"),dm),n(t,e("Opposite"),Xu)})}function km(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: 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=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function Em(t,e,n){t.prototype[e]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new M(`Graph.${e}: 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=""+r,a=""+arguments[1];if(i=Pe(this,o,a,n),!i)throw new A(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,i=this._edges.get(r),!i)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function Sm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: 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=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function Tm(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: 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=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=Pe(this,s,l,n),!a)throw new A(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,a=this._edges.get(r),!a)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return a.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function Am(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: 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=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=Pe(this,s,l,n),!a)throw new A(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,a=this._edges.get(r),!a)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new N(`Graph.${e}: updater should be a function.`);return a.attributes[i]=o(a.attributes[i]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function Rm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: 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=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function Cm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: 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=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!me(i))throw new N(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Nm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: 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=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!me(i))throw new N(`Graph.${e}: provided attributes are not a plain object.`);return ce(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function Lm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: 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=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new N(`Graph.${e}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var Pm=[{name:t=>`get${t}Attribute`,attacher:km},{name:t=>`get${t}Attributes`,attacher:Em},{name:t=>`has${t}Attribute`,attacher:Sm},{name:t=>`set${t}Attribute`,attacher:Tm},{name:t=>`update${t}Attribute`,attacher:Am},{name:t=>`remove${t}Attribute`,attacher:Rm},{name:t=>`replace${t}Attributes`,attacher:Cm},{name:t=>`merge${t}Attributes`,attacher:Nm},{name:t=>`update${t}Attributes`,attacher:Lm}];function Dm(t){Pm.forEach(function({name:e,attacher:n}){n(t,e("Edge"),"mixed"),n(t,e("DirectedEdge"),"directed"),n(t,e("UndirectedEdge"),"undirected")})}var Im=[{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 Gm(t,e,n,r){let i=!1;for(let o in e){if(o===r)continue;let a=e[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),t&&i)return a.key}}function Mm(t,e,n,r){let i,o,a,s=!1;for(let l in e)if(l!==r){i=e[l];do{if(o=i.source,a=i.target,s=n(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected),t&&s)return i.key;i=i.next}while(i!==void 0)}}function _o(t,e){let n=Object.keys(t),r=n.length,i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=r)return{done:!0};let a=n[o++];if(a===e){i=void 0;continue}i=t[a]}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 Om(t,e,n,r){let i=e[n];if(!i)return;let o=i.source,a=i.target;if(r(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected)&&t)return i.key}function Fm(t,e,n,r){let i=e[n];if(!i)return;let o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),t&&o)return i.key;i=i.next}while(i!==void 0)}function ko(t,e){let n=t[e];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let i={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:i}}};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 zm(t,e){if(t.size===0)return[];if(e==="mixed"||e===t.type)return Array.from(t._edges.keys());let n=e==="undirected"?t.undirectedSize:t.directedSize,r=new Array(n),i=e==="undirected",o=t._edges.values(),a=0,s,l;for(;s=o.next(),s.done!==!0;)l=s.value,l.undirected===i&&(r[a++]=l.key);return r}function Zu(t,e,n,r){if(e.size===0)return;let i=n!=="mixed"&&n!==e.type,o=n==="undirected",a,s,l=!1,u=e._edges.values();for(;a=u.next(),a.done!==!0;){if(s=a.value,i&&s.undirected!==o)continue;let{key:c,attributes:h,source:d,target:f}=s;if(l=r(c,h,d.key,f.key,d.attributes,f.attributes,s.undirected),t&&l)return c}}function $m(t,e){if(t.size===0)return Vt();let n=e!=="mixed"&&e!==t.type,r=e==="undirected",i=t._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(n&&a.undirected!==r))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function Eo(t,e,n,r,i,o){let a=e?Mm:Gm,s;if(n!=="undirected"&&(r!=="out"&&(s=a(t,i.in,o),t&&s)||r!=="in"&&(s=a(t,i.out,o,r?void 0:i.key),t&&s))||n!=="directed"&&(s=a(t,i.undirected,o),t&&s))return s}function Um(t,e,n,r){let i=[];return Eo(!1,t,e,n,r,function(o){i.push(o)}),i}function Hm(t,e,n){let r=Vt();return t!=="undirected"&&(e!=="out"&&typeof n.in<"u"&&(r=et(r,_o(n.in))),e!=="in"&&typeof n.out<"u"&&(r=et(r,_o(n.out,e?void 0:n.key)))),t!=="directed"&&typeof n.undirected<"u"&&(r=et(r,_o(n.undirected))),r}function So(t,e,n,r,i,o,a){let s=n?Fm:Om,l;if(e!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(l=s(t,i.in,o,a),t&&l)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(l=s(t,i.out,o,a),t&&l))||e!=="directed"&&typeof i.undirected<"u"&&(l=s(t,i.undirected,o,a),t&&l))return l}function Bm(t,e,n,r,i){let o=[];return So(!1,t,e,n,r,i,function(a){o.push(a)}),o}function Wm(t,e,n,r){let i=Vt();return t!=="undirected"&&(typeof n.in<"u"&&e!=="out"&&r in n.in&&(i=et(i,ko(n.in,r))),typeof n.out<"u"&&e!=="in"&&r in n.out&&(e||n.key!==r)&&(i=et(i,ko(n.out,r)))),t!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=et(i,ko(n.undirected,r))),i}function Km(t,e){let{name:n,type:r,direction:i}=e;t.prototype[n]=function(o,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return zm(this,r);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new A(`Graph.${n}: could not find the "${o}" node in the graph.`);return Um(this.multi,r==="mixed"?this.type:r,i,s)}if(arguments.length===2){o=""+o,a=""+a;let s=this._nodes.get(o);if(!s)throw new A(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new A(`Graph.${n}: could not find the "${a}" target node in the graph.`);return Bm(r,this.multi,i,s,a)}throw new N(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Vm(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,c,h){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return h=u,Zu(!1,this,r,h);if(arguments.length===2){u=""+u,h=c;let d=this._nodes.get(u);if(typeof d>"u")throw new A(`Graph.${o}: could not find the "${u}" node in the graph.`);return Eo(!1,this.multi,r==="mixed"?this.type:r,i,d,h)}if(arguments.length===3){u=""+u,c=""+c;let d=this._nodes.get(u);if(!d)throw new A(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new A(`Graph.${o}: could not find the "${c}" target node in the graph.`);return So(!1,r,this.multi,i,d,c,h)}throw new N(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h;if(u.length===0){let d=0;r!=="directed"&&(d+=this.undirectedSize),r!=="undirected"&&(d+=this.directedSize),h=new Array(d);let f=0;u.push((g,m,v,y,w,k,_)=>{h[f++]=c(g,m,v,y,w,k,_)})}else h=[],u.push((d,f,g,m,v,y,w)=>{h.push(c(d,f,g,m,v,y,w))});return this[o].apply(this,u),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h=[];return u.push((d,f,g,m,v,y,w)=>{c(d,f,g,m,v,y,w)&&h.push(d)}),this[o].apply(this,u),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(){let u=Array.prototype.slice.call(arguments);if(u.length<2||u.length>4)throw new N(`Graph.${l}: invalid number of arguments (expecting 2, 3 or 4 and got ${u.length}).`);if(typeof u[u.length-1]=="function"&&typeof u[u.length-2]!="function")throw new N(`Graph.${l}: 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 c,h;u.length===2?(c=u[0],h=u[1],u=[]):u.length===3?(c=u[1],h=u[2],u=[u[0]]):u.length===4&&(c=u[2],h=u[3],u=[u[0],u[1]]);let d=h;return u.push((f,g,m,v,y,w,k)=>{d=c(d,f,g,m,v,y,w,k)}),this[o].apply(this,u),d}}function jm(t,e){let{name:n,type:r,direction:i}=e,o="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(l,u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return c=l,Zu(!0,this,r,c);if(arguments.length===2){l=""+l,c=u;let h=this._nodes.get(l);if(typeof h>"u")throw new A(`Graph.${o}: could not find the "${l}" node in the graph.`);return Eo(!0,this.multi,r==="mixed"?this.type:r,i,h,c)}if(arguments.length===3){l=""+l,u=""+u;let h=this._nodes.get(l);if(!h)throw new A(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(u))throw new A(`Graph.${o}: could not find the "${u}" target node in the graph.`);return So(!0,r,this.multi,i,h,u,c)}throw new N(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let a="some"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[a]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,f,g,m,v,y)=>u(h,d,f,g,m,v,y)),!!this[o].apply(this,l)};let s="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,f,g,m,v,y)=>!u(h,d,f,g,m,v,y)),!this[o].apply(this,l)}}function qm(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Vt();if(!arguments.length)return $m(this,r);if(arguments.length===1){a=""+a;let l=this._nodes.get(a);if(!l)throw new A(`Graph.${o}: could not find the "${a}" node in the graph.`);return Hm(r,i,l)}if(arguments.length===2){a=""+a,s=""+s;let l=this._nodes.get(a);if(!l)throw new A(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new A(`Graph.${o}: could not find the "${s}" target node in the graph.`);return Wm(r,i,l,s)}throw new N(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Ym(t){Im.forEach(e=>{Km(t,e),Vm(t,e),jm(t,e),qm(t,e)})}var Xm=[{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 Or(){this.A=null,this.B=null}Or.prototype.wrap=function(t){this.A===null?this.A=t:this.B===null&&(this.B=t)};Or.prototype.has=function(t){return this.A!==null&&t in this.A||this.B!==null&&t in this.B};function wn(t,e,n,r,i){for(let o in r){let a=r[o],s=a.source,l=a.target,u=s===n?l:s;if(e&&e.has(u.key))continue;let c=i(u.key,u.attributes);if(t&&c)return u.key}}function To(t,e,n,r,i){if(e!=="mixed"){if(e==="undirected")return wn(t,null,r,r.undirected,i);if(typeof n=="string")return wn(t,null,r,r[n],i)}let o=new Or,a;if(e!=="undirected"){if(n!=="out"){if(a=wn(t,null,r,r.in,i),t&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=wn(t,o,r,r.out,i),t&&a)return a;o.wrap(r.out)}}if(e!=="directed"&&(a=wn(t,o,r,r.undirected,i),t&&a))return a}function Zm(t,e,n){if(t!=="mixed"){if(t==="undirected")return Object.keys(n.undirected);if(typeof e=="string")return Object.keys(n[e])}let r=[];return To(!1,t,e,n,function(i){r.push(i)}),r}function bn(t,e,n){let r=Object.keys(n),i=r.length,o=0;return{[Symbol.iterator](){return this},next(){let a=null;do{if(o>=i)return t&&t.wrap(n),{done:!0};let s=n[r[o++]],l=s.source,u=s.target;if(a=l===e?u:l,t&&t.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function Qm(t,e,n){if(t!=="mixed"){if(t==="undirected")return bn(null,n,n.undirected);if(typeof e=="string")return bn(null,n,n[e])}let r=Vt(),i=new Or;return t!=="undirected"&&(e!=="out"&&(r=et(r,bn(i,n,n.in))),e!=="in"&&(r=et(r,bn(i,n,n.out)))),t!=="directed"&&(r=et(r,bn(i,n,n.undirected))),r}function Jm(t,e){let{name:n,type:r,direction:i}=e;t.prototype[n]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];o=""+o;let a=this._nodes.get(o);if(typeof a>"u")throw new A(`Graph.${n}: could not find the "${o}" node in the graph.`);return Zm(r==="mixed"?this.type:r,i,a)}}function ev(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let h=this._nodes.get(u);if(typeof h>"u")throw new A(`Graph.${o}: could not find the "${u}" node in the graph.`);To(!1,r==="mixed"?this.type:r,i,h,c)};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(u,c){let h=[];return this[o](u,(d,f)=>{h.push(c(d,f))}),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(u,c){let h=[];return this[o](u,(d,f)=>{c(d,f)&&h.push(d)}),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(u,c,h){if(arguments.length<3)throw new N(`Graph.${l}: 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 d=h;return this[o](u,(f,g)=>{d=c(d,f,g)}),d}}function tv(t,e){let{name:n,type:r,direction:i}=e,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;t.prototype[a]=function(u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let h=this._nodes.get(u);if(typeof h>"u")throw new A(`Graph.${a}: could not find the "${u}" node in the graph.`);return To(!0,r==="mixed"?this.type:r,i,h,c)};let s="some"+o;t.prototype[s]=function(u,c){return!!this[a](u,c)};let l="every"+o;t.prototype[l]=function(u,c){return!this[a](u,(d,f)=>!c(d,f))}}function nv(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Vt();a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new A(`Graph.${o}: could not find the "${a}" node in the graph.`);return Qm(r==="mixed"?this.type:r,i,s)}}function rv(t){Xm.forEach(e=>{Jm(t,e),ev(t,e),tv(t,e),nv(t,e)})}function Lr(t,e,n,r,i){let o=r._nodes.values(),a=r.type,s,l,u,c,h,d,f;for(;s=o.next(),s.done!==!0;){let g=!1;if(l=s.value,a!=="undirected"){c=l.out;for(u in c){h=c[u];do{if(d=h.target,g=!0,f=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(a!=="directed"){c=l.undirected;for(u in c)if(!(e&&l.key>u)){h=c[u];do{if(d=h.target,d.key!==u&&(d=h.source),g=!0,f=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(n&&!g&&(f=i(l.key,null,l.attributes,null,null,null,null),t&&f))return null}}function iv(t,e){let n={key:t};return Wu(e.attributes)||(n.attributes=ce({},e.attributes)),n}function ov(t,e,n){let r={key:e,source:n.source.key,target:n.target.key};return Wu(n.attributes)||(r.attributes=ce({},n.attributes)),t==="mixed"&&n.undirected&&(r.undirected=!0),r}function av(t){if(!me(t))throw new N('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new N("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!me(t.attributes)||t.attributes===null))throw new N("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function sv(t){if(!me(t))throw new N('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new N("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new N("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!me(t.attributes)||t.attributes===null))throw new N("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&typeof t.undirected!="boolean")throw new N("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var lv=cm(),uv=new Set(["directed","undirected","mixed"]),Uu=new Set(["domain","_events","_eventsCount","_maxListeners"]),cv=[{name:t=>`${t}Edge`,generateKey:!0},{name:t=>`${t}DirectedEdge`,generateKey:!0,type:"directed"},{name:t=>`${t}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:t=>`${t}EdgeWithKey`},{name:t=>`${t}DirectedEdgeWithKey`,type:"directed"},{name:t=>`${t}UndirectedEdgeWithKey`,type:"undirected"}],dv={allowSelfLoops:!0,multi:!1,type:"mixed"};function hv(t,e,n){if(n&&!me(n))throw new N(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(e=""+e,n=n||{},t._nodes.has(e))throw new M(`Graph.addNode: the "${e}" node already exist in the graph.`);let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function Hu(t,e,n){let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function Qu(t,e,n,r,i,o,a,s){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!me(s))throw new N(`Graph.${e}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!t.allowSelfLoops&&o===a)throw new M(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=t._nodes.get(o),u=t._nodes.get(a);if(!l)throw new A(`Graph.${e}: source node "${o}" not found.`);if(!u)throw new A(`Graph.${e}: target node "${a}" not found.`);let c={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!t.multi&&(r?typeof l.undirected[a]<"u":typeof l.out[a]<"u"))throw new M(`Graph.${e}: an edge linking "${o}" to "${a}" 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 h=new jt(r,i,l,u,s);t._edges.set(i,h);let d=o===a;return r?(l.undirectedDegree++,u.undirectedDegree++,d&&(l.undirectedLoops++,t._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,d&&(l.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),r?t._undirectedSize++:t._directedSize++,c.key=i,t.emit("edgeAdded",c),i}function fv(t,e,n,r,i,o,a,s,l){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(l){if(typeof s!="function")throw new N(`Graph.${e}: invalid updater function. Expecting a function but got "${s}"`)}else if(!me(s))throw new N(`Graph.${e}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let u;if(l&&(u=s,s=void 0),!t.allowSelfLoops&&o===a)throw new M(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=t._nodes.get(o),h=t._nodes.get(a),d,f;if(!n&&(d=t._edges.get(i),d)){if((d.source.key!==o||d.target.key!==a)&&(!r||d.source.key!==a||d.target.key!==o))throw new M(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${a}" target vs. ("${d.source.key}", "${d.target.key}").`);f=d}if(!f&&!t.multi&&c&&(f=r?c.undirected[a]:c.out[a]),f){let w=[f.key,!1,!1,!1];if(l?!u:!s)return w;if(l){let k=f.attributes;f.attributes=u(k),t.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else ce(f.attributes,s),t.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return w}s=s||{},l&&u&&(s=u(s));let g={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);let m=!1,v=!1;c||(c=Hu(t,o,{}),m=!0,o===a&&(h=c,v=!0)),h||(h=Hu(t,a,{}),v=!0),d=new jt(r,i,c,h,s),t._edges.set(i,d);let y=o===a;return r?(c.undirectedDegree++,h.undirectedDegree++,y&&(c.undirectedLoops++,t._undirectedSelfLoopCount++)):(c.outDegree++,h.inDegree++,y&&(c.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,g.key=i,t.emit("edgeAdded",g),[i,!0,m,v]}function Kt(t,e){t._edges.delete(e.key);let{source:n,target:r,attributes:i}=e,o=e.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),o?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:i,source:n.key,target:r.key,undirected:o})}var K=class t extends Bu.EventEmitter{constructor(e){if(super(),e=ce({},dv,e),typeof e.multi!="boolean")throw new N(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!uv.has(e.type))throw new N(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new N(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let n=e.type==="mixed"?Ku:e.type==="directed"?Vu:ju;Le(this,"NodeDataClass",n);let r="geid_"+lv()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};Le(this,"_attributes",{}),Le(this,"_nodes",new Map),Le(this,"_edges",new Map),Le(this,"_directedSize",0),Le(this,"_undirectedSize",0),Le(this,"_directedSelfLoopCount",0),Le(this,"_undirectedSelfLoopCount",0),Le(this,"_edgeKeyGenerator",o),Le(this,"_options",e),Uu.forEach(a=>Le(this,a,this[a])),Fe(this,"order",()=>this._nodes.size),Fe(this,"size",()=>this._edges.size),Fe(this,"directedSize",()=>this._directedSize),Fe(this,"undirectedSize",()=>this._undirectedSize),Fe(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Fe(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Fe(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Fe(this,"multi",this._options.multi),Fe(this,"type",this._options.type),Fe(this,"allowSelfLoops",this._options.allowSelfLoops),Fe(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,n){if(this.type==="undirected")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.out.hasOwnProperty(n):!1}throw new N(`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,n){if(this.type==="directed")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.undirected.hasOwnProperty(n):!1}throw new N(`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,n){if(arguments.length===1){let r=""+e;return this._edges.has(r)}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new N(`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,n){if(this.type==="undirected")return;if(e=""+e,n=""+n,this.multi)throw new M("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");let r=this._nodes.get(e);if(!r)throw new A(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new A(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);let i=r.out&&r.out[n]||void 0;if(i)return i.key}undirectedEdge(e,n){if(this.type==="directed")return;if(e=""+e,n=""+n,this.multi)throw new M("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");let r=this._nodes.get(e);if(!r)throw new A(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new A(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);let i=r.undirected&&r.undirected[n]||void 0;if(i)return i.key}edge(e,n){if(this.multi)throw new M("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new A(`Graph.edge: could not find the "${n}" target node in the graph.`);let i=r.out&&r.out[n]||r.undirected&&r.undirected[n]||void 0;if(i)return i.key}areDirectedNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.degree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree,i+=n.directedLoops),r-i}outboundDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.outDegree,i+=n.directedLoops),r-i}degreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree,i+=n.directedLoops*2),r-i}source(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.source: could not find the "${e}" edge in the graph.`);return n.source.key}target(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.target: could not find the "${e}" edge in the graph.`);return n.target.key}extremities(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(e,n){e=""+e,n=""+n;let r=this._edges.get(n);if(!r)throw new A(`Graph.opposite: could not find the "${n}" edge in the graph.`);let i=r.source.key,o=r.target.key;if(e===i)return o;if(e===o)return i;throw new A(`Graph.opposite: the "${e}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(e,n){e=""+e,n=""+n;let r=this._edges.get(e);if(!r)throw new A(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return n.undirected}isDirected(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!n.undirected}isSelfLoop(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return n.source===n.target}addNode(e,n){return hv(this,e,n).key}mergeNode(e,n){if(n&&!me(n))throw new N(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);e=""+e,n=n||{};let r=this._nodes.get(e);return r?(n&&(ce(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:r.attributes,data:n})),[e,!1]):(r=new this.NodeDataClass(e,n),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:n}),[e,!0])}updateNode(e,n){if(n&&typeof n!="function")throw new N(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);e=""+e;let r=this._nodes.get(e);if(r){if(n){let o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:r.attributes})}return[e,!1]}let i=n?n({}):{};return r=new this.NodeDataClass(e,i),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.dropNode: could not find the "${e}" node in the graph.`);let r;if(this.type!=="undirected"){for(let i in n.out){r=n.out[i];do Kt(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do Kt(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do Kt(this,r),r=r.next;while(r)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:n.attributes})}dropEdge(e){let n;if(arguments.length>1){let r=""+arguments[0],i=""+arguments[1];if(n=Pe(this,r,i,this.type),!n)throw new A(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(e=""+e,n=this._edges.get(e),!n)throw new A(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return Kt(this,n),this}dropDirectedEdge(e,n){if(arguments.length<2)throw new M("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 M("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,n=""+n;let r=Pe(this,e,n,"directed");if(!r)throw new A(`Graph.dropDirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return Kt(this,r),this}dropUndirectedEdge(e,n){if(arguments.length<2)throw new M("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 M("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 r=Pe(this,e,n,"undirected");if(!r)throw new A(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return Kt(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),n;for(;n=e.next(),n.done!==!0;)n.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,n){return this._attributes[e]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,n){if(typeof n!="function")throw new N("Graph.updateAttribute: updater should be a function.");let r=this._attributes[e];return this._attributes[e]=n(r),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(!me(e))throw new N("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(!me(e))throw new N("Graph.mergeAttributes: provided attributes are not a plain object.");return ce(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new N("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,n){if(typeof e!="function")throw new N("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!$u(n))throw new N("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._nodes.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(e,n){if(typeof e!="function")throw new N("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!$u(n))throw new N("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._edges.values(),i,o,a,s;for(;i=r.next(),i.done!==!0;)o=i.value,a=o.source,s=o.target,o.attributes=e(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new N("Graph.forEachAdjacencyEntry: expecting a callback.");Lr(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new N("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Lr(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new N("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Lr(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new N("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Lr(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new N("Graph.forEachNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new N("Graph.findNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new N("Graph.mapNode: expecting a callback.");let n=this._nodes.values(),r,i,o=new Array(this.order),a=0;for(;r=n.next(),r.done!==!0;)i=r.value,o[a++]=e(i.key,i.attributes);return o}someNode(e){if(typeof e!="function")throw new N("Graph.someNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new N("Graph.everyNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new N("Graph.filterNodes: expecting a callback.");let n=this._nodes.values(),r,i,o=[];for(;r=n.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(e,n){if(typeof e!="function")throw new N("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new N("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 r=n,i=this._nodes.values(),o,a;for(;o=i.next(),o.done!==!0;)a=o.value,r=e(r,a.key,a.attributes);return r}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let n=e.next();if(n.done)return n;let r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){let e=new Array(this._nodes.size),n=0;this._nodes.forEach((i,o)=>{e[n++]=iv(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=ov(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:r}}import(e,n=!1){if(e instanceof t)return e.forEachNode((l,u)=>{n?this.mergeNode(l,u):this.addNode(l,u)}),e.forEachEdge((l,u,c,h,d,f,g)=>{n?g?this.mergeUndirectedEdgeWithKey(l,c,h,u):this.mergeDirectedEdgeWithKey(l,c,h,u):g?this.addUndirectedEdgeWithKey(l,c,h,u):this.addDirectedEdgeWithKey(l,c,h,u)}),this;if(!me(e))throw new N("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!me(e.attributes))throw new N("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let r,i,o,a,s;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new N("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],av(a);let{key:l,attributes:u}=a;n?this.mergeNode(l,u):this.addNode(l,u)}}if(e.edges){let l=!1;if(this.type==="undirected"&&(l=!0),o=e.edges,!Array.isArray(o))throw new N("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],sv(s);let{source:u,target:c,attributes:h,undirected:d=l}=s,f;"key"in s?(f=n?d?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:d?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,u,c,h)):(f=n?d?this.mergeUndirectedEdge:this.mergeDirectedEdge:d?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,u,c,h))}}return this}nullCopy(e){let n=new t(ce({},this._options,e));return n.replaceAttributes(ce({},this.getAttributes())),n}emptyCopy(e){let n=this.nullCopy(e);return this._nodes.forEach((r,i)=>{let o=ce({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new M(`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 M("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 M("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 n=this.emptyCopy(e),r=this._edges.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,Qu(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,ce({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let e={};this._nodes.forEach((o,a)=>{e[a]=o.attributes});let n={},r={};this._edges.forEach((o,a)=>{let s=o.undirected?"--":"->",l="",u=o.source.key,c=o.target.key,h;o.undirected&&u>c&&(h=u,u=c,c=h);let d=`(${u})${s}(${c})`;a.startsWith("geid_")?this.multi&&(typeof r[d]>"u"?r[d]=0:r[d]++,l+=`${r[d]}. `):l+=`[${a}]: `,l+=d,n[l]=o.attributes});let i={};for(let o in this)this.hasOwnProperty(o)&&!Uu.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=e,i.edges=n,Le(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(K.prototype[Symbol.for("nodejs.util.inspect.custom")]=K.prototype.inspect);cv.forEach(t=>{["add","merge","update"].forEach(e=>{let n=t.name(e),r=e==="add"?Qu:fv;t.generateKey?K.prototype[n]=function(i,o,a){return r(this,n,!0,(t.type||this.type)==="undirected",null,i,o,a,e==="update")}:K.prototype[n]=function(i,o,a,s){return r(this,n,!1,(t.type||this.type)==="undirected",i,o,a,s,e==="update")}})});_m(K);Dm(K);Ym(K);rv(K);var Pr=class extends K{constructor(e){let n=ce({type:"directed"},e);if("multi"in n&&n.multi!==!1)throw new N("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new N('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Dr=class extends K{constructor(e){let n=ce({type:"undirected"},e);if("multi"in n&&n.multi!==!1)throw new N("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new N('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Ir=class extends K{constructor(e){let n=ce({multi:!0},e);if("multi"in n&&n.multi!==!0)throw new N("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},Gr=class extends K{constructor(e){let n=ce({type:"directed",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new N("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new N('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Mr=class extends K{constructor(e){let n=ce({type:"undirected",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new N("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new N('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function qt(t){t.from=function(e,n){let r=ce({},e.options,n),i=new t(r);return i.import(e),i}}qt(K);qt(Pr);qt(Dr);qt(Ir);qt(Gr);qt(Mr);K.Graph=K;K.DirectedGraph=Pr;K.UndirectedGraph=Dr;K.MultiGraph=Ir;K.MultiDirectedGraph=Gr;K.MultiUndirectedGraph=Mr;K.InvalidArgumentsGraphError=N;K.NotFoundGraphError=A;K.UsageGraphError=M;function pv(){return new K({multi:!0,type:"directed"})}function Ao(t){let e=pv();for(let n of t.nodes){let{id:r,...i}=n;e.addNode(r,i)}for(let n of t.edges){let{key:r,source:i,target:o,...a}=n;e.addDirectedEdgeWithKey(r,i,o,{source:i,target:o,...a})}return e}function Ju(t,e){let n=0;for(let[r,i]of e)t.hasNode(r)&&(!Number.isFinite(i.x)||!Number.isFinite(i.y)||(t.mergeNodeAttributes(r,{x:i.x,y:i.y}),n++));return n}function Ro(t){let e=new Map;return t.forEachNode((n,r)=>{e.set(n,{x:r.x,y:r.y})}),e}function ec(t,e){let n=null,r=Ao({nodes:[],edges:[]}),i=null,o=()=>{},a=()=>{},s=()=>{},l=()=>{},u=null,c=f=>{if(u===null)return;let g=u;u=null,n?.setSetting("enableCameraPanning",!0),(f===null||f===g)&&l(g)},h=()=>Du([...Ro(r).values()]),d=f=>{let g=Ou(i),m=Fu(i);f.setSetting("nodeReducer",(v,y)=>({...y,...g(v,y,e)})),f.setSetting("edgeReducer",(v,y)=>({...y,...m(v,y,e)}))};return{mount(f){if(n!==null)return;let g=t(r,f,zu(e));g.on("clickNode",({node:m})=>o(m)),g.on("clickStage",()=>o(null)),g.on("downNode",({node:m})=>{u=m,n?.setSetting("enableCameraPanning",!1),a(m)}),g.on("moveBody",m=>{u!==null&&(m.preventSigmaDefault(),s(u,g.viewportToGraph({x:m.event.x,y:m.event.y})))}),g.on("upNode",()=>c(u)),g.on("upStage",()=>c(null)),d(g),g.setCustomBBox(h()),n=g},setGraph(f){r=Ao(f),n?.setGraph(r),n?.setCustomBBox(h())},setPositions(f){Ju(r,f),n?.refresh()},setHighlight(f){i=f,n!==null&&d(n)},onSelect(f){o=f},onDragStart(f){a=f},onDragMove(f){s=f},onDragEnd(f){l=f},fit(){n?.setCustomBBox(h()),n?.getCamera().animatedReset()},positions(){return Ro(r)},destroy(){n?.kill(),n=null}}}var tc=t=>ec((e,n,r)=>new Rl(e,n,r),t);var nc=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function rc(t,e,n){return t===0?null:t===1?0:e<0?n?t-1:0:n?e===0?t-1:e-1:e===t-1?0:e+1}function ic(t,e,n,r){return t==="Tab"&&!e&&!n&&!r}function oc(t){return t===null?!1:(t.focus(),!0)}function Fr(){let t=ee(null);return ie(()=>{let e=document.activeElement;return t.current?.focus(),()=>{oc(e instanceof HTMLElement?e:null)}},[]),{ref:t,onKeyDown(e){if(!ic(e.key,e.ctrlKey,e.metaKey,e.altKey))return!1;let n=[...t.current?.querySelectorAll(nc)??[]],r=rc(n.length,n.indexOf(document.activeElement),e.shiftKey);return r===null?!1:(e.preventDefault(),n[r]?.focus(),!0)}}}function lc(t,e){let n=e.trim().toLowerCase();if(!n)return 0;let r=t.toLowerCase(),i=r.indexOf(n);return i<0?0:r===n?100:i===0?70:/[a-z0-9]/.test(r.charAt(i-1))?30:50}function gv(t){return Math.min(Math.max(t,0),10)*2}function mv(t){return`note:${t}`}function vv(t,e){return lc(t.summary.title,e)+gv(t.score)}function yv(t,e){return lc(t.label,e)}var wv=["path","manifest","url","slug"];function bv(t){for(let e of wv){let n=t.detail[e];if(typeof n=="string"&&n)return n}return""}function xv(t,e){return t.score!==e.score?e.score-t.score:t.kind!==e.kind?t.kind==="note"?-1:1:t.label.localeCompare(e.label)||t.id.localeCompare(e.id)}function _v(t,e,n,r){let i=new Map;for(let o of t){let a=mv(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:vv(o,e)})}for(let o of n){if(i.has(o.id))continue;let a=yv(o,r);a&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:bv(o),badge:o.kind,score:a})}return[...i.values()].sort(xv).slice(0,20)}function uc(){return{query:"",answered:"",hits:[],cursor:0,loading:!1,failed:!1}}function Co(t,e){return e<=0?0:Math.min(Math.max(t,0),e-1)}function ac(t,e,n){return n<=0?0:((t+e)%n+n)%n}function cc(t,e){return e===null?null:t[e]?.id??null}function dc(t,e,n){let r={cursor:t,activate:null,dismiss:!1,handled:!1},i=Co(t,n);return e==="ArrowDown"?{...r,cursor:ac(i,1,n),handled:!0}:e==="ArrowUp"?{...r,cursor:ac(i,-1,n),handled:!0}:e==="Home"?{...r,cursor:0,handled:!0}:e==="End"?{...r,cursor:Co(n-1,n),handled:!0}:e==="Escape"?{...r,dismiss:!0,handled:!0}:e!=="Enter"||n===0?r:{...r,cursor:i,activate:i,dismiss:!0,handled:!0}}var zr="Search the workspace",hc="Search notes and repository…",fc="↑↓ move · ↵ open · esc close";function kv(t,e){return t.query.trim()?e>0?null:t.failed?"search failed — the workspace server may be gone":t.loading?"searching…":`no matches for “${t.query.trim()}”`:"Type to search notes, modules, files and entry points."}function Ev(t){return t===1?"1 result":`${t} results`}function sc(t){return`weave-search-row-${t}`}function pc(t,e){let n=_v(t.hits,t.answered,e?.model.nodes??[],t.query),r=Co(t.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:sc(a)})),status:kv(t,n.length),count:n.length,countLabel:Ev(n.length),cursor:r,activeDomId:n.length?sc(r):null}}var Sv=0;function x(t,e,n,r,i,o){e||(e={});var a,s,l=e;if("ref"in l)for(s in l={},e)s=="ref"?a=e[s]:l[s]=e[s];var u={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Sv,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(a=t.defaultProps))for(s in a)l[s]===void 0&&(l[s]=a[s]);return B.vnode&&B.vnode(u),u}function Av({row:t,onPick:e,onHover:n}){return x("li",{id:t.domId,role:"option","aria-selected":t.active,class:`weave-hit weave-hit-${t.kind}${t.active?" weave-hit-on":""}`,onMouseMove:n,onClick:e,children:[x("span",{class:"weave-hit-badge",children:t.badge}),x("span",{class:"weave-hit-label",children:t.label}),x("span",{class:"weave-hit-detail",children:t.detail})]})}function gc(t){let[e,n]=oe(uc),r=ee(0),i=ee(null),o=Fr(),a=ee(null);ie(()=>{a.current?.focus()},[]),ie(()=>{let u=e.query.trim(),c=!0;if(!u)return i.current?.abort(),n(d=>({...d,hits:[],answered:"",loading:!1,failed:!1})),()=>{c=!1};let h=window.setTimeout(async()=>{let d=++r.current;i.current?.abort();let f=new AbortController;i.current=f,n(m=>({...m,loading:!0,failed:!1}));let g=await _s(t.ports.fetch,u,f.signal);!c||f.signal.aborted||d!==r.current||n(m=>g.ok?{...m,hits:g.data.hits,answered:u,loading:!1,failed:!1,cursor:0}:{...m,loading:!1,failed:!0})},140);return()=>{c=!1,window.clearTimeout(h),i.current?.abort()}},[e.query,t.ports.fetch]);let s=pc(e,t.graph),l=u=>{let c=cc(s.rows,u);c!==null&&t.onSelect(c),t.onClose()};return x("div",{class:"weave-scrim",onClick:()=>l(null),children:x("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":zr,tabIndex:-1,ref:o.ref,onClick:u=>u.stopPropagation(),onKeyDown:u=>{if(o.onKeyDown(u))return;let c=dc(e.cursor,u.key,s.count);c.handled&&(u.preventDefault(),n(h=>({...h,cursor:c.cursor})),c.dismiss&&l(c.activate))},children:[x("input",{type:"search",class:"weave-palette-input",ref:a,value:e.query,placeholder:hc,"aria-label":zr,"aria-controls":"weave-search-results","aria-activedescendant":s.activeDomId??void 0,onInput:u=>n(c=>({...c,query:u.currentTarget.value,cursor:0}))}),s.status===null?x("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":zr,children:s.rows.map((u,c)=>x(Av,{row:u,onPick:()=>l(c),onHover:()=>n(h=>({...h,cursor:c}))},u.id))}):x("p",{class:"weave-palette-status",role:"status",children:s.status}),x("p",{class:"weave-palette-foot",children:[x("span",{children:s.countLabel}),x("span",{class:"weave-palette-hint",children:fc})]})]})})}var mc="pi-weave.selection.v1";function vc(t,e){try{return t.setItem(mc,e??""),!0}catch{return!1}}function yc(t,e){if(t===null)return null;let n;try{n=e.getItem(mc)}catch{return null}return n===null||n===""?null:t.model.nodes.some(r=>r.id===n)?n:null}function wc(){return{graph:null,graphFailed:!1,note:null,recentIds:new Set,selectedId:null}}var Rv=2e3,Cv=3e3,xc=new Set;function Nv(t,e){if(t===null)return xc;let n=new Set(t.model.nodes.map(r=>r.id));return new Set(e.model.nodes.filter(r=>!n.has(r.id)).map(r=>r.id))}function bc(t){if(t===null||!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}function _c(t){let e=t.state,n=!1,r=!1,i=null,o=d=>{Object.entries(d).every(([f,g])=>e[f]===g)||(e={...e,...d},t.setState(e))},a=t.defer??((d,f)=>{let g=setTimeout(d,f);return()=>clearTimeout(g)}),s=async()=>{let d=bc(e.selectedId);if(d===null){o({note:null});return}let f=await xs(t.fetch,d);f.ok&&o({note:f.data})},l=async()=>{let d=e.graph,f=await bs(t.fetch,e.graph);if(!f.ok)return e.graph===null&&o({graphFailed:!0}),f;if(!f.cached){let g=Nv(d,f.data);o({graph:f.data,graphFailed:!1,recentIds:g}),i?.(),i=null,g.size>0&&(i=a(()=>{i=null,o({recentIds:xc})},Cv))}return f},u=async()=>{if(!(n||r)){r=!0;try{let d=await l();d.ok&&!d.cached&&bc(e.selectedId)!==null&&await s()}finally{r=!1}}},h=(t.repeat??((d,f)=>{let g=setInterval(d,f);return()=>clearInterval(g)}))(()=>{u()},Rv);return u(),{refresh:()=>{u()},select:async d=>{o({selectedId:d}),await s()},syncNote:s,stop:()=>{n||(n=!0,h(),i?.(),i=null)}}}function kc(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^=e>>>16,e>>>0}var Lv=300,Pv=1;function Dv(t,e,n){let r=new Map(n??[]);if(r.size>0)for(let o of e){if(o.kind!=="contains"&&o.kind!=="anchored-at"||r.has(o.target))continue;let a=r.get(o.source);a!==void 0&&r.set(o.target,{x:a.x,y:a.y})}let i={ticks:Lv,seed:Pv,pinWarm:!0};return r.size>0&&(i.initial=r),lu({generatedAt:"",staleness:null,nodes:[...t],edges:[...e],contentDigest:""},i)}function Iv(t,e){let n=0,r=0;for(let o of t){let a=kc(o.id);n^=a,r=r+a>>>0}for(let o of e){let a=kc(`${o.source}\0${o.target}\0${o.kind}`);n^=a,r=r+a>>>0}return[t.length,e.length,n>>>0,r].map(o=>o.toString(16)).join("-")}var Sc="pi-weave.graph.positions.v3";function Ec(t){return Math.round(t*10)/10}function Gv(t,e){let n={};for(let[r,i]of e)n[r]=[Ec(i.x),Ec(i.y)];return JSON.stringify({v:3,key:t,at:n})}function Mv(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==3||r.key!==e)return null;let i=r.at;if(typeof i!="object"||i===null||Array.isArray(i))return null;let o=new Map;for(let[a,s]of Object.entries(i)){if(!Array.isArray(s)||s.length!==2)return null;let[l,u]=s;if(typeof l!="number"||typeof u!="number"||!Number.isFinite(l)||!Number.isFinite(u))return null;o.set(a,{x:l,y:u})}return o.size===0?null:o}function Ov(t,e){let n;try{n=t.getItem(Sc)}catch{return null}return Mv(n,e)}function Fv(t,e,n){try{return t.setItem(Sc,Gv(e,n)),!0}catch{return!1}}function Tc(t,e,n){let r=Iv(e,n),i=Ov(t,r);if(i!==null&&e.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=Dv(e,n);return Fv(t,r,o),{key:r,positions:o,cached:!1}}function zv(t){return{expanded:new Set(Ar(t,new Set).clusters.keys())}}function Rc(t,e){return e!==null?e:t===null?{expanded:new Set}:zv(kt(t))}function $v(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function Uv(t,e){return{...t,expanded:new Set(e.keys())}}function Hv(t){return{...t,expanded:new Set}}function Bv(t,e){return e===null?null:go(e,t)}function Cc(t){return t?"collapse":"expand"}function Nc(t){return t?"collapse every cluster back to the roots":"expand every cluster"}function No(t,e){if(e.size===0)return!1;for(let n of e.keys())if(!t.expanded.has(n))return!1;return!0}function Lc(t,e){return No(t,e)?Hv(t):Uv(t,e)}var Pc="fit",Dc="frame the whole graph",$r={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Ic(t,e){let n=e===1?"node":"nodes";return t===e?`${e} ${n}`:`${t} of ${e} ${n}`}function Wv(t,e){return t===null?"Loading…":t.model.nodes.length===0?"Nothing indexed yet — add a note or run /weave-scan.":e===0?"Nothing to draw at this expansion.":null}var Kv="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",Ac={graph:Iu,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function Gc(t,e,n,r,i,o=!1){if(t===null)return o?{...Ac,empty:Kv}:Ac;let a=kt(t),s=Ar(a,n.expanded),l=Tc(r,s.nodes,s.edges);return{graph:Mu(s.nodes,s.edges,l.positions,i),highlight:Bv(s.edges,e),key:l.key,cached:l.cached,clusters:s.clusters,visible:s.nodes.length,total:a.nodes.length,empty:Wv(t,s.nodes.length)}}function Mc(t,e,n){return n===null?{state:t,selectedId:null}:e.get(n)===void 0||t.expanded.has(n)?{state:t,selectedId:n}:{state:$v(t,n),selectedId:n}}var Vv=.06,jv=.2,Lo=.001;function Oc(t,e){if(t.nodes.length===0)return null;let n=t.nodes.map(s=>{let l=e?.get(s.id);return{id:s.id,x:l!==void 0&&Number.isFinite(l.x)?l.x:s.x,y:l!==void 0&&Number.isFinite(l.y)?l.y:s.y,vx:0,vy:0,r:lo(s.size)}}),r=new Map(n.map(s=>[s.id,s])),i=new Set,o=[];for(let s of t.edges){if(s.source===s.target||!r.has(s.source)||!r.has(s.target))continue;let l=`${s.source}\0${s.target}\0${s.kind}`;i.has(l)||(i.add(l),o.push({source:s.source,target:s.target,kind:s.kind}))}let a=uo({nodes:n,links:o,seed:1}).alpha(Vv).alphaMin(Lo);return{tick(){a.tick()},awake(){return a.alphaTarget()>Lo||a.alpha()>Lo},positions(){return new Map(n.map(s=>[s.id,{x:s.x??0,y:s.y??0}]))},pin(s,l){let u=r.get(s);u&&(u.fx=l.x,u.fy=l.y,a.alphaTarget(jv))},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,a.alphaTarget(0))}}}function Fc(t){let e=ee(null),n=ee(null),r=ee(null),i=ee(null),o=ms(()=>{if(i.current!==null)return;let f=()=>{i.current=null;let g=r.current;g!==null&&(g.tick(),g.awake()&&(n.current?.setPositions(g.positions()),i.current=requestAnimationFrame(f)))};i.current=requestAnimationFrame(f)},[]),[a,s]=oe(null),l=t.scheme??ir(t.host),u=Rc(t.graph,a),c=qe(()=>Gc(t.graph,t.selectedId,u,t.storage,l,t.bootFailed),[t.graph,t.selectedId,u,t.storage,l,t.bootFailed]),h=No(u,c.clusters),d=ee({view:u,model:c,onSelect:t.onSelect});return d.current={view:u,model:c,onSelect:t.onSelect},ie(()=>{let f=t.renderer(l);return f.onSelect(g=>{let m=Mc(d.current.view,d.current.model.clusters,g);s(m.state),d.current.onSelect(m.selectedId)}),f.onDragStart(g=>{let m=n.current?.positions().get(g);m&&(r.current?.pin(g,m),o())}),f.onDragMove((g,m)=>{r.current?.pin(g,m)}),f.onDragEnd(g=>{r.current?.release(g)}),f.mount(e.current??{clientWidth:0,clientHeight:0}),n.current=f,f.setGraph(d.current.model.graph),f.setHighlight(d.current.model.highlight),t.fit.current=()=>f.fit(),()=>{f.destroy(),n.current=null,t.fit.current=null}},[t.renderer,l]),ie(()=>{n.current?.setGraph(c.graph)},[c.key]),ie(()=>{let f=Oc(c.graph,n.current?.positions());return r.current=f,f!==null&&o(),()=>{r.current=null}},[c.key,o]),ie(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),ie(()=>{n.current?.setHighlight(c.highlight)},[c.highlight]),x("div",{class:"weave-graph",children:[c.empty===null?null:x("p",{class:"weave-graph-empty",children:c.empty}),x("div",{class:"weave-graph-canvas",ref:e,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),x("div",{class:"weave-graph-controls",children:[x("button",{type:"button",class:"weave-chip",title:Dc,onClick:()=>n.current?.fit(),children:Pc}),x("button",{type:"button",class:"weave-chip",title:Nc(h),onClick:()=>s(Lc(u,c.clusters)),children:Cc(h)}),x("span",{class:"weave-graph-legend",children:[x("span",{class:"weave-legend-on",children:["◉ ",$r.selected]}),x("span",{class:"weave-legend-near",children:["● ",$r.neighborhood]}),x("span",{class:"weave-legend-dim",children:["· ",$r.dimmed]})]})]}),x("p",{class:"weave-graph-count",children:Ic(c.visible,c.total)})]})}function zc(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function qv(t){if(Array.isArray(t))return t}function Yv(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,e!==0)for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function Xv(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
333
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zv(t,e){return qv(t)||Yv(t,e)||Qv(t,e)||Xv()}function Qv(t,e){if(t){if(typeof t=="string")return zc(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?zc(t,e):void 0}}var ed=Object.entries,$c=Object.setPrototypeOf,Jv=Object.isFrozen,ey=Object.getPrototypeOf,ty=Object.getOwnPropertyDescriptor,de=Object.freeze,pe=Object.seal,Yt=Object.create,td=typeof Reflect<"u"&&Reflect,Fo=td.apply,zo=td.construct;de||(de=function(e){return e});pe||(pe=function(e){return e});Fo||(Fo=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return e.apply(n,i)});zo||(zo=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});var Tt=se(Array.prototype.forEach),ny=se(Array.prototype.lastIndexOf),Uc=se(Array.prototype.pop),_n=se(Array.prototype.push),ry=se(Array.prototype.splice),Xt=Array.isArray,Sn=se(String.prototype.toLowerCase),Po=se(String.prototype.toString),Hc=se(String.prototype.match),kn=se(String.prototype.replace),Bc=se(String.prototype.indexOf),iy=se(String.prototype.trim),oy=se(Number.prototype.toString),ay=se(Boolean.prototype.toString),Wc=typeof BigInt>"u"?null:se(BigInt.prototype.toString),Kc=typeof Symbol>"u"?null:se(Symbol.prototype.toString),Se=se(Object.prototype.hasOwnProperty),En=se(Object.prototype.toString),ve=se(RegExp.prototype.test),St=sy(TypeError);function se(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Fo(t,e,r)}}function sy(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return zo(t,n)}}function H(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Sn;if($c&&$c(t,null),!Xt(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){let o=n(i);o!==i&&(Jv(e)||(e[r]=o),i=o)}t[i]=!0}return t}function ly(t){for(let e=0;e<t.length;e++)Se(t,e)||(t[e]=null);return t}function Re(t){let e=Yt(null);for(let r of ed(t)){var n=Zv(r,2);let i=n[0],o=n[1];Se(t,i)&&(Xt(o)?e[i]=ly(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Re(o):e[i]=o)}return e}function uy(t){switch(typeof t){case"string":return t;case"number":return oy(t);case"boolean":return ay(t);case"bigint":return Wc?Wc(t):"0";case"symbol":return Kc?Kc(t):"Symbol()";case"undefined":return En(t);case"function":case"object":{if(t===null)return En(t);let e=t,n=ze(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:En(r)}return En(t)}default:return En(t)}}function ze(t,e){for(;t!==null;){let r=ty(t,e);if(r){if(r.get)return se(r.get);if(typeof r.value=="function")return se(r.value)}t=ey(t)}function n(){return null}return n}function cy(t){try{return ve(t,""),!0}catch{return!1}}var Vc=de(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Do=de(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Io=de(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),dy=de(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Go=de(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),hy=de(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),jc=de(["#text"]),qc=de(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Mo=de(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Yc=de(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ur=de(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),fy=pe(/{{[\w\W]*|^[\w\W]*}}/g),py=pe(/<%[\w\W]*|^[\w\W]*%>/g),gy=pe(/\${[\w\W]*/g),my=pe(/^data-[\-\w.\u00B7-\uFFFF]+$/),vy=pe(/^aria-[\-\w]+$/),Xc=pe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),yy=pe(/^(?:\w+script|data):/i),wy=pe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),by=pe(/^html$/i),xy=pe(/^[a-z][.\w]*(-[.\w]+)+$/i),Zc=pe(/<[/\w!]/g),Qc=pe(/<[/\w]/g),_y=pe(/<\/no(script|embed|frames)/i),ky=pe(/\/>/i),Ae={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},nd=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Ey=de(H({},nd)),Sy=(function(){let t={};return Tt(nd,e=>{t[e]=pe(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),de(t)})(),Ty=function(){return typeof window>"u"?null:window},Ay=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));let o="dompurify"+(r?"#"+r:"");try{return e.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Jc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},dt=function(e,n,r,i){return Se(e,n)&&Xt(e[n])?H(i.base?Re(i.base):{},e[n],i.transform):r},Oo=function(e,n,r){let i=Se(e,n)?e[n]:void 0;return i&&typeof i=="object"?Re(i):r()};function rd(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ty(),e=T=>rd(T);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==Ae.document||!t.Element)return e.isSupported=!1,e;let n=t.document,r=n,i=r.currentScript;t.DocumentFragment;let o=t.HTMLTemplateElement,a=t.Node,s=t.Element,l=t.NodeFilter,u=t.NamedNodeMap;u===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let c=t.DOMParser,h=t.trustedTypes,d=s.prototype,f=ze(d,"cloneNode"),g=ze(d,"remove"),m=ze(d,"nextSibling"),v=ze(d,"childNodes"),y=ze(d,"parentNode"),w=ze(d,"shadowRoot"),k=ze(d,"attributes"),_=a&&a.prototype?ze(a.prototype,"nodeType"):null,L=a&&a.prototype?ze(a.prototype,"nodeName"):null,R=a&&a.prototype?ze(a.prototype,"ownerDocument"):null,D=function(p){return _?_(p):p.nodeType},z=function(p){return L?L(p):p.nodeName};if(typeof o=="function"){let T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let F,G="",U,j=!1,Q=0,ge=function(){if(Q>0)throw St('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},he=function(p){ge(),Q++;try{return F.createHTML(p)}finally{Q--}},Be=function(p){ge(),Q++;try{return F.createScriptURL(p)}finally{Q--}},Nt=function(){return j||(U=Ay(h,i),j=!0),U},De=n,Ie=De.implementation,Ge=De.createNodeIterator,We=De.createDocumentFragment,Jt=De.getElementsByTagName,Ce=r.importNode,q=Jc();e.isSupported=typeof ed=="function"&&typeof y=="function"&&Ie&&Ie.createHTMLDocument!==void 0;let en=fy,Kh=py,Vh=gy,jh=my,qh=vy,Yh=yy,ha=wy,Xh=xy,fa=Xc,X=null,ni=H({},[...Vc,...Do,...Io,...Go,...jc]),Z=null,ri=H({},[...qc,...Mo,...Yc,...Ur]),Ke=Object.seal(Yt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),tn=null,pa=null,rt=Object.seal(Yt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ga=!0,ii=!0,ma=!1,va=!0,it=!1,pt=!0,gt=!1,oi=!1,In=null,Gn=null,ai=!1,Lt=!1,Mn=!1,On=!1,ya=!0,wa=!1,ba="user-content-",si=!0,li=!1,Pt={},Dt=null,xa=H({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),_a=null,ka=H({},["audio","video","img","source","image","track"]),Ea=null,Sa=H({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Fn="http://www.w3.org/1998/Math/MathML",zn="http://www.w3.org/2000/svg",Ve="http://www.w3.org/1999/xhtml",It=Ve,ui=!1,ci=null,Zh=H({},[Fn,zn,Ve],Po),Ta=de(["mi","mo","mn","ms","mtext"]),di=H({},Ta),Aa=de(["annotation-xml"]),hi=H({},Aa),Qh=H({},["title","style","font","a","script"]),nn=null,Jh=["application/xhtml+xml","text/html"],ef="text/html",ne=null,Gt=null,tf=n.createElement("form"),Ra=function(p){return p instanceof RegExp||p instanceof Function},fi=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Gt&&Gt===p)return;(!p||typeof p!="object")&&(p={}),p=Re(p),nn=Jh.indexOf(p.PARSER_MEDIA_TYPE)===-1?ef:p.PARSER_MEDIA_TYPE,ne=nn==="application/xhtml+xml"?Po:Sn,X=dt(p,"ALLOWED_TAGS",ni,{transform:ne}),Z=dt(p,"ALLOWED_ATTR",ri,{transform:ne}),ci=dt(p,"ALLOWED_NAMESPACES",Zh,{transform:Po}),Ea=dt(p,"ADD_URI_SAFE_ATTR",Sa,{transform:ne,base:Sa}),_a=dt(p,"ADD_DATA_URI_TAGS",ka,{transform:ne,base:ka}),Dt=dt(p,"FORBID_CONTENTS",xa,{transform:ne}),tn=dt(p,"FORBID_TAGS",Re({}),{transform:ne}),pa=dt(p,"FORBID_ATTR",Re({}),{transform:ne}),Pt=Se(p,"USE_PROFILES")?p.USE_PROFILES&&typeof p.USE_PROFILES=="object"?Re(p.USE_PROFILES):p.USE_PROFILES:!1,ga=p.ALLOW_ARIA_ATTR!==!1,ii=p.ALLOW_DATA_ATTR!==!1,ma=p.ALLOW_UNKNOWN_PROTOCOLS||!1,va=p.ALLOW_SELF_CLOSE_IN_ATTR!==!1,it=p.SAFE_FOR_TEMPLATES||!1,pt=p.SAFE_FOR_XML!==!1,gt=p.WHOLE_DOCUMENT||!1,Lt=p.RETURN_DOM||!1,Mn=p.RETURN_DOM_FRAGMENT||!1,On=p.RETURN_TRUSTED_TYPE||!1,ai=p.FORCE_BODY||!1,ya=p.SANITIZE_DOM!==!1,wa=p.SANITIZE_NAMED_PROPS||!1,si=p.KEEP_CONTENT!==!1,li=p.IN_PLACE||!1,fa=cy(p.ALLOWED_URI_REGEXP)?p.ALLOWED_URI_REGEXP:Xc,It=typeof p.NAMESPACE=="string"?p.NAMESPACE:Ve,di=Oo(p,"MATHML_TEXT_INTEGRATION_POINTS",()=>H({},Ta)),hi=Oo(p,"HTML_INTEGRATION_POINTS",()=>H({},Aa));let b=Oo(p,"CUSTOM_ELEMENT_HANDLING",()=>Yt(null));if(Ke=Yt(null),Se(b,"tagNameCheck")&&Ra(b.tagNameCheck)&&(Ke.tagNameCheck=b.tagNameCheck),Se(b,"attributeNameCheck")&&Ra(b.attributeNameCheck)&&(Ke.attributeNameCheck=b.attributeNameCheck),Se(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(Ke.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),pe(Ke),it&&(ii=!1),Mn&&(Lt=!0),Pt&&(X=H({},jc),Z=Yt(null),Pt.html===!0&&(H(X,Vc),H(Z,qc)),Pt.svg===!0&&(H(X,Do),H(Z,Mo),H(Z,Ur)),Pt.svgFilters===!0&&(H(X,Io),H(Z,Mo),H(Z,Ur)),Pt.mathMl===!0&&(H(X,Go),H(Z,Yc),H(Z,Ur))),rt.tagCheck=null,rt.attributeCheck=null,Se(p,"ADD_TAGS")&&(typeof p.ADD_TAGS=="function"?rt.tagCheck=p.ADD_TAGS:Xt(p.ADD_TAGS)&&(X===ni&&(X=Re(X)),H(X,p.ADD_TAGS,ne))),Se(p,"ADD_ATTR")&&(typeof p.ADD_ATTR=="function"?rt.attributeCheck=p.ADD_ATTR:Xt(p.ADD_ATTR)&&(Z===ri&&(Z=Re(Z)),H(Z,p.ADD_ATTR,ne))),Se(p,"ADD_FORBID_CONTENTS")&&Xt(p.ADD_FORBID_CONTENTS)&&(Dt===xa&&(Dt=Re(Dt)),H(Dt,p.ADD_FORBID_CONTENTS,ne)),si&&(X["#text"]=!0),gt&&H(X,["html","head","body"]),X.table&&(H(X,["tbody"]),delete tn.tbody),p.TRUSTED_TYPES_POLICY){if(typeof p.TRUSTED_TYPES_POLICY.createHTML!="function")throw St('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof p.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw St('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let E=F;F=p.TRUSTED_TYPES_POLICY;try{G=he("")}catch(C){throw F=E,C}}else p.TRUSTED_TYPES_POLICY===null?(F=void 0,G=""):(F===void 0&&(F=Nt()),F&&typeof G=="string"&&(G=he("")));de&&de(p),Gt=p},Ca=H({},[...Do,...Io,...dy]),Na=H({},[...Go,...hy]),nf=function(p,b,E){return b.namespaceURI===Ve?p==="svg":b.namespaceURI===Fn?p==="svg"&&(E==="annotation-xml"||di[E]):!!Ca[p]},rf=function(p,b,E){return b.namespaceURI===Ve?p==="math":b.namespaceURI===zn?p==="math"&&hi[E]:!!Na[p]},of=function(p,b,E){return b.namespaceURI===zn&&!hi[E]||b.namespaceURI===Fn&&!di[E]?!1:!Na[p]&&(Qh[p]||!Ca[p])},af=function(p){let b=y(p);(!b||!b.tagName)&&(b={namespaceURI:It,tagName:"template"});let E=Sn(p.tagName),C=Sn(b.tagName);return ci[p.namespaceURI]?p.namespaceURI===zn?nf(E,b,C):p.namespaceURI===Fn?rf(E,b,C):p.namespaceURI===Ve?of(E,b,C):!!(nn==="application/xhtml+xml"&&ci[p.namespaceURI]):!1},ot=function(p){_n(e.removed,{element:p});try{y(p).removeChild(p)}catch{if(g(p),!y(p))throw St("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},La=function(p,b,E){try{p.removeAttributeNode(b)}catch{try{p.removeAttribute(E)}catch{}}},$n=function(p){Un(p);let b=v(p);if(b){let C=[];Tt(b,I=>{_n(C,I)}),Tt(C,I=>{try{g(I)}catch{}})}let E=k(p);if(E)for(let C=E.length-1;C>=0;--C){let I=E[C],O=I&&I.name;typeof O=="string"&&La(p,I,O)}},mt=function(p,b,E){if(!E)try{E=b.getAttributeNode(p)}catch{E=null}_n(e.removed,{attribute:E||null,from:b});try{E?b.removeAttributeNode(E):b.removeAttribute(p)}catch{try{b.removeAttribute(p)}catch{}}if(p==="is")if(Lt||Mn)try{ot(b)}catch{}else try{b.setAttribute(p,"")}catch{}},sf=function(p){let b=k(p);if(b)for(let E=b.length-1;E>=0;--E){let C=b[E],I=C&&C.name;typeof I!="string"||Z[ne(I)]||La(p,C,I)}},Un=function(p){let b=[p];for(;b.length>0;){let E=b.pop();D(E)===Ae.element&&sf(E);let I=v(E);if(I)for(let O=I.length-1;O>=0;--O)b.push(I[O])}},Pa=function(p,b){return pt?p==="patchsrc"?!0:p==="for"&&b!=="label"&&b!=="output":!1},lf=function(p){if(!pt)return;let b=[p];for(;b.length>0;){let E=b.pop(),C=D(E);if(C===Ae.processingInstruction||C===Ae.comment&&ve(Qc,E.data)){try{g(E)}catch{}continue}if(C===Ae.element){let O=E,Y=ne(z(E));try{O.hasAttribute&&O.hasAttribute("patchsrc")&&O.removeAttribute("patchsrc"),O.hasAttribute&&O.hasAttribute("for")&&Pa("for",Y)&&O.removeAttribute("for")}catch{}}let I=v(E);if(I)for(let O=I.length-1;O>=0;--O)b.push(I[O])}},Da=function(p){let b=null,E=null;if(ai)p="<remove></remove>"+p;else{let O=Hc(p,/^[\r\n\t ]+/);E=O&&O[0]}nn==="application/xhtml+xml"&&It===Ve&&(p='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+p+"</body></html>");let C=F?he(p):p;if(It===Ve)try{b=new c().parseFromString(C,nn)}catch{}if(!b||!b.documentElement){b=Ie.createDocument(It,"template",null);try{b.documentElement.innerHTML=ui?G:C}catch{}}let I=b.body||b.documentElement;return p&&E&&I.insertBefore(n.createTextNode(E),I.childNodes[0]||null),It===Ve?Jt.call(b,gt?"html":"body")[0]:gt?b.documentElement:I},Ia=function(p){let b=R?R(p):p.ownerDocument;return Ge.call(b||p,p,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Hn=function(p){return p=kn(p,en," "),p=kn(p,Kh," "),p=kn(p,Vh," "),p},pi=function(p){var b;p.normalize();let E=R?R(p):p.ownerDocument,C=Ge.call(E||p,p,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),I=C.nextNode();for(;I;)I.data=Hn(I.data),I=C.nextNode();let O=(b=p.querySelectorAll)===null||b===void 0?void 0:b.call(p,"template");O&&Tt(O,Y=>{Mt(Y.content)&&pi(Y.content)})},Bn=function(p){let b=L?L(p):null;return typeof b!="string"||ne(b)!=="form"?!1:typeof p.nodeName!="string"||typeof p.textContent!="string"||typeof p.removeChild!="function"||p.attributes!==k(p)||typeof p.removeAttribute!="function"||typeof p.setAttribute!="function"||typeof p.namespaceURI!="string"||typeof p.insertBefore!="function"||typeof p.hasChildNodes!="function"||p.nodeType!==_(p)||p.childNodes!==v(p)},Mt=function(p){if(!_||typeof p!="object"||p===null)return!1;try{return _(p)===Ae.documentFragment}catch{return!1}},rn=function(p){if(!_||typeof p!="object"||p===null)return!1;try{return typeof _(p)=="number"}catch{return!1}};function je(T,p,b){T.length!==0&&Tt(T,E=>{E.call(e,p,b,Gt)})}let uf=function(p,b){return!!(pt&&p.hasChildNodes()&&!rn(p.firstElementChild)&&ve(Zc,p.textContent)&&ve(Zc,p.innerHTML)||pt&&p.namespaceURI===Ve&&Ey[b]&&(rn(p.firstElementChild)||typeof p.textContent=="string"&&ve(Sy[b],p.textContent))||p.nodeType===Ae.processingInstruction||pt&&p.nodeType===Ae.comment&&ve(Qc,p.data))},Wn=function(p,b){if(p instanceof RegExp)return ve(p,b);if(p instanceof Function){for(var E=arguments.length,C=new Array(E>2?E-2:0),I=2;I<E;I++)C[I-2]=arguments[I];return!!p(b,...C)}return!1},cf=function(p,b,E){if(!tn[b]&&za(b)&&Wn(Ke.tagNameCheck,b))return!1;if(si&&!Dt[b]){let C=y(p),I=v(p);if(I&&C){let O=I.length;for(let Y=O-1;Y>=0;--Y){let J=p===E?f(I[Y],!0):I[Y];C.insertBefore(J,m(p))}}}return ot(p),!0},Ga=function(p,b,E,C){return p.length===0?b:b===E||b===C?Re(b):b},Ma=function(p,b){return p===b||y(p)!==null?!1:(li&&Un(p),!0)},Oa=function(p,b){if(je(q.beforeSanitizeElements,p,null),Ma(p,b))return!0;if(Bn(p))return ot(p),!0;let E=ne(z(p));if(X=Ga(q.uponSanitizeElement,X,ni,In),je(q.uponSanitizeElement,p,{tagName:E,allowedTags:X}),Ma(p,b))return!0;if(uf(p,E))return ot(p),!0;if(tn[E]||!(rt.tagCheck instanceof Function&&rt.tagCheck(E))&&!X[E]){let I=cf(p,E,b);return I===!1&&je(q.afterSanitizeElements,p,null),I}if(D(p)===Ae.element&&!af(p)||(E==="noscript"||E==="noembed"||E==="noframes")&&ve(_y,p.innerHTML))return ot(p),!0;if(it&&p.nodeType===Ae.text){let I=Hn(p.textContent);p.textContent!==I&&(_n(e.removed,{element:p.cloneNode()}),p.textContent=I)}return je(q.afterSanitizeElements,p,null),!1},Fa=function(p,b,E){if(pa[b]||Pa(b,p)||ya&&(b==="id"||b==="name")&&(E in n||E in tf))return!1;let C=Z[b]||rt.attributeCheck instanceof Function&&rt.attributeCheck(b,p);return ii&&ve(jh,b)||ga&&ve(qh,b)?!0:C?Ea[b]||ve(fa,kn(E,ha,""))||(b==="src"||b==="xlink:href"||b==="href")&&p!=="script"&&Bc(E,"data:")===0&&_a[p]||ma&&!ve(Yh,kn(E,ha,""))?!0:!E:za(p)&&Wn(Ke.tagNameCheck,p)&&Wn(Ke.attributeNameCheck,b,p)||b==="is"&&Ke.allowCustomizedBuiltInElements&&Wn(Ke.tagNameCheck,E)},df=H({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),za=function(p){return!df[Sn(p)]&&ve(Xh,p)},hf=function(p,b,E,C){if(F&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!E)switch(h.getAttributeType(p,b)){case"TrustedHTML":return he(C);case"TrustedScriptURL":return Be(C)}return C},ff=function(p,b,E,C){try{E?p.setAttributeNS(E,b,C):p.setAttribute(b,C),Bn(p)?ot(p):Uc(e.removed)}catch{mt(b,p)}},$a=function(p){je(q.beforeSanitizeAttributes,p,null);let b=p.attributes;if(!b||Bn(p))return;Z=Ga(q.uponSanitizeAttribute,Z,ri,Gn);let E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z,forceKeepAttr:void 0},C=b.length,I=ne(p.nodeName);for(;C--;){let O=b[C],Y=O.name,J=O.namespaceURI,ke=O.value,Ee=ne(Y),mi=ke,we=Y==="value"?mi:iy(mi);if(E.attrName=Ee,E.attrValue=we,E.keepAttr=!0,E.forceKeepAttr=void 0,je(q.uponSanitizeAttribute,p,E),we=E.attrValue,wa&&(Ee==="id"||Ee==="name")&&Bc(we,ba)!==0&&(mt(Y,p,O),we=ba+we),pt&&ve(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,we)){mt(Y,p,O);continue}if(Ee==="attributename"&&Hc(we,"href")){mt(Y,p,O);continue}if(!E.forceKeepAttr){if(!E.keepAttr){mt(Y,p,O);continue}if(!va&&ve(ky,we)){mt(Y,p,O);continue}if(it&&(we=Hn(we)),!Fa(I,Ee,we)){mt(Y,p,O);continue}we=hf(I,Ee,J,we),we!==mi&&ff(p,Y,J,we)}}je(q.afterSanitizeAttributes,p,null)},Kn=function(p){let b=null,E=Ia(p);for(je(q.beforeSanitizeShadowDOM,p,null);b=E.nextNode();)if(je(q.uponSanitizeShadowNode,b,null),Oa(b,p),$a(b),Mt(b.content)&&Kn(b.content),D(b)===Ae.element){let C=w(b);Mt(C)&&(gi(C),Kn(C))}je(q.afterSanitizeShadowDOM,p,null)},gi=function(p){let b=[{node:p,shadow:null}];for(;b.length>0;){let E=b.pop();if(E.shadow){Kn(E.shadow);continue}let C=E.node,O=D(C)===Ae.element,Y=v(C);if(Y)for(let J=Y.length-1;J>=0;--J)b.push({node:Y[J],shadow:null});if(O){let J=L?L(C):null;if(typeof J=="string"&&ne(J)==="template"){let ke=C.content;Mt(ke)&&b.push({node:ke,shadow:null})}}if(O){let J=w(C);Mt(J)&&b.push({node:null,shadow:J},{node:J,shadow:null})}}};return e.sanitize=function(T){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,E=null,C=null,I=null;if(ui=!T,ui&&(T="<!-->"),typeof T!="string"&&!rn(T)&&(T=uy(T),typeof T!="string"))throw St("dirty is not a string, aborting");if(!e.isSupported)return T;oi?(X=In,Z=Gn):fi(p),(q.uponSanitizeElement.length>0||q.uponSanitizeAttribute.length>0)&&(X=Re(X)),q.uponSanitizeAttribute.length>0&&(Z=Re(Z)),e.removed=[];let O=li&&typeof T!="string"&&rn(T);if(O){lf(T);let ke=z(T);if(typeof ke=="string"){let Ee=ne(ke);if(!X[Ee]||tn[Ee])throw $n(T),St("root node is forbidden and cannot be sanitized in-place")}if(Bn(T))throw $n(T),St("root node is clobbered and cannot be sanitized in-place");try{gi(T)}catch(Ee){throw $n(T),Ee}}else if(rn(T))b=Da("<!---->"),E=b.ownerDocument.importNode(T,!0),E.nodeType===Ae.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?b=E:b.appendChild(E),gi(E);else{if(!Lt&&!it&&!gt&&T.indexOf("<")===-1)return F&&On?he(T):T;if(b=Da(T),!b)return Lt?null:On?G:""}b&&ai&&ot(b.firstChild);let Y=O?T:b;try{let ke=Ia(Y);for(;C=ke.nextNode();)Oa(C,Y),$a(C),Mt(C.content)&&Kn(C.content)}catch(ke){throw O&&($n(T),Tt(e.removed,Ee=>{Ee.element&&Un(Ee.element)})),ke}if(O)return Tt(e.removed,ke=>{ke.element&&Un(ke.element)}),it&&pi(T),T;if(Lt){if(it&&pi(b),Mn)for(I=We.call(b.ownerDocument);b.firstChild;)I.appendChild(b.firstChild);else I=b;return(Z.shadowroot||Z.shadowrootmode)&&(I=Ce.call(r,I,!0)),I}let J=gt?b.outerHTML:b.innerHTML;return gt&&X["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&ve(by,b.ownerDocument.doctype.name)&&(J="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
334
|
-
`+J),
|
|
335
|
-
]`).replace("lheading",
|
|
331
|
+
`,Op=Mp,al=WebGLRenderingContext,Vs=al.UNSIGNED_BYTE,hn=al.FLOAT,Fp=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],sl=(function(t){function e(){return le(this,e),be(this,e,arguments)}return xe(e,t),ue(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:Op,FRAGMENT_SHADER_SOURCE:nl,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:Fp,ATTRIBUTES:[{name:"a_positionStart",size:2,type:hn},{name:"a_positionEnd",size:2,type:hn},{name:"a_normal",size:2,type:hn},{name:"a_color",size:4,type:Vs,normalized:!0},{name:"a_id",size:4,type:Vs,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:hn},{name:"a_normalCoef",size:1,type:hn}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,o,a,s){var l=s.size||1,u=o.x,c=o.y,h=a.x,d=a.y,f=$t(s.color),p=h-u,m=d-c,v=p*p+m*m,y=0,w=0;v&&(v=1/Math.sqrt(v),y=-m*v*l,w=p*v*l);var k=this.array;k[i++]=u,k[i++]=c,k[i++]=h,k[i++]=d,k[i++]=y,k[i++]=w,k[i++]=f,k[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,a=i.uniformLocations,s=a.u_matrix,l=a.u_zoomRatio,u=a.u_feather,c=a.u_pixelRatio,h=a.u_correctionRatio,d=a.u_sizeRatio,f=a.u_minEdgeThickness;o.uniformMatrix3fv(s,!1,r.matrix),o.uniform1f(l,r.zoomRatio),o.uniform1f(d,r.sizeRatio),o.uniform1f(h,r.correctionRatio),o.uniform1f(c,r.pixelRatio),o.uniform1f(u,r.antiAliasingFeather),o.uniform1f(f,r.minEdgeThickness)}}])})(Wi);var yl=an(dr()),hr=(function(t){function e(){var n;return le(this,e),n=be(this,e),n.rawEmitter=n,n}return xe(e,t),ue(e)})(yl.EventEmitter);var _l=an(ji());var Kp=function(e){return e},Vp=function(e){return e*e},jp=function(e){return e*(2-e)},qp=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},Yp=function(e){return e*e*e},Xp=function(e){return--e*e*e+1},Zp=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},kl={linear:Kp,quadraticIn:Vp,quadraticOut:jp,quadraticInOut:qp,cubicIn:Yp,cubicOut:Xp,cubicInOut:Zp},El={easing:"quadraticInOut",duration:150};function Le(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function fr(t,e,n){return t[0]=e,t[4]=typeof n=="number"?n:e,t}function bl(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[3]=-n,t[4]=r,t}function xl(t,e,n){return t[6]=e,t[7]=n,t}function ht(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=e[0],d=e[1],f=e[2],p=e[3],m=e[4],v=e[5],y=e[6],w=e[7],k=e[8];return t[0]=h*n+d*o+f*l,t[1]=h*r+d*a+f*u,t[2]=h*i+d*s+f*c,t[3]=p*n+m*o+v*l,t[4]=p*r+m*a+v*u,t[5]=p*i+m*s+v*c,t[6]=y*n+w*o+k*l,t[7]=y*r+w*a+k*u,t[8]=y*i+w*s+k*c,t}function pr(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=t[0],i=t[1],o=t[3],a=t[4],s=t[6],l=t[7],u=e.x,c=e.y;return{x:u*r+c*o+s*n,y:u*i+c*a+l*n}}function Qp(t,e){var n=t.height/t.width,r=e.height/e.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function Ht(t,e,n,r,i){var o=t.angle,a=t.ratio,s=t.x,l=t.y,u=e.width,c=e.height,h=Le(),d=Math.min(u,c)-2*r,f=Qp(e,n);return i?(ht(h,xl(Le(),s,l)),ht(h,fr(Le(),a)),ht(h,bl(Le(),o)),ht(h,fr(Le(),u/d/2/f,c/d/2/f))):(ht(h,fr(Le(),2*(d/u)*f,2*(d/c)*f)),ht(h,bl(Le(),-o)),ht(h,fr(Le(),1/a)),ht(h,xl(Le(),-s,-l))),h}function Sl(t,e,n){var r=pr(t,{x:Math.cos(e.angle),y:Math.sin(e.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function Tl(t){if(!t.order)return{x:[0,1],y:[0,1]};var e=1/0,n=-1/0,r=1/0,i=-1/0;return t.forEachNode(function(o,a){var s=a.x,l=a.y;s<e&&(e=s),s>n&&(n=s),l<r&&(r=l),l>i&&(i=l)}),{x:[e,n],y:[r,i]}}function Al(t){if(!(0,_l.default)(t))throw new Error("Sigma: invalid graph instance.");t.forEachNode(function(e,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(e," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Rl(t,e,n){var r=document.createElement(t);if(e)for(var i in e)r.style[i]=e[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function qi(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Yi(t,e,n){return n.sort(function(r,i){var o=e(r)||0,a=e(i)||0;return o<a?-1:o>a?1:0})}function Xi(t){var e=dt(t.x,2),n=e[0],r=e[1],i=dt(t.y,2),o=i[0],a=i[1],s=Math.max(r-n,a-o),l=(r+n)/2,u=(a+o)/2;(s===0||Math.abs(s)===1/0||isNaN(s))&&(s=1),isNaN(l)&&(l=0),isNaN(u)&&(u=0);var c=function(d){return{x:.5+(d.x-l)/s,y:.5+(d.y-u)/s}};return c.applyTo=function(h){h.x=.5+(h.x-l)/s,h.y=.5+(h.y-u)/s},c.inverse=function(h){return{x:l+s*(h.x-.5),y:u+s*(h.y-.5)}},c.ratio=s,c}function gr(t){"@babel/helpers - typeof";return gr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gr(t)}function Zi(t,e){var n=e.size;if(n!==0){var r=t.length;t.length+=n;var i=0;e.forEach(function(o){t[r+i]=o,i++})}}function mr(t){t=t||{};for(var e=0,n=arguments.length<=1?0:arguments.length-1;e<n;e++){var r=e+1<1||arguments.length<=e+1?void 0:arguments[e+1];r&&Object.assign(t,r)}return t}var vr={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:Xs,defaultDrawNodeLabel:Ki,defaultDrawNodeHover:Zs,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},Jp={circle:fn},eg={arrow:ol,line:sl};function yr(t){if(typeof t.labelDensity!="number"||t.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var e=t.minCameraRatio,n=t.maxCameraRatio;if(typeof e=="number"&&typeof n=="number"&&n<e)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function Cl(t){var e=mr({},vr,t);return e.nodeProgramClasses=mr({},Jp,e.nodeProgramClasses),e.edgeProgramClasses=mr({},eg,e.edgeProgramClasses),e}var Gx=an(dr()),Mx=an(ji()),wr=1.5,Nl=(function(t){function e(){var n;return le(this,e),n=be(this,e),S(n,"x",.5),S(n,"y",.5),S(n,"angle",0),S(n,"ratio",1),S(n,"minRatio",null),S(n,"maxRatio",null),S(n,"enabledZooming",!0),S(n,"enabledPanning",!0),S(n,"enabledRotation",!0),S(n,"clean",null),S(n,"nextFrame",null),S(n,"previousState",null),S(n,"enabled",!0),n.previousState=n.getState(),n}return xe(e,t),ue(e,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(r){return this.x===r.x&&this.y===r.y&&this.ratio===r.ratio&&this.angle===r.angle}},{key:"getPreviousState",value:function(){var r=this.previousState;return r?{x:r.x,y:r.y,angle:r.angle,ratio:r.ratio}:null}},{key:"getBoundedRatio",value:function(r){var i=r;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(r){var i={};return this.enabledPanning&&typeof r.x=="number"&&(i.x=r.x),this.enabledPanning&&typeof r.y=="number"&&(i.y=r.y),this.enabledZooming&&typeof r.ratio=="number"&&(i.ratio=this.getBoundedRatio(r.ratio)),this.enabledRotation&&typeof r.angle=="number"&&(i.angle=r.angle),this.clean?this.clean(D(D({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(r){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(r);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(r){return this.setState(r(this.getState())),this}},{key:"animate",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if(!a)return new Promise(function(f){return i.animate(r,o,f)});if(this.enabled){var s=D(D({},El),o),l=this.validateState(r),u=typeof s.easing=="function"?s.easing:kl[s.easing],c=Date.now(),h=this.getState(),d=function(){var p=(Date.now()-c)/s.duration;if(p>=1){i.nextFrame=null,i.setState(l),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var m=u(p),v={};typeof l.x=="number"&&(v.x=h.x+(l.x-h.x)*m),typeof l.y=="number"&&(v.y=h.y+(l.y-h.y)*m),i.enabledRotation&&typeof l.angle=="number"&&(v.angle=h.angle+(l.angle-h.angle)*m),typeof l.ratio=="number"&&(v.ratio=h.ratio+(l.ratio-h.ratio)*m),i.setState(v),i.nextFrame=requestAnimationFrame(d)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(d)):d(),this.animationCallback=a}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||wr)},r):this.animate({ratio:this.ratio/wr})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||wr)},r):this.animate({ratio:this.ratio*wr})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return e.from(this.getState())}}],[{key:"from",value:function(r){var i=new e;return i.setState(r)}}])})(hr);function Oe(t,e){var n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}function tt(t,e){var n=D(D({},Oe(t,e)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:t});return n}function pn(t){var e="x"in t?t:D(D({},t.touches[0]||t.previousTouches[0]),{},{original:t.original,sigmaDefaultPrevented:t.sigmaDefaultPrevented,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0,e.sigmaDefaultPrevented=!0}});return e}function tg(t,e){return D(D({},tt(t,e)),{},{delta:Ml(t)})}var ng=2;function br(t){for(var e=[],n=0,r=Math.min(t.length,ng);n<r;n++)e.push(t[n]);return e}function gn(t,e,n){var r={touches:br(t.touches).map(function(i){return Oe(i,n)}),previousTouches:e.map(function(i){return Oe(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:t};return r}function Ml(t){if(typeof t.deltaY<"u")return t.deltaY*-3/360;if(typeof t.detail<"u")return t.detail/-9;throw new Error("Captor: could not extract delta from event.")}var Ol=(function(t){function e(n,r){var i;return le(this,e),i=be(this,e),i.container=n,i.renderer=r,i}return xe(e,t),ue(e)})(hr),rg=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],ig=rg.reduce(function(t,e){return D(D({},t),{},S({},e,vr[e]))},{}),og=(function(t){function e(n,r){var i;return le(this,e),i=be(this,e,[n,r]),S(i,"enabled",!0),S(i,"draggedEvents",0),S(i,"downStartTime",null),S(i,"lastMouseX",null),S(i,"lastMouseY",null),S(i,"isMouseDown",!1),S(i,"isMoving",!1),S(i,"movingTimeout",null),S(i,"startCameraState",null),S(i,"clicks",0),S(i,"doubleClickTimeout",null),S(i,"currentWheelDirection",0),S(i,"settings",ig),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),n.addEventListener("click",i.handleClick,{capture:!1}),n.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),n.addEventListener("mousedown",i.handleDown,{capture:!1}),n.addEventListener("wheel",i.handleWheel,{capture:!1}),n.addEventListener("mouseleave",i.handleLeave,{capture:!1}),n.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return xe(e,t),ue(e,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("click",this.handleClick),r.removeEventListener("contextmenu",this.handleRightClick),r.removeEventListener("mousedown",this.handleDown),r.removeEventListener("wheel",this.handleWheel),r.removeEventListener("mouseleave",this.handleLeave),r.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(r){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(r);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",tt(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",tt(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=tt(r,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var o=this.renderer.getCamera(),a=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(Oe(r,this.container),a),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(r){if(this.enabled){if(r.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=Oe(r,this.container),o=i.x,a=i.y;this.lastMouseX=o,this.lastMouseY=a,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",tt(r,this.container))}}},{key:"handleUp",value:function(r){var i=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var a=Oe(r,this.container),s=a.x,l=a.y,u=o.getState(),c=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:u.x+this.settings.inertiaRatio*(u.x-c.x),y:u.y+this.settings.inertiaRatio*(u.y-c.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==s||this.lastMouseY!==l)&&o.setState({x:u.x,y:u.y}),this.isMoving=!1,setTimeout(function(){var h=i.draggedEvents>0;i.draggedEvents=0,h&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",tt(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=tt(r,this.container);if(this.emit("mousemovebody",o),(r.target===this.container||r.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var a=this.renderer.getCamera(),s=Oe(r,this.container),l=s.x,u=s.y,c=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),h=this.renderer.viewportToFramedGraph({x:l,y:u}),d=c.x-h.x,f=c.y-h.y,p=a.getState(),m=p.x+d,v=p.y+f;a.setState({x:m,y:v}),this.lastMouseX=l,this.lastMouseY=u,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",tt(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",tt(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var a=Ml(r);if(a){var s=tg(r,this.container);if(this.emit("wheel",s),s.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var l=o.getState().ratio,u=a>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,c=o.getBoundedRatio(l*u),h=a>0?1:-1,d=Date.now();l!==c&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===h&&this.lastWheelTriggerTime&&d-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(Oe(r,this.container),c),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=h,this.lastWheelTriggerTime=d))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Ol),ag=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],sg=ag.reduce(function(t,e){return D(D({},t),{},S({},e,vr[e]))},{}),lg=(function(t){function e(n,r){var i;return le(this,e),i=be(this,e,[n,r]),S(i,"enabled",!0),S(i,"isMoving",!1),S(i,"hasMoved",!1),S(i,"touchMode",0),S(i,"startTouchesPositions",[]),S(i,"lastTouches",[]),S(i,"lastTap",null),S(i,"settings",sg),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),n.addEventListener("touchstart",i.handleStart,{capture:!1}),n.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return xe(e,t),ue(e,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("touchstart",this.handleStart),r.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(r){var i=this;if(this.enabled){r.preventDefault();var o=br(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return Oe(f,i.container)}),this.touchMode===2){var a=dt(this.startTouchesPositions,2),s=a[0],l=s.x,u=s.y,c=a[1],h=c.x,d=c.y;this.startTouchesAngle=Math.atan2(d-u,h-l),this.startTouchesDistance=Math.sqrt(Math.pow(h-l,2)+Math.pow(d-u,2))}this.emit("touchdown",gn(r,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(r){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(r.cancelable&&r.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(r.touches.length===1){this.handleStart(r),r.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),o=i.getState(),a=i.getPreviousState()||{x:0,y:0};i.animate({x:o.x+this.settings.inertiaRatio*(o.x-a.x),y:o.y+this.settings.inertiaRatio*(o.y-a.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",gn(r,this.lastTouches,this.container)),!r.touches.length){var s=Oe(this.lastTouches[0],this.container),l=this.startTouchesPositions[0],u=Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2);if(!r.touches.length&&u<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var c=gn(r,this.lastTouches,this.container);if(this.emit("doubletap",c),this.lastTap=null,!c.sigmaDefaultPrevented){var h=this.renderer.getCamera(),d=h.getBoundedRatio(h.getState().ratio/this.settings.doubleClickZoomingRatio);h.animate(this.renderer.getViewportZoomedState(s,d),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=gn(r,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=br(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=br(r.touches),a=o.map(function(We){return Oe(We,i.container)}),s=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=a;var l=gn(r,s,this.container);if(this.emit("touchmove",l),!l.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=a.some(function(We,en){var Ne=i.startTouchesPositions[en];return Ne&&(We.x!==Ne.x||We.y!==Ne.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var u=this.renderer.getCamera(),c=this.startCameraState,h=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var d=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=d.x,p=d.y,m=this.renderer.viewportToFramedGraph(a[0]),v=m.x,y=m.y;u.setState({x:c.x+f-v,y:c.y+p-y});break}case 2:{var w={x:.5,y:.5,angle:0,ratio:1},k=a[0],_=k.x,L=k.y,R=a[1],P=R.x,z=R.y,F=Math.atan2(z-L,P-_)-this.startTouchesAngle,G=Math.hypot(z-L,P-_)/this.startTouchesDistance,U=u.getBoundedRatio(c.ratio/G);w.ratio=U,w.angle=c.angle+F;var j=this.getDimensions(),Q=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:c}),ge=Math.min(j.width,j.height)-2*h,he=ge/j.width,Be=ge/j.height,Lt=U/ge,Ie=_-ge/2/he,Ge=L-ge/2/Be,Me=[Ie*Math.cos(-w.angle)-Ge*Math.sin(-w.angle),Ge*Math.cos(-w.angle)+Ie*Math.sin(-w.angle)];Ie=Me[0],Ge=Me[1],w.x=Q.x-Ie*Lt,w.y=Q.y+Ge*Lt,u.setState(w);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(Ol);function ug(t){if(Array.isArray(t))return sr(t)}function cg(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function dg(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
332
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ll(t){return ug(t)||cg(t)||Oi(t)||dg()}function hg(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function Qi(t,e){if(t==null)return{};var n,r,i=hg(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}var Dl=(function(){function t(e,n){le(this,t),this.key=e,this.size=n}return ue(t,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),Pl=(function(){function t(){le(this,t),S(this,"width",0),S(this,"height",0),S(this,"cellSize",0),S(this,"columns",0),S(this,"rows",0),S(this,"cells",{})}return ue(t,[{key:"resizeAndClear",value:function(n,r){this.width=n.width,this.height=n.height,this.cellSize=r,this.columns=Math.ceil(n.width/r),this.rows=Math.ceil(n.height/r),this.cells={}}},{key:"getIndex",value:function(n){var r=Math.floor(n.x/this.cellSize),i=Math.floor(n.y/this.cellSize);return i*this.columns+r}},{key:"add",value:function(n,r,i){var o=new Dl(n,r),a=this.getIndex(i),s=this.cells[a];s||(s=[],this.cells[a]=s),s.push(o)}},{key:"organize",value:function(){for(var n in this.cells){var r=this.cells[n];r.sort(Dl.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,o=i/n/n,a=o*r/i,s=Math.ceil(a),l=[];for(var u in this.cells)for(var c=this.cells[u],h=0;h<Math.min(s,c.length);h++)l.push(c[h].key);return l}}])})();function fg(t){var e=t.graph,n=t.hoveredNode,r=t.highlightedNodes,i=t.displayedNodeLabels,o=[];return e.forEachEdge(function(a,s,l,u){(l===n||u===n||r.has(l)||r.has(u)||i.has(l)&&i.has(u))&&o.push(a)}),o}var Il=150,Gl=50,nt=Object.prototype.hasOwnProperty;function pg(t,e,n){if(!nt.call(n,"x")||!nt.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(e,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return n.color||(n.color=t.defaultNodeColor),!n.label&&n.label!==""&&(n.label=null),n.label!==void 0&&n.label!==null?n.label=""+n.label:n.label=null,n.size||(n.size=2),nt.call(n,"hidden")||(n.hidden=!1),nt.call(n,"highlighted")||(n.highlighted=!1),nt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultNodeType),n.zIndex||(n.zIndex=0),n}function gg(t,e,n){return n.color||(n.color=t.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),nt.call(n,"hidden")||(n.hidden=!1),nt.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=t.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var mg=(function(t){function e(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(le(this,e),i=be(this,e),S(i,"elements",{}),S(i,"canvasContexts",{}),S(i,"webGLContexts",{}),S(i,"pickingLayers",new Set),S(i,"textures",{}),S(i,"frameBuffers",{}),S(i,"activeListeners",{}),S(i,"labelGrid",new Pl),S(i,"nodeDataCache",{}),S(i,"edgeDataCache",{}),S(i,"nodeProgramIndex",{}),S(i,"edgeProgramIndex",{}),S(i,"nodesWithForcedLabels",new Set),S(i,"edgesWithForcedLabels",new Set),S(i,"nodeExtent",{x:[0,1],y:[0,1]}),S(i,"nodeZExtent",[1/0,-1/0]),S(i,"edgeZExtent",[1/0,-1/0]),S(i,"matrix",Le()),S(i,"invMatrix",Le()),S(i,"correctionRatio",1),S(i,"customBBox",null),S(i,"normalizationFunction",Xi({x:[0,1],y:[0,1]})),S(i,"graphToViewportRatio",1),S(i,"itemIDsIndex",{}),S(i,"nodeIndices",{}),S(i,"edgeIndices",{}),S(i,"width",0),S(i,"height",0),S(i,"pixelRatio",qi()),S(i,"pickingDownSizingRatio",2*i.pixelRatio),S(i,"displayedNodeLabels",new Set),S(i,"displayedEdgeLabels",new Set),S(i,"highlightedNodes",new Set),S(i,"hoveredNode",null),S(i,"hoveredEdge",null),S(i,"renderFrame",null),S(i,"renderHighlightedNodesFrame",null),S(i,"needToProcess",!1),S(i,"checkEdgesEventsFrame",null),S(i,"nodePrograms",{}),S(i,"nodeHoverPrograms",{}),S(i,"edgePrograms",{}),i.settings=Cl(o),yr(i.settings),Al(n),!(r instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=n,i.container=r,i.createWebGLContext("edges",{picking:o.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var a in i.settings.nodeProgramClasses)i.registerNodeProgram(a,i.settings.nodeProgramClasses[a],i.settings.nodeHoverProgramClasses[a]);for(var s in i.settings.edgeProgramClasses)i.registerEdgeProgram(s,i.settings.edgeProgramClasses[s]);return i.camera=new Nl,i.bindCameraHandlers(),i.mouseCaptor=new og(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new lg(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return xe(e,t),ue(e,[{key:"registerNodeProgram",value:function(r,i,o){return this.nodePrograms[r]&&this.nodePrograms[r].kill(),this.nodeHoverPrograms[r]&&this.nodeHoverPrograms[r].kill(),this.nodePrograms[r]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[r]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(r,i){return this.edgePrograms[r]&&this.edgePrograms[r].kill(),this.edgePrograms[r]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(r){if(this.nodePrograms[r]){var i=this.nodePrograms,o=i[r],a=Qi(i,[r].map(bt));o.kill(),this.nodePrograms=a}if(this.nodeHoverPrograms[r]){var s=this.nodeHoverPrograms,l=s[r],u=Qi(s,[r].map(bt));l.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],a=Qi(i,[r].map(bt));o.kill(),this.edgePrograms=a}return this}},{key:"resetWebGLTexture",value:function(r){var i=this.webGLContexts[r],o=this.frameBuffers[r],a=this.textures[r];a&&i.deleteTexture(a);var s=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,o),i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,s,0),this.textures[r]=s,this}},{key:"bindCameraHandlers",value:function(){var r=this;return this.activeListeners.camera=function(){r.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(r){var i=r.x,o=r.y,a=$i(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),s=zi.apply(void 0,Ll(a)),l=this.itemIDsIndex[s];return l&&l.type==="node"?l.id:null}},{key:"bindEventHandlers",value:function(){var r=this;this.activeListeners.handleResize=function(){r.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var a=pn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}},l=r.getNodeAtPosition(a);if(l&&r.hoveredNode!==l&&!r.nodeDataCache[l].hidden){r.hoveredNode&&r.emit("leaveNode",D(D({},s),{},{node:r.hoveredNode})),r.hoveredNode=l,r.emit("enterNode",D(D({},s),{},{node:l})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(a)!==r.hoveredNode){var u=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",D(D({},s),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var c=r.hoveredNode?null:r.getEdgeAtPoint(s.event.x,s.event.y);c!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",D(D({},s),{},{edge:r.hoveredEdge})),c&&r.emit("enterEdge",D(D({},s),{},{edge:c})),r.hoveredEdge=c)}},this.activeListeners.handleMoveBody=function(o){var a=pn(o);r.emit("moveBody",{event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var a=pn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",D(D({},s),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",D(D({},s),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",D({},s))},this.activeListeners.handleEnter=function(o){var a=pn(o),s={event:a,preventSigmaDefault:function(){a.preventSigmaDefault()}};r.emit("enterStage",D({},s))};var i=function(a){return function(s){var l=pn(s),u={event:l,preventSigmaDefault:function(){l.preventSigmaDefault()}},c=r.getNodeAtPosition(l);if(c)return r.emit("".concat(a,"Node"),D(D({},u),{},{node:c}));if(r.settings.enableEdgeEvents){var h=r.getEdgeAtPoint(l.x,l.y);if(h)return r.emit("".concat(a,"Edge"),D(D({},u),{},{edge:h}))}return r.emit("".concat(a,"Stage"),u)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var r=this,i=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachNode(function(c){return r.updateNode(c)});var u=!l||l.some(function(c){return o.has(c)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!u,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(a){var s,l=(s=a.hints)===null||s===void 0?void 0:s.attributes;r.graph.forEachEdge(function(c){return r.updateEdge(c)});var u=l&&["zIndex","type"].some(function(c){return l?.includes(c)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!u,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(a){var s=a.key;r.addNode(s),r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{nodes:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(a){var s=a.key;r.removeNode(s),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(a){var s=a.key;r.addEdge(s),r.refresh({partialGraph:{edges:[s]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(a){var s=a.key;r.refresh({partialGraph:{edges:[s]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(a){var s=a.key;r.removeEdge(s),r.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){r.clearEdgeState(),r.clearEdgeIndices(),r.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){r.clearEdgeState(),r.clearNodeState(),r.clearEdgeIndices(),r.clearNodeIndices(),r.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var r=this.graph;r.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(r,i){var o=$i(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),a=zi.apply(void 0,Ll(o)),s=this.itemIDsIndex[a];return s&&s.type==="edge"?s.id:null}},{key:"process",value:function(){var r=this;this.emit("beforeProcess");var i=this.graph,o=this.settings,a=this.getDimensions();if(this.nodeExtent=Tl(this.graph),!this.settings.autoRescale){var s=a.width,l=a.height,u=this.nodeExtent,c=u.x,h=u.y;this.nodeExtent={x:[(c[0]+c[1])/2-s/2,(c[0]+c[1])/2+s/2],y:[(h[0]+h[1])/2-l/2,(h[0]+h[1])/2+l/2]}}this.normalizationFunction=Xi(this.customBBox||this.nodeExtent);var d=new Nl,f=Ht(d.getState(),a,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(a,o.labelGridCellSize);for(var p={},m={},v={},y={},w=1,k=i.nodes(),_=0,L=k.length;_<L;_++){var R=k[_],P=this.nodeDataCache[R],z=i.getNodeAttributes(R);P.x=z.x,P.y=z.y,this.normalizationFunction.applyTo(P),typeof P.label=="string"&&!P.hidden&&this.labelGrid.add(R,P.size,this.framedGraphToViewport(P,{matrix:f})),p[P.type]=(p[P.type]||0)+1}this.labelGrid.organize();for(var F in this.nodePrograms){if(!nt.call(this.nodePrograms,F))throw new Error('Sigma: could not find a suitable program for node type "'.concat(F,'"!'));this.nodePrograms[F].reallocate(p[F]||0),p[F]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(k=Yi(this.nodeZExtent,function(tn){return r.nodeDataCache[tn].zIndex},k));for(var G=0,U=k.length;G<U;G++){var j=k[G];m[j]=w,y[m[j]]={type:"node",id:j},w++;var Q=this.nodeDataCache[j];this.addNodeToProgram(j,m[j],p[Q.type]++)}for(var ge={},he=i.edges(),Be=0,Lt=he.length;Be<Lt;Be++){var Ie=he[Be],Ge=this.edgeDataCache[Ie];ge[Ge.type]=(ge[Ge.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(he=Yi(this.edgeZExtent,function(tn){return r.edgeDataCache[tn].zIndex},he));for(var Me in this.edgePrograms){if(!nt.call(this.edgePrograms,Me))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(Me,'"!'));this.edgePrograms[Me].reallocate(ge[Me]||0),ge[Me]=0}for(var We=0,en=he.length;We<en;We++){var Ne=he[We];v[Ne]=w,y[v[Ne]]={type:"edge",id:Ne},w++;var q=this.edgeDataCache[Ne];this.addEdgeToProgram(Ne,v[Ne],ge[q.type]++)}return this.itemIDsIndex=y,this.nodeIndices=m,this.edgeIndices=v,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(c){return i.cleanCameraState(c,o.cameraPanBoundaries&&gr(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==o.edgeProgramClasses){for(var a in o.edgeProgramClasses)o.edgeProgramClasses[a]!==r.edgeProgramClasses[a]&&this.registerEdgeProgram(a,o.edgeProgramClasses[a]);for(var s in r.edgeProgramClasses)o.edgeProgramClasses[s]||this.unregisterEdgeProgram(s)}if(r.nodeProgramClasses!==o.nodeProgramClasses||r.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var l in o.nodeProgramClasses)(o.nodeProgramClasses[l]!==r.nodeProgramClasses[l]||o.nodeHoverProgramClasses[l]!==r.nodeHoverProgramClasses[l])&&this.registerNodeProgram(l,o.nodeProgramClasses[l],o.nodeHoverProgramClasses[l]);for(var u in r.nodeProgramClasses)o.nodeProgramClasses[u]||this.unregisterNodeProgram(u)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.tolerance,a=o===void 0?0:o,s=i.boundaries,l=D({},r),u=s||this.nodeExtent,c=dt(u.x,2),h=c[0],d=c[1],f=dt(u.y,2),p=f[0],m=f[1],v=[this.graphToViewport({x:h,y:p},{cameraState:r}),this.graphToViewport({x:d,y:p},{cameraState:r}),this.graphToViewport({x:h,y:m},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r})],y=1/0,w=-1/0,k=1/0,_=-1/0;v.forEach(function(ge){var he=ge.x,Be=ge.y;y=Math.min(y,he),w=Math.max(w,he),k=Math.min(k,Be),_=Math.max(_,Be)});var L=w-y,R=_-k,P=this.getDimensions(),z=P.width,F=P.height,G=0,U=0;if(L>=z?w<z-a?G=w-(z-a):y>a&&(G=y-a):w>z+a?G=w-(z+a):y<-a&&(G=y+a),R>=F?_<F-a?U=_-(F-a):k>a&&(U=k-a):_>F+a?U=_-(F+a):k<-a&&(U=k+a),G||U){var j=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),Q=this.viewportToFramedGraph({x:G,y:U},{cameraState:r});G=Q.x-j.x,U=Q.y-j.y,l.x+=G,l.y+=U}return l}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var r=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(r.ratio,this.settings.labelDensity);Zi(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,a=0,s=i.length;a<s;a++){var l=i[a],u=this.nodeDataCache[l];if(!this.displayedNodeLabels.has(l)&&!u.hidden){var c=this.framedGraphToViewport(u),h=c.x,d=c.y,f=this.scaleSize(u.size);if(!(!u.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(h<-Il||h>this.width+Il||d<-Gl||d>this.height+Gl)){this.displayedNodeLabels.add(l);var p=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[u.type],v=m?.drawLabel||p;v(o,D(D({key:l},u),{},{size:f,x:h,y:d}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var r=this.canvasContexts.edgeLabels;r.clearRect(0,0,this.width,this.height);var i=fg({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Zi(i,this.edgesWithForcedLabels);for(var o=new Set,a=0,s=i.length;a<s;a++){var l=i[a],u=this.graph.extremities(l),c=this.nodeDataCache[u[0]],h=this.nodeDataCache[u[1]],d=this.edgeDataCache[l];if(!o.has(l)&&!(d.hidden||c.hidden||h.hidden)){var f=this.settings.defaultDrawEdgeLabel,p=this.edgePrograms[d.type],m=p?.drawLabel||f;m(r,D(D({key:l},d),{},{size:this.scaleSize(d.size)}),D(D(D({key:u[0]},c),this.framedGraphToViewport(c)),{},{size:this.scaleSize(c.size)}),D(D(D({key:u[1]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),this.settings),o.add(l)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(f){var p=r.nodeDataCache[f],m=r.framedGraphToViewport(p),v=m.x,y=m.y,w=r.scaleSize(p.size),k=r.settings.defaultDrawNodeHover,_=r.nodePrograms[p.type],L=_?.drawHover||k;L(i,D(D({key:f},p),{},{size:w,x:v,y}),r.settings)},a=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&a.push(this.hoveredNode),this.highlightedNodes.forEach(function(d){d!==r.hoveredNode&&a.push(d)}),a.forEach(function(d){return o(d)});var s={};a.forEach(function(d){var f=r.nodeDataCache[d].type;s[f]=(s[f]||0)+1});for(var l in this.nodeHoverPrograms)this.nodeHoverPrograms[l].reallocate(s[l]||0),s[l]=0;a.forEach(function(d){var f=r.nodeDataCache[d];r.nodeHoverPrograms[f.type].process(0,s[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var u=this.getRenderParams();for(var c in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[c];h.render(u)}}},{key:"scheduleHighlightedNodesRender",value:function(){var r=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){r.renderHighlightedNodesFrame=null,r.renderHighlightedNodes(),r.renderEdgeLabels()}))}},{key:"render",value:function(){var r=this;this.emit("beforeRender");var i=function(){return r.emit("afterRender"),r};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(v){return r.resetWebGLTexture(v)}),!this.graph.order)return i();var o=this.mouseCaptor,a=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,s=this.camera.getState(),l=this.getDimensions(),u=this.getGraphDimensions(),c=this.getStagePadding();this.matrix=Ht(s,l,u,c),this.invMatrix=Ht(s,l,u,c,!0),this.correctionRatio=Sl(this.matrix,s,l),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var d in this.nodePrograms){var f=this.nodePrograms[d];f.render(h)}if(!this.settings.hideEdgesOnMove||!a)for(var p in this.edgePrograms){var m=this.edgePrograms[p];m.render(h)}return this.settings.hideLabelsOnMove&&a||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(r){var i=Object.assign({},this.graph.getNodeAttributes(r));this.settings.nodeReducer&&(i=this.settings.nodeReducer(r,i));var o=pg(this.settings,r,i);this.nodeDataCache[r]=o,this.nodesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(r),this.highlightedNodes.delete(r),o.highlighted&&!o.hidden&&this.highlightedNodes.add(r),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(r){this.addNode(r);var i=this.nodeDataCache[r];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(r){delete this.nodeDataCache[r],delete this.nodeProgramIndex[r],this.highlightedNodes.delete(r),this.hoveredNode===r&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(r)}},{key:"addEdge",value:function(r){var i=Object.assign({},this.graph.getEdgeAttributes(r));this.settings.edgeReducer&&(i=this.settings.edgeReducer(r,i));var o=gg(this.settings,r,i);this.edgeDataCache[r]=o,this.edgesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(r),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(r){this.addEdge(r)}},{key:"removeEdge",value:function(r){delete this.edgeDataCache[r],delete this.edgeProgramIndex[r],this.hoveredEdge===r&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(r)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new Pl,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(r,i,o){var a=this.nodeDataCache[r],s=this.nodePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for node type "'.concat(a.type,'"!'));s.process(i,o,a),this.nodeProgramIndex[r]=o}},{key:"addEdgeToProgram",value:function(r,i,o){var a=this.edgeDataCache[r],s=this.edgePrograms[a.type];if(!s)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(a.type,'"!'));var l=this.graph.extremities(r),u=this.nodeDataCache[l[0]],c=this.nodeDataCache[l[1]];s.process(i,o,u,c,a),this.edgeProgramIndex[r]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var r=this.settings,i=r.stagePadding,o=r.autoRescale;return o&&i||0}},{key:"createLayer",value:function(r,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[r])throw new Error('Sigma: a layer named "'.concat(r,'" already exists'));var a=Rl(i,{position:"absolute"},{class:"sigma-".concat(r)});return o.style&&Object.assign(a.style,o.style),this.elements[r]=a,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(a):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(a):this.container.appendChild(a),a}},{key:"createCanvas",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(r,"canvas",i)}},{key:"createCanvasContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(r,i),a={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[r]=o.getContext("2d",a),this}},{key:"createWebGLContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i?.canvas||this.createCanvas(r,i);i.hidden&&o.remove();var a=D({preserveDrawingBuffer:!1,antialias:!1},i),s;s=o.getContext("webgl2",a),s||(s=o.getContext("webgl",a)),s||(s=o.getContext("experimental-webgl",a));var l=s;if(this.webGLContexts[r]=l,l.blendFunc(l.ONE,l.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var u=l.createFramebuffer();if(!u)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=u}return l}},{key:"killLayer",value:function(r){var i=this.elements[r];if(!i)throw new Error("Sigma: cannot kill layer ".concat(r,", which does not exist"));if(this.webGLContexts[r]){var o,a=this.webGLContexts[r];(o=a.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[r]}else this.canvasContexts[r]&&delete this.canvasContexts[r];return i.remove(),delete this.elements[r],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(r){this.unbindCameraHandlers(),this.camera=r,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(r){r!==this.graph&&(this.hoveredNode&&!r.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!r.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=r,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var r=this.customBBox||this.nodeExtent;return{width:r.x[1]-r.x[0]||1,height:r.y[1]-r.y[0]||1}}},{key:"getNodeDisplayData",value:function(r){var i=this.nodeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(r){var i=this.edgeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return D({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=D({},this.settings);return this.settings[r]=i,yr(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(r,i){return this.setSetting(r,i(this.settings[r])),this}},{key:"setSettings",value:function(r){var i=D({},this.settings);return this.settings=D(D({},this.settings),r),yr(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(r){var i=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=qi(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!r&&i===this.width&&o===this.height)return this;for(var a in this.elements){var s=this.elements[a];s.style.width=this.width+"px",s.style.height=this.height+"px"}for(var l in this.canvasContexts)this.elements[l].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[l].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[l].scale(this.pixelRatio,this.pixelRatio);for(var u in this.webGLContexts){this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px");var c=this.webGLContexts[u];if(c.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(u)){var h=this.textures[u];h&&c.deleteTexture(h)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(r){var i=this,o=r?.skipIndexation!==void 0?r?.skipIndexation:!1,a=r?.schedule!==void 0?r.schedule:!1,s=!r||!r.partialGraph;if(s)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(_){return i.addNode(_)}),this.graph.forEachEdge(function(_){return i.addEdge(_)});else{for(var l,u,c=((l=r.partialGraph)===null||l===void 0?void 0:l.nodes)||[],h=0,d=c?.length||0;h<d;h++){var f=c[h];if(this.updateNode(f),o){var p=this.nodeProgramIndex[f];if(p===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],p)}}for(var m=(r==null||(u=r.partialGraph)===null||u===void 0?void 0:u.edges)||[],v=0,y=m.length;v<y;v++){var w=m[v];if(this.updateEdge(w),o){var k=this.edgeProgramIndex[w];if(k===void 0)throw new Error('Sigma: edge "'.concat(w,`" can't be repaint`));this.addEdgeToProgram(w,this.edgeIndices[w],k)}}}return(s||!o)&&(this.needToProcess=!0),a?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var r=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){r.render()})),this}},{key:"scheduleRefresh",value:function(r){return this.refresh(D(D({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var o=this.camera.getState(),a=o.ratio,s=o.angle,l=o.x,u=o.y,c=this.settings,h=c.minCameraRatio,d=c.maxCameraRatio;typeof d=="number"&&(i=Math.min(i,d)),typeof h=="number"&&(i=Math.max(i,h));var f=i/a,p={x:this.width/2,y:this.height/2},m=this.viewportToFramedGraph(r),v=this.viewportToFramedGraph(p);return{angle:s,x:(m.x-v.x)*(1-f)+l,y:(m.y-v.y)*(1-f)+u,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,a=i.matrix?i.matrix:o?Ht(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,s=pr(a,r);return{x:(1+s.x)*this.width/2,y:(1-s.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,a=i.matrix?i.matrix:o?Ht(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,s=pr(a,{x:r.x/this.width*2-1,y:1-r.y/this.height*2});return isNaN(s.x)&&(s.x=0),isNaN(s.y)&&(s.y=0),s}},{key:"viewportToGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(r,i))}},{key:"graphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(r),i)}},{key:"getGraphToViewportRatio",value:function(){var r={x:0,y:0},i={x:1,y:1},o=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),a=this.graphToViewport(r),s=this.graphToViewport(i),l=Math.sqrt(Math.pow(a.x-s.x,2)+Math.pow(a.y-s.y,2));return l/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(r){return this.customBBox=r,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var r=this.container;r.firstChild;)r.removeChild(r.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var a in this.edgePrograms)this.edgePrograms[a].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var s in this.elements)this.killLayer(s);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return r/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var r={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(r[i]=this.elements[i]);return r}}])})(hr),Fl=mg;function zl(t){let e=+this._x.call(null,t),n=+this._y.call(null,t);return $l(this.cover(e,n),e,n,t)}function $l(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o=t._root,a={data:r},s=t._x0,l=t._y0,u=t._x1,c=t._y1,h,d,f,p,m,v,y,w;if(!o)return t._root=a,t;for(;o.length;)if((m=e>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d,i=o,!(o=o[y=v<<1|m]))return i[y]=a,t;if(f=+t._x.call(null,o.data),p=+t._y.call(null,o.data),e===f&&n===p)return a.next=o,i?i[y]=a:t._root=a,t;do i=i?i[y]=new Array(4):t._root=new Array(4),(m=e>=(h=(s+u)/2))?s=h:u=h,(v=n>=(d=(l+c)/2))?l=d:c=d;while((y=v<<1|m)===(w=(p>=d)<<1|f>=h));return i[w]=o,i[y]=a,t}function Ul(t){var e,n,r=t.length,i,o,a=new Array(r),s=new Array(r),l=1/0,u=1/0,c=-1/0,h=-1/0;for(n=0;n<r;++n)isNaN(i=+this._x.call(null,e=t[n]))||isNaN(o=+this._y.call(null,e))||(a[n]=i,s[n]=o,i<l&&(l=i),i>c&&(c=i),o<u&&(u=o),o>h&&(h=o));if(l>c||u>h)return this;for(this.cover(l,u).cover(c,h),n=0;n<r;++n)$l(this,a[n],s[n],t[n]);return this}function Hl(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a=i-n||1,s=this._root,l,u;n>t||t>=i||r>e||e>=o;)switch(u=(e<r)<<1|t<n,l=new Array(4),l[u]=s,s=l,a*=2,u){case 0:i=n+a,o=r+a;break;case 1:n=i-a,o=r+a;break;case 2:i=n+a,r=o-a;break;case 3:n=i-a,r=o-a;break}this._root&&this._root.length&&(this._root=s)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this}function Bl(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function Wl(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function fe(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function Kl(t,e,n){var r,i=this._x0,o=this._y0,a,s,l,u,c=this._x1,h=this._y1,d=[],f=this._root,p,m;for(f&&d.push(new fe(f,i,o,c,h)),n==null?n=1/0:(i=t-n,o=e-n,c=t+n,h=e+n,n*=n);p=d.pop();)if(!(!(f=p.node)||(a=p.x0)>c||(s=p.y0)>h||(l=p.x1)<i||(u=p.y1)<o))if(f.length){var v=(a+l)/2,y=(s+u)/2;d.push(new fe(f[3],v,y,l,u),new fe(f[2],a,y,v,u),new fe(f[1],v,s,l,y),new fe(f[0],a,s,v,y)),(m=(e>=y)<<1|t>=v)&&(p=d[d.length-1],d[d.length-1]=d[d.length-1-m],d[d.length-1-m]=p)}else{var w=t-+this._x.call(null,f.data),k=e-+this._y.call(null,f.data),_=w*w+k*k;if(_<n){var L=Math.sqrt(n=_);i=t-L,o=e-L,c=t+L,h=e+L,r=f.data}}return r}function Vl(t){if(isNaN(c=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t)))return this;var e,n=this._root,r,i,o,a=this._x0,s=this._y0,l=this._x1,u=this._y1,c,h,d,f,p,m,v,y;if(!n)return this;if(n.length)for(;;){if((p=c>=(d=(a+l)/2))?a=d:l=d,(m=h>=(f=(s+u)/2))?s=f:u=f,e=n,!(n=n[v=m<<1|p]))return this;if(!n.length)break;(e[v+1&3]||e[v+2&3]||e[v+3&3])&&(r=e,y=v)}for(;n.data!==t;)if(i=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,i?(o?i.next=o:delete i.next,this):e?(o?e[v]=o:delete e[v],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[y]=n:this._root=n),this):(this._root=o,this)}function jl(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function ql(){return this._root}function Yl(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function Xl(t){var e=[],n,r=this._root,i,o,a,s,l;for(r&&e.push(new fe(r,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(r=n.node,o=n.x0,a=n.y0,s=n.x1,l=n.y1)&&r.length){var u=(o+s)/2,c=(a+l)/2;(i=r[3])&&e.push(new fe(i,u,c,s,l)),(i=r[2])&&e.push(new fe(i,o,c,u,l)),(i=r[1])&&e.push(new fe(i,u,a,s,c)),(i=r[0])&&e.push(new fe(i,o,a,u,c))}return this}function Zl(t){var e=[],n=[],r;for(this._root&&e.push(new fe(this._root,this._x0,this._y0,this._x1,this._y1));r=e.pop();){var i=r.node;if(i.length){var o,a=r.x0,s=r.y0,l=r.x1,u=r.y1,c=(a+l)/2,h=(s+u)/2;(o=i[0])&&e.push(new fe(o,a,s,c,h)),(o=i[1])&&e.push(new fe(o,c,s,l,h)),(o=i[2])&&e.push(new fe(o,a,h,c,u)),(o=i[3])&&e.push(new fe(o,c,h,l,u))}n.push(r)}for(;r=n.pop();)t(r.node,r.x0,r.y0,r.x1,r.y1);return this}function Ql(t){return t[0]}function Jl(t){return arguments.length?(this._x=t,this):this._x}function eu(t){return t[1]}function tu(t){return arguments.length?(this._y=t,this):this._y}function _t(t,e,n){var r=new Ji(e??Ql,n??eu,NaN,NaN,NaN,NaN);return t==null?r:r.addAll(t)}function Ji(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function nu(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var _e=_t.prototype=Ji.prototype;_e.copy=function(){var t=new Ji(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,r;if(!e)return t;if(!e.length)return t._root=nu(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var i=0;i<4;++i)(r=e.source[i])&&(r.length?n.push({source:r,target:e.target[i]=new Array(4)}):e.target[i]=nu(r));return t};_e.add=zl;_e.addAll=Ul;_e.cover=Hl;_e.data=Bl;_e.extent=Wl;_e.find=Kl;_e.remove=Vl;_e.removeAll=jl;_e.root=ql;_e.size=Yl;_e.visit=Xl;_e.visitAfter=Zl;_e.x=Jl;_e.y=tu;function ae(t){return function(){return t}}function Fe(t){return(t()-.5)*1e-6}function vg(t){return t.x+t.vx}function yg(t){return t.y+t.vy}function eo(t){var e,n,r,i=1,o=1;typeof t!="function"&&(t=ae(t==null?1:+t));function a(){for(var u,c=e.length,h,d,f,p,m,v,y=0;y<o;++y)for(h=_t(e,vg,yg).visitAfter(s),u=0;u<c;++u)d=e[u],m=n[d.index],v=m*m,f=d.x+d.vx,p=d.y+d.vy,h.visit(w);function w(k,_,L,R,P){var z=k.data,F=k.r,G=m+F;if(z){if(z.index>d.index){var U=f-z.x-z.vx,j=p-z.y-z.vy,Q=U*U+j*j;Q<G*G&&(U===0&&(U=Fe(r),Q+=U*U),j===0&&(j=Fe(r),Q+=j*j),Q=(G-(Q=Math.sqrt(Q)))/Q*i,d.vx+=(U*=Q)*(G=(F*=F)/(v+F)),d.vy+=(j*=Q)*G,z.vx-=U*(G=1-G),z.vy-=j*G)}return}return _>f+G||R<f-G||L>p+G||P<p-G}}function s(u){if(u.data)return u.r=n[u.data.index];for(var c=u.r=0;c<4;++c)u[c]&&u[c].r>u.r&&(u.r=u[c].r)}function l(){if(e){var u,c=e.length,h;for(n=new Array(c),u=0;u<c;++u)h=e[u],n[h.index]=+t(h,u,e)}}return a.initialize=function(u,c){e=u,r=c,l()},a.iterations=function(u){return arguments.length?(o=+u,a):o},a.strength=function(u){return arguments.length?(i=+u,a):i},a.radius=function(u){return arguments.length?(t=typeof u=="function"?u:ae(+u),l(),a):t},a}function wg(t){return t.index}function ru(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function to(t){var e=wg,n=h,r,i=ae(30),o,a,s,l,u,c=1;t==null&&(t=[]);function h(v){return 1/Math.min(s[v.source.index],s[v.target.index])}function d(v){for(var y=0,w=t.length;y<c;++y)for(var k=0,_,L,R,P,z,F,G;k<w;++k)_=t[k],L=_.source,R=_.target,P=R.x+R.vx-L.x-L.vx||Fe(u),z=R.y+R.vy-L.y-L.vy||Fe(u),F=Math.sqrt(P*P+z*z),F=(F-o[k])/F*v*r[k],P*=F,z*=F,R.vx-=P*(G=l[k]),R.vy-=z*G,L.vx+=P*(G=1-G),L.vy+=z*G}function f(){if(a){var v,y=a.length,w=t.length,k=new Map(a.map((L,R)=>[e(L,R,a),L])),_;for(v=0,s=new Array(y);v<w;++v)_=t[v],_.index=v,typeof _.source!="object"&&(_.source=ru(k,_.source)),typeof _.target!="object"&&(_.target=ru(k,_.target)),s[_.source.index]=(s[_.source.index]||0)+1,s[_.target.index]=(s[_.target.index]||0)+1;for(v=0,l=new Array(w);v<w;++v)_=t[v],l[v]=s[_.source.index]/(s[_.source.index]+s[_.target.index]);r=new Array(w),p(),o=new Array(w),m()}}function p(){if(a)for(var v=0,y=t.length;v<y;++v)r[v]=+n(t[v],v,t)}function m(){if(a)for(var v=0,y=t.length;v<y;++v)o[v]=+i(t[v],v,t)}return d.initialize=function(v,y){a=v,u=y,f()},d.links=function(v){return arguments.length?(t=v,f(),d):t},d.id=function(v){return arguments.length?(e=v,d):e},d.iterations=function(v){return arguments.length?(c=+v,d):c},d.strength=function(v){return arguments.length?(n=typeof v=="function"?v:ae(+v),p(),d):n},d.distance=function(v){return arguments.length?(i=typeof v=="function"?v:ae(+v),m(),d):i},d}var bg={value:()=>{}};function ou(){for(var t=0,e=arguments.length,n={},r;t<e;++t){if(!(r=arguments[t]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new xr(n)}function xr(t){this._=t}function xg(t,e){return t.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}xr.prototype=ou.prototype={constructor:xr,on:function(t,e){var n=this._,r=xg(t+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(t=r[o]).type)&&(i=_g(n[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<a;)if(i=(t=r[o]).type)n[i]=iu(n[i],t.name,e);else if(e==null)for(i in n)n[i]=iu(n[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new xr(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};function _g(t,e){for(var n=0,r=t.length,i;n<r;++n)if((i=t[n]).name===e)return i.value}function iu(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=bg,t=t.slice(0,r).concat(t.slice(r+1));break}return n!=null&&t.push({name:e,value:n}),t}var no=ou;var Bt=0,vn=0,mn=0,su=1e3,_r,yn,kr=0,kt=0,Er=0,wn=typeof performance=="object"&&performance.now?performance:Date,lu=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function oo(){return kt||(lu(kg),kt=wn.now()+Er)}function kg(){kt=0}function ro(){this._call=this._time=this._next=null}ro.prototype=Sr.prototype={constructor:ro,restart:function(t,e,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?oo():+n)+(e==null?0:+e),!this._next&&yn!==this&&(yn?yn._next=this:_r=this,yn=this),this._call=t,this._time=n,io()},stop:function(){this._call&&(this._call=null,this._time=1/0,io())}};function Sr(t,e,n){var r=new ro;return r.restart(t,e,n),r}function uu(){oo(),++Bt;for(var t=_r,e;t;)(e=kt-t._time)>=0&&t._call.call(void 0,e),t=t._next;--Bt}function au(){kt=(kr=wn.now())+Er,Bt=vn=0;try{uu()}finally{Bt=0,Sg(),kt=0}}function Eg(){var t=wn.now(),e=t-kr;e>su&&(Er-=e,kr=t)}function Sg(){for(var t,e=_r,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:_r=n);yn=t,io(r)}function io(t){if(!Bt){vn&&(vn=clearTimeout(vn));var e=t-kt;e>24?(t<1/0&&(vn=setTimeout(au,t-wn.now()-Er)),mn&&(mn=clearInterval(mn))):(mn||(kr=wn.now(),mn=setInterval(Eg,su)),Bt=1,lu(au))}}function cu(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}function du(t){return t.x}function hu(t){return t.y}var Tg=10,Ag=Math.PI*(3-Math.sqrt(5));function ao(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=Sr(h),u=no("tick","end"),c=cu();t==null&&(t=[]);function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(m){var v,y=t.length,w;m===void 0&&(m=1);for(var k=0;k<m;++k)for(n+=(o-n)*i,s.forEach(function(_){_(n)}),v=0;v<y;++v)w=t[v],w.fx==null?w.x+=w.vx*=a:(w.x=w.fx,w.vx=0),w.fy==null?w.y+=w.vy*=a:(w.y=w.fy,w.vy=0);return e}function f(){for(var m=0,v=t.length,y;m<v;++m){if(y=t[m],y.index=m,y.fx!=null&&(y.x=y.fx),y.fy!=null&&(y.y=y.fy),isNaN(y.x)||isNaN(y.y)){var w=Tg*Math.sqrt(.5+m),k=m*Ag;y.x=w*Math.cos(k),y.y=w*Math.sin(k)}(isNaN(y.vx)||isNaN(y.vy))&&(y.vx=y.vy=0)}}function p(m){return m.initialize&&m.initialize(t,c),m}return f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(m){return arguments.length?(t=m,f(),s.forEach(p),e):t},alpha:function(m){return arguments.length?(n=+m,e):n},alphaMin:function(m){return arguments.length?(r=+m,e):r},alphaDecay:function(m){return arguments.length?(i=+m,e):+i},alphaTarget:function(m){return arguments.length?(o=+m,e):o},velocityDecay:function(m){return arguments.length?(a=1-m,e):1-a},randomSource:function(m){return arguments.length?(c=m,s.forEach(p),e):c},force:function(m,v){return arguments.length>1?(v==null?s.delete(m):s.set(m,p(v)),e):s.get(m)},find:function(m,v,y){var w=0,k=t.length,_,L,R,P,z;for(y==null?y=1/0:y*=y,w=0;w<k;++w)P=t[w],_=m-P.x,L=v-P.y,R=_*_+L*L,R<y&&(z=P,y=R);return z},on:function(m,v){return arguments.length>1?(u.on(m,v),e):u.on(m)}}}function so(){var t,e,n,r,i=ae(-30),o,a=1,s=1/0,l=.81;function u(f){var p,m=t.length,v=_t(t,du,hu).visitAfter(h);for(r=f,p=0;p<m;++p)e=t[p],v.visit(d)}function c(){if(t){var f,p=t.length,m;for(o=new Array(p),f=0;f<p;++f)m=t[f],o[m.index]=+i(m,f,t)}}function h(f){var p=0,m,v,y=0,w,k,_;if(f.length){for(w=k=_=0;_<4;++_)(m=f[_])&&(v=Math.abs(m.value))&&(p+=m.value,y+=v,w+=v*m.x,k+=v*m.y);f.x=w/y,f.y=k/y}else{m=f,m.x=m.data.x,m.y=m.data.y;do p+=o[m.data.index];while(m=m.next)}f.value=p}function d(f,p,m,v){if(!f.value)return!0;var y=f.x-e.x,w=f.y-e.y,k=v-p,_=y*y+w*w;if(k*k/l<_)return _<s&&(y===0&&(y=Fe(n),_+=y*y),w===0&&(w=Fe(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)),e.vx+=y*f.value*r/_,e.vy+=w*f.value*r/_),!0;if(f.length||_>=s)return;(f.data!==e||f.next)&&(y===0&&(y=Fe(n),_+=y*y),w===0&&(w=Fe(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)));do f.data!==e&&(k=o[f.data.index]*r/_,e.vx+=y*k,e.vy+=w*k);while(f=f.next)}return u.initialize=function(f,p){t=f,n=p,c()},u.strength=function(f){return arguments.length?(i=typeof f=="function"?f:ae(+f),c(),u):i},u.distanceMin=function(f){return arguments.length?(a=f*f,u):Math.sqrt(a)},u.distanceMax=function(f){return arguments.length?(s=f*f,u):Math.sqrt(s)},u.theta=function(f){return arguments.length?(l=f*f,u):Math.sqrt(l)},u}function lo(t){var e=ae(.1),n,r,i;typeof t!="function"&&(t=ae(t==null?0:+t));function o(s){for(var l=0,u=n.length,c;l<u;++l)c=n[l],c.vx+=(i[l]-c.x)*r[l]*s}function a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+t(n[s],s,n))?0:+e(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:ae(+s),a(),o):e},o.x=function(s){return arguments.length?(t=typeof s=="function"?s:ae(+s),a(),o):t},o}function uo(t){var e=ae(.1),n,r,i;typeof t!="function"&&(t=ae(t==null?0:+t));function o(s){for(var l=0,u=n.length,c;l<u;++l)c=n[l],c.vy+=(i[l]-c.y)*r[l]*s}function a(){if(n){var s,l=n.length;for(r=new Array(l),i=new Array(l),s=0;s<l;++s)r[s]=isNaN(i[s]=+t(n[s],s,n))?0:+e(n[s],s,n)}}return o.initialize=function(s){n=s,a()},o.strength=function(s){return arguments.length?(e=typeof s=="function"?s:ae(+s),a(),o):e},o.y=function(s){return arguments.length?(t=typeof s=="function"?s:ae(+s),a(),o):t},o}var Rg=9,Tr=6,Ar=18,Cg=32,mu=9,Rr=Rg+mu;function co(t){let e=Number.isFinite(t)&&t>0?t:0,n=Math.min(1,Math.log2(1+e)/Math.log2(1+Cg));return Tr+(Ar-Tr)*n}function ho(t){return t+mu}var Ng=300,vu=1,fu=.001,Lg=90,Dg=.02,Pg=170,Ig=.05,Gg=-50,pu=.09;function gu(t){return t==="contains"||t==="anchored-at"}function Mg(t){let e=Math.trunc(t)>>>0;return()=>(e=(1664525*e+1013904223)%4294967296)/4294967296}function Og(t){let e=[],n=new Set;for(let o of t.nodes)n.has(o.id)||(n.add(o.id),e.push(o.id));let r=[],i=new Set;for(let o of t.edges){if(o.source===o.target||!n.has(o.source)||!n.has(o.target))continue;let a=`${o.source}\0${o.target}\0${o.kind}`;i.has(a)||(i.add(a),r.push(o))}return{ids:e,edges:r}}function fo(t){let e=to(t.links).id(n=>n.id).distance(n=>gu(n.kind)?Lg:Pg).strength(n=>gu(n.kind)?Dg:Ig).iterations(2);return ao(t.nodes).randomSource(Mg(t.seed??vu)).force("charge",so().strength(Gg)).force("link",e).force("collide",eo(n=>n.r??Rr).strength(1)).force("x",lo(0).strength(pu)).force("y",uo(0).strength(pu)).stop()}function Fg(t,e,n){let r=fo({nodes:t,links:e.map(({source:i,target:o,kind:a})=>({source:i,target:o,kind:a})),seed:n.seed}).alpha(n.warm?.3:1).alphaMin(fu).alphaDecay(n.ticks>0?1-Math.pow(fu,1/n.ticks):0);for(let i=0;i<n.ticks;i++)r.tick()}function yu(t,e={}){let n=Math.max(0,Math.trunc(e.ticks??Ng)),{ids:r,edges:i}=Og(t),o=r.map(l=>{let u=e.initial?.get(l),c={id:l,vx:0,vy:0};return u!==void 0&&Number.isFinite(u.x)&&Number.isFinite(u.y)&&(c.x=u.x,c.y=u.y,e.pinWarm===!0&&(c.fx=u.x,c.fy=u.y)),c}),a=new Map;for(let l of i)a.set(l.source,(a.get(l.source)??0)+1),a.set(l.target,(a.get(l.target)??0)+1);for(let l of o)l.r=ho(co(a.get(l.id)??0));o.length>1&&Fg(o,i,{ticks:n,seed:e.seed??vu,warm:e.initial!==void 0});let s=new Map;for(let l of o)s.set(l.id,{x:Number.isFinite(l.x)?l.x:0,y:Number.isFinite(l.y)?l.y:0});return s}function Te(t){if(t.kind==="external"&&t.detail.url){let e=t.detail.url.replace(/^[a-z]+:\/\//,"").replace(/^[^@\/]+@/,"").replace(/\.git$/,"").replace(/\/+$/,"");if(e)return e}return t.kind==="package"&&t.detail.manifest?`${t.label} (${t.detail.manifest})`:t.label}function zg(t){let e=new Map;for(let l of t.nodes)e.set(l.id,l);let n=new Map,r=new Map,i=new Set;for(let l of t.edges){if(l.kind==="contains"){let u=n.get(l.source);u?u.push(l.target):n.set(l.source,[l.target])}if(l.kind==="contains"||l.kind==="anchored-at"){let u=r.get(l.source);u?u.push(l.target):r.set(l.source,[l.target]),i.add(l.target)}}let o=l=>{if(!l.detail.path)return null;let u=l.detail.path,c=null,h=0,d=n.get("repository")??[];for(let f of d){let p=e.get(f);if(p&&p.kind==="module"&&p.detail.path){let m=p.detail.path;u.startsWith(m+"/")&&m.length>h&&(c=f,h=m.length)}}return c},a=new Map;for(let l of t.nodes){if(l.kind!=="entryPoint")continue;let u=o(l);if(u){let c=a.get(u);c?c.push(l.id):a.set(u,[l.id])}}let s=t.nodes.filter(l=>!i.has(l.id)).map(l=>l.id);return{byId:e,contains:n,tree:r,incoming:i,moduleEntries:a,roots:s}}function xu(t){let e=new Set;for(let n of t.edges)(n.kind==="contains"||n.kind==="anchored-at")&&e.add(n.target);return t.nodes.filter(n=>!e.has(n.id)).map(n=>n.id)}function $g(t){return t==="gitState"||t==="external"||t==="package"||t==="entryPoint"}function wu(t){return t?t.kind==="module"||t.id.startsWith("vfolder:"):!1}function Ug(t,e){return t.slice().sort((n,r)=>{let i=e.get(n),o=e.get(r),a=wu(i),s=wu(o);if(a!==s)return a?-1:1;let l=Te(i),u=Te(o);return l.localeCompare(u)})}function bu(t,e,n){let r=Number(t);return Number.isFinite(r)?{kind:"count",n:r,unit:e,phrasing:n}:{kind:"text",text:n==="attribute"?`${e}=${t}`:`${t} ${e}`}}function Hg(t){switch(t.kind){case"note":return t.detail.updated?{kind:"relTime",iso:t.detail.updated}:null;case"module":return t.detail.files?bu(t.detail.files,"files","attribute"):null;case"gitState":return t.detail.commit?{kind:"commit",sha:t.detail.commit}:null;case"repository":return t.detail.files?bu(t.detail.files,"files","prose"):null;case"package":return t.detail.kind?{kind:"text",text:t.detail.kind}:null;case"entryPoint":return t.detail.summary?{kind:"text",text:"summary"}:null;default:return null}}function po(t,e){let n=zg(t),{byId:r,tree:i,moduleEntries:o,roots:a}=n,s=p=>{let y=(i.get(p)??[]).filter(w=>{let k=r.get(w);if(!k||k.kind!=="entryPoint")return!0;for(let[,_]of o)if(_.includes(w))return!1;return!0}).concat(o.get(p)??[]);return y=y.filter(w=>r.has(w)),e.showInternals||(y=y.filter(w=>{let k=r.get(w);return!(k&&$g(k.kind))})),Ug(y,r)},l=e.provFilter!==null||e.query.length>0,u=p=>!(e.provFilter!==null&&p.provenance!==e.provFilter||e.query.length>0&&!Te(p).toLowerCase().includes(e.query.toLowerCase())),c=new Set,h=p=>{let m=r.get(p),v=!1;for(let w of s(p))h(w)&&(v=!0);let y=u(m)||v;return y&&c.add(p),y};for(let p of a)h(p);let d=[],f=(p,m)=>{if(!c.has(p))return;let v=r.get(p),y=s(p),w=y.filter(_=>c.has(_)),k=l?w.length>0:e.expanded.has(p);if(d.push({id:p,depth:m,hasKids:y.length>0,expanded:k,label:Te(v),kind:v.kind,provenance:v.provenance,meta:Hg(v)}),k)for(let _ of w)f(_,m+1)};for(let p of a)f(p,0);return d}function go(t){if(!t.nodes.find(i=>i.kind==="vault"))return null;let n=t.nodes.some(i=>i.kind==="note"),r=t.nodes.some(i=>i.kind==="repository");return!n&&!r?"no notes yet — add one with the weave_note tool":null}function bn(t,e){if(!t)return"";let n=Date.parse(t);if(Number.isNaN(n))return"";let r=Math.max(0,Math.floor((e-n)/1e3));if(r<60)return"just now";let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let o=Math.floor(i/60);if(o<24)return`${o}h ago`;let a=Math.floor(o/24);if(a<30)return`${a}d ago`;let s=Math.floor(a/30);return s<12?`${s}mo ago`:`${Math.floor(s/12)}y ago`}var Bg=7;function mo(t,e){if(t===null)return"";switch(t.kind){case"relTime":return bn(t.iso,e);case"count":return t.phrasing==="attribute"?`${t.unit}=${t.n}`:`${t.n} ${t.unit}`;case"commit":return t.sha.slice(0,Bg);case"text":return t.text}}var Wg=["title","description","path","size","slug","source","updated","created","tags","files","languages","branch","commit","uncommitted changes","captured","manifest","kind","url","summarized files","summarized by","summarized at","summary","dangling links","link references","warning","stale","preview","root","notes","state"];function vo(t,e){let n=new Map;for(let s of t.nodes)n.set(s.id,s);let r=n.get(e);if(!r)return null;let i=[];for(let s of Wg){let l=r.detail[s];l===void 0||l===""||i.push({id:`meta:${s}`,label:s,value:l})}let o=[];for(let s of t.edges){if(s.source!==e)continue;let l=n.get(s.target);l&&o.push({id:`link:${s.kind}:${s.target}`,target:s.target,label:`${s.kind} → ${Te(l)}`,kind:l.kind,provenance:l.provenance,direction:"link"})}let a=[];for(let s of t.edges){if(s.kind!=="links-to"||s.target!==e)continue;let l=n.get(s.source);l&&a.push({id:`backlink:${s.source}`,target:s.source,label:`← ${Te(l)}`,kind:l.kind,provenance:l.provenance,direction:"backlink"})}return{id:e,label:Te(r),kind:r.kind,provenance:r.provenance,meta:i,links:o,backlinks:a}}function yo(t,e){let n=new Set([t]);for(let r of e)r.source===t&&n.add(r.target),r.target===t&&n.add(r.source);return n}var Kg=["contains","anchored-at"];function Vg(t){return Kg.includes(t)}function Cr(t,e){let n=new Map;for(let d of t.nodes)n.set(d.id,d);let r=jg(t,n),i=xu(t),o=new Set,a=d=>{if(!o.has(d)&&(o.add(d),!!e.has(d)))for(let f of r.get(d)??[])a(f)};for(let d of i)a(d);let s=new Map;for(let d of r.keys())s.set(d,qg(d,r));let l=new Map;for(let d of t.nodes)if(!(!o.has(d.id)||e.has(d.id)))for(let f of s.get(d.id)??[])!o.has(f)&&!l.has(f)&&l.set(f,d.id);for(let d of t.nodes)!o.has(d.id)&&!l.has(d.id)&&o.add(d.id);let u=new Map;for(let[d,f]of r){let p=s.get(d);u.set(d,{children:f,descendants:p,members:p.filter(m=>l.get(m)===d),provenance:Yg(p,n),expanded:e.has(d)})}let c=new Set,h=[];for(let d of t.nodes)o.has(d.id)?h.push(d):c.add(d.id);return{nodes:h,edges:Xg(t.edges,o,l),clusters:u,hidden:c,representative:l,roots:i}}function jg(t,e){let n=new Map;for(let r of t.edges){if(!Vg(r.kind)||!e.has(r.source)||!e.has(r.target))continue;let i=n.get(r.source);i===void 0?n.set(r.source,[r.target]):i.includes(r.target)||i.push(r.target)}return n}function qg(t,e){let n=[],r=new Set([t]),i=o=>{for(let a of e.get(o)??[])r.has(a)||(r.add(a),n.push(a),i(a))};return i(t),n}function Yg(t,e){let n={human:0,agent:0,generated:0,none:0};for(let r of t){let i=e.get(r)?.provenance??null;i===null?n.none++:n[i]++}return n}function Xg(t,e,n){let r=a=>e.has(a)?a:n.get(a),i=[],o=new Set;for(let a of t){let s=r(a.source),l=r(a.target);if(s===void 0||l===void 0||s===l)continue;let u=`${s}\0${l}\0${a.kind}`;o.has(u)||(o.add(u),i.push({source:s,target:l,kind:a.kind}))}return i}function wo(t){let e=new Map;for(let n of t){if(n.kind!=="links-to")continue;let r=e.get(n.target);r?r.push(n.source):e.set(n.target,[n.source])}return e}var Wt=[null,"human","agent","generated"];function _u(t=["vault","repository"]){return{expanded:new Set(t),showInternals:!1,provFilter:null,query:""}}function Et(t){return{...t.model,danglingLinks:t.dangling}}function ku(t,e){return t===null?[]:po(Et(t),e)}function _o(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function Qg(t,e){if(t.expanded.has(e))return t;let n=new Set(t.expanded);return n.add(e),{...t,expanded:n}}function Jg(t,e){if(!t.expanded.has(e))return t;let n=new Set(t.expanded);return n.delete(e),{...t,expanded:n}}function ko(t){return t==="vault"?null:t.startsWith("vfolder:")?t.slice(8):void 0}function Lr(t){return t.startsWith("note:")?{type:"note",path:t.slice(5)}:t.startsWith("vfolder:")?{type:"folder",path:t.slice(8)}:null}function Eu(t,e){return t===null?!1:e.type==="note"?t===`note:${e.path}`:t===`vfolder:${e.path}`||t.startsWith(`vfolder:${e.path}/`)||t.startsWith(`note:${e.path}/`)}function Su(t){return t.type==="folder"}function Tu(t,e){return t.query===e?t:{...t,query:e}}function Au(t){let e=Wt.indexOf(t.provFilter),n=Wt[(e+1)%Wt.length]??null;return{...t,provFilter:n}}function Ru(t){return{...t,showInternals:!t.showInternals}}function Dr(t,e){return e===null?-1:t.findIndex(n=>n.id===e)}function xo(t,e){return t[e]?.id??null}function bo(t,e,n){if(t.length===0)return null;let r=Dr(t,e),i=r===-1?n>0?-1:t.length:r;return xo(t,Math.min(t.length-1,Math.max(0,i+n)))}function em(t,e){let n=Dr(t,e),r=n<=0?void 0:t[n];if(r===void 0)return null;for(let i of t.slice(0,n).reverse())if(i.depth<r.depth)return i.id;return null}var tm={j:"ArrowDown",k:"ArrowUp"};function nm(t){return tm[t]??t}function Cu(t,e,n,r,i=!1){let o={state:e,selectedId:n,handled:!1};if(i)return o;let a=h=>({state:e,selectedId:h,handled:!0}),s=nm(r);if(s==="ArrowDown")return a(bo(t,n,1));if(s==="ArrowUp")return a(bo(t,n,-1));if(s==="Home")return a(xo(t,0));if(s==="End")return a(xo(t,t.length-1));if(s!=="ArrowRight"&&s!=="ArrowLeft")return o;let l=Dr(t,n),u=l===-1?void 0:t[l];if(u===void 0||n===null)return o;if(s==="ArrowRight")return u.hasKids?u.expanded?a(bo(t,n,1)):{state:Qg(e,n),selectedId:n,handled:!0}:o;if(u.hasKids&&u.expanded)return{state:Jg(e,n),selectedId:n,handled:!0};let c=em(t,n);return c===null?o:a(c)}var rm={vault:"vault",note:"note",repository:"repository",module:"module",package:"package",entryPoint:"entryPoint",gitState:"gitState",external:"external",file:"file"};function Eo(t){return rm[t]}var im={human:"●",agent:"◐",generated:"○"};function St(t){return t===null?"":im[t]}function Kt(t){return t===null?"":`${t}-authored`}function Nu(t){return`weave-row-${t.replace(/[^A-Za-z0-9_-]/g,"-")}`}function om(t){let e=t.map(()=>({posinset:1,setsize:1})),n=[],r=i=>{for(let o of n.splice(i+1))for(let[a,s]of o.entries())e[s]={posinset:a+1,setsize:o.length}};for(let[i,o]of t.entries()){r(o.depth);let a=n[o.depth];if(a===void 0){for(a=[];n.length<o.depth;)n.push([]);n.push(a)}a.push(i)}return r(-1),e}function am(t,e,n,r={posinset:1,setsize:1}){let i=t.hasKids?t.expanded?"open":"closed":"leaf";return{id:t.id,domId:Nu(t.id),posinset:r.posinset,setsize:r.setsize,depth:t.depth,label:t.label,kind:t.kind,kindIcon:Eo(t.kind),provenance:t.provenance,provenanceGlyph:St(t.provenance),provenanceTitle:Kt(t.provenance),twisty:i,hasKids:t.hasKids,expanded:t.expanded,selected:t.id===e,meta:mo(t.meta,n),level:t.depth+1}}function Lu(t,e,n){let r=om(t);return t.map((i,o)=>am(i,e,n,r[o]))}function Du(t,e){return Dr(t,e)===-1?null:Nu(e)}function Pu(t){return{"--weave-depth":String(Math.max(0,t))}}function Nr(t){return t===null?"all":t}function Iu(t){let e=Wt.indexOf(t),n=Wt[(e+1)%Wt.length]??null;return`provenance filter: ${Nr(t)} — click for ${Nr(n)}`}function Gu(t){return t?"internals":"knowledge"}function Mu(t){return t?"showing git state, packages, externals and entry points — click to hide":"hiding git state, packages, externals and entry points — click to show"}var Ou="filter…",Fu="Vault and repository",zu="Filter the tree",$u="Filter the tree (/)";function Uu(t,e,n){if(t===null)return"loading…";let r=go(Et(t));return r!==null?r:e.length>0?null:n.query.length>0||n.provFilter!==null?"nothing matches this filter — clear it to see the whole vault":"nothing to show"}function Hu(t){return t.length===1?"1 row":`${t.length} rows`}var Pr={dark:{accent:"#c6a0f6",success:"#a6da95",warning:"#eed49f",dim:"#a5adcb",text:"#cad3f5",muted:"#939ab7",line:"#494d64",ground:"#24273a"},light:{accent:"#7113ec",success:"#28641b",warning:"#7c4f10",dim:"#56586a",text:"#4c4f69",muted:"#606274",line:"#bcc0cc",ground:"#eff1f5"}},sm={vault:"accent",note:"text",repository:"accent",module:"dim",package:"dim",entryPoint:"dim",gitState:"dim",external:"dim",file:"dim"},lm={contains:"dim","anchored-at":"dim","links-to":"accent",mentions:"accent"};function um(t,e){return Pr[e][sm[t]]}function Bu(t,e){return Pr[e][lm[t]]}function cm(t,e){return dm(t)?So(Bu(t,e),e,fm):Bu(t,e)}function dm(t){return t==="contains"||t==="anchored-at"}var hm=.85,fm=.3;function pm(t,e,n){let r=l=>/^#[0-9a-f]{6}$/.test(l)?[Number.parseInt(l.slice(1,3),16),Number.parseInt(l.slice(3,5),16),Number.parseInt(l.slice(5,7),16)]:null,i=r(t),o=r(e);if(i===null||o===null)return t;let a=Math.min(1,Math.max(0,Number.isFinite(n)?n:0)),s=(l,u)=>Math.round(l+(u-l)*a).toString(16).padStart(2,"0");return`#${s(i[0],o[0])}${s(i[1],o[1])}${s(i[2],o[2])}`}function So(t,e,n=hm){return pm(t,Pr[e].ground,n)}var gm={contains:1,"anchored-at":1,"links-to":1.4,mentions:1},mm=1.6,Wu=32,vm=Wu/2;function ym(t,e=Wu){if(e<=0)return t.length>0?"…":t;if(t.length<=e)return t;let n=e-1,i=t.slice(0,n).lastIndexOf(" "),o=i>=vm?i:n;return`${t.slice(0,o).trimEnd()}…`}function wm(t){let e=St(t.provenance),n=Te(t);return ym(e===""?n:`${e} ${n}`)}function Ku(t){let e=1/0,n=1/0,r=-1/0,i=-1/0,o=0;for(let a of t)!Number.isFinite(a.x)||!Number.isFinite(a.y)||(o++,a.x<e&&(e=a.x),a.x>r&&(r=a.x),a.y<n&&(n=a.y),a.y>i&&(i=a.y));return o===0?null:{x:[e,r],y:[n,i]}}var Vu={nodes:[],edges:[]};function ju(t){return`${t.source}\0${t.target}\0${t.kind}`}function bm(t,e){let n=new Map,r=new Set;for(let i of t){if(i.source===i.target||!e.has(i.source)||!e.has(i.target))continue;let o=ju(i);r.has(o)||(r.add(o),n.set(i.source,(n.get(i.source)??0)+1),n.set(i.target,(n.get(i.target)??0)+1))}return n}function qu(t,e,n,r){let i=new Map;for(let c of t){if(i.has(c.id))continue;let h=n.get(c.id);h===void 0||!Number.isFinite(h.x)||!Number.isFinite(h.y)||i.set(c.id,c)}let o=new Set(i.keys()),a=bm(e,o),s=[];for(let[c,h]of i){let d=n.get(c),f=co(a.get(c)??0);s.push({id:c,x:d.x,y:d.y,size:f,label:wm(h),color:um(h.kind,r),kind:h.kind,provenance:h.provenance,zIndex:Math.round(f),type:"circle"})}let l=[],u=new Set;for(let c of e){if(c.source===c.target||!o.has(c.source)||!o.has(c.target))continue;let h=ju(c);u.has(h)||(u.add(h),l.push({key:h,source:c.source,target:c.target,size:gm[c.kind],color:cm(c.kind,r),kind:c.kind,zIndex:0,type:"line"}))}return{nodes:s,edges:l}}function Yu(t){return(e,n,r)=>t===null?{}:t.has(e)?{zIndex:n.zIndex+xm}:{color:So(n.color,r),label:null,zIndex:0}}var xm=Ar+1;function Xu(t){return(e,n,r)=>t===null?{}:t.has(n.source)&&t.has(n.target)?{zIndex:1,size:n.size*mm}:{color:So(n.color,r)}}var _m=(Tr+Ar)/2,km=Rr*4,Em=1;function Zu(t){let e=Pr[t];return{hideEdgesOnMove:!0,enableCameraPanning:!0,renderEdgeLabels:!1,labelDensity:Em,labelGridCellSize:km,labelRenderedSizeThreshold:_m,labelFont:"inherit",labelSize:11,labelColor:{color:e.text},defaultNodeColor:e.dim,defaultEdgeColor:e.line,defaultNodeType:"circle",defaultEdgeType:"line",minEdgeThickness:.6,zIndex:!0,itemSizesReference:"positions",zoomToSizeRatioFunction:n=>n,stagePadding:Rr,allowInvalidContainer:!0}}var tc=an(dr(),1);function Sm(){let t=arguments[0];for(let e=1,n=arguments.length;e<n;e++)if(arguments[e])for(let r in arguments[e])t[r]=arguments[e][r];return t}var ce=Sm;typeof Object.assign=="function"&&(ce=Object.assign);function Pe(t,e,n,r){let i=t._nodes.get(e),o=null;return i&&(r==="mixed"?o=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?o=i.out&&i.out[n]:o=i.undirected&&i.undirected[n]),o}function me(t){return typeof t=="object"&&t!==null}function nc(t){let e;for(e in t)return!1;return!0}function De(t,e,n){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:n})}function ze(t,e,n){let r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(t,e,r)}function Qu(t){return!(!me(t)||t.attributes&&!Array.isArray(t.attributes))}function Tm(){let t=Math.floor(Math.random()*256)&255;return()=>t++}function rt(){let t=arguments,e=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(e===null){if(n++,n>=t.length)return{done:!0};e=t[n][Symbol.iterator]()}if(r=e.next(),r.done){e=null;continue}break}while(!0);return r}}}function jt(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var kn=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},N=class t extends kn{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},A=class t extends kn{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}},M=class t extends kn{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,t.prototype.constructor)}};function rc(t,e){this.key=t,this.attributes=e,this.clear()}rc.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 ic(t,e){this.key=t,this.attributes=e,this.clear()}ic.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function oc(t,e){this.key=t,this.attributes=e,this.clear()}oc.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function qt(t,e,n,r,i){this.key=e,this.attributes=i,this.undirected=t,this.source=n,this.target=r}qt.prototype.attach=function(){let t="out",e="in";this.undirected&&(t=e="undirected");let n=this.source.key,r=this.target.key;this.source[t][r]=this,!(this.undirected&&n===r)&&(this.target[e][n]=this)};qt.prototype.attachMulti=function(){let t="out",e="in",n=this.source.key,r=this.target.key;this.undirected&&(t=e="undirected");let i=this.source[t],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[e][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[e][n]=this};qt.prototype.detach=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][e],delete this.target[r][t]};qt.prototype.detachMulti=function(){let t=this.source.key,e=this.target.key,n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][e],delete this.target[r][t]):(this.next.previous=void 0,this.source[n][e]=this.next,this.target[r][t]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var ac=0,sc=1,Am=2,lc=3;function it(t,e,n,r,i,o,a){let s,l,u,c;if(r=""+r,n===ac){if(s=t._nodes.get(r),!s)throw new A(`Graph.${e}: could not find the "${r}" node in the graph.`);u=i,c=o}else if(n===lc){if(i=""+i,l=t._edges.get(i),!l)throw new A(`Graph.${e}: could not find the "${i}" edge in the graph.`);let h=l.source.key,d=l.target.key;if(r===h)s=l.target;else if(r===d)s=l.source;else throw new A(`Graph.${e}: the "${r}" node is not attached to the "${i}" edge (${h}, ${d}).`);u=o,c=a}else{if(l=t._edges.get(r),!l)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`);n===sc?s=l.source:s=l.target,u=i,c=o}return[s,u,c]}function Rm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=it(this,e,n,r,i,o);return a.attributes[s]}}function Cm(t,e,n){t.prototype[e]=function(r,i){let[o]=it(this,e,n,r,i);return o.attributes}}function Nm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=it(this,e,n,r,i,o);return a.attributes.hasOwnProperty(s)}}function Lm(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=it(this,e,n,r,i,o,a);return s.attributes[l]=u,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Dm(t,e,n){t.prototype[e]=function(r,i,o,a){let[s,l,u]=it(this,e,n,r,i,o,a);if(typeof u!="function")throw new N(`Graph.${e}: updater should be a function.`);let c=s.attributes,h=u(c[l]);return c[l]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:l}),this}}function Pm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=it(this,e,n,r,i,o);return delete a.attributes[s],this.emit("nodeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:s}),this}}function Im(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=it(this,e,n,r,i,o);if(!me(s))throw new N(`Graph.${e}: provided attributes are not a plain object.`);return a.attributes=s,this.emit("nodeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function Gm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=it(this,e,n,r,i,o);if(!me(s))throw new N(`Graph.${e}: provided attributes are not a plain object.`);return ce(a.attributes,s),this.emit("nodeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:s}),this}}function Mm(t,e,n){t.prototype[e]=function(r,i,o){let[a,s]=it(this,e,n,r,i,o);if(typeof s!="function")throw new N(`Graph.${e}: provided updater is not a function.`);return a.attributes=s(a.attributes),this.emit("nodeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}var Om=[{name:t=>`get${t}Attribute`,attacher:Rm},{name:t=>`get${t}Attributes`,attacher:Cm},{name:t=>`has${t}Attribute`,attacher:Nm},{name:t=>`set${t}Attribute`,attacher:Lm},{name:t=>`update${t}Attribute`,attacher:Dm},{name:t=>`remove${t}Attribute`,attacher:Pm},{name:t=>`replace${t}Attributes`,attacher:Im},{name:t=>`merge${t}Attributes`,attacher:Gm},{name:t=>`update${t}Attributes`,attacher:Mm}];function Fm(t){Om.forEach(function({name:e,attacher:n}){n(t,e("Node"),ac),n(t,e("Source"),sc),n(t,e("Target"),Am),n(t,e("Opposite"),lc)})}function zm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: 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=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function $m(t,e,n){t.prototype[e]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new M(`Graph.${e}: 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=""+r,a=""+arguments[1];if(i=Pe(this,o,a,n),!i)throw new A(`Graph.${e}: could not find an edge for the given path ("${o}" - "${a}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,i=this._edges.get(r),!i)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function Um(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: 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=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function Hm(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: 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=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=Pe(this,s,l,n),!a)throw new A(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,a=this._edges.get(r),!a)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return a.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function Bm(t,e,n){t.prototype[e]=function(r,i,o){let a;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new M(`Graph.${e}: 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=""+r,l=""+i;if(i=arguments[2],o=arguments[3],a=Pe(this,s,l,n),!a)throw new A(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,a=this._edges.get(r),!a)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new N(`Graph.${e}: updater should be a function.`);return a.attributes[i]=o(a.attributes[i]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}function Wm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: 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=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function Km(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: 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=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!me(i))throw new N(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Vm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: 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=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(!me(i))throw new N(`Graph.${e}: provided attributes are not a plain object.`);return ce(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function jm(t,e,n){t.prototype[e]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new M(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new M(`Graph.${e}: 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=""+r,s=""+i;if(i=arguments[2],o=Pe(this,a,s,n),!o)throw new A(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!=="mixed")throw new M(`Graph.${e}: 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(r=""+r,o=this._edges.get(r),!o)throw new A(`Graph.${e}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new N(`Graph.${e}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var qm=[{name:t=>`get${t}Attribute`,attacher:zm},{name:t=>`get${t}Attributes`,attacher:$m},{name:t=>`has${t}Attribute`,attacher:Um},{name:t=>`set${t}Attribute`,attacher:Hm},{name:t=>`update${t}Attribute`,attacher:Bm},{name:t=>`remove${t}Attribute`,attacher:Wm},{name:t=>`replace${t}Attributes`,attacher:Km},{name:t=>`merge${t}Attributes`,attacher:Vm},{name:t=>`update${t}Attributes`,attacher:jm}];function Ym(t){qm.forEach(function({name:e,attacher:n}){n(t,e("Edge"),"mixed"),n(t,e("DirectedEdge"),"directed"),n(t,e("UndirectedEdge"),"undirected")})}var Xm=[{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 Zm(t,e,n,r){let i=!1;for(let o in e){if(o===r)continue;let a=e[o];if(i=n(a.key,a.attributes,a.source.key,a.target.key,a.source.attributes,a.target.attributes,a.undirected),t&&i)return a.key}}function Qm(t,e,n,r){let i,o,a,s=!1;for(let l in e)if(l!==r){i=e[l];do{if(o=i.source,a=i.target,s=n(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected),t&&s)return i.key;i=i.next}while(i!==void 0)}}function To(t,e){let n=Object.keys(t),r=n.length,i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=r)return{done:!0};let a=n[o++];if(a===e){i=void 0;continue}i=t[a]}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 Jm(t,e,n,r){let i=e[n];if(!i)return;let o=i.source,a=i.target;if(r(i.key,i.attributes,o.key,a.key,o.attributes,a.attributes,i.undirected)&&t)return i.key}function ev(t,e,n,r){let i=e[n];if(!i)return;let o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),t&&o)return i.key;i=i.next}while(i!==void 0)}function Ao(t,e){let n=t[e];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let i={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:i}}};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 tv(t,e){if(t.size===0)return[];if(e==="mixed"||e===t.type)return Array.from(t._edges.keys());let n=e==="undirected"?t.undirectedSize:t.directedSize,r=new Array(n),i=e==="undirected",o=t._edges.values(),a=0,s,l;for(;s=o.next(),s.done!==!0;)l=s.value,l.undirected===i&&(r[a++]=l.key);return r}function uc(t,e,n,r){if(e.size===0)return;let i=n!=="mixed"&&n!==e.type,o=n==="undirected",a,s,l=!1,u=e._edges.values();for(;a=u.next(),a.done!==!0;){if(s=a.value,i&&s.undirected!==o)continue;let{key:c,attributes:h,source:d,target:f}=s;if(l=r(c,h,d.key,f.key,d.attributes,f.attributes,s.undirected),t&&l)return c}}function nv(t,e){if(t.size===0)return jt();let n=e!=="mixed"&&e!==t.type,r=e==="undirected",i=t._edges.values();return{[Symbol.iterator](){return this},next(){let o,a;for(;;){if(o=i.next(),o.done)return o;if(a=o.value,!(n&&a.undirected!==r))break}return{value:{edge:a.key,attributes:a.attributes,source:a.source.key,target:a.target.key,sourceAttributes:a.source.attributes,targetAttributes:a.target.attributes,undirected:a.undirected},done:!1}}}}function Ro(t,e,n,r,i,o){let a=e?Qm:Zm,s;if(n!=="undirected"&&(r!=="out"&&(s=a(t,i.in,o),t&&s)||r!=="in"&&(s=a(t,i.out,o,r?void 0:i.key),t&&s))||n!=="directed"&&(s=a(t,i.undirected,o),t&&s))return s}function rv(t,e,n,r){let i=[];return Ro(!1,t,e,n,r,function(o){i.push(o)}),i}function iv(t,e,n){let r=jt();return t!=="undirected"&&(e!=="out"&&typeof n.in<"u"&&(r=rt(r,To(n.in))),e!=="in"&&typeof n.out<"u"&&(r=rt(r,To(n.out,e?void 0:n.key)))),t!=="directed"&&typeof n.undirected<"u"&&(r=rt(r,To(n.undirected))),r}function Co(t,e,n,r,i,o,a){let s=n?ev:Jm,l;if(e!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(l=s(t,i.in,o,a),t&&l)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(l=s(t,i.out,o,a),t&&l))||e!=="directed"&&typeof i.undirected<"u"&&(l=s(t,i.undirected,o,a),t&&l))return l}function ov(t,e,n,r,i){let o=[];return Co(!1,t,e,n,r,i,function(a){o.push(a)}),o}function av(t,e,n,r){let i=jt();return t!=="undirected"&&(typeof n.in<"u"&&e!=="out"&&r in n.in&&(i=rt(i,Ao(n.in,r))),typeof n.out<"u"&&e!=="in"&&r in n.out&&(e||n.key!==r)&&(i=rt(i,Ao(n.out,r)))),t!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=rt(i,Ao(n.undirected,r))),i}function sv(t,e){let{name:n,type:r,direction:i}=e;t.prototype[n]=function(o,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return tv(this,r);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(typeof s>"u")throw new A(`Graph.${n}: could not find the "${o}" node in the graph.`);return rv(this.multi,r==="mixed"?this.type:r,i,s)}if(arguments.length===2){o=""+o,a=""+a;let s=this._nodes.get(o);if(!s)throw new A(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(a))throw new A(`Graph.${n}: could not find the "${a}" target node in the graph.`);return ov(r,this.multi,i,s,a)}throw new N(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function lv(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,c,h){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return h=u,uc(!1,this,r,h);if(arguments.length===2){u=""+u,h=c;let d=this._nodes.get(u);if(typeof d>"u")throw new A(`Graph.${o}: could not find the "${u}" node in the graph.`);return Ro(!1,this.multi,r==="mixed"?this.type:r,i,d,h)}if(arguments.length===3){u=""+u,c=""+c;let d=this._nodes.get(u);if(!d)throw new A(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new A(`Graph.${o}: could not find the "${c}" target node in the graph.`);return Co(!1,r,this.multi,i,d,c,h)}throw new N(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h;if(u.length===0){let d=0;r!=="directed"&&(d+=this.undirectedSize),r!=="undirected"&&(d+=this.directedSize),h=new Array(d);let f=0;u.push((p,m,v,y,w,k,_)=>{h[f++]=c(p,m,v,y,w,k,_)})}else h=[],u.push((d,f,p,m,v,y,w)=>{h.push(c(d,f,p,m,v,y,w))});return this[o].apply(this,u),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(){let u=Array.prototype.slice.call(arguments),c=u.pop(),h=[];return u.push((d,f,p,m,v,y,w)=>{c(d,f,p,m,v,y,w)&&h.push(d)}),this[o].apply(this,u),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(){let u=Array.prototype.slice.call(arguments);if(u.length<2||u.length>4)throw new N(`Graph.${l}: invalid number of arguments (expecting 2, 3 or 4 and got ${u.length}).`);if(typeof u[u.length-1]=="function"&&typeof u[u.length-2]!="function")throw new N(`Graph.${l}: 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 c,h;u.length===2?(c=u[0],h=u[1],u=[]):u.length===3?(c=u[1],h=u[2],u=[u[0]]):u.length===4&&(c=u[2],h=u[3],u=[u[0],u[1]]);let d=h;return u.push((f,p,m,v,y,w,k)=>{d=c(d,f,p,m,v,y,w,k)}),this[o].apply(this,u),d}}function uv(t,e){let{name:n,type:r,direction:i}=e,o="find"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(l,u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return c=l,uc(!0,this,r,c);if(arguments.length===2){l=""+l,c=u;let h=this._nodes.get(l);if(typeof h>"u")throw new A(`Graph.${o}: could not find the "${l}" node in the graph.`);return Ro(!0,this.multi,r==="mixed"?this.type:r,i,h,c)}if(arguments.length===3){l=""+l,u=""+u;let h=this._nodes.get(l);if(!h)throw new A(`Graph.${o}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(u))throw new A(`Graph.${o}: could not find the "${u}" target node in the graph.`);return Co(!0,r,this.multi,i,h,u,c)}throw new N(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let a="some"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[a]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,f,p,m,v,y)=>u(h,d,f,p,m,v,y)),!!this[o].apply(this,l)};let s="every"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[s]=function(){let l=Array.prototype.slice.call(arguments),u=l.pop();return l.push((h,d,f,p,m,v,y)=>!u(h,d,f,p,m,v,y)),!this[o].apply(this,l)}}function cv(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return jt();if(!arguments.length)return nv(this,r);if(arguments.length===1){a=""+a;let l=this._nodes.get(a);if(!l)throw new A(`Graph.${o}: could not find the "${a}" node in the graph.`);return iv(r,i,l)}if(arguments.length===2){a=""+a,s=""+s;let l=this._nodes.get(a);if(!l)throw new A(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new A(`Graph.${o}: could not find the "${s}" target node in the graph.`);return av(r,i,l,s)}throw new N(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function dv(t){Xm.forEach(e=>{sv(t,e),lv(t,e),uv(t,e),cv(t,e)})}var hv=[{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 $r(){this.A=null,this.B=null}$r.prototype.wrap=function(t){this.A===null?this.A=t:this.B===null&&(this.B=t)};$r.prototype.has=function(t){return this.A!==null&&t in this.A||this.B!==null&&t in this.B};function xn(t,e,n,r,i){for(let o in r){let a=r[o],s=a.source,l=a.target,u=s===n?l:s;if(e&&e.has(u.key))continue;let c=i(u.key,u.attributes);if(t&&c)return u.key}}function No(t,e,n,r,i){if(e!=="mixed"){if(e==="undirected")return xn(t,null,r,r.undirected,i);if(typeof n=="string")return xn(t,null,r,r[n],i)}let o=new $r,a;if(e!=="undirected"){if(n!=="out"){if(a=xn(t,null,r,r.in,i),t&&a)return a;o.wrap(r.in)}if(n!=="in"){if(a=xn(t,o,r,r.out,i),t&&a)return a;o.wrap(r.out)}}if(e!=="directed"&&(a=xn(t,o,r,r.undirected,i),t&&a))return a}function fv(t,e,n){if(t!=="mixed"){if(t==="undirected")return Object.keys(n.undirected);if(typeof e=="string")return Object.keys(n[e])}let r=[];return No(!1,t,e,n,function(i){r.push(i)}),r}function _n(t,e,n){let r=Object.keys(n),i=r.length,o=0;return{[Symbol.iterator](){return this},next(){let a=null;do{if(o>=i)return t&&t.wrap(n),{done:!0};let s=n[r[o++]],l=s.source,u=s.target;if(a=l===e?u:l,t&&t.has(a.key)){a=null;continue}}while(a===null);return{done:!1,value:{neighbor:a.key,attributes:a.attributes}}}}}function pv(t,e,n){if(t!=="mixed"){if(t==="undirected")return _n(null,n,n.undirected);if(typeof e=="string")return _n(null,n,n[e])}let r=jt(),i=new $r;return t!=="undirected"&&(e!=="out"&&(r=rt(r,_n(i,n,n.in))),e!=="in"&&(r=rt(r,_n(i,n,n.out)))),t!=="directed"&&(r=rt(r,_n(i,n,n.undirected))),r}function gv(t,e){let{name:n,type:r,direction:i}=e;t.prototype[n]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];o=""+o;let a=this._nodes.get(o);if(typeof a>"u")throw new A(`Graph.${n}: could not find the "${o}" node in the graph.`);return fv(r==="mixed"?this.type:r,i,a)}}function mv(t,e){let{name:n,type:r,direction:i}=e,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);t.prototype[o]=function(u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let h=this._nodes.get(u);if(typeof h>"u")throw new A(`Graph.${o}: could not find the "${u}" node in the graph.`);No(!1,r==="mixed"?this.type:r,i,h,c)};let a="map"+n[0].toUpperCase()+n.slice(1);t.prototype[a]=function(u,c){let h=[];return this[o](u,(d,f)=>{h.push(c(d,f))}),h};let s="filter"+n[0].toUpperCase()+n.slice(1);t.prototype[s]=function(u,c){let h=[];return this[o](u,(d,f)=>{c(d,f)&&h.push(d)}),h};let l="reduce"+n[0].toUpperCase()+n.slice(1);t.prototype[l]=function(u,c,h){if(arguments.length<3)throw new N(`Graph.${l}: 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 d=h;return this[o](u,(f,p)=>{d=c(d,f,p)}),d}}function vv(t,e){let{name:n,type:r,direction:i}=e,o=n[0].toUpperCase()+n.slice(1,-1),a="find"+o;t.prototype[a]=function(u,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let h=this._nodes.get(u);if(typeof h>"u")throw new A(`Graph.${a}: could not find the "${u}" node in the graph.`);return No(!0,r==="mixed"?this.type:r,i,h,c)};let s="some"+o;t.prototype[s]=function(u,c){return!!this[a](u,c)};let l="every"+o;t.prototype[l]=function(u,c){return!this[a](u,(d,f)=>!c(d,f))}}function yv(t,e){let{name:n,type:r,direction:i}=e,o=n.slice(0,-1)+"Entries";t.prototype[o]=function(a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return jt();a=""+a;let s=this._nodes.get(a);if(typeof s>"u")throw new A(`Graph.${o}: could not find the "${a}" node in the graph.`);return pv(r==="mixed"?this.type:r,i,s)}}function wv(t){hv.forEach(e=>{gv(t,e),mv(t,e),vv(t,e),yv(t,e)})}function Ir(t,e,n,r,i){let o=r._nodes.values(),a=r.type,s,l,u,c,h,d,f;for(;s=o.next(),s.done!==!0;){let p=!1;if(l=s.value,a!=="undirected"){c=l.out;for(u in c){h=c[u];do{if(d=h.target,p=!0,f=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(a!=="directed"){c=l.undirected;for(u in c)if(!(e&&l.key>u)){h=c[u];do{if(d=h.target,d.key!==u&&(d=h.source),p=!0,f=i(l.key,d.key,l.attributes,d.attributes,h.key,h.attributes,h.undirected),t&&f)return h;h=h.next}while(h)}}if(n&&!p&&(f=i(l.key,null,l.attributes,null,null,null,null),t&&f))return null}}function bv(t,e){let n={key:t};return nc(e.attributes)||(n.attributes=ce({},e.attributes)),n}function xv(t,e,n){let r={key:e,source:n.source.key,target:n.target.key};return nc(n.attributes)||(r.attributes=ce({},n.attributes)),t==="mixed"&&n.undirected&&(r.undirected=!0),r}function _v(t){if(!me(t))throw new N('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new N("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!me(t.attributes)||t.attributes===null))throw new N("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function kv(t){if(!me(t))throw new N('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new N("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new N("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!me(t.attributes)||t.attributes===null))throw new N("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&typeof t.undirected!="boolean")throw new N("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var Ev=Tm(),Sv=new Set(["directed","undirected","mixed"]),Ju=new Set(["domain","_events","_eventsCount","_maxListeners"]),Tv=[{name:t=>`${t}Edge`,generateKey:!0},{name:t=>`${t}DirectedEdge`,generateKey:!0,type:"directed"},{name:t=>`${t}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:t=>`${t}EdgeWithKey`},{name:t=>`${t}DirectedEdgeWithKey`,type:"directed"},{name:t=>`${t}UndirectedEdgeWithKey`,type:"undirected"}],Av={allowSelfLoops:!0,multi:!1,type:"mixed"};function Rv(t,e,n){if(n&&!me(n))throw new N(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(e=""+e,n=n||{},t._nodes.has(e))throw new M(`Graph.addNode: the "${e}" node already exist in the graph.`);let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function ec(t,e,n){let r=new t.NodeDataClass(e,n);return t._nodes.set(e,r),t.emit("nodeAdded",{key:e,attributes:n}),r}function cc(t,e,n,r,i,o,a,s){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!me(s))throw new N(`Graph.${e}: invalid attributes. Expecting an object but got "${s}"`);if(o=""+o,a=""+a,s=s||{},!t.allowSelfLoops&&o===a)throw new M(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=t._nodes.get(o),u=t._nodes.get(a);if(!l)throw new A(`Graph.${e}: source node "${o}" not found.`);if(!u)throw new A(`Graph.${e}: target node "${a}" not found.`);let c={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!t.multi&&(r?typeof l.undirected[a]<"u":typeof l.out[a]<"u"))throw new M(`Graph.${e}: an edge linking "${o}" to "${a}" 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 h=new qt(r,i,l,u,s);t._edges.set(i,h);let d=o===a;return r?(l.undirectedDegree++,u.undirectedDegree++,d&&(l.undirectedLoops++,t._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,d&&(l.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),r?t._undirectedSize++:t._directedSize++,c.key=i,t.emit("edgeAdded",c),i}function Cv(t,e,n,r,i,o,a,s,l){if(!r&&t.type==="undirected")throw new M(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&t.type==="directed")throw new M(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(l){if(typeof s!="function")throw new N(`Graph.${e}: invalid updater function. Expecting a function but got "${s}"`)}else if(!me(s))throw new N(`Graph.${e}: invalid attributes. Expecting an object but got "${s}"`)}o=""+o,a=""+a;let u;if(l&&(u=s,s=void 0),!t.allowSelfLoops&&o===a)throw new M(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=t._nodes.get(o),h=t._nodes.get(a),d,f;if(!n&&(d=t._edges.get(i),d)){if((d.source.key!==o||d.target.key!==a)&&(!r||d.source.key!==a||d.target.key!==o))throw new M(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${a}" target vs. ("${d.source.key}", "${d.target.key}").`);f=d}if(!f&&!t.multi&&c&&(f=r?c.undirected[a]:c.out[a]),f){let w=[f.key,!1,!1,!1];if(l?!u:!s)return w;if(l){let k=f.attributes;f.attributes=u(k),t.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else ce(f.attributes,s),t.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return w}s=s||{},l&&u&&(s=u(s));let p={key:null,undirected:r,source:o,target:a,attributes:s};if(n)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new M(`Graph.${e}: the "${i}" edge already exists in the graph.`);let m=!1,v=!1;c||(c=ec(t,o,{}),m=!0,o===a&&(h=c,v=!0)),h||(h=ec(t,a,{}),v=!0),d=new qt(r,i,c,h,s),t._edges.set(i,d);let y=o===a;return r?(c.undirectedDegree++,h.undirectedDegree++,y&&(c.undirectedLoops++,t._undirectedSelfLoopCount++)):(c.outDegree++,h.inDegree++,y&&(c.directedLoops++,t._directedSelfLoopCount++)),t.multi?d.attachMulti():d.attach(),r?t._undirectedSize++:t._directedSize++,p.key=i,t.emit("edgeAdded",p),[i,!0,m,v]}function Vt(t,e){t._edges.delete(e.key);let{source:n,target:r,attributes:i}=e,o=e.undirected,a=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,a&&(n.undirectedLoops--,t._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,a&&(n.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),o?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:i,source:n.key,target:r.key,undirected:o})}var K=class t extends tc.EventEmitter{constructor(e){if(super(),e=ce({},Av,e),typeof e.multi!="boolean")throw new N(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Sv.has(e.type))throw new N(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new N(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let n=e.type==="mixed"?rc:e.type==="directed"?ic:oc;De(this,"NodeDataClass",n);let r="geid_"+Ev()+"_",i=0,o=()=>{let a;do a=r+i++;while(this._edges.has(a));return a};De(this,"_attributes",{}),De(this,"_nodes",new Map),De(this,"_edges",new Map),De(this,"_directedSize",0),De(this,"_undirectedSize",0),De(this,"_directedSelfLoopCount",0),De(this,"_undirectedSelfLoopCount",0),De(this,"_edgeKeyGenerator",o),De(this,"_options",e),Ju.forEach(a=>De(this,a,this[a])),ze(this,"order",()=>this._nodes.size),ze(this,"size",()=>this._edges.size),ze(this,"directedSize",()=>this._directedSize),ze(this,"undirectedSize",()=>this._undirectedSize),ze(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ze(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ze(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ze(this,"multi",this._options.multi),ze(this,"type",this._options.type),ze(this,"allowSelfLoops",this._options.allowSelfLoops),ze(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,n){if(this.type==="undirected")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.out.hasOwnProperty(n):!1}throw new N(`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,n){if(this.type==="directed")return!1;if(arguments.length===1){let r=""+e,i=this._edges.get(r);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?r.undirected.hasOwnProperty(n):!1}throw new N(`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,n){if(arguments.length===1){let r=""+e;return this._edges.has(r)}else if(arguments.length===2){e=""+e,n=""+n;let r=this._nodes.get(e);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new N(`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,n){if(this.type==="undirected")return;if(e=""+e,n=""+n,this.multi)throw new M("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");let r=this._nodes.get(e);if(!r)throw new A(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new A(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);let i=r.out&&r.out[n]||void 0;if(i)return i.key}undirectedEdge(e,n){if(this.type==="directed")return;if(e=""+e,n=""+n,this.multi)throw new M("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");let r=this._nodes.get(e);if(!r)throw new A(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new A(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);let i=r.undirected&&r.undirected[n]||void 0;if(i)return i.key}edge(e,n){if(this.multi)throw new M("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(n))throw new A(`Graph.edge: could not find the "${n}" target node in the graph.`);let i=r.out&&r.out[n]||r.undirected&&r.undirected[n]||void 0;if(i)return i.key}areDirectedNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(e,n){e=""+e,n=""+n;let r=this._nodes.get(e);if(!r)throw new A(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.degree: could not find the "${e}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree,i+=n.directedLoops),r-i}outboundDegreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.outDegree,i+=n.directedLoops),r-i}degreeWithoutSelfLoops(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree,i+=n.directedLoops*2),r-i}source(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.source: could not find the "${e}" edge in the graph.`);return n.source.key}target(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.target: could not find the "${e}" edge in the graph.`);return n.target.key}extremities(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(e,n){e=""+e,n=""+n;let r=this._edges.get(n);if(!r)throw new A(`Graph.opposite: could not find the "${n}" edge in the graph.`);let i=r.source.key,o=r.target.key;if(e===i)return o;if(e===o)return i;throw new A(`Graph.opposite: the "${e}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(e,n){e=""+e,n=""+n;let r=this._edges.get(e);if(!r)throw new A(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return n.undirected}isDirected(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!n.undirected}isSelfLoop(e){e=""+e;let n=this._edges.get(e);if(!n)throw new A(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return n.source===n.target}addNode(e,n){return Rv(this,e,n).key}mergeNode(e,n){if(n&&!me(n))throw new N(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);e=""+e,n=n||{};let r=this._nodes.get(e);return r?(n&&(ce(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:r.attributes,data:n})),[e,!1]):(r=new this.NodeDataClass(e,n),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:n}),[e,!0])}updateNode(e,n){if(n&&typeof n!="function")throw new N(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);e=""+e;let r=this._nodes.get(e);if(r){if(n){let o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:r.attributes})}return[e,!1]}let i=n?n({}):{};return r=new this.NodeDataClass(e,i),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;let n=this._nodes.get(e);if(!n)throw new A(`Graph.dropNode: could not find the "${e}" node in the graph.`);let r;if(this.type!=="undirected"){for(let i in n.out){r=n.out[i];do Vt(this,r),r=r.next;while(r)}for(let i in n.in){r=n.in[i];do Vt(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(let i in n.undirected){r=n.undirected[i];do Vt(this,r),r=r.next;while(r)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:n.attributes})}dropEdge(e){let n;if(arguments.length>1){let r=""+arguments[0],i=""+arguments[1];if(n=Pe(this,r,i,this.type),!n)throw new A(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(e=""+e,n=this._edges.get(e),!n)throw new A(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return Vt(this,n),this}dropDirectedEdge(e,n){if(arguments.length<2)throw new M("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 M("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,n=""+n;let r=Pe(this,e,n,"directed");if(!r)throw new A(`Graph.dropDirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return Vt(this,r),this}dropUndirectedEdge(e,n){if(arguments.length<2)throw new M("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 M("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 r=Pe(this,e,n,"undirected");if(!r)throw new A(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${n}" edge in the graph.`);return Vt(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),n;for(;n=e.next(),n.done!==!0;)n.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,n){return this._attributes[e]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,n){if(typeof n!="function")throw new N("Graph.updateAttribute: updater should be a function.");let r=this._attributes[e];return this._attributes[e]=n(r),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(!me(e))throw new N("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(!me(e))throw new N("Graph.mergeAttributes: provided attributes are not a plain object.");return ce(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new N("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,n){if(typeof e!="function")throw new N("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!Qu(n))throw new N("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._nodes.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(e,n){if(typeof e!="function")throw new N("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!Qu(n))throw new N("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let r=this._edges.values(),i,o,a,s;for(;i=r.next(),i.done!==!0;)o=i.value,a=o.source,s=o.target,o.attributes=e(o.key,o.attributes,a.key,s.key,a.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new N("Graph.forEachAdjacencyEntry: expecting a callback.");Ir(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new N("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Ir(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new N("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Ir(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new N("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Ir(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new N("Graph.forEachNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new N("Graph.findNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new N("Graph.mapNode: expecting a callback.");let n=this._nodes.values(),r,i,o=new Array(this.order),a=0;for(;r=n.next(),r.done!==!0;)i=r.value,o[a++]=e(i.key,i.attributes);return o}someNode(e){if(typeof e!="function")throw new N("Graph.someNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new N("Graph.everyNode: expecting a callback.");let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new N("Graph.filterNodes: expecting a callback.");let n=this._nodes.values(),r,i,o=[];for(;r=n.next(),r.done!==!0;)i=r.value,e(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(e,n){if(typeof e!="function")throw new N("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new N("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 r=n,i=this._nodes.values(),o,a;for(;o=i.next(),o.done!==!0;)a=o.value,r=e(r,a.key,a.attributes);return r}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let n=e.next();if(n.done)return n;let r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){let e=new Array(this._nodes.size),n=0;this._nodes.forEach((i,o)=>{e[n++]=bv(o,i)});let r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=xv(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:r}}import(e,n=!1){if(e instanceof t)return e.forEachNode((l,u)=>{n?this.mergeNode(l,u):this.addNode(l,u)}),e.forEachEdge((l,u,c,h,d,f,p)=>{n?p?this.mergeUndirectedEdgeWithKey(l,c,h,u):this.mergeDirectedEdgeWithKey(l,c,h,u):p?this.addUndirectedEdgeWithKey(l,c,h,u):this.addDirectedEdgeWithKey(l,c,h,u)}),this;if(!me(e))throw new N("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!me(e.attributes))throw new N("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let r,i,o,a,s;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new N("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],_v(a);let{key:l,attributes:u}=a;n?this.mergeNode(l,u):this.addNode(l,u)}}if(e.edges){let l=!1;if(this.type==="undirected"&&(l=!0),o=e.edges,!Array.isArray(o))throw new N("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],kv(s);let{source:u,target:c,attributes:h,undirected:d=l}=s,f;"key"in s?(f=n?d?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:d?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,u,c,h)):(f=n?d?this.mergeUndirectedEdge:this.mergeDirectedEdge:d?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,u,c,h))}}return this}nullCopy(e){let n=new t(ce({},this._options,e));return n.replaceAttributes(ce({},this.getAttributes())),n}emptyCopy(e){let n=this.nullCopy(e);return this._nodes.forEach((r,i)=>{let o=ce({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new M(`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 M("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 M("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 n=this.emptyCopy(e),r=this._edges.values(),i,o;for(;i=r.next(),i.done!==!0;)o=i.value,cc(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,ce({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let e={};this._nodes.forEach((o,a)=>{e[a]=o.attributes});let n={},r={};this._edges.forEach((o,a)=>{let s=o.undirected?"--":"->",l="",u=o.source.key,c=o.target.key,h;o.undirected&&u>c&&(h=u,u=c,c=h);let d=`(${u})${s}(${c})`;a.startsWith("geid_")?this.multi&&(typeof r[d]>"u"?r[d]=0:r[d]++,l+=`${r[d]}. `):l+=`[${a}]: `,l+=d,n[l]=o.attributes});let i={};for(let o in this)this.hasOwnProperty(o)&&!Ju.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=e,i.edges=n,De(i,"constructor",this.constructor),i}};typeof Symbol<"u"&&(K.prototype[Symbol.for("nodejs.util.inspect.custom")]=K.prototype.inspect);Tv.forEach(t=>{["add","merge","update"].forEach(e=>{let n=t.name(e),r=e==="add"?cc:Cv;t.generateKey?K.prototype[n]=function(i,o,a){return r(this,n,!0,(t.type||this.type)==="undirected",null,i,o,a,e==="update")}:K.prototype[n]=function(i,o,a,s){return r(this,n,!1,(t.type||this.type)==="undirected",i,o,a,s,e==="update")}})});Fm(K);Ym(K);dv(K);wv(K);var Gr=class extends K{constructor(e){let n=ce({type:"directed"},e);if("multi"in n&&n.multi!==!1)throw new N("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new N('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Mr=class extends K{constructor(e){let n=ce({type:"undirected"},e);if("multi"in n&&n.multi!==!1)throw new N("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new N('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},Or=class extends K{constructor(e){let n=ce({multi:!0},e);if("multi"in n&&n.multi!==!0)throw new N("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}},Fr=class extends K{constructor(e){let n=ce({type:"directed",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new N("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new N('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}},zr=class extends K{constructor(e){let n=ce({type:"undirected",multi:!0},e);if("multi"in n&&n.multi!==!0)throw new N("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new N('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}};function Yt(t){t.from=function(e,n){let r=ce({},e.options,n),i=new t(r);return i.import(e),i}}Yt(K);Yt(Gr);Yt(Mr);Yt(Or);Yt(Fr);Yt(zr);K.Graph=K;K.DirectedGraph=Gr;K.UndirectedGraph=Mr;K.MultiGraph=Or;K.MultiDirectedGraph=Fr;K.MultiUndirectedGraph=zr;K.InvalidArgumentsGraphError=N;K.NotFoundGraphError=A;K.UsageGraphError=M;function Nv(){return new K({multi:!0,type:"directed"})}function Lo(t){let e=Nv();for(let n of t.nodes){let{id:r,...i}=n;e.addNode(r,i)}for(let n of t.edges){let{key:r,source:i,target:o,...a}=n;e.addDirectedEdgeWithKey(r,i,o,{source:i,target:o,...a})}return e}function dc(t,e){let n=0;for(let[r,i]of e)t.hasNode(r)&&(!Number.isFinite(i.x)||!Number.isFinite(i.y)||(t.mergeNodeAttributes(r,{x:i.x,y:i.y}),n++));return n}function Do(t){let e=new Map;return t.forEachNode((n,r)=>{e.set(n,{x:r.x,y:r.y})}),e}function hc(t,e){let n=null,r=Lo({nodes:[],edges:[]}),i=null,o=()=>{},a=()=>{},s=()=>{},l=()=>{},u=null,c=f=>{if(u===null)return;let p=u;u=null,n?.setSetting("enableCameraPanning",!0),(f===null||f===p)&&l(p)},h=()=>Ku([...Do(r).values()]),d=f=>{let p=Yu(i),m=Xu(i);f.setSetting("nodeReducer",(v,y)=>({...y,...p(v,y,e)})),f.setSetting("edgeReducer",(v,y)=>({...y,...m(v,y,e)}))};return{mount(f){if(n!==null)return;let p=t(r,f,Zu(e));p.on("clickNode",({node:m})=>o(m)),p.on("clickStage",()=>o(null)),p.on("downNode",({node:m})=>{u=m,n?.setSetting("enableCameraPanning",!1),a(m)}),p.on("moveBody",m=>{u!==null&&(m.preventSigmaDefault(),s(u,p.viewportToGraph({x:m.event.x,y:m.event.y})))}),p.on("upNode",()=>c(u)),p.on("upStage",()=>c(null)),d(p),p.setCustomBBox(h()),n=p},setGraph(f){r=Lo(f),n?.setGraph(r),n?.setCustomBBox(h())},setPositions(f){dc(r,f),n?.refresh()},setHighlight(f){i=f,n!==null&&d(n)},onSelect(f){o=f},onDragStart(f){a=f},onDragMove(f){s=f},onDragEnd(f){l=f},fit(){n?.setCustomBBox(h()),n?.getCamera().animatedReset()},positions(){return Do(r)},destroy(){n?.kill(),n=null}}}var fc=t=>hc((e,n,r)=>new Fl(e,n,r),t);var pc=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(",");function gc(t,e,n){return t===0?null:t===1?0:e<0?n?t-1:0:n?e===0?t-1:e-1:e===t-1?0:e+1}function mc(t,e,n,r){return t==="Tab"&&!e&&!n&&!r}function vc(t){return t===null?!1:(t.focus(),!0)}function Ur(){let t=ee(null);return oe(()=>{let e=document.activeElement;return t.current?.focus(),()=>{vc(e instanceof HTMLElement?e:null)}},[]),{ref:t,onKeyDown(e){if(!mc(e.key,e.ctrlKey,e.metaKey,e.altKey))return!1;let n=[...t.current?.querySelectorAll(pc)??[]],r=gc(n.length,n.indexOf(document.activeElement),e.shiftKey);return r===null?!1:(e.preventDefault(),n[r]?.focus(),!0)}}}function bc(t,e){let n=e.trim().toLowerCase();if(!n)return 0;let r=t.toLowerCase(),i=r.indexOf(n);return i<0?0:r===n?100:i===0?70:/[a-z0-9]/.test(r.charAt(i-1))?30:50}function Lv(t){return Math.min(Math.max(t,0),10)*2}function Dv(t){return`note:${t}`}function Pv(t,e){return bc(t.summary.title,e)+Lv(t.score)}function Iv(t,e){return bc(t.label,e)}var Gv=["path","manifest","url","slug"];function Mv(t){for(let e of Gv){let n=t.detail[e];if(typeof n=="string"&&n)return n}return""}function Ov(t,e){return t.score!==e.score?e.score-t.score:t.kind!==e.kind?t.kind==="note"?-1:1:t.label.localeCompare(e.label)||t.id.localeCompare(e.id)}function Fv(t,e,n,r){let i=new Map;for(let o of t){let a=Dv(o.summary.slug);i.set(a,{id:a,kind:"note",label:o.summary.title,detail:o.snippet,badge:"note",score:Pv(o,e)})}for(let o of n){if(i.has(o.id))continue;let a=Iv(o,r);a&&i.set(o.id,{id:o.id,kind:"node",label:o.label,detail:Mv(o),badge:o.kind,score:a})}return[...i.values()].sort(Ov).slice(0,20)}function xc(){return{query:"",answered:"",hits:[],cursor:0,loading:!1,failed:!1}}function Po(t,e){return e<=0?0:Math.min(Math.max(t,0),e-1)}function yc(t,e,n){return n<=0?0:((t+e)%n+n)%n}function _c(t,e){return e===null?null:t[e]?.id??null}function kc(t,e,n){let r={cursor:t,activate:null,dismiss:!1,handled:!1},i=Po(t,n);return e==="ArrowDown"?{...r,cursor:yc(i,1,n),handled:!0}:e==="ArrowUp"?{...r,cursor:yc(i,-1,n),handled:!0}:e==="Home"?{...r,cursor:0,handled:!0}:e==="End"?{...r,cursor:Po(n-1,n),handled:!0}:e==="Escape"?{...r,dismiss:!0,handled:!0}:e!=="Enter"||n===0?r:{...r,cursor:i,activate:i,dismiss:!0,handled:!0}}var Hr="Search the workspace",Ec="Search notes and repository…",Sc="↑↓ move · ↵ open · esc close";function zv(t,e){return t.query.trim()?e>0?null:t.failed?"search failed — the workspace server may be gone":t.loading?"searching…":`no matches for “${t.query.trim()}”`:"Type to search notes, modules, files and entry points."}function $v(t){return t===1?"1 result":`${t} results`}function wc(t){return`weave-search-row-${t}`}function Tc(t,e){let n=Fv(t.hits,t.answered,e?.model.nodes??[],t.query),r=Po(t.cursor,n.length);return{rows:n.map((o,a)=>({...o,active:a===r,domId:wc(a)})),status:zv(t,n.length),count:n.length,countLabel:$v(n.length),cursor:r,activeDomId:n.length?wc(r):null}}var Uv=0;function x(t,e,n,r,i,o){e||(e={});var a,s,l=e;if("ref"in l)for(s in l={},e)s=="ref"?a=e[s]:l[s]=e[s];var u={type:t,props:l,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Uv,__i:-1,__u:0,__source:i,__self:o};if(typeof t=="function"&&(a=t.defaultProps))for(s in a)l[s]===void 0&&(l[s]=a[s]);return B.vnode&&B.vnode(u),u}function Bv({row:t,onPick:e,onHover:n}){return x("li",{id:t.domId,role:"option","aria-selected":t.active,class:`weave-hit weave-hit-${t.kind}${t.active?" weave-hit-on":""}`,onMouseMove:n,onClick:e,children:[x("span",{class:"weave-hit-badge",children:t.badge}),x("span",{class:"weave-hit-label",children:t.label}),x("span",{class:"weave-hit-detail",children:t.detail})]})}function Ac(t){let[e,n]=ne(xc),r=ee(0),i=ee(null),o=Ur(),a=ee(null);oe(()=>{a.current?.focus()},[]),oe(()=>{let u=e.query.trim(),c=!0;if(!u)return i.current?.abort(),n(d=>({...d,hits:[],answered:"",loading:!1,failed:!1})),()=>{c=!1};let h=window.setTimeout(async()=>{let d=++r.current;i.current?.abort();let f=new AbortController;i.current=f,n(m=>({...m,loading:!0,failed:!1}));let p=await Ts(t.ports.fetch,u,f.signal);!c||f.signal.aborted||d!==r.current||n(m=>p.ok?{...m,hits:p.data.hits,answered:u,loading:!1,failed:!1,cursor:0}:{...m,loading:!1,failed:!0})},140);return()=>{c=!1,window.clearTimeout(h),i.current?.abort()}},[e.query,t.ports.fetch]);let s=Tc(e,t.graph),l=u=>{let c=_c(s.rows,u);c!==null&&t.onSelect(c),t.onClose()};return x("div",{class:"weave-scrim",onClick:()=>l(null),children:x("div",{class:"weave-palette",role:"dialog","aria-modal":"true","aria-label":Hr,tabIndex:-1,ref:o.ref,onClick:u=>u.stopPropagation(),onKeyDown:u=>{if(o.onKeyDown(u))return;let c=kc(e.cursor,u.key,s.count);c.handled&&(u.preventDefault(),n(h=>({...h,cursor:c.cursor})),c.dismiss&&l(c.activate))},children:[x("input",{type:"search",class:"weave-palette-input",ref:a,value:e.query,placeholder:Ec,"aria-label":Hr,"aria-controls":"weave-search-results","aria-activedescendant":s.activeDomId??void 0,onInput:u=>n(c=>({...c,query:u.currentTarget.value,cursor:0}))}),s.status===null?x("ul",{id:"weave-search-results",class:"weave-hits",role:"listbox","aria-label":Hr,children:s.rows.map((u,c)=>x(Bv,{row:u,onPick:()=>l(c),onHover:()=>n(h=>({...h,cursor:c}))},u.id))}):x("p",{class:"weave-palette-status",role:"status",children:s.status}),x("p",{class:"weave-palette-foot",children:[x("span",{children:s.countLabel}),x("span",{class:"weave-palette-hint",children:Sc})]})]})})}var Rc="pi-weave.selection.v1";function Cc(t,e){try{return t.setItem(Rc,e??""),!0}catch{return!1}}function Nc(t,e){if(t===null)return null;let n;try{n=e.getItem(Rc)}catch{return null}return n===null||n===""?null:t.model.nodes.some(r=>r.id===n)?n:null}function Lc(){return{graph:null,graphFailed:!1,note:null,recentIds:new Set,selectedId:null}}var Wv=2e3,Kv=3e3,Pc=new Set;function Vv(t,e){if(t===null)return Pc;let n=new Set(t.model.nodes.map(r=>r.id));return new Set(e.model.nodes.filter(r=>!n.has(r.id)).map(r=>r.id))}function Dc(t){if(t===null||!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}function Ic(t){let e=t.state,n=!1,r=!1,i=null,o=d=>{Object.entries(d).every(([f,p])=>e[f]===p)||(e={...e,...d},t.setState(e))},a=t.defer??((d,f)=>{let p=setTimeout(d,f);return()=>clearTimeout(p)}),s=async()=>{let d=Dc(e.selectedId);if(d===null){o({note:null});return}let f=await Ss(t.fetch,d);f.ok&&o({note:f.data})},l=async()=>{let d=e.graph,f=await Es(t.fetch,e.graph);if(!f.ok)return e.graph===null&&o({graphFailed:!0}),f;if(!f.cached){let p=Vv(d,f.data);o({graph:f.data,graphFailed:!1,recentIds:p}),i?.(),i=null,p.size>0&&(i=a(()=>{i=null,o({recentIds:Pc})},Kv))}return f},u=async()=>{if(!(n||r)){r=!0;try{let d=await l();d.ok&&!d.cached&&Dc(e.selectedId)!==null&&await s()}finally{r=!1}}},h=(t.repeat??((d,f)=>{let p=setInterval(d,f);return()=>clearInterval(p)}))(()=>{u()},Wv);return u(),{refresh:()=>{u()},select:async d=>{o({selectedId:d}),await s()},syncNote:s,stop:()=>{n||(n=!0,h(),i?.(),i=null)}}}function Gc(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^=e>>>16,e>>>0}var jv=300,qv=1;function Yv(t,e,n){let r=new Map(n??[]);if(r.size>0)for(let o of e){if(o.kind!=="contains"&&o.kind!=="anchored-at"||r.has(o.target))continue;let a=r.get(o.source);a!==void 0&&r.set(o.target,{x:a.x,y:a.y})}let i={ticks:jv,seed:qv,pinWarm:!0};return r.size>0&&(i.initial=r),yu({generatedAt:"",staleness:null,nodes:[...t],edges:[...e],contentDigest:""},i)}function Xv(t,e){let n=0,r=0;for(let o of t){let a=Gc(o.id);n^=a,r=r+a>>>0}for(let o of e){let a=Gc(`${o.source}\0${o.target}\0${o.kind}`);n^=a,r=r+a>>>0}return[t.length,e.length,n>>>0,r].map(o=>o.toString(16)).join("-")}var Oc="pi-weave.graph.positions.v3";function Mc(t){return Math.round(t*10)/10}function Zv(t,e){let n={};for(let[r,i]of e)n[r]=[Mc(i.x),Mc(i.y)];return JSON.stringify({v:3,key:t,at:n})}function Qv(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==3||r.key!==e)return null;let i=r.at;if(typeof i!="object"||i===null||Array.isArray(i))return null;let o=new Map;for(let[a,s]of Object.entries(i)){if(!Array.isArray(s)||s.length!==2)return null;let[l,u]=s;if(typeof l!="number"||typeof u!="number"||!Number.isFinite(l)||!Number.isFinite(u))return null;o.set(a,{x:l,y:u})}return o.size===0?null:o}function Jv(t,e){let n;try{n=t.getItem(Oc)}catch{return null}return Qv(n,e)}function ey(t,e,n){try{return t.setItem(Oc,Zv(e,n)),!0}catch{return!1}}function Fc(t,e,n){let r=Xv(e,n),i=Jv(t,r);if(i!==null&&e.every(a=>i.has(a.id)))return{key:r,positions:i,cached:!0};let o=Yv(e,n);return ey(t,r,o),{key:r,positions:o,cached:!1}}function ty(t){return{expanded:new Set(Cr(t,new Set).clusters.keys())}}function $c(t,e){return e!==null?e:t===null?{expanded:new Set}:ty(Et(t))}function ny(t,e){let n=new Set(t.expanded);return n.delete(e)||n.add(e),{...t,expanded:n}}function ry(t,e){return{...t,expanded:new Set(e.keys())}}function iy(t){return{...t,expanded:new Set}}function oy(t,e){return e===null?null:yo(e,t)}function Uc(t){return t?"collapse":"expand"}function Hc(t){return t?"collapse every cluster back to the roots":"expand every cluster"}function Io(t,e){if(e.size===0)return!1;for(let n of e.keys())if(!t.expanded.has(n))return!1;return!0}function Bc(t,e){return Io(t,e)?iy(t):ry(t,e)}var Wc="fit",Kc="frame the whole graph",Br={selected:"selected",neighborhood:"neighborhood",dimmed:"not related"};function Vc(t,e){let n=e===1?"node":"nodes";return t===e?`${e} ${n}`:`${t} of ${e} ${n}`}function ay(t,e){return t===null?"Loading…":t.model.nodes.length===0?"Nothing indexed yet — add a note or run /weave-scan.":e===0?"Nothing to draw at this expansion.":null}var sy="The workspace did not load — ⟳ retries now, and the next change to the vault retries on its own.",zc={graph:Vu,highlight:null,key:"",cached:!1,clusters:new Map,visible:0,total:0,empty:"Loading…"};function jc(t,e,n,r,i,o=!1){if(t===null)return o?{...zc,empty:sy}:zc;let a=Et(t),s=Cr(a,n.expanded),u=n.expanded.has("vault")?s.edges.filter(h=>h.source!=="vault"&&h.target!=="vault"):s.edges,c=Fc(r,s.nodes,u);return{graph:qu(s.nodes,u,c.positions,i),highlight:oy(u,e),key:c.key,cached:c.cached,clusters:s.clusters,visible:s.nodes.length,total:a.nodes.length,empty:ay(t,s.nodes.length)}}function qc(t,e,n){return n===null?{state:t,selectedId:null}:e.get(n)===void 0||t.expanded.has(n)?{state:t,selectedId:n}:{state:ny(t,n),selectedId:n}}var ly=.06,uy=.2,Go=.001;function Yc(t,e){if(t.nodes.length===0)return null;let n=t.nodes.map(s=>{let l=e?.get(s.id);return{id:s.id,x:l!==void 0&&Number.isFinite(l.x)?l.x:s.x,y:l!==void 0&&Number.isFinite(l.y)?l.y:s.y,vx:0,vy:0,r:ho(s.size)}}),r=new Map(n.map(s=>[s.id,s])),i=new Set,o=[];for(let s of t.edges){if(s.source===s.target||!r.has(s.source)||!r.has(s.target))continue;let l=`${s.source}\0${s.target}\0${s.kind}`;i.has(l)||(i.add(l),o.push({source:s.source,target:s.target,kind:s.kind}))}let a=fo({nodes:n,links:o,seed:1}).alpha(ly).alphaMin(Go);return{tick(){a.tick()},awake(){return a.alphaTarget()>Go||a.alpha()>Go},positions(){return new Map(n.map(s=>[s.id,{x:s.x??0,y:s.y??0}]))},pin(s,l){let u=r.get(s);u&&(u.fx=l.x,u.fy=l.y,a.alphaTarget(uy))},release(s){let l=r.get(s);l&&(l.fx=null,l.fy=null,a.alphaTarget(0))}}}function Xc(t){let e=ee(null),n=ee(null),r=ee(null),i=ee(null),o=bs(()=>{if(i.current!==null)return;let f=()=>{i.current=null;let p=r.current;p!==null&&(p.tick(),p.awake()&&(n.current?.setPositions(p.positions()),i.current=requestAnimationFrame(f)))};i.current=requestAnimationFrame(f)},[]),[a,s]=ne(null),l=t.scheme??ar(t.host),u=$c(t.graph,a),c=Ye(()=>jc(t.graph,t.selectedId,u,t.storage,l,t.bootFailed),[t.graph,t.selectedId,u,t.storage,l,t.bootFailed]),h=Io(u,c.clusters),d=ee({view:u,model:c,onSelect:t.onSelect});return d.current={view:u,model:c,onSelect:t.onSelect},oe(()=>{let f=t.renderer(l);return f.onSelect(p=>{let m=qc(d.current.view,d.current.model.clusters,p);s(m.state),d.current.onSelect(m.selectedId)}),f.onDragStart(p=>{let m=n.current?.positions().get(p);m&&(r.current?.pin(p,m),o())}),f.onDragMove((p,m)=>{r.current?.pin(p,m)}),f.onDragEnd(p=>{r.current?.release(p)}),f.mount(e.current??{clientWidth:0,clientHeight:0}),n.current=f,f.setGraph(d.current.model.graph),f.setHighlight(d.current.model.highlight),t.fit.current=()=>f.fit(),()=>{f.destroy(),n.current=null,t.fit.current=null}},[t.renderer,l]),oe(()=>{n.current?.setGraph(c.graph)},[c.key]),oe(()=>{let f=Yc(c.graph,n.current?.positions());return r.current=f,f!==null&&o(),()=>{r.current=null}},[c.key,o]),oe(()=>()=>{i.current!==null&&(cancelAnimationFrame(i.current),i.current=null)},[]),oe(()=>{n.current?.setHighlight(c.highlight)},[c.highlight]),x("div",{class:"weave-graph",children:[c.empty===null?null:x("p",{class:"weave-graph-empty",children:c.empty}),x("div",{class:"weave-graph-canvas",ref:e,role:"img","aria-label":"Knowledge graph",tabIndex:-1}),x("div",{class:"weave-graph-controls",children:[x("button",{type:"button",class:"weave-chip",title:Kc,onClick:()=>n.current?.fit(),children:Wc}),x("button",{type:"button",class:"weave-chip",title:Hc(h),onClick:()=>s(Bc(u,c.clusters)),children:Uc(h)}),x("span",{class:"weave-graph-legend",children:[x("span",{class:"weave-legend-on",children:["◉ ",Br.selected]}),x("span",{class:"weave-legend-near",children:["● ",Br.neighborhood]}),x("span",{class:"weave-legend-dim",children:["· ",Br.dimmed]})]})]}),x("p",{class:"weave-graph-count",children:Vc(c.visible,c.total)})]})}function Zc(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function cy(t){if(Array.isArray(t))return t}function dy(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,e!==0)for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(c){u=!0,i=c}finally{try{if(!l&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}function hy(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
333
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fy(t,e){return cy(t)||dy(t,e)||py(t,e)||hy()}function py(t,e){if(t){if(typeof t=="string")return Zc(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Zc(t,e):void 0}}var hd=Object.entries,Qc=Object.setPrototypeOf,gy=Object.isFrozen,my=Object.getPrototypeOf,vy=Object.getOwnPropertyDescriptor,de=Object.freeze,pe=Object.seal,Xt=Object.create,fd=typeof Reflect<"u"&&Reflect,Ho=fd.apply,Bo=fd.construct;de||(de=function(e){return e});pe||(pe=function(e){return e});Ho||(Ho=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return e.apply(n,i)});Bo||(Bo=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});var At=se(Array.prototype.forEach),yy=se(Array.prototype.lastIndexOf),Jc=se(Array.prototype.pop),En=se(Array.prototype.push),wy=se(Array.prototype.splice),Zt=Array.isArray,An=se(String.prototype.toLowerCase),Mo=se(String.prototype.toString),ed=se(String.prototype.match),Sn=se(String.prototype.replace),td=se(String.prototype.indexOf),by=se(String.prototype.trim),xy=se(Number.prototype.toString),_y=se(Boolean.prototype.toString),nd=typeof BigInt>"u"?null:se(BigInt.prototype.toString),rd=typeof Symbol>"u"?null:se(Symbol.prototype.toString),Se=se(Object.prototype.hasOwnProperty),Tn=se(Object.prototype.toString),ve=se(RegExp.prototype.test),Tt=ky(TypeError);function se(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Ho(t,e,r)}}function ky(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Bo(t,n)}}function H(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:An;if(Qc&&Qc(t,null),!Zt(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){let o=n(i);o!==i&&(gy(e)||(e[r]=o),i=o)}t[i]=!0}return t}function Ey(t){for(let e=0;e<t.length;e++)Se(t,e)||(t[e]=null);return t}function Re(t){let e=Xt(null);for(let r of hd(t)){var n=fy(r,2);let i=n[0],o=n[1];Se(t,i)&&(Zt(o)?e[i]=Ey(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=Re(o):e[i]=o)}return e}function Sy(t){switch(typeof t){case"string":return t;case"number":return xy(t);case"boolean":return _y(t);case"bigint":return nd?nd(t):"0";case"symbol":return rd?rd(t):"Symbol()";case"undefined":return Tn(t);case"function":case"object":{if(t===null)return Tn(t);let e=t,n=$e(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:Tn(r)}return Tn(t)}default:return Tn(t)}}function $e(t,e){for(;t!==null;){let r=vy(t,e);if(r){if(r.get)return se(r.get);if(typeof r.value=="function")return se(r.value)}t=my(t)}function n(){return null}return n}function Ty(t){try{return ve(t,""),!0}catch{return!1}}var id=de(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Oo=de(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Fo=de(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Ay=de(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),zo=de(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Ry=de(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),od=de(["#text"]),ad=de(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),$o=de(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),sd=de(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wr=de(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Cy=pe(/{{[\w\W]*|^[\w\W]*}}/g),Ny=pe(/<%[\w\W]*|^[\w\W]*%>/g),Ly=pe(/\${[\w\W]*/g),Dy=pe(/^data-[\-\w.\u00B7-\uFFFF]+$/),Py=pe(/^aria-[\-\w]+$/),ld=pe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Iy=pe(/^(?:\w+script|data):/i),Gy=pe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),My=pe(/^html$/i),Oy=pe(/^[a-z][.\w]*(-[.\w]+)+$/i),ud=pe(/<[/\w!]/g),cd=pe(/<[/\w]/g),Fy=pe(/<\/no(script|embed|frames)/i),zy=pe(/\/>/i),Ae={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},pd=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],$y=de(H({},pd)),Uy=(function(){let t={};return At(pd,e=>{t[e]=pe(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),de(t)})(),Hy=function(){return typeof window>"u"?null:window},By=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));let o="dompurify"+(r?"#"+r:"");try{return e.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},dd=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},ft=function(e,n,r,i){return Se(e,n)&&Zt(e[n])?H(i.base?Re(i.base):{},e[n],i.transform):r},Uo=function(e,n,r){let i=Se(e,n)?e[n]:void 0;return i&&typeof i=="object"?Re(i):r()};function gd(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Hy(),e=T=>gd(T);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==Ae.document||!t.Element)return e.isSupported=!1,e;let n=t.document,r=n,i=r.currentScript;t.DocumentFragment;let o=t.HTMLTemplateElement,a=t.Node,s=t.Element,l=t.NodeFilter,u=t.NamedNodeMap;u===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let c=t.DOMParser,h=t.trustedTypes,d=s.prototype,f=$e(d,"cloneNode"),p=$e(d,"remove"),m=$e(d,"nextSibling"),v=$e(d,"childNodes"),y=$e(d,"parentNode"),w=$e(d,"shadowRoot"),k=$e(d,"attributes"),_=a&&a.prototype?$e(a.prototype,"nodeType"):null,L=a&&a.prototype?$e(a.prototype,"nodeName"):null,R=a&&a.prototype?$e(a.prototype,"ownerDocument"):null,P=function(g){return _?_(g):g.nodeType},z=function(g){return L?L(g):g.nodeName};if(typeof o=="function"){let T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let F,G="",U,j=!1,Q=0,ge=function(){if(Q>0)throw Tt('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},he=function(g){ge(),Q++;try{return F.createHTML(g)}finally{Q--}},Be=function(g){ge(),Q++;try{return F.createScriptURL(g)}finally{Q--}},Lt=function(){return j||(U=By(h,i),j=!0),U},Ie=n,Ge=Ie.implementation,Me=Ie.createNodeIterator,We=Ie.createDocumentFragment,en=Ie.getElementsByTagName,Ne=r.importNode,q=dd();e.isSupported=typeof hd=="function"&&typeof y=="function"&&Ge&&Ge.createHTMLDocument!==void 0;let tn=Cy,sf=Ny,lf=Ly,uf=Dy,cf=Py,df=Iy,ma=Gy,hf=Oy,va=ld,X=null,oi=H({},[...id,...Oo,...Fo,...zo,...od]),Z=null,ai=H({},[...ad,...$o,...sd,...Wr]),Ke=Object.seal(Xt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),nn=null,ya=null,st=Object.seal(Xt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),wa=!0,si=!0,ba=!1,xa=!0,lt=!1,gt=!0,mt=!1,li=!1,Mn=null,On=null,ui=!1,Dt=!1,Fn=!1,zn=!1,_a=!0,ka=!1,Ea="user-content-",ci=!0,di=!1,Pt={},It=null,Sa=H({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Ta=null,Aa=H({},["audio","video","img","source","image","track"]),Ra=null,Ca=H({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),$n="http://www.w3.org/1998/Math/MathML",Un="http://www.w3.org/2000/svg",Ve="http://www.w3.org/1999/xhtml",Gt=Ve,hi=!1,fi=null,ff=H({},[$n,Un,Ve],Mo),Na=de(["mi","mo","mn","ms","mtext"]),pi=H({},Na),La=de(["annotation-xml"]),gi=H({},La),pf=H({},["title","style","font","a","script"]),rn=null,gf=["application/xhtml+xml","text/html"],mf="text/html",re=null,Mt=null,vf=n.createElement("form"),Da=function(g){return g instanceof RegExp||g instanceof Function},mi=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Mt&&Mt===g)return;(!g||typeof g!="object")&&(g={}),g=Re(g),rn=gf.indexOf(g.PARSER_MEDIA_TYPE)===-1?mf:g.PARSER_MEDIA_TYPE,re=rn==="application/xhtml+xml"?Mo:An,X=ft(g,"ALLOWED_TAGS",oi,{transform:re}),Z=ft(g,"ALLOWED_ATTR",ai,{transform:re}),fi=ft(g,"ALLOWED_NAMESPACES",ff,{transform:Mo}),Ra=ft(g,"ADD_URI_SAFE_ATTR",Ca,{transform:re,base:Ca}),Ta=ft(g,"ADD_DATA_URI_TAGS",Aa,{transform:re,base:Aa}),It=ft(g,"FORBID_CONTENTS",Sa,{transform:re}),nn=ft(g,"FORBID_TAGS",Re({}),{transform:re}),ya=ft(g,"FORBID_ATTR",Re({}),{transform:re}),Pt=Se(g,"USE_PROFILES")?g.USE_PROFILES&&typeof g.USE_PROFILES=="object"?Re(g.USE_PROFILES):g.USE_PROFILES:!1,wa=g.ALLOW_ARIA_ATTR!==!1,si=g.ALLOW_DATA_ATTR!==!1,ba=g.ALLOW_UNKNOWN_PROTOCOLS||!1,xa=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,lt=g.SAFE_FOR_TEMPLATES||!1,gt=g.SAFE_FOR_XML!==!1,mt=g.WHOLE_DOCUMENT||!1,Dt=g.RETURN_DOM||!1,Fn=g.RETURN_DOM_FRAGMENT||!1,zn=g.RETURN_TRUSTED_TYPE||!1,ui=g.FORCE_BODY||!1,_a=g.SANITIZE_DOM!==!1,ka=g.SANITIZE_NAMED_PROPS||!1,ci=g.KEEP_CONTENT!==!1,di=g.IN_PLACE||!1,va=Ty(g.ALLOWED_URI_REGEXP)?g.ALLOWED_URI_REGEXP:ld,Gt=typeof g.NAMESPACE=="string"?g.NAMESPACE:Ve,pi=Uo(g,"MATHML_TEXT_INTEGRATION_POINTS",()=>H({},Na)),gi=Uo(g,"HTML_INTEGRATION_POINTS",()=>H({},La));let b=Uo(g,"CUSTOM_ELEMENT_HANDLING",()=>Xt(null));if(Ke=Xt(null),Se(b,"tagNameCheck")&&Da(b.tagNameCheck)&&(Ke.tagNameCheck=b.tagNameCheck),Se(b,"attributeNameCheck")&&Da(b.attributeNameCheck)&&(Ke.attributeNameCheck=b.attributeNameCheck),Se(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(Ke.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),pe(Ke),lt&&(si=!1),Fn&&(Dt=!0),Pt&&(X=H({},od),Z=Xt(null),Pt.html===!0&&(H(X,id),H(Z,ad)),Pt.svg===!0&&(H(X,Oo),H(Z,$o),H(Z,Wr)),Pt.svgFilters===!0&&(H(X,Fo),H(Z,$o),H(Z,Wr)),Pt.mathMl===!0&&(H(X,zo),H(Z,sd),H(Z,Wr))),st.tagCheck=null,st.attributeCheck=null,Se(g,"ADD_TAGS")&&(typeof g.ADD_TAGS=="function"?st.tagCheck=g.ADD_TAGS:Zt(g.ADD_TAGS)&&(X===oi&&(X=Re(X)),H(X,g.ADD_TAGS,re))),Se(g,"ADD_ATTR")&&(typeof g.ADD_ATTR=="function"?st.attributeCheck=g.ADD_ATTR:Zt(g.ADD_ATTR)&&(Z===ai&&(Z=Re(Z)),H(Z,g.ADD_ATTR,re))),Se(g,"ADD_FORBID_CONTENTS")&&Zt(g.ADD_FORBID_CONTENTS)&&(It===Sa&&(It=Re(It)),H(It,g.ADD_FORBID_CONTENTS,re)),ci&&(X["#text"]=!0),mt&&H(X,["html","head","body"]),X.table&&(H(X,["tbody"]),delete nn.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Tt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Tt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let E=F;F=g.TRUSTED_TYPES_POLICY;try{G=he("")}catch(C){throw F=E,C}}else g.TRUSTED_TYPES_POLICY===null?(F=void 0,G=""):(F===void 0&&(F=Lt()),F&&typeof G=="string"&&(G=he("")));de&&de(g),Mt=g},Pa=H({},[...Oo,...Fo,...Ay]),Ia=H({},[...zo,...Ry]),yf=function(g,b,E){return b.namespaceURI===Ve?g==="svg":b.namespaceURI===$n?g==="svg"&&(E==="annotation-xml"||pi[E]):!!Pa[g]},wf=function(g,b,E){return b.namespaceURI===Ve?g==="math":b.namespaceURI===Un?g==="math"&&gi[E]:!!Ia[g]},bf=function(g,b,E){return b.namespaceURI===Un&&!gi[E]||b.namespaceURI===$n&&!pi[E]?!1:!Ia[g]&&(pf[g]||!Pa[g])},xf=function(g){let b=y(g);(!b||!b.tagName)&&(b={namespaceURI:Gt,tagName:"template"});let E=An(g.tagName),C=An(b.tagName);return fi[g.namespaceURI]?g.namespaceURI===Un?yf(E,b,C):g.namespaceURI===$n?wf(E,b,C):g.namespaceURI===Ve?bf(E,b,C):!!(rn==="application/xhtml+xml"&&fi[g.namespaceURI]):!1},ut=function(g){En(e.removed,{element:g});try{y(g).removeChild(g)}catch{if(p(g),!y(g))throw Tt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ga=function(g,b,E){try{g.removeAttributeNode(b)}catch{try{g.removeAttribute(E)}catch{}}},Hn=function(g){Bn(g);let b=v(g);if(b){let C=[];At(b,I=>{En(C,I)}),At(C,I=>{try{p(I)}catch{}})}let E=k(g);if(E)for(let C=E.length-1;C>=0;--C){let I=E[C],O=I&&I.name;typeof O=="string"&&Ga(g,I,O)}},vt=function(g,b,E){if(!E)try{E=b.getAttributeNode(g)}catch{E=null}En(e.removed,{attribute:E||null,from:b});try{E?b.removeAttributeNode(E):b.removeAttribute(g)}catch{try{b.removeAttribute(g)}catch{}}if(g==="is")if(Dt||Fn)try{ut(b)}catch{}else try{b.setAttribute(g,"")}catch{}},_f=function(g){let b=k(g);if(b)for(let E=b.length-1;E>=0;--E){let C=b[E],I=C&&C.name;typeof I!="string"||Z[re(I)]||Ga(g,C,I)}},Bn=function(g){let b=[g];for(;b.length>0;){let E=b.pop();P(E)===Ae.element&&_f(E);let I=v(E);if(I)for(let O=I.length-1;O>=0;--O)b.push(I[O])}},Ma=function(g,b){return gt?g==="patchsrc"?!0:g==="for"&&b!=="label"&&b!=="output":!1},kf=function(g){if(!gt)return;let b=[g];for(;b.length>0;){let E=b.pop(),C=P(E);if(C===Ae.processingInstruction||C===Ae.comment&&ve(cd,E.data)){try{p(E)}catch{}continue}if(C===Ae.element){let O=E,Y=re(z(E));try{O.hasAttribute&&O.hasAttribute("patchsrc")&&O.removeAttribute("patchsrc"),O.hasAttribute&&O.hasAttribute("for")&&Ma("for",Y)&&O.removeAttribute("for")}catch{}}let I=v(E);if(I)for(let O=I.length-1;O>=0;--O)b.push(I[O])}},Oa=function(g){let b=null,E=null;if(ui)g="<remove></remove>"+g;else{let O=ed(g,/^[\r\n\t ]+/);E=O&&O[0]}rn==="application/xhtml+xml"&&Gt===Ve&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");let C=F?he(g):g;if(Gt===Ve)try{b=new c().parseFromString(C,rn)}catch{}if(!b||!b.documentElement){b=Ge.createDocument(Gt,"template",null);try{b.documentElement.innerHTML=hi?G:C}catch{}}let I=b.body||b.documentElement;return g&&E&&I.insertBefore(n.createTextNode(E),I.childNodes[0]||null),Gt===Ve?en.call(b,mt?"html":"body")[0]:mt?b.documentElement:I},Fa=function(g){let b=R?R(g):g.ownerDocument;return Me.call(b||g,g,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Wn=function(g){return g=Sn(g,tn," "),g=Sn(g,sf," "),g=Sn(g,lf," "),g},vi=function(g){var b;g.normalize();let E=R?R(g):g.ownerDocument,C=Me.call(E||g,g,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),I=C.nextNode();for(;I;)I.data=Wn(I.data),I=C.nextNode();let O=(b=g.querySelectorAll)===null||b===void 0?void 0:b.call(g,"template");O&&At(O,Y=>{Ot(Y.content)&&vi(Y.content)})},Kn=function(g){let b=L?L(g):null;return typeof b!="string"||re(b)!=="form"?!1:typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||g.attributes!==k(g)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function"||g.nodeType!==_(g)||g.childNodes!==v(g)},Ot=function(g){if(!_||typeof g!="object"||g===null)return!1;try{return _(g)===Ae.documentFragment}catch{return!1}},on=function(g){if(!_||typeof g!="object"||g===null)return!1;try{return typeof _(g)=="number"}catch{return!1}};function je(T,g,b){T.length!==0&&At(T,E=>{E.call(e,g,b,Mt)})}let Ef=function(g,b){return!!(gt&&g.hasChildNodes()&&!on(g.firstElementChild)&&ve(ud,g.textContent)&&ve(ud,g.innerHTML)||gt&&g.namespaceURI===Ve&&$y[b]&&(on(g.firstElementChild)||typeof g.textContent=="string"&&ve(Uy[b],g.textContent))||g.nodeType===Ae.processingInstruction||gt&&g.nodeType===Ae.comment&&ve(cd,g.data))},Vn=function(g,b){if(g instanceof RegExp)return ve(g,b);if(g instanceof Function){for(var E=arguments.length,C=new Array(E>2?E-2:0),I=2;I<E;I++)C[I-2]=arguments[I];return!!g(b,...C)}return!1},Sf=function(g,b,E){if(!nn[b]&&Ba(b)&&Vn(Ke.tagNameCheck,b))return!1;if(ci&&!It[b]){let C=y(g),I=v(g);if(I&&C){let O=I.length;for(let Y=O-1;Y>=0;--Y){let J=g===E?f(I[Y],!0):I[Y];C.insertBefore(J,m(g))}}}return ut(g),!0},za=function(g,b,E,C){return g.length===0?b:b===E||b===C?Re(b):b},$a=function(g,b){return g===b||y(g)!==null?!1:(di&&Bn(g),!0)},Ua=function(g,b){if(je(q.beforeSanitizeElements,g,null),$a(g,b))return!0;if(Kn(g))return ut(g),!0;let E=re(z(g));if(X=za(q.uponSanitizeElement,X,oi,Mn),je(q.uponSanitizeElement,g,{tagName:E,allowedTags:X}),$a(g,b))return!0;if(Ef(g,E))return ut(g),!0;if(nn[E]||!(st.tagCheck instanceof Function&&st.tagCheck(E))&&!X[E]){let I=Sf(g,E,b);return I===!1&&je(q.afterSanitizeElements,g,null),I}if(P(g)===Ae.element&&!xf(g)||(E==="noscript"||E==="noembed"||E==="noframes")&&ve(Fy,g.innerHTML))return ut(g),!0;if(lt&&g.nodeType===Ae.text){let I=Wn(g.textContent);g.textContent!==I&&(En(e.removed,{element:g.cloneNode()}),g.textContent=I)}return je(q.afterSanitizeElements,g,null),!1},Ha=function(g,b,E){if(ya[b]||Ma(b,g)||_a&&(b==="id"||b==="name")&&(E in n||E in vf))return!1;let C=Z[b]||st.attributeCheck instanceof Function&&st.attributeCheck(b,g);return si&&ve(uf,b)||wa&&ve(cf,b)?!0:C?Ra[b]||ve(va,Sn(E,ma,""))||(b==="src"||b==="xlink:href"||b==="href")&&g!=="script"&&td(E,"data:")===0&&Ta[g]||ba&&!ve(df,Sn(E,ma,""))?!0:!E:Ba(g)&&Vn(Ke.tagNameCheck,g)&&Vn(Ke.attributeNameCheck,b,g)||b==="is"&&Ke.allowCustomizedBuiltInElements&&Vn(Ke.tagNameCheck,E)},Tf=H({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ba=function(g){return!Tf[An(g)]&&ve(hf,g)},Af=function(g,b,E,C){if(F&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!E)switch(h.getAttributeType(g,b)){case"TrustedHTML":return he(C);case"TrustedScriptURL":return Be(C)}return C},Rf=function(g,b,E,C){try{E?g.setAttributeNS(E,b,C):g.setAttribute(b,C),Kn(g)?ut(g):Jc(e.removed)}catch{vt(b,g)}},Wa=function(g){je(q.beforeSanitizeAttributes,g,null);let b=g.attributes;if(!b||Kn(g))return;Z=za(q.uponSanitizeAttribute,Z,ai,On);let E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Z,forceKeepAttr:void 0},C=b.length,I=re(g.nodeName);for(;C--;){let O=b[C],Y=O.name,J=O.namespaceURI,ke=O.value,Ee=re(Y),wi=ke,we=Y==="value"?wi:by(wi);if(E.attrName=Ee,E.attrValue=we,E.keepAttr=!0,E.forceKeepAttr=void 0,je(q.uponSanitizeAttribute,g,E),we=E.attrValue,ka&&(Ee==="id"||Ee==="name")&&td(we,Ea)!==0&&(vt(Y,g,O),we=Ea+we),gt&&ve(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,we)){vt(Y,g,O);continue}if(Ee==="attributename"&&ed(we,"href")){vt(Y,g,O);continue}if(!E.forceKeepAttr){if(!E.keepAttr){vt(Y,g,O);continue}if(!xa&&ve(zy,we)){vt(Y,g,O);continue}if(lt&&(we=Wn(we)),!Ha(I,Ee,we)){vt(Y,g,O);continue}we=Af(I,Ee,J,we),we!==wi&&Rf(g,Y,J,we)}}je(q.afterSanitizeAttributes,g,null)},jn=function(g){let b=null,E=Fa(g);for(je(q.beforeSanitizeShadowDOM,g,null);b=E.nextNode();)if(je(q.uponSanitizeShadowNode,b,null),Ua(b,g),Wa(b),Ot(b.content)&&jn(b.content),P(b)===Ae.element){let C=w(b);Ot(C)&&(yi(C),jn(C))}je(q.afterSanitizeShadowDOM,g,null)},yi=function(g){let b=[{node:g,shadow:null}];for(;b.length>0;){let E=b.pop();if(E.shadow){jn(E.shadow);continue}let C=E.node,O=P(C)===Ae.element,Y=v(C);if(Y)for(let J=Y.length-1;J>=0;--J)b.push({node:Y[J],shadow:null});if(O){let J=L?L(C):null;if(typeof J=="string"&&re(J)==="template"){let ke=C.content;Ot(ke)&&b.push({node:ke,shadow:null})}}if(O){let J=w(C);Ot(J)&&b.push({node:null,shadow:J},{node:J,shadow:null})}}};return e.sanitize=function(T){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,E=null,C=null,I=null;if(hi=!T,hi&&(T="<!-->"),typeof T!="string"&&!on(T)&&(T=Sy(T),typeof T!="string"))throw Tt("dirty is not a string, aborting");if(!e.isSupported)return T;li?(X=Mn,Z=On):mi(g),(q.uponSanitizeElement.length>0||q.uponSanitizeAttribute.length>0)&&(X=Re(X)),q.uponSanitizeAttribute.length>0&&(Z=Re(Z)),e.removed=[];let O=di&&typeof T!="string"&&on(T);if(O){kf(T);let ke=z(T);if(typeof ke=="string"){let Ee=re(ke);if(!X[Ee]||nn[Ee])throw Hn(T),Tt("root node is forbidden and cannot be sanitized in-place")}if(Kn(T))throw Hn(T),Tt("root node is clobbered and cannot be sanitized in-place");try{yi(T)}catch(Ee){throw Hn(T),Ee}}else if(on(T))b=Oa("<!---->"),E=b.ownerDocument.importNode(T,!0),E.nodeType===Ae.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?b=E:b.appendChild(E),yi(E);else{if(!Dt&&!lt&&!mt&&T.indexOf("<")===-1)return F&&zn?he(T):T;if(b=Oa(T),!b)return Dt?null:zn?G:""}b&&ui&&ut(b.firstChild);let Y=O?T:b;try{let ke=Fa(Y);for(;C=ke.nextNode();)Ua(C,Y),Wa(C),Ot(C.content)&&jn(C.content)}catch(ke){throw O&&(Hn(T),At(e.removed,Ee=>{Ee.element&&Bn(Ee.element)})),ke}if(O)return At(e.removed,ke=>{ke.element&&Bn(ke.element)}),lt&&vi(T),T;if(Dt){if(lt&&vi(b),Fn)for(I=We.call(b.ownerDocument);b.firstChild;)I.appendChild(b.firstChild);else I=b;return(Z.shadowroot||Z.shadowrootmode)&&(I=Ne.call(r,I,!0)),I}let J=mt?b.outerHTML:b.innerHTML;return mt&&X["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&ve(My,b.ownerDocument.doctype.name)&&(J="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
334
|
+
`+J),lt&&(J=Wn(J)),F&&zn?he(J):J},e.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};mi(T),li=!0,Mn=X,On=Z},e.clearConfig=function(){Mt=null,li=!1,Mn=null,On=null,F=U,G=""},e.isValidAttribute=function(T,g,b){Mt||mi({});let E=re(T),C=re(g);return Ha(E,C,b)},e.addHook=function(T,g){typeof g=="function"&&Se(q,T)&&En(q[T],g)},e.removeHook=function(T,g){if(Se(q,T)){if(g!==void 0){let b=yy(q[T],g);return b===-1?void 0:wy(q[T],b,1)[0]}return Jc(q[T])}},e.removeHooks=function(T){Se(q,T)&&(q[T]=[])},e.removeAllHooks=function(){q=dd()},e}var md=gd();function jo(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Nt=jo();function Ed(t){Nt=t}var Rt={exec:()=>null};function Qt(t){let e=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=e[r];return i||(i=t(r),e[r]=i),i}}function $(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(ye.caret,"$1"),n=n.replace(i,a),r},getRegex:()=>new RegExp(n,e)};return r}var Wy=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),ye={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Qt(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Qt(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Qt(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:Qt(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:Qt(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Qt(t=>new RegExp(`^ {0,${t}}>`))},Ky=/^(?:[ \t]*(?:\n|$))+/,Vy=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,jy=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Nn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,qy=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,qo=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Sd=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Td=$(Sd).replace(/bull/g,qo).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Yy=$(Sd).replace(/bull/g,qo).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Yo=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Xy=/^[^\n]+/,Xo=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Zy=$(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Xo).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Qy=$(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,qo).getRegex(),Yr="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Zo=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Jy=$("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Zo).replace("tag",Yr).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ad=t=>$(Yo).replace("hr",Nn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list",t).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Yr).getRegex(),ew=Ad(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),tw=Ad(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),nw=$(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",tw).getRegex(),Qo={blockquote:nw,code:Vy,def:Zy,fences:jy,heading:qy,hr:Nn,html:Jy,lheading:Td,list:Qy,newline:Ky,paragraph:ew,table:Rt,text:Xy},vd=$("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Nn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Yr).getRegex(),rw={...Qo,lheading:Yy,table:vd,paragraph:$(Yo).replace("hr",Nn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",vd).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Yr).getRegex()},iw={...Qo,html:$(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Zo).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Rt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:$(Yo).replace("hr",Nn).replace("heading",` *#{1,6} *[^
|
|
335
|
+
]`).replace("lheading",Td).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ow=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,aw=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Rd=/^( {2,}|\\)\n(?!\s*$)/,sw=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ot=/[\p{P}\p{S}]/u,Jt=/[\s\p{P}\p{S}]/u,Ln=/[^\s\p{P}\p{S}]/u,lw=$(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Jt).getRegex(),uw=/[\p{Pi}\p{Ps}"']/u,Cd=/(?!~)[\p{P}\p{S}]/u,cw=/(?!~)[\s\p{P}\p{S}]/u,dw=/(?:[^\s\p{P}\p{S}]|~)/u,hw=$(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Wy?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Nd=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,fw=$(Nd,"u").replace(/punct/g,ot).getRegex(),pw=$(Nd,"u").replace(/punct/g,Cd).getRegex(),gw=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,mw=$(gw,"u").replace(/openQuote/g,uw).replace(/punct/g,ot).getRegex(),Ld="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",vw=$(Ld,"gu").replace(/notPunctSpace/g,Ln).replace(/punctSpace/g,Jt).replace(/punct/g,ot).getRegex(),yw=$(Ld,"gu").replace(/notPunctSpace/g,dw).replace(/punctSpace/g,cw).replace(/punct/g,Cd).getRegex(),ww="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",bw=$(ww,"gu").replace(/notPunctSpace/g,Ln).replace(/punctSpace/g,Jt).replace(/punct/g,ot).getRegex(),xw=$("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ln).replace(/punctSpace/g,Jt).replace(/punct/g,ot).getRegex(),_w="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",kw=$(_w,"gu").replace(/notPunctSpace/g,Ln).replace(/punctSpace/g,Jt).replace(/punct/g,ot).getRegex(),Ew=$(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ot).getRegex(),Sw="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Tw=$(Sw,"gu").replace(/notPunctSpace/g,Ln).replace(/punctSpace/g,Jt).replace(/punct/g,ot).getRegex(),Aw=$(/\\(punct)/,"gu").replace(/punct/g,ot).getRegex(),Rw=$(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Cw=$(Zo).replace("(?:-->|$)","-->").getRegex(),Nw=$("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Cw).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Vr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Lw=$(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Vr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Dd=$(/^!?\[(label)\]\[(ref)\]/).replace("label",Vr).replace("ref",Xo).getRegex(),Pd=$(/^!?\[(ref)\](?:\[\])?/).replace("ref",Xo).getRegex(),Dw=$("reflink|nolink(?!\\()","g").replace("reflink",Dd).replace("nolink",Pd).getRegex(),yd=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Jo={_backpedal:Rt,anyPunctuation:Aw,autolink:Rw,blockSkip:hw,br:Rd,code:aw,del:Rt,delLDelim:Rt,delRDelim:Rt,emStrongLDelim:fw,emStrongRDelimAst:vw,emStrongRDelimUnd:xw,escape:ow,link:Lw,nolink:Pd,punctuation:lw,reflink:Dd,reflinkSearch:Dw,tag:Nw,text:sw,url:Rt},Pw={...Jo,emStrongLDelim:mw,emStrongRDelimAst:bw,emStrongRDelimUnd:kw,link:$(/^!?\[(label)\]\((.*?)\)/).replace("label",Vr).getRegex(),reflink:$(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Vr).getRegex()},Wo={...Jo,emStrongRDelimAst:yw,emStrongLDelim:pw,delLDelim:Ew,delRDelim:Tw,url:$(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",yd).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:$(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",yd).getRegex()},Iw={...Wo,br:$(Rd).replace("{2,}","*").getRegex(),text:$(Wo.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Kr={normal:Qo,gfm:rw,pedantic:iw},Rn={normal:Jo,gfm:Wo,breaks:Iw,pedantic:Pw},Gw={"&":"&","<":"<",">":">",'"':""","'":"'"},wd=t=>Gw[t];function Ze(t,e){if(e){if(ye.escapeTest.test(t))return t.replace(ye.escapeReplace,wd)}else if(ye.escapeTestNoEncode.test(t))return t.replace(ye.escapeReplaceNoEncode,wd);return t}function bd(t){try{t=encodeURI(t).replace(ye.percentDecode,"%")}catch{return null}return t}function xd(t,e){let n=t.replace(ye.findPipe,(o,a,s)=>{let l=!1,u=a;for(;--u>=0&&s[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(ye.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(ye.slashPipe,"|");return r}function pt(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r;){let o=t.charAt(r-i-1);if(o===e&&!n)i++;else if(o!==e&&n)i++;else break}return t.slice(0,r-i)}function _d(t){let e=t.split(`
|
|
336
336
|
`),n=e.length-1;for(;n>=0&&ye.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`
|
|
337
|
-
`)}function
|
|
337
|
+
`)}function Mw(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function Ow(t,e=0){let n=e,r="";for(let i of t)if(i===" "){let o=4-n%4;r+=" ".repeat(o),n+=o}else r+=i,n++;return r}function kd(t,e,n,r,i){let o=e.href,a=e.title||null,s=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,l}function Fw(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
|
|
338
338
|
`).map(o=>{let a=o.match(n.other.beginningSpace);if(a===null)return o;let[s]=a;return s.length>=i.length?o.slice(i.length):o}).join(`
|
|
339
|
-
`)}var
|
|
340
|
-
`),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:
|
|
341
|
-
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=
|
|
339
|
+
`)}var jr=class{options;rules;lexer;constructor(t){this.options=t||Nt}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:_d(e[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=Fw(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=pt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:pt(e[0],`
|
|
340
|
+
`),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:pt(e[0],`
|
|
341
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=pt(e[0],`
|
|
342
342
|
`).split(`
|
|
343
343
|
`),r="",i="",o=[];for(;n.length>0;){let a=!1,s=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))s.push(n[l]),a=!0;else if(!a)s.push(n[l]);else break;n=n.slice(l);let u=s.join(`
|
|
344
344
|
`),c=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
345
345
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
346
346
|
${u}`:u,i=i?`${i}
|
|
347
|
-
${c}`:c;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,o,!0),this.lexer.state.top=h,n.length===0)break;let d=o.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let f=d,
|
|
347
|
+
${c}`:c;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,o,!0),this.lexer.state.top=h,n.length===0)break;let d=o.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let f=d,p=n.join(`
|
|
348
348
|
`),m=f.raw+`
|
|
349
|
-
`+
|
|
350
|
-
${
|
|
349
|
+
`+p.replace(this.rules.other.blockquoteSetextReplace2,""),v=this.blockquote(m);o[o.length-1]=v,r=`${r}
|
|
350
|
+
${p}`,i=i.substring(0,i.length-f.text.length)+v.text;break}else if(d?.type==="list"){let f=d,p=f.raw+`
|
|
351
351
|
`+n.join(`
|
|
352
|
-
`),m=this.list(
|
|
353
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),a=!1;for(;t;){let l=!1,u="",c="";if(!(e=o.exec(t))||this.rules.block.hr.test(t))break;u=e[0],t=t.substring(u.length);let h=
|
|
352
|
+
`),m=this.list(p);o[o.length-1]=m,r=r.substring(0,r.length-d.raw.length)+m.raw,i=i.substring(0,i.length-f.raw.length)+m.raw,n=p.substring(o.at(-1).raw.length).split(`
|
|
353
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),a=!1;for(;t;){let l=!1,u="",c="";if(!(e=o.exec(t))||this.rules.block.hr.test(t))break;u=e[0],t=t.substring(u.length);let h=Ow(e[2].split(`
|
|
354
354
|
`,1)[0],e[1].length),d=t.split(`
|
|
355
|
-
`,1)[0],f=!h.trim(),
|
|
356
|
-
`,t=t.substring(d.length+1),l=!0),!l){let m=this.rules.other.nextBulletRegex(
|
|
357
|
-
`,1)[0],R;if(d=L,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),R=d):R=d.replace(this.rules.other.tabCharGlobal," "),y.test(d)||w.test(d)||k.test(d)||_.test(d)||m.test(d)||v.test(d))break;if(R.search(this.rules.other.nonSpaceChar)>=
|
|
358
|
-
`+R.slice(
|
|
355
|
+
`,1)[0],f=!h.trim(),p=0;if(this.options.pedantic?(p=2,c=h.trimStart()):f?p=e[1].length+1:(p=h.search(this.rules.other.nonSpaceChar),p=p>4?1:p,c=h.slice(p),p+=e[1].length),f&&this.rules.other.blankLine.test(d)&&(u+=d+`
|
|
356
|
+
`,t=t.substring(d.length+1),l=!0),!l){let m=this.rules.other.nextBulletRegex(p),v=this.rules.other.hrRegex(p),y=this.rules.other.fencesBeginRegex(p),w=this.rules.other.headingBeginRegex(p),k=this.rules.other.htmlBeginRegex(p),_=this.rules.other.blockquoteBeginRegex(p);for(;t;){let L=t.split(`
|
|
357
|
+
`,1)[0],R;if(d=L,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),R=d):R=d.replace(this.rules.other.tabCharGlobal," "),y.test(d)||w.test(d)||k.test(d)||_.test(d)||m.test(d)||v.test(d))break;if(R.search(this.rules.other.nonSpaceChar)>=p||!d.trim())c+=`
|
|
358
|
+
`+R.slice(p);else{if(f||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||y.test(h)||w.test(h)||v.test(h))break;c+=`
|
|
359
359
|
`+d}f=!d.trim(),u+=L+`
|
|
360
|
-
`,t=t.substring(L.length+1),h=R.slice(
|
|
361
|
-
`),href:r,title:i}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=
|
|
362
|
-
`):[],o={type:"table",raw:
|
|
363
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of i)o.rows.push(
|
|
360
|
+
`,t=t.substring(L.length+1),h=R.slice(p)}}i.loose||(a?i.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(a=!0)),i.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),i.raw+=u}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.items)if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),!i.loose){let u=l.tokens.filter(h=>h.type==="space"),c=u.length>0&&u.some(h=>this.rules.other.anyLine.test(h.raw));i.loose=c}for(let l of i.items){let u=l.tokens[0];if(l.task&&(u?.type==="text"||u?.type==="paragraph")){l.text=l.text.replace(this.rules.other.listReplaceTask,""),u.raw=u.raw.replace(this.rules.other.listReplaceTask,""),u.text=u.text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}let c=this.rules.other.listTaskCheckbox.exec(l.raw);if(c){let h={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};l.checked=h.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=h.raw+l.tokens[0].raw,l.tokens[0].text=h.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(h)):l.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):l.tokens.unshift(h)}}else l.task&&(l.task=!1)}if(i.loose)for(let l of i.items){l.loose=!0;for(let u of l.tokens)u.type==="text"&&(u.type="paragraph")}return i}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=_d(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:pt(e[0],`
|
|
361
|
+
`),href:r,title:i}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=xd(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
362
|
+
`):[],o={type:"table",raw:pt(e[0],`
|
|
363
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let a of r)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of i)o.rows.push(xd(a,o.header.length).map((s,l)=>({text:s,tokens:this.lexer.inline(s),header:!1,align:o.align[l]})));return o}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:pt(e[0],`
|
|
364
364
|
`),depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
365
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=
|
|
365
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=pt(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=Mw(e[2],"()");if(o===-2)return;if(o>-1){let a=(e[0].indexOf("!")===0?5:4)+e[1].length+o;e[2]=e[2].substring(0,o),e[0]=e[0].substring(0,a).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),kd(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return kd(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,a,s=i,l=0,u=r[0][0],c=n===u,h=u==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*t.length+i);(r=h.exec(e))!==null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(a=[...o].length,r[3]||r[4]){s+=a;continue}else if(r[5]||r[6]){if(i%3&&!((i+a)%3)){l+=a;continue}if(c)break}if(s-=a,s>0)continue;a=Math.min(a,a+s+l);let d=[...r[0]][0].length,f=t.slice(0,i+r.index+d+a);if(Math.min(i,a)%2){let m=f.slice(1,-1);return{type:"em",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}let p=f.slice(2,-2);return{type:"strong",raw:f,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,a,s=i,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+i);(r=l.exec(e))!==null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o||(a=[...o].length,a!==i))continue;if(r[3]||r[4]){s+=a;continue}if(s-=a,s>0)continue;a=Math.min(a,a+s);let u=[...r[0]][0].length,c=t.slice(0,i+r.index+u+a),h=c.slice(i,-i);return{type:"del",raw:c,text:h,tokens:this.lexer.inlineTokens(h)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let i;do i=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(i!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},Ue=class Ko{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Nt,this.options.tokenizer=this.options.tokenizer||new jr,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:ye,block:Kr.normal,inline:Rn.normal};this.options.pedantic?(n.block=Kr.pedantic,n.inline=Rn.pedantic):this.options.gfm&&(n.block=Kr.gfm,this.options.breaks?n.inline=Rn.breaks:n.inline=Rn.gfm),this.tokenizer.rules=n}static get rules(){return{block:Kr,inline:Rn}}static lex(e,n){return new Ko(n).lex(e)}static lexInline(e,n){return new Ko(n).inlineTokens(e)}lex(e){e=e.replace(ye.carriageReturn,`
|
|
366
366
|
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(ye.tabCharGlobal," ").replace(ye.spaceLine,""));let i=1/0;for(;e;){if(e.length<i)i=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let o;if(this.options.extensions?.block?.some(s=>(o=s.call({lexer:this},e,n))?(e=e.substring(o.raw.length),n.push(o),!0):!1))continue;if(o=this.tokenizer.space(e)){e=e.substring(o.raw.length);let s=n.at(-1);o.raw.length===1&&s!==void 0?s.raw+=`
|
|
367
367
|
`:n.push(o);continue}if(o=this.tokenizer.code(e)){e=e.substring(o.raw.length);let s=n.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
368
368
|
`)?"":`
|
|
@@ -376,9 +376,9 @@ ${g}`,i=i.substring(0,i.length-f.text.length)+v.text;break}else if(d?.type==="li
|
|
|
376
376
|
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o),r=a.length!==e.length,e=e.substring(o.raw.length);continue}if(o=this.tokenizer.text(e)){e=e.substring(o.raw.length);let s=n.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
377
377
|
`)?"":`
|
|
378
378
|
`)+o.raw,s.text+=`
|
|
379
|
-
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let s=Object.keys(this.tokens.links);s.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,l=>s.includes(l.slice(l.lastIndexOf("[")+1,-1))?"["+"a".repeat(l.length-2)+"]":l))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(s,l,u)=>{let c=u?u.length:0;return s.slice(0,c)+"["+"a".repeat(s.length-c-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,o="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}i||(o=""),i=!1;let s;if(this.options.extensions?.inline?.some(u=>(s=u.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.escape(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.tag(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.link(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let u=n.at(-1);s.type==="text"&&u?.type==="text"?(u.raw+=s.raw,u.text+=s.text):n.push(s);continue}if(s=this.tokenizer.emStrong(e,r,o)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.codespan(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.br(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.del(e,r,o)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.autolink(e)){e=e.substring(s.raw.length),n.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),n.push(s);continue}let l=e;if(this.options.extensions?.startInline){let u=1/0,c=e.slice(1),h;this.options.extensions.startInline.forEach(d=>{h=d.call({lexer:this},c),typeof h=="number"&&h>=0&&(u=Math.min(u,h))}),u<1/0&&u>=0&&(l=e.substring(0,u+1))}if(s=this.tokenizer.inlineText(l)){e=e.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(o=s.raw.slice(-1)),i=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=s.raw,u.text+=s.text):n.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},
|
|
380
|
-
`;return r?'<pre><code class="language-'+
|
|
381
|
-
`:"<pre><code>"+(n?i:
|
|
379
|
+
`+o.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):n.push(o);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let s=Object.keys(this.tokens.links);s.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,l=>s.includes(l.slice(l.lastIndexOf("[")+1,-1))?"["+"a".repeat(l.length-2)+"]":l))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,s=>"+".repeat(s.length)),r=r.replace(this.tokenizer.rules.inline.blockSkip,(s,l,u)=>{let c=u?u.length:0;return s.slice(0,c)+"["+"a".repeat(s.length-c-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,o="",a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}i||(o=""),i=!1;let s;if(this.options.extensions?.inline?.some(u=>(s=u.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.escape(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.tag(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.link(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let u=n.at(-1);s.type==="text"&&u?.type==="text"?(u.raw+=s.raw,u.text+=s.text):n.push(s);continue}if(s=this.tokenizer.emStrong(e,r,o)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.codespan(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.br(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.del(e,r,o)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.autolink(e)){e=e.substring(s.raw.length),n.push(s);continue}if(!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),n.push(s);continue}let l=e;if(this.options.extensions?.startInline){let u=1/0,c=e.slice(1),h;this.options.extensions.startInline.forEach(d=>{h=d.call({lexer:this},c),typeof h=="number"&&h>=0&&(u=Math.min(u,h))}),u<1/0&&u>=0&&(l=e.substring(0,u+1))}if(s=this.tokenizer.inlineText(l)){e=e.substring(s.raw.length),s.raw.slice(-1)!=="_"&&(o=s.raw.slice(-1)),i=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=s.raw,u.text+=s.text):n.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},qr=class{options;parser;constructor(t){this.options=t||Nt}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(ye.notSpaceStart)?.[0],i=t.replace(ye.endingNewline,"")+`
|
|
380
|
+
`;return r?'<pre><code class="language-'+Ze(r)+'">'+(n?i:Ze(i,!0))+`</code></pre>
|
|
381
|
+
`:"<pre><code>"+(n?i:Ze(i,!0))+`</code></pre>
|
|
382
382
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
383
383
|
${this.parser.parse(t)}</blockquote>
|
|
384
384
|
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
@@ -394,14 +394,14 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
394
394
|
`}tablerow({text:t}){return`<tr>
|
|
395
395
|
${t}</tr>
|
|
396
396
|
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
397
|
-
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${
|
|
398
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+Ye(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Rt=new Zo;function V(t,e){return Rt.parse(t,e)}V.options=V.setOptions=function(t){return Rt.setOptions(t),V.defaults=Rt.defaults,hd(V.defaults),V};V.getDefaults=Bo;V.defaults=Ct;function kw(...t){return Rt.use(...t),V.defaults=Rt.defaults,hd(V.defaults),V}V.use=kw;V.walkTokens=function(t,e){return Rt.walkTokens(t,e)};V.parseInline=Rt.parseInline;V.Parser=Ue;V.parser=Ue.parse;V.Renderer=Kr;V.TextRenderer=Xo;V.Lexer=$e;V.lexer=$e.lex;V.Tokenizer=Wr;V.Hooks=An;V.parse=V;var Yk=V.options,Xk=V.setOptions,Zk=V.walkTokens,Qk=V.parseInline;var Jk=Ue.parse,eE=$e.lex;var kd={"&":"&","<":"<",">":">",'"':""","'":"'"},Ew=new RegExp(`[${Object.keys(kd).join("")}]`,"g");function He(t){return t.replace(Ew,e=>kd[e])}var Sw=["http:","https:","mailto:"],Tw=/^[a-z][a-z0-9+.-]*:/i,Aw=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function _d(t){let e=t.replace(Aw,""),n=Tw.exec(e);return n===null?e===""?null:t:Sw.includes(n[0].toLowerCase())?t:null}var ft="data-weave-target",jr="note:",Rw={bySpelling:new Map,hasGhosts:!1};function Cw(t){if(t.kind!=="note"||!t.id.startsWith(jr))return null;let e=t.id.slice(jr.length);return e===""?null:e}function Ed(t){if(t.kind!=="file"||!t.id.startsWith("artifact:"))return null;let e=t.detail.path;return e!==void 0&&/\.html?$/i.test(e)?e:null}function Sd(t){let e=Ed(t);return e===null?null:`${e}:${t.detail.updated??""}`}function Td(t,e){if(t===null||e===null)return null;let n=t.model.nodes.find(r=>r.id===e);return n===void 0?null:Ed(n)}function Ad(t,e){if(t===null)return Rw;let n=new Map;for(let i of t.model.nodes){let o=Cw(i);if(o!==null)for(let a of[o,i.label])n.set(a,o),n.set(a.toLowerCase(),o)}let r=e!==null&&(t.dangling[e]?.length??0)>0;return{bySpelling:n,hasGhosts:r}}function Nw(t,e){let n=e.trim();return t.bySpelling.get(n)??t.bySpelling.get(n.toLowerCase())??null}function Lw(t){return t.hasGhosts}var Pw=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function Dw(t){let e=t.indexOf("[[");return e===-1?void 0:e}function Iw(t){return{name:"wikilink",level:"inline",start:Dw,tokenizer(e){return Mw(e)},renderer(e){return Gw(t,e)}}}function Gw(t,e){let n=typeof e.target=="string"?e.target:"",r=typeof e.alias=="string"?e.alias:"";return Ow(t,n,r)}function Mw(t){let e=Pw.exec(t);if(e!==null)return{type:"wikilink",raw:e[0],target:e[1],alias:e[2]??""}}function Ow(t,e,n){let r=He((n===""?e:n).trim());if(r==="")return"";let i=Nw(t,e);return i!==null?`<a class="weave-wiki" ${ft}="${He(i)}" role="link" tabindex="0" title="${He(e.trim())}">${r}</a>`:Lw(t)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${He(e.trim())}">${r}</span>`:r}function Fw(t){return new Zo({gfm:!0,async:!1,extensions:[Iw(t)],renderer:{html({text:e}){return He(e)},link({href:e,title:n,tokens:r}){let i=_d(e),o=this.parser.parseInline(r);return`<a${[i===null?"":` href="${He(i)}"`,n==null||n===""?"":` title="${He(n)}"`,i===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${o}</a>`},image({href:e,title:n,text:r}){let i=_d(e);if(i===null)return He(r);let o=n==null||n===""?"":` title="${He(n)}"`;return`<img src="${He(i)}" alt="${He(r)}"${o}>`}}})}function zw(t,e){return Fw(e).parse(t,{async:!1})}function Nn(t){return Object.freeze(t)}var $w=Nn({ALLOWED_TAGS:Nn(["p","br","hr","h1","h2","h3","h4","h5","h6","em","strong","del","code","pre","blockquote","ul","ol","li","a","span","img","table","thead","tbody","tr","th","td","input"]),ALLOWED_ATTR:Nn(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","disabled","start",ft]),ADD_URI_SAFE_ATTR:Nn([ft]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1,USE_PROFILES:Nn({html:!0})});function Rd(t,e,n){return t.sanitize(zw(e,n),$w)}var Cd=32;function Qo(t){let e=t;for(let n=0;e!==null&&n<Cd;n++){let r=e.getAttribute(ft);if(r!==null&&r!=="")return`${jr}${r}`;e=e.parentElement}return null}function Nd(t){if(!t||t.isCollapsed===!0)return!1;let e=t.toString;return(typeof e=="function"&&e!==Object.prototype.toString?e.call(t):"").length>0}var Ld="edited",Pd="created";function Dd(t,e){return{title:t.title,slug:t.slug,provenance:t.source,provenanceGlyph:Et(t.source),provenanceTitle:Wt(t.source),updated:yn(t.updated,e),updatedIso:t.updated,created:yn(t.created,e),createdIso:t.created,tags:t.tags}}function Id(t){return`#${t}`}var Uw=200,Hw=8,Bw="no note",Jo="weave-preview";function ea(t){let e=t;for(let n=0;e!==null&&n<Cd;n++){let r=e.getAttribute(ft);if(r!==null&&r!=="")return{slug:r,text:(e.textContent??"").trim()};if((e.className??"").split(/\s+/).includes("weave-wiki-ghost"))return{slug:null,text:(e.textContent??"").trim()};e=e.parentElement}return null}function Ww(t){return t.replace(/```[\s\S]*?(?:```|$)/g," ").replace(/~~~[\s\S]*?(?:~~~|$)/g," ").replace(/`([^`]*)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[\[([^\]|]*)(?:\|([^\]]*))?\]\]/g,(e,n,r)=>r??n).replace(/<[^>]*>/g," ").replace(/^\s{0,3}#{1,6}\s+/gm,"").replace(/^\s{0,3}>\s?/gm,"").replace(/^\s{0,3}([-*_][ \t]?){3,}$/gm," ").replace(/^\s{0,3}[-*+]\s+/gm,"").replace(/^\s{0,3}\d+[.)]\s+/gm,"").replace(/[*_~]{1,3}([^*_~]*)[*_~]{1,3}/g,"$1").replace(/\s+/g," ").trim()}function Kw(t,e=Uw){let n=Ww(t);if(n.length<=e)return n;let r=n.lastIndexOf(" ",e);return`${r>0?n.slice(0,r):n.slice(0,e)}…`}function Gd(t,e){if(e.slug===null){let i=e.text===""?"this link":e.text;return{ghost:!0,title:i,kind:Bw,text:`no note named “${i}” yet`}}let n=t?.model.nodes.find(i=>i.id===`note:${e.slug}`&&i.kind==="note");if(n===void 0)return null;let r=n.provenance===null?n.kind:`${n.kind} · ${Wt(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:Kw(n.detail.preview??"")}}function Md(t,e,n,r,i,o,a=Hw){let s=t+a,l=e+a;return s+n>i-a&&(s=t-a-n),l+r>o-a&&(l=e-a-r),s=Math.min(Math.max(s,a),Math.max(a,i-a-n)),l=Math.min(Math.max(l,a),Math.max(a,o-a-r)),{x:s,y:l}}var qr={anchor:null,pointerX:0,pointerY:0};function Od(t,e){switch(e.type){case"show":return e.anchor.slug===null&&e.anchor.text===""?t:{anchor:e.anchor,pointerX:e.x,pointerY:e.y};case"hide":return t.anchor===null?t:qr;case"dismiss":return qr}}function Fd(t,e){return e!==null?null:t===null?"Nothing open — search with ⌘K, or walk the tree with j and k.":t.startsWith(jr)?"Loading…":"This node has no note body — see the context rail for what it connects to."}var Vw="weave-preview-x",jw="weave-preview-y";function qw({view:t,open:e}){return x("header",{class:"weave-note-head",children:[x("h3",{class:"weave-note-title",children:t.title}),x("p",{class:"weave-note-meta",children:[x("button",{type:"button",class:"weave-note-open",title:"Open in $EDITOR","aria-label":"Open in $EDITOR",onClick:e,children:x("span",{class:"weave-note-open-mark","aria-hidden":"true",children:"↗"})}),x("span",{class:`weave-prov weave-prov-${t.provenance}`,title:t.provenanceTitle,children:[t.provenanceGlyph," ",t.provenance]}),x("span",{class:"weave-note-time",title:t.updatedIso,children:[Ld," ",t.updated]}),x("span",{class:"weave-note-time",title:t.createdIso,children:[Pd," ",t.created]})]}),x("p",{class:"weave-note-tags",children:t.tags.map(n=>x("span",{class:"weave-tag",children:Id(n)},n))})]})}function zd(t){let e=t.note?.note??null,n=Td(t.graph,t.selectedId),r=Fd(t.selectedId,e),i=qe(()=>e===null?null:Ad(t.graph,e.slug),[e,t.graph]),o=qe(()=>e===null||i===null?"":Rd(id,e.body,i),[e,i]),[a,s]=oe(qr),l=f=>{s(g=>Od(g,f))},u=ee(null),c=ee(null),h=a.anchor===null?null:Gd(t.graph,a.anchor);if(ln(()=>{l({type:"hide"})},[e===null?null:e.slug]),ln(()=>{let f=u.current;if(f!==null){let v=a.anchor?.slug??null;for(let y of f.querySelectorAll(`a[${ft}]`))v!==null&&y.getAttribute(ft)===v?y.setAttribute("aria-describedby",Jo):y.removeAttribute("aria-describedby")}let g=c.current;if(g===null||h===null)return;let m=Md(a.pointerX,a.pointerY,g.offsetWidth,g.offsetHeight,window.innerWidth,window.innerHeight);g.style.setProperty(`--${Vw}`,`${m.x}px`),g.style.setProperty(`--${jw}`,`${m.y}px`)},[a,h]),n!==null){let f=t.graph?.model.nodes.find(v=>v.id===t.selectedId),g=f?.label??n,m=f===void 0?n:Sd(f)??n;return x("article",{class:"weave-note weave-note-artifact",children:[x("header",{class:"weave-note-head",children:[x("h3",{class:"weave-note-title",children:g}),x("p",{class:"weave-note-meta",children:x("span",{class:"weave-note-time",children:n})})]}),x("iframe",{class:"weave-artifact-frame",title:g,sandbox:"allow-scripts",src:`/api/artifact/${encodeURIComponent(n)}`},m)]},m)}if(e===null||i===null)return x("p",{class:"weave-note-empty",children:r});let d=Dd(e,t.now);return x("article",{class:`weave-note weave-note-${d.provenance}`,children:[x(qw,{view:d,open:()=>t.onOpen(e.slug)}),x("div",{ref:u,class:"weave-note-body",tabIndex:-1,onMouseOver:f=>{let g=ea(f.target);l(g!==null?{type:"show",anchor:g,x:f.clientX,y:f.clientY}:{type:"hide"})},onMouseLeave:()=>l({type:"hide"}),onFocus:f=>{let g=ea(f.target);if(g===null)return;let m=f.target.getBoundingClientRect?.();l({type:"show",anchor:g,x:m?.left??0,y:m?.bottom??0})},onBlur:()=>l({type:"hide"}),onClick:f=>{let g=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(Nd(g))return;let m=Qo(f.target);if(m!==null){t.onSelect(m);return}},onKeyDown:f=>{if(f.key==="Escape"&&a.anchor!==null){f.stopPropagation(),l({type:"dismiss"});return}if(f.key!=="Enter"&&f.key!==" ")return;let g=Qo(f.target);g!==null&&(f.preventDefault(),t.onSelect(g))},dangerouslySetInnerHTML:{__html:o}}),h===null?null:x("div",{ref:c,id:Jo,role:"tooltip",class:`weave-preview${h.ghost?" weave-preview-ghost":""}`,children:[x("span",{class:"weave-preview-kind",children:h.kind}),x("span",{class:"weave-preview-title",children:h.title}),h.text===""?null:x("p",{class:"weave-preview-text",children:h.text})]})]},e.slug)}var Ln=["tree","note","graph"],ta={tree:180,note:320,graph:260},Hd={tree:.22,note:.46,graph:.32},Yw=1100,Xw=800;function Bd(t){return!Number.isFinite(t)||t<Xw?"narrow":t<Yw?"medium":"wide"}function $d(t){return t==="wide"?Ln:t==="medium"?["tree","note"]:["note"]}function Wd(t,e,n){let r={tree:0,note:0,graph:0},i=0;for(let l of t){let u=e[l];r[l]=Number.isFinite(u)&&u>0?u:Hd[l],i+=r[l]}for(let l of t)r[l]/=i;let o=0,a=0,s={tree:!1,note:!1,graph:!1};for(let l of t){let u=n[l];r[l]<u?(o+=u-r[l],r[l]=u,s[l]=!0):a+=r[l]-u}if(o>0&&a>0){let l=Math.min(o,a)/a;for(let u of t)s[u]||(r[u]-=(r[u]-n[u])*l)}return{tree:r.tree,note:r.note,graph:r.graph}}function Kd(t,e){return Wd(Ln,t,e)}function ra(t){let e=Number.isFinite(t)&&t>0?t:1,n={tree:ta.tree/e,note:ta.note/e,graph:ta.graph/e},r=n.tree+n.note+n.graph;if(r<=.9)return n;let i=.9/r;return{tree:n.tree*i,note:n.note*i,graph:n.graph*i}}function Vd(t,e){return{fractions:Kd(t,ra(e))}}function Ud(t){return Vd(Hd,t)}function jd(t,e,n){let r=Number.isFinite(e)&&e>0?e:0,i=Wd($d(n),t.fractions,ra(r));return $d(n).map(o=>({id:o,width:i[o]*r}))}function Zw(t){return t==="tree"?["tree","note"]:["note","graph"]}function ia(t,e,n,r){let i=Number.isFinite(r)&&r>0?r:0;if(i===0||!Number.isFinite(n)||n===0)return t;let[o,a]=Zw(e),s=ra(i),l=Math.max(-Math.max(0,t.fractions[o]-s[o]),Math.min(Math.max(0,t.fractions[a]-s[a]),n/i));return l===0?t:{fractions:Kd({...t.fractions,[o]:t.fractions[o]+l,[a]:t.fractions[a]-l},s)}}var qd="pi-weave.layout.v1",na=t=>Math.round(t*1e4)/1e4;function Qw(t){return JSON.stringify({v:1,tree:na(t.fractions.tree),note:na(t.fractions.note),graph:na(t.fractions.graph)})}function Jw(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==1)return null;let i={};for(let o of Ln){let a=r[o];if(typeof a!="number"||!Number.isFinite(a)||a<=0)return null;i[o]=a}return Vd(i,e)}function Yd(t,e){try{return Jw(t.getItem(qd),e)??Ud(e)}catch{return Ud(e)}}function Xd(t,e){try{return t.setItem(qd,Qw(e)),!0}catch{return!1}}var eb={notes:0,repo:null,nodes:0},tb=["note"];function Zd(t){if(t===null)return eb;let e=t.model.nodes;return{notes:e.filter(n=>tb.includes(n.kind)).length,repo:t.model.staleness?.state??null,nodes:e.length}}function nb(t){return t===null||t==="missing"?"unindexed":t}function Qd(t){return[`vault:${t.notes}`,`repo:${nb(t.repo)}`,`${t.nodes} nodes`]}var rb={tree:{title:"Tree"},note:{title:"Note"},graph:{title:"Graph"}};function Jd(t){return rb[t]}var oa={title:"Context"},eh="—";function th(t,e,n){return{cwd:t===""?eh:t,selection:e??"nothing selected",stamp:n}}function nh(t){return t===null?eh:/T(\d{2}:\d{2}:\d{2})/.exec(t)?.[1]??t}var rh=["M21 12a9 9 0 1 1-2.64-6.36","M21 3v6h-6"],ih=6e4,oh="Search…";function aa(t){return t?"⌘K":"Ctrl K"}function ah(t){return`Search notes and repository (${t})`}function sa(t){return/mac|iphone|ipad/i.test(t)}var ib={k:{type:"openSearch"}},sh={1:"tree",2:"note",3:"graph"},ob=new Set(["tree","graph"]);function ab(t){return t.ctrl!==t.meta&&!t.alt&&!t.shift}function sb(t){return!t.ctrl&&!t.meta&&!t.alt}var lb={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"cycleTheme"}};function lh(t,e){if(e.overlay!==null)return t.key==="Escape"?{type:"closeOverlay"}:null;if(ab(t)){let n=ib[t.key.toLowerCase()];if(n!==void 0)return n;let r=sh[t.key];return r===void 0?null:{type:"focusColumn",column:r}}return t.key==="Escape"?e.hasSelection?{type:"clearSelection"}:null:!sb(t)||t.typing?null:lb[t.key]??null}var ub=["INPUT","TEXTAREA","SELECT"];function la(t,e){return e?!0:t!==null&&ub.includes(t.toUpperCase())}function uh(t){return{key:t.key,ctrl:t.ctrlKey,meta:t.metaKey,shift:t.shiftKey,alt:t.altKey,typing:la(t.target?.tagName??null,t.target?.isContentEditable===!0)}}var cb={tree:".weave-col-tree .weave-rows",note:".weave-col-note .weave-note-body",graph:".weave-col-graph .weave-graph-canvas"},db=".weave-col-tree .weave-filter";function hb(t){let e=t;return typeof e?.focus=="function"?e:null}function ch(t,e){let n=hb(t.querySelector(e));return n===null?!1:(n.focus(),!0)}function dh(t,e){switch(t.type){case"openSearch":return e.setOverlay("search");case"openHelp":return e.setOverlay("help");case"closeOverlay":return e.setOverlay(null);case"focusColumn":return void e.focusSelector(cb[t.column]);case"filterTree":return void e.focusSelector(db);case"fitGraph":return e.fitGraph();case"clearSelection":return e.clearSelection();case"cycleTheme":return e.cycleTheme()}}function hh(t){return[{title:"Global",entries:[{combo:`${t}K`,what:"Search notes and the repository"},...Object.entries(sh).map(([e,n])=>({combo:`${t}${e}`,what:`Focus the ${n} column${ob.has(n)?" (when on screen)":""}`})),{combo:"?",what:"This help"},{combo:"t",what:"Cycle the colour theme (system / light / dark)"},{combo:"Esc",what:"Clear the selection, or close an overlay"}]},{title:"Tree",entries:[{combo:"/",what:"Filter the tree"},{combo:"j / ↓",what:"Next row"},{combo:"k / ↑",what:"Previous row"},{combo:"→",what:"Expand, or step into"},{combo:"←",what:"Collapse, or step out"},{combo:"Home / End",what:"First / last row"}]},{title:"Graph",entries:[{combo:"g",what:"Fit the whole graph"}]},{title:"Search",entries:[{combo:"↑ / ↓",what:"Move through results"},{combo:"↵",what:"Open the highlighted result"},{combo:"Esc",what:"Close the palette"}]}]}var ua="Keyboard shortcuts",fh="esc close";var ph={chevron:{d:["M5.75 4.25 9.5 8l-3.75 3.75"],filled:!1},vault:{d:["M8 2.6 13.4 8 8 13.4 2.6 8Z"],filled:!0},note:{d:["M4.5 2.75h4.75l2.25 2.25v8.25h-7Z","M9.25 2.75V5h2.25"],filled:!1},repository:{d:["M2.75 4.25h10.5v7.5H2.75Z","M2.75 6.75h10.5"],filled:!1},module:{d:["M2.75 4.25h4l1.5 1.75h5v5.75h-10.5Z"],filled:!1},package:{d:["M8 2.5 13.25 5v6L8 13.5 2.75 11V5Z","M2.75 5 8 7.5 13.25 5","M8 7.5v6"],filled:!1},entryPoint:{d:["M5.75 3.75v8.5L12.75 8Z"],filled:!0},gitState:{d:["M8 2.85 13.15 8 8 13.15 2.85 8Z"],filled:!1},external:{d:["M4.5 11.5l7-7","M6.75 4.5h4.75v4.75"],filled:!1},file:{d:["M4.5 2.75h7v10.5h-7Z"],filled:!1}};function Pn({name:t,class:e}){let n=ph[t];return x("svg",{class:e,width:16,height:16,viewBox:`0 0 ${16} ${16}`,fill:n.filled?"currentColor":"none",stroke:n.filled?void 0:"currentColor","stroke-width":n.filled?void 0:n.width??1.5,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:n.d.map(r=>x("path",{d:r}))})}function pb({view:t,recentIds:e,onSelect:n,onToggle:r}){return x("li",{id:t.domId,"data-row-id":t.id,class:`weave-row weave-row-${t.kind}${t.selected?" weave-row-on":""}${e.has(t.id)?" weave-row-new":""}`,role:"treeitem","aria-level":t.level,"aria-posinset":t.posinset,"aria-setsize":t.setsize,"aria-selected":t.selected,"aria-expanded":t.hasKids?t.expanded:void 0,style:xu(t.depth),onClick:n,children:[x("span",{class:"weave-twisty","aria-hidden":"true",onClick:i=>{i.stopPropagation(),r()},children:t.hasKids?x(Pn,{name:"chevron",class:t.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),x("span",{class:"weave-kind","aria-hidden":"true",children:x(Pn,{name:t.kindIcon,class:"weave-icon"})}),x("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),x("span",{class:"weave-label",children:t.label}),x("span",{class:"weave-meta",children:t.meta})]})}function gh(t){let[e,n]=oe(hu),r=fu(t.graph,e),i=Cu(t.graph,r,e);return x("div",{class:"weave-tree",onKeyDown:o=>{let a=o.target,s=vu(r,e,t.selectedId,o.key,la(a?.tagName??null,a?.isContentEditable===!0));s.handled&&(o.preventDefault(),n(s.state),s.selectedId!==null&&t.onSelect(s.selectedId))},children:[x("div",{class:"weave-tree-controls",children:[x("input",{type:"search",class:"weave-filter",value:e.query,placeholder:Su,"aria-label":Au,title:Ru,onInput:o=>n(pu(e,o.currentTarget.value))}),x("button",{type:"button",class:"weave-chip",title:_u(e.provFilter),onClick:()=>n(gu(e)),children:["◧ ",Rr(e.provFilter)]}),x("button",{type:"button",class:"weave-chip",title:Eu(e.showInternals),onClick:()=>n(mu(e)),children:["◧ ",ku(e.showInternals)]})]}),i===null?x("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":Tu,"aria-activedescendant":bu(r,t.selectedId)??void 0,children:wu(r,t.selectedId,t.now).map(o=>x(pb,{view:o,recentIds:t.recentIds,onSelect:()=>{t.onSelect(o.id),o.hasKids&&n(a=>wo(a,o.id))},onToggle:()=>n(wo(e,o.id))},o.id))}):x("p",{class:"weave-tree-empty",children:i}),x("p",{class:"weave-tree-count",children:Nu(r)})]})}var Dn={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function Zr(t,e,n){return{id:t,target:e.id,label:Te(e),kind:e.kind,kindIcon:bo(e.kind),provenance:e.provenance,provenanceGlyph:Et(e.provenance),provenanceTitle:Wt(e.provenance),selected:e.id===n}}function gb(t,e,n){let r=t.target;if(r===void 0)return null;let i=e.get(r);return i===void 0?null:Zr(t.id,i,n)}function mb(t){let e=new Map;for(let n of t.nodes)e.set(n.id,n);return e}var vb=["link:links-to:"];function yb(t){return vb.some(e=>t.id.startsWith(e))}function wb(t){return t.id.startsWith("link:mentions:")}function bb(t,e,n,r){let i=[];for(let[o,a]of Object.entries(t.tags)){if(!a.includes(e))continue;let s=[];for(let l of a){if(l===e)continue;let u=n.get(`note:${l}`);u!==void 0&&s.push(Zr(`tag:${o}:${l}`,u,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function xb(t,e,n,r){let i=[];for(let o of t.edges){if(o.kind!=="mentions"||o.target!==e)continue;let a=n.get(o.source);a!==void 0&&i.push(Zr(`mentioned-by:${o.source}`,a,r))}return i}function _b(t){if(!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}var Xr={loading:"Loading…",noSelection:"Select anything to see what it connects to.",unknown:"This node is not in the current graph.",isolated:"Nothing links to or from this yet."};function ca(t){return{subject:null,groups:[],tags:[],tagsCount:0,empty:t}}function mh(t,e){if(t===null)return ca(Xr.loading);if(e===null)return ca(Xr.noSelection);let n=kt(t),r=po(n,e);if(r===null)return ca(Xr.unknown);let i=mb(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,count:d.length,rows:d})},s=h=>h.map(d=>gb(d,i,e)).filter(d=>d!==null);a(Dn.links,s(r.links.filter(yb)));let l=mo(n.edges).get(e)??[];a(Dn.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>Zr(`backlink:${h.id}`,h,e))),a(Dn.mentions,[...s(r.links.filter(wb)),...xb(n,e,i,e)]);let u=_b(e),c=u===null?[]:bb(t,u,i,e);return o.length===0&&c.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:Xr.isolated}:{subject:r.label,groups:o,tags:c,tagsCount:c.length,empty:null}}function vh(){return{open:new Set,closed:new Set}}var kb=8;function yh(t,e,n,r){return r?!1:t.closed.has(e)?!0:t.open.has(e)?!1:n>kb}function Eb(t){return t.some(e=>e.selected)}function wh(t,e){let n=yh(e,t.heading,t.count,Eb(t.rows));return{heading:t.heading,count:t.count,collapsed:n,rows:n?[]:t.rows}}function bh(t,e){let n=yh(e,Dn.tags,t.length,t.some(r=>r.siblings.some(i=>i.selected)));return{heading:Dn.tags,count:t.length,collapsed:n,rows:[]}}function xh(t,e,n){let r=new Set(t.open),i=new Set(t.closed);return n?(r.add(e),i.delete(e)):(i.add(e),r.delete(e)),{open:r,closed:i}}function Qr(t){return`weave-ctx-panel-${t.toLowerCase()}`}function _h({row:t,onSelect:e}){return x("li",{class:`weave-ctx-row${t.selected?" weave-row-on":""}`,children:x("button",{type:"button",class:"weave-ctx-link",onClick:e,children:[x("span",{class:"weave-kind","aria-hidden":"true",children:x(Pn,{name:t.kindIcon,class:"weave-icon"})}),x("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),x("span",{class:"weave-label",children:t.label})]})})}function kh({view:t,onToggle:e}){return x("h4",{class:"weave-ctx-head",children:x("button",{type:"button",class:"weave-ctx-heading","aria-expanded":!t.collapsed,"aria-controls":Qr(t.heading),onClick:e,children:[x("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:x(Pn,{name:"chevron",class:t.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),t.heading,x("span",{class:"weave-ctx-count",children:t.count})]})})}function Sb({view:t,onSelect:e,onToggle:n}){return x("section",{class:"weave-ctx-group",children:[x(kh,{view:t,onToggle:n}),x("ul",{class:"weave-ctx-rows",id:Qr(t.heading),hidden:t.collapsed,children:t.rows.map(r=>x(_h,{row:r,onSelect:()=>e(r.target)},r.id))})]})}function Tb({tag:t,onSelect:e}){return x("li",{class:"weave-ctx-tag",children:[x("span",{class:"weave-tag",children:["#",t.tag]}),x("ul",{class:"weave-ctx-rows",children:t.siblings.map(n=>x(_h,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function Eh(t){let e=mh(t.graph,t.selectedId),[n,r]=oe(vh),i=a=>()=>r(xh(n,a.heading,a.collapsed)),o=bh(e.tags,n);return x("div",{class:"weave-rail","aria-label":oa.title,children:[x("h2",{class:"weave-col-title",children:oa.title}),e.empty===null?null:x("p",{class:"weave-ctx-empty",children:e.empty}),e.groups.map(a=>{let s=wh(a,n);return x(Sb,{view:s,onSelect:t.onSelect,onToggle:i(s)},a.heading)}),e.tags.length===0?null:x("section",{class:"weave-ctx-group",children:[x(kh,{view:o,onToggle:i(o)}),x("ul",{class:"weave-ctx-tags",id:Qr(o.heading),hidden:o.collapsed,children:e.tags.map(a=>x(Tb,{tag:a,onSelect:t.onSelect},a.tag))})]})]})}function Sh(t){return x("div",{class:"weave-divider",role:"separator","aria-orientation":"vertical","aria-label":t.label,tabIndex:0,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),t.onDown(e.clientX)},onPointerMove:e=>t.onMove(e.clientX),onPointerUp:e=>{e.currentTarget.releasePointerCapture(e.pointerId),t.onUp()},onKeyDown:e=>t.onKey(e.key)})}function Ab({id:t,props:e}){let n=Jd(t);return x("section",{class:`weave-col weave-col-${t}`,"aria-label":n.title,children:[x("h2",{class:"weave-col-title",children:n.title}),t==="tree"?x(gh,{graph:e.graph,selectedId:e.selectedId,recentIds:e.recentIds,onSelect:e.onSelect,now:e.now}):null,t==="note"?x(zd,{note:e.note,graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now,onOpen:e.onOpen}):null,t==="graph"?x(Fc,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,renderer:e.renderer,storage:e.storage,host:e.host,scheme:e.scheme,bootFailed:e.bootFailed,fit:e.fit}):null,t==="graph"?x(Eh,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect}):null]})}function Th(t){let e=ee(null);return ln(()=>{let n=e.current;if(n!==null)for(let{id:r,width:i}of t.resolved)n.style.setProperty(`--weave-col-${r}`,`${Math.round(i)}px`)},[t.resolved]),x("div",{class:"weave-grid",ref:e,"data-columns":t.resolved.length,children:t.resolved.map((n,r)=>{let i=r<t.resolved.length-1&&n.id!=="graph"?n.id:null;return[x(Ab,{id:n.id,props:t},`${n.id}-column`),i===null?null:x(Sh,{label:`Resize ${n.id} column`,onDown:o=>t.onDown(i,o),onMove:t.onMove,onUp:t.onUp,onKey:o=>t.onKey(i,o)},`${n.id}-divider`)]})})}function Rb(t){if(t===""||t==="#")return null;let e=t.slice(1),n=/^note[/:](.+)$/.exec(e);return n===null?null:`note:${n[1]}`}function Ah(t,e){let n=Rb(t);return n===null||e===null?null:e.model.nodes.some(r=>r.id===n)?n:null}function Rh(t){let e=t===null?null:t.startsWith("note:")?t.slice(5):null;return e===null||e===""?"":`#note/${e}`}function Cb(t,e,n){return{divider:t,origin:e,base:n}}function Nb(t,e,n){return ia(t.base,t.divider,e-t.origin,n)}function Lb(t,e){return Ln.some(n=>t.base.fractions[n]!==e.fractions[n])}var Ch=24;function Pb(t){return t==="ArrowLeft"?-Ch:t==="ArrowRight"?Ch:0}function Nh(t){let e=null;return{onDown(n,r){e=Cb(n,r,t.layout())},onMove(n){e!==null&&t.setLayout(Nb(e,n,t.width()))},onUp(){let n=e;e=null,n!==null&&Lb(n,t.layout())&&t.persist(t.layout())},onKey(n,r){let i=ia(t.layout(),n,Pb(r),t.width());i!==t.layout()&&(t.setLayout(i),t.persist(i))}}}var Lh="image/png",Ph="iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAMKADAAQAAAABAAAAMAAAAADbN2wMAAALxElEQVRoBe1ZCXCU1R3/f+d+u5s9sleyOUlICBAMkQQQgpqBKqAoFQZFEYwWUAShjsco7dg4njRtPQcoXhSxWMGCimIYj1QqeICAcoQrd0iy2c1+u/vdZ9+m0xnFVCKw0+kMb+fb7/vevnnv//v/f//jvQVIYWtsbCn47uTJ3BQuAXgqJzdRM9CVyjVSCkACCUBIpfgAZCqnl5D8GJ5aBCm1ACALiGIqVZRqC7AIAGApRZBSCiUUBVN14/8YAJfAdN1MKU1TagEuwWEgp1T+1EYhRVUMhdNSmgdSagFeEHVJU/RUOkFKAThIWknLZNRUAkhFjKPSg2Muszocl/i8/mLT1M1IpO/rCBvaK/cePXGhwVxAANacYEHlkmEjymeguFNKUhShaToYhgG6rgJuAifL4oHjpxo3xdu/fAkBuSCWuSAAPNljLsvPH/lCusdfSVlIkFUFVCS0CQYkazkMuTGJEUAQJMrMEkTD3TvaWg/dJUab2s7XIsT5TkA6Cifl5434sCCvqEAS4sBzMdAVFdxYOjgxF6ShD6VTkBCjoEkiEKYBAX9WsaGT0yKh8DsAYvx8ZDhPADnW4SXlr+XnDh0WY3tBlgQwDQ10UQe/NQgOygkexoe4E4WE0AdgIkohWskiD440t9/EKX+cbd36PwNgd+ffMyR/2GJZjoOmySAryfITAxNHQkoyiLLYT6U2thHRB0djNPSuAY4lnyVQVLlMEMm9utp3zs59XmnSmeaelmZzgq7KkIjHgY3FQFOUfs4HHYUgawLQuAVspgdZRgcFAWRZFlRFRmMMtJvCMIKiZpyPBX5WHnA4hvkom/N6VVc+T4S/bXU4XCUCokZSaJokUd3JIDBqP4CuWDMIegRaIhIQyIFV1A+GCXbG2n/XVR2NN4AkiYokAE+g4mqapsrZRHSzFDvWPFhQPweAy+HxfZQdLBgtSVxPs8I/gdji1ZA2RVEAl98D106fAjzPw57P9gAb7QQLZQHVjIOAAKYHAjCheiLgyOY7360HmZdQiNWSlilM95c9npeT9yBJMxS0Q013DMYiAPxgQAzaiTOyxt/rcqXPa2tvApLA0zCcmsrQFIVhBmaxW+DJVQ/BroZdEOrugoUL58LB/Y0gCRLKAQZk5GTA0uXz4Z2t28Fuo+GeZTWwc+enIAhC8nerlbFeoagScbqrA3wejx8j3L0C3/XFYAAMygfs9pIyl9O1MhYNQzzGrgj1hrZKsoYbhorzXByurL4Mwt2nYcNL68DvcUKWzwlFQ7OQU8ugagoMLciEHL8Lcd6Etc+sAcxQYEzFJSAl95zID+KcBD294Q2JRGI5G2fB5fI8YnGUlAwGwGAohNMMU4cWc/Sx7KuG2vI8x8Jawjpso81mmZNmRTRBcV9B/PbmFcNL6zfD9voGmFRZDiamIfEwiERZmHbDIojHBQgOLQBJ1UBE1jGQdRTN0AVBXGfIJ+9FAstRlqqgKOttDEU/JQPMRn0/Wc2elUIMkzGEsTlXJXi+XUzEb3K48m7Jy7/0EcOQFUXRhtusNN7dE4aJl08EX4YXWFGFkqJC6Go/jaKO0p+JNeSweYUFkOb3wby5M5AlLPD2W+8ix1ZAkuWEw2FrzM4tu0/RGUaMs8+aOH4NTuIVkkmvBzWe+ClLDFhK+EpmVyL1lbsN/vWOrhM3khbrBo7nZjot+JFA5tBGTdcJUeIhnuDAjixgtzKQGcyCEWWjkBNz0Hz8GIR6QuByu4GiCYhGYuAPeKFg2HCw0BQc2PsN9PR0I+2bIKJ84XQ60BwOFJFIs635cLEO5FCLzb5D4rnZdXJz/ZHPDyxDfNz38pTxn5wJ5kcWmANziGYf9iFGuhbqBN7Js20WXZY/MOSWjZnZZS/abday1o6WQ5KsHHc60rOCmQGcZaMgoeza2dIKXW0toMgyijYYTKwaC5mZGdDe2g4CL0BHczN0oOcYyhcySmrZwWyQUaWXiLEf83w84fP6gjhppWN9B59XJThlc1C23KorJkEw94+KwE+4IT+4tqGh4Qeb7IEsgPmLZ69EaX4egSmfUTR2imacR+OhZi7T5XqPZXvtPT1dNarUvKmoZFqb00ZmtnR2ogJOA4eVAgrlA5Ig+rmvo7LBRB+CJPqppOs6SMixeVRqoAgGOUE/RFi+tbNt9xAgcmbl5Q3ZYrenR4pmVNxUfvVUXzwSzVVwwq243NNNTd/46rSJz53pEwNFIbP3xNtP2OhEFYqRR2UdX6OqYjdtd47ri/bSmirL/iFF3ZfPucfNxkInBIEDK00jpcu7E6KcYHmUlUUZBFlFOcAE3cRAkDTgBBlinAhokxZFkekf6e505AIqJBJsY119faD6uqmGpkiapPE2f0awCJXeB8W+wPOuuNzl23tgChL+2TOFT9JpIADJfmj77v0oup2wEDCpff+bewvGD98IFBWxEDiDwsf9hM8/05WT2xxLJEyaJmm7le7ho9FxkswvS/Dc/dFY/LlonNvSF49vY+Pc6hifWIpC8Dw+dqrS7XIj7zaocJQ1Kqdc0YZJ9PRwT2QJCrOU2+8Jjysd/envp08+FtBbr8RVaF710J2xfqEG+PqRD3x/THG+rUU0PLPtROE39uyMcWxXVycKLZM5Nmoc++dbS1csvnnrRx/vxVE9M8GTkV3qyw6Ee1u/qtOVyB50fajJvZs1Ofw3XQl/sF2OfDtz6W29TYfaF1hp+0IBhdFYLPrI8f31D+x88y+H4qz2G4vV6qXtrqdLKyrJ2b+YcJITbTNDVGjTvu3bf8D778s4kA98/3fIKps1BjOpsa5AuuXIod2vOBStHsXpqr6+SHX1pJrPWaqlINTW8QeU1aZnlZdR+eUlvyU0vY1kLCRptZiMg0F1EkHjBBgUQVQ27W+8dt+2nXYbSW5cNOf2Y8hDTr++7a9MU1vTG2Coh2PRo1WPPrZ1kSpKhkbInz39WM2+Hwh0xstZE5nOmx2YlamPhGWtIOeSxlioqV6K81W+YPbdLN1ZihEWLm/kqId0XT7sLyzo0riEDyfpRlRRNxk4jRJcQiEMtLtXyOt0IHYXlA45Xgiz4tmZubvwU60tkjdQ6khzLZIVExsz8tK9117+6Aw9xDxoIWweTQmNOEPeH72eFYCVIXHJNATAqBzd0Ce7fJmbuGhjKaIRf2Bn9lqAWqNi8WIqXUhvf3/VijXXPFCbyTC2+QppYSinN6wIHI2Z2DTM1Hc4KAPFePygE7PLoUhk7JMvLD+GJPoGyLxWmmb+XpI36kFRkGehAtxiqFo3SgtnPZL5r078H6gthzd345g6iTbk0ThmNuMYE1S4ozWSzNYlhU+Oo7stowRePJ18/qCutnvT75bVaR5fjeTyf6va019WJellKsxyAqcH/jR/7sHTEaVN541MtF/+N4UJc7MiHJ8f8GVUaqZqSlhstAnRisdfXHDWsvqsFkgKdfrQm+3olrwOF1feOLdk4q23B4cVvdawvhZ1AaBN1nBTV79MPpfOqaXdQmQ838OC1euTUbncjHP4nSoeWGF09d2VHLNu3Z3C8kWruTvueMqHXntfe3hD56HOYzWKIsefeWUJOrFIHgMMrp3ViQeapqRqbiVOWyfjJLlTZZwdjMrfAgb/itXmrqJJy0gMx47rUmSXf/pV3m1Lbm655f4X51oY5zgqLh7Red5u8PoXhElngsnkY5i4h6TwaswkGla/sfTrgdb7qb5zApCcsKTqDlTAkLertPNhAsMkq5pYzxDYJ1+9v2bX9xe8fuHKDJr2/nLL6vv+nOxfsOBJryli1zFGcKWN8hbzemiLyLX/6o0dted0OnHOAJLClFy1LEvBiMMYQSgMSHUUgUcoEpOApFmaolkGw3UrYbuR0I3dhKoLlEGmo2LDhTb4HGV4J1Fgv17RYr9+ddvit5LznUs7LwDJBUurby1C1aPW2LC+pbT67jTKTfssFOFFB1lOdJSF6lSKoHCStSgGj0qkMNrDhN97r7b/j7M5U2s9m+tr0XnLxXZRAxc1cFEDFzVwUQPnpoF/AbqLsVZFbswxAAAAAElFTkSuQmCC";function Db({onRefresh:t}){let[e,n]=oe(!1);return x("button",{type:"button",class:"weave-refresh",onClick:()=>{t(),n(!0)},onAnimationEnd:()=>n(!1),title:"Refetch everything","aria-busy":e?"true":void 0,children:x("svg",{class:e?"weave-refresh-glyph weave-refresh-spinning":"weave-refresh-glyph",viewBox:"0 0 24 24",width:14,height:14,fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:rh.map(r=>x("path",{d:r},r))})})}function Dh(t){return x("header",{class:"weave-header",children:[x("span",{class:"weave-brand",children:[x("img",{class:"weave-brand-mark",src:`data:${Lh};base64,${Ph}`,alt:"",width:18,height:18}),"pi-weave"]}),x("button",{type:"button",class:"weave-search",title:ah(t.shortcut),onClick:t.onSearch,children:[x("span",{class:"weave-search-text",children:oh}),x("kbd",{children:t.shortcut})]}),x("span",{class:"weave-summary",children:Qd(t.summary).map(e=>x("span",{class:"weave-summary-part",children:e},e))}),x("button",{type:"button",class:"weave-theme",onClick:t.onTheme,title:t.theme.hint,"aria-label":t.theme.hint,children:t.theme.glyph}),x(Db,{onRefresh:t.onRefresh})]})}function Ib({group:t}){return x("div",{children:[x("p",{class:"weave-key-group",children:t.title}),t.entries.map(e=>x("div",{class:"weave-key-row",children:[x("kbd",{class:"weave-key-combo",children:e.combo}),x("span",{class:"weave-key-what",children:e.what})]},e.combo))]})}function Ih(t){let e=Fr(),n=t.shortcut.slice(0,-1);return x("div",{class:"weave-scrim",onClick:t.onClose,children:x("div",{class:"weave-help",role:"dialog","aria-modal":"true","aria-label":ua,tabIndex:-1,ref:e.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{e.onKeyDown(r)},children:[x("h2",{class:"weave-help-title",children:ua}),x("div",{class:"weave-keys",children:hh(n).map(r=>x(Ib,{group:r},r.title))}),x("p",{class:"weave-help-foot",children:[x("button",{type:"button",class:"weave-chip",onClick:t.onClose,children:"close"}),x("span",{class:"weave-help-hint",children:fh})]})]})})}function Gh(t,e){let n=r=>{let i=lh(uh(r),e.context());i!==null&&(r.preventDefault(),e.run(i))};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)}function Mh({model:t}){return x("footer",{class:"weave-status",children:[x("span",{class:"weave-status-cwd",title:t.cwd,children:t.cwd}),x("span",{class:"weave-status-sel",title:"the §1.3 context bus — one signal, every column",children:t.selection}),x("span",{class:"weave-status-stamp",title:"data as of",children:nh(t.stamp)})]})}var da=["system","light","dark"],Oh="pi-weave.theme.v1";function Gb(t){return t==="system"||t==="light"||t==="dark"}function Jr(t){try{let e=t.getItem(Oh);return Gb(e)?e:null}catch{return null}}function Fh(t,e){try{return t.setItem(Oh,e),!0}catch{return!1}}function ei(t){let e=da.indexOf(t);return da[(e+1)%da.length]??"system"}function zh(t,e){return t==="system"?e:t}function ti(t){return t==="system"?null:t}var Mb={dark:"●",system:"◐",light:"○"};function $h(t){return{glyph:Mb[t],hint:`Colour theme: ${t} — click for ${ei(t)}`}}function Ob(t){t===null?delete document.documentElement.dataset.weaveTheme:document.documentElement.dataset.weaveTheme=t}function Uh(t){let[e,n]=oe(wc),[r,i]=oe(null),[o,a]=oe(t.initialWidth),[s,l]=oe(()=>Yd(localStorage,t.initialWidth)),[u,c]=oe(()=>Jr(localStorage)??"system"),[h,d]=oe(()=>ir(window)),f=ee(null),g=ee(null),m=ee({overlay:r,selectedId:e.selectedId,layout:s,width:o});m.current={overlay:r,selectedId:e.selectedId,layout:s,width:o},ie(()=>{let R=_c({fetch:rr,state:e,setState:n});return f.current=R,()=>R.stop()},[]),ie(()=>{let R=()=>a(window.innerWidth);return window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[]);let v=ee(!1),y=ee(location.hash);ie(()=>{v.current&&(vc(localStorage,e.selectedId),history.replaceState(null,"",Rh(e.selectedId)))},[e.selectedId]),ie(()=>{if(v.current||e.graph===null||(v.current=!0,e.selectedId!==null))return;let R=Ah(y.current,e.graph);if(R!==null)f.current?.select(R);else{let D=yc(e.graph,localStorage);D!==null&&f.current?.select(D)}},[e.graph]);let[w,k]=oe(()=>Date.now());ie(()=>{let R=setInterval(()=>k(Date.now()),ih);return()=>clearInterval(R)},[]),ie(()=>Ob(ti(u)),[u]),ie(()=>{Fh(localStorage,u)},[u]),ie(()=>Ss(window,d),[]),ie(()=>Gh(document,{context:()=>({overlay:m.current.overlay,hasSelection:m.current.selectedId!==null}),run:R=>dh(R,{setOverlay:i,focusSelector:D=>ch(document,D),fitGraph:()=>g.current?.(),clearSelection:()=>{f.current?.select(null)},cycleTheme:()=>c(D=>ei(D))})}),[]);let _=qe(()=>jd(s,o,Bd(o)),[s,o]),L=qe(()=>Nh({layout:()=>m.current.layout,width:()=>m.current.width,setLayout:l,persist:R=>{Xd(localStorage,R)}}),[]);return x(st,{children:[x(Dh,{summary:Zd(e.graph),shortcut:aa(sa(t.platform)),onRefresh:()=>f.current?.refresh(),onSearch:()=>i("search"),theme:$h(u),onTheme:()=>c(R=>ei(R))}),x(Th,{resolved:_,onDown:L.onDown,onMove:L.onMove,onUp:L.onUp,onKey:L.onKey,scheme:zh(u,h),bootFailed:e.graphFailed,graph:e.graph,note:e.note,selectedId:e.selectedId,recentIds:e.recentIds,onSelect:R=>{f.current?.select(R)},onOpen:R=>{ks(rr,R)},now:w,renderer:tc,storage:localStorage,host:window,fit:g}),x(Mh,{model:th(t.cwd,e.selectedId,e.graph?.model.generatedAt??null)}),r==="search"?x(gc,{graph:e.graph,onSelect:R=>{f.current?.select(R)},onClose:()=>i(null),ports:{fetch:rr}}):null,r==="help"?x(Ih,{shortcut:aa(sa(t.platform)),onClose:()=>i(null)}):null]})}var Hh=`
|
|
397
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Ze(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),i=bd(t);if(i===null)return r;t=i;let o='<a href="'+t+'"';return e&&(o+=' title="'+Ze(e)+'"'),o+=">"+r+"</a>",o}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=bd(t);if(i===null)return Ze(n);t=i;let o=`<img src="${t}" alt="${Ze(n)}"`;return e&&(o+=` title="${Ze(e)}"`),o+=">",o}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Ze(t.text)}},ea=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},He=class Vo{options;renderer;textRenderer;constructor(e){this.options=e||Nt,this.options.renderer=this.options.renderer||new qr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ea}static parse(e,n){return new Vo(n).parse(e)}static parseInline(e,n){return new Vo(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let a=i,s=this.options.extensions.renderers[a.type].call({parser:this},a);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(a.type)){n+=s||"";continue}}let o=i;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let o=e[i];if(this.options.extensions?.renderers?.[o.type]){let s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(o.type)){r+=s||"";continue}}let a=o;switch(a.type){case"escape":{r+=n.text(a);break}case"html":{r+=n.html(a);break}case"link":{r+=n.link(a);break}case"image":{r+=n.image(a);break}case"checkbox":{r+=n.checkbox(a);break}case"strong":{r+=n.strong(a);break}case"em":{r+=n.em(a);break}case"codespan":{r+=n.codespan(a);break}case"br":{r+=n.br(a);break}case"del":{r+=n.del(a);break}case"text":{r+=n.text(a);break}default:{let s='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return r}},Cn=class{options;block;constructor(t){this.options=t||Nt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?Ue.lex:Ue.lexInline}provideParser(t=this.block){return t?He.parse:He.parseInline}},ta=class{defaults=jo();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=He;Renderer=qr;TextRenderer=ea;Lexer=Ue;Tokenizer=jr;Hooks=Cn;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let i=r;for(let o of i.header)n=n.concat(this.walkTokens(o.tokens,e));for(let o of i.rows)for(let a of o)n=n.concat(this.walkTokens(a.tokens,e));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,e));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(o=>{let a=i[o].flat(1/0);n=n.concat(this.walkTokens(a,e))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=e.renderers[i.name];o?e.renderers[i.name]=function(...a){let s=i.renderer.apply(this,a);return s===!1&&(s=o.apply(this,a)),s}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=e[i.level];o?o.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){let i=this.defaults.renderer||new qr(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,s=n.renderer[a],l=i[a];i[a]=(...u)=>{let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new jr(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,s=n.tokenizer[a],l=i[a];i[a]=(...u)=>{let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Cn;for(let o in n.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,s=n.hooks[a],l=i[a];Cn.passThroughHooks.has(o)?i[a]=u=>{if(this.defaults.async&&Cn.passThroughHooksRespectAsync.has(o))return(async()=>{let h=await s.call(i,u);return l.call(i,h)})();let c=s.call(i,u);return l.call(i,c)}:i[a]=(...u)=>{if(this.defaults.async)return(async()=>{let h=await s.apply(i,u);return h===!1&&(h=await l.apply(i,u)),h})();let c=s.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,o=n.walkTokens;r.walkTokens=function(a){let s=[];return s.push(o.call(this,a)),i&&(s=s.concat(i.call(this,a))),s}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Ue.lex(t,e??this.defaults)}parser(t,e){return He.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let a=i.hooks?await i.hooks.preprocess(e):e,s=await(i.hooks?await i.hooks.provideLexer(t):t?Ue.lex:Ue.lexInline)(a,i),l=i.hooks?await i.hooks.processAllTokens(s):s;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser(t):t?He.parse:He.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(o);try{i.hooks&&(e=i.hooks.preprocess(e));let a=(i.hooks?i.hooks.provideLexer(t):t?Ue.lex:Ue.lexInline)(e,i);i.hooks&&(a=i.hooks.processAllTokens(a)),i.walkTokens&&this.walkTokens(a,i.walkTokens);let s=(i.hooks?i.hooks.provideParser(t):t?He.parse:He.parseInline)(a,i);return i.hooks&&(s=i.hooks.postprocess(s)),s}catch(a){return o(a)}}}onError(t,e){return n=>{if(n.message+=`
|
|
398
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+Ze(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Ct=new ta;function V(t,e){return Ct.parse(t,e)}V.options=V.setOptions=function(t){return Ct.setOptions(t),V.defaults=Ct.defaults,Ed(V.defaults),V};V.getDefaults=jo;V.defaults=Nt;function zw(...t){return Ct.use(...t),V.defaults=Ct.defaults,Ed(V.defaults),V}V.use=zw;V.walkTokens=function(t,e){return Ct.walkTokens(t,e)};V.parseInline=Ct.parseInline;V.Parser=He;V.parser=He.parse;V.Renderer=qr;V.TextRenderer=ea;V.Lexer=Ue;V.lexer=Ue.lex;V.Tokenizer=jr;V.Hooks=Cn;V.parse=V;var uE=V.options,cE=V.setOptions,dE=V.walkTokens,hE=V.parseInline;var fE=He.parse,pE=Ue.lex;var Gd={"&":"&","<":"<",">":">",'"':""","'":"'"},$w=new RegExp(`[${Object.keys(Gd).join("")}]`,"g");function Ce(t){return t.replace($w,e=>Gd[e])}var Uw=["http:","https:","mailto:"],Md=/^[a-z][a-z0-9+.-]*:/i,Od=/[\u0000-\u0020\u00a0\u1680\u180e\u2000-\u2029\u205f\u3000]/g;function Id(t){let e=t.replace(Od,""),n=Md.exec(e);return n===null?e===""?null:t:Uw.includes(n[0].toLowerCase())?t:null}var at="data-weave-target",Xr="note:",Hw={bySpelling:new Map,hasGhosts:!1,currentSlug:null};function Bw(t){if(t.kind!=="note"||!t.id.startsWith(Xr))return null;let e=t.id.slice(Xr.length);return e===""?null:e}function Fd(t){if(t.kind!=="file"||!t.id.startsWith("artifact:"))return null;let e=t.detail.path;return e!==void 0&&/\.html?$/i.test(e)?e:null}function zd(t){let e=Fd(t);return e===null?null:`${e}:${t.detail.updated??""}`}function $d(t,e){if(t===null||e===null)return null;let n=t.model.nodes.find(r=>r.id===e);return n===void 0?null:Fd(n)}function Ud(t,e){if(t===null)return Hw;let n=new Map;for(let i of t.model.nodes){let o=Bw(i);if(o!==null)for(let a of[o,i.label])n.set(a,o),n.set(a.toLowerCase(),o)}let r=e!==null&&(t.dangling[e]?.length??0)>0;return{bySpelling:n,hasGhosts:r,currentSlug:e}}function Hd(t,e){let n=e.trim();return t.bySpelling.get(n)??t.bySpelling.get(n.toLowerCase())??null}function Ww(t,e){if(t.currentSlug===null||Md.test(e.replace(Od,"")))return null;try{let n=new URL(e,`https://weave.invalid/${t.currentSlug}.md`);return n.origin!=="https://weave.invalid"||!n.pathname.toLowerCase().endsWith(".md")?null:Hd(t,decodeURIComponent(n.pathname.slice(1,-3)))}catch{return null}}function Kw(t){return t.hasGhosts}var Vw=/^\[\[([^\][|]+)(?:\|([^\]]*))?\]\]/;function jw(t){let e=t.indexOf("[[");return e===-1?void 0:e}function qw(t){return{name:"wikilink",level:"inline",start:jw,tokenizer(e){return Xw(e)},renderer(e){return Yw(t,e)}}}function Yw(t,e){let n=typeof e.target=="string"?e.target:"",r=typeof e.alias=="string"?e.alias:"";return Zw(t,n,r)}function Xw(t){let e=Vw.exec(t);if(e!==null)return{type:"wikilink",raw:e[0],target:e[1],alias:e[2]??""}}function Zw(t,e,n){let r=Ce((n===""?e:n).trim());if(r==="")return"";let i=Hd(t,e);return i!==null?`<a class="weave-wiki" ${at}="${Ce(i)}" role="link" tabindex="0" title="${Ce(e.trim())}">${r}</a>`:Kw(t)?`<span class="weave-wiki weave-wiki-ghost" title="no note named ${Ce(e.trim())}">${r}</span>`:r}function Qw(t){return new ta({gfm:!0,async:!1,extensions:[qw(t)],renderer:{html({text:e}){return/^\s*<!--[\s\S]*?-->\s*$/.test(e)?"":Ce(e)},link({href:e,title:n,tokens:r}){let i=Id(e),o=this.parser.parseInline(r),a=i===null?null:Ww(t,i);if(a!==null){let l=n==null||n===""?"":` title="${Ce(n)}"`;return`<a class="weave-wiki" ${at}="${Ce(a)}" role="link" tabindex="0"${l}>${o}</a>`}return`<a${[i===null?"":` href="${Ce(i)}"`,n==null||n===""?"":` title="${Ce(n)}"`,i===null?"":' rel="noreferrer noopener" target="_blank"'].join("")}>${o}</a>`},image({href:e,title:n,text:r}){let i=Id(e);if(i===null)return Ce(r);let o=n==null||n===""?"":` title="${Ce(n)}"`;return`<img src="${Ce(i)}" alt="${Ce(r)}"${o}>`}}})}function Jw(t,e){return Qw(e).parse(t,{async:!1})}function Dn(t){return Object.freeze(t)}var eb=Dn({ALLOWED_TAGS:Dn(["p","br","hr","h1","h2","h3","h4","h5","h6","em","strong","del","code","pre","blockquote","ul","ol","li","a","span","img","table","thead","tbody","tr","th","td","input"]),ALLOWED_ATTR:Dn(["href","src","alt","title","class","role","tabindex","colspan","rowspan","align","type","checked","disabled","start",at]),ADD_URI_SAFE_ATTR:Dn([at]),ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1,ALLOW_UNKNOWN_PROTOCOLS:!1,USE_PROFILES:Dn({html:!0})});function Bd(t,e,n){return t.sanitize(Jw(e,n),eb)}var Wd=32;function na(t){let e=t;for(let n=0;e!==null&&n<Wd;n++){let r=e.getAttribute(at);if(r!==null&&r!=="")return`${Xr}${r}`;e=e.parentElement}return null}function Kd(t){if(!t||t.isCollapsed===!0)return!1;let e=t.toString;return(typeof e=="function"&&e!==Object.prototype.toString?e.call(t):"").length>0}var Vd="edited",jd="created";function qd(t,e){return{title:t.title,slug:t.slug,provenance:t.source,provenanceGlyph:St(t.source),provenanceTitle:Kt(t.source),updated:bn(t.updated,e),updatedIso:t.updated,created:bn(t.created,e),createdIso:t.created,tags:t.tags}}function Yd(t){return`#${t}`}var tb=200,nb=8,rb="no note",ra="weave-preview";function ia(t){let e=t;for(let n=0;e!==null&&n<Wd;n++){let r=e.getAttribute(at);if(r!==null&&r!=="")return{slug:r,text:(e.textContent??"").trim()};if((e.className??"").split(/\s+/).includes("weave-wiki-ghost"))return{slug:null,text:(e.textContent??"").trim()};e=e.parentElement}return null}function ib(t){return t.replace(/```[\s\S]*?(?:```|$)/g," ").replace(/~~~[\s\S]*?(?:~~~|$)/g," ").replace(/`([^`]*)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[\[([^\]|]*)(?:\|([^\]]*))?\]\]/g,(e,n,r)=>r??n).replace(/<[^>]*>/g," ").replace(/^\s{0,3}#{1,6}\s+/gm,"").replace(/^\s{0,3}>\s?/gm,"").replace(/^\s{0,3}([-*_][ \t]?){3,}$/gm," ").replace(/^\s{0,3}[-*+]\s+/gm,"").replace(/^\s{0,3}\d+[.)]\s+/gm,"").replace(/[*_~]{1,3}([^*_~]*)[*_~]{1,3}/g,"$1").replace(/\s+/g," ").trim()}function ob(t,e=tb){let n=ib(t);if(n.length<=e)return n;let r=n.lastIndexOf(" ",e);return`${r>0?n.slice(0,r):n.slice(0,e)}…`}function Xd(t,e){if(e.slug===null){let i=e.text===""?"this link":e.text;return{ghost:!0,title:i,kind:rb,text:`no note named “${i}” yet`}}let n=t?.model.nodes.find(i=>i.id===`note:${e.slug}`&&i.kind==="note");if(n===void 0)return null;let r=n.provenance===null?n.kind:`${n.kind} · ${Kt(n.provenance)}`;return{ghost:!1,title:n.label,kind:r,text:ob(n.detail.preview??"")}}function Zd(t,e,n,r,i,o,a=nb){let s=t+a,l=e+a;return s+n>i-a&&(s=t-a-n),l+r>o-a&&(l=e-a-r),s=Math.min(Math.max(s,a),Math.max(a,i-a-n)),l=Math.min(Math.max(l,a),Math.max(a,o-a-r)),{x:s,y:l}}var Zr={anchor:null,pointerX:0,pointerY:0};function Qd(t,e){switch(e.type){case"show":return e.anchor.slug===null&&e.anchor.text===""?t:{anchor:e.anchor,pointerX:e.x,pointerY:e.y};case"hide":return t.anchor===null?t:Zr;case"dismiss":return Zr}}function Jd(t,e){return e!==null?null:t===null?"Nothing open — search with ⌘K, or walk the tree with j and k.":t.startsWith(Xr)?"Loading…":"This node has no note body — see the context rail for what it connects to."}var ab="weave-preview-x",sb="weave-preview-y";function lb({view:t,open:e}){return x("header",{class:"weave-note-head",children:[x("h3",{class:"weave-note-title",children:t.title}),x("p",{class:"weave-note-meta",children:[x("button",{type:"button",class:"weave-note-open",title:"Open in $EDITOR","aria-label":"Open in $EDITOR",onClick:e,children:x("span",{class:"weave-note-open-mark","aria-hidden":"true",children:"↗"})}),x("span",{class:`weave-prov weave-prov-${t.provenance}`,title:t.provenanceTitle,children:[t.provenanceGlyph," ",t.provenance]}),x("span",{class:"weave-note-time",title:t.updatedIso,children:[Vd," ",t.updated]}),x("span",{class:"weave-note-time",title:t.createdIso,children:[jd," ",t.created]})]}),x("p",{class:"weave-note-tags",children:t.tags.map(n=>x("span",{class:"weave-tag",children:Yd(n)},n))})]})}function eh(t){let e=t.note?.note??null,n=$d(t.graph,t.selectedId),r=Jd(t.selectedId,e),i=Ye(()=>e===null?null:Ud(t.graph,e.slug),[e,t.graph]),o=Ye(()=>e===null||i===null?"":Bd(md,e.body,i),[e,i]),[a,s]=ne(Zr),l=f=>{s(p=>Qd(p,f))},u=ee(null),c=ee(null),h=a.anchor===null?null:Xd(t.graph,a.anchor);if(un(()=>{l({type:"hide"})},[e===null?null:e.slug]),un(()=>{let f=u.current;if(f!==null){let v=a.anchor?.slug??null;for(let y of f.querySelectorAll(`a[${at}]`))v!==null&&y.getAttribute(at)===v?y.setAttribute("aria-describedby",ra):y.removeAttribute("aria-describedby")}let p=c.current;if(p===null||h===null)return;let m=Zd(a.pointerX,a.pointerY,p.offsetWidth,p.offsetHeight,window.innerWidth,window.innerHeight);p.style.setProperty(`--${ab}`,`${m.x}px`),p.style.setProperty(`--${sb}`,`${m.y}px`)},[a,h]),n!==null){let f=t.graph?.model.nodes.find(v=>v.id===t.selectedId),p=f?.label??n,m=f===void 0?n:zd(f)??n;return x("article",{class:"weave-note weave-note-artifact",children:[x("header",{class:"weave-note-head",children:[x("h3",{class:"weave-note-title",children:p}),x("p",{class:"weave-note-meta",children:x("span",{class:"weave-note-time",children:n})})]}),x("iframe",{class:"weave-artifact-frame",title:p,sandbox:"allow-scripts",src:`/api/artifact/${encodeURIComponent(n)}`},m)]},m)}if(e===null||i===null)return x("p",{class:"weave-note-empty",children:r});let d=qd(e,t.now);return x("article",{class:`weave-note weave-note-${d.provenance}`,children:[x(lb,{view:d,open:()=>t.onOpen(e.slug)}),x("div",{ref:u,class:"weave-note-body",tabIndex:-1,onMouseOver:f=>{let p=ia(f.target);l(p!==null?{type:"show",anchor:p,x:f.clientX,y:f.clientY}:{type:"hide"})},onMouseLeave:()=>l({type:"hide"}),onFocus:f=>{let p=ia(f.target);if(p===null)return;let m=f.target.getBoundingClientRect?.();l({type:"show",anchor:p,x:m?.left??0,y:m?.bottom??0})},onBlur:()=>l({type:"hide"}),onClick:f=>{let p=typeof window<"u"&&typeof window.getSelection=="function"?window.getSelection():null;if(Kd(p))return;let m=na(f.target);if(m!==null){t.onSelect(m);return}},onKeyDown:f=>{if(f.key==="Escape"&&a.anchor!==null){f.stopPropagation(),l({type:"dismiss"});return}if(f.key!=="Enter"&&f.key!==" ")return;let p=na(f.target);p!==null&&(f.preventDefault(),t.onSelect(p))},dangerouslySetInnerHTML:{__html:o}}),h===null?null:x("div",{ref:c,id:ra,role:"tooltip",class:`weave-preview${h.ghost?" weave-preview-ghost":""}`,children:[x("span",{class:"weave-preview-kind",children:h.kind}),x("span",{class:"weave-preview-title",children:h.title}),h.text===""?null:x("p",{class:"weave-preview-text",children:h.text})]})]},e.slug)}var Pn=["tree","note","graph"],oa={tree:180,note:320,graph:260},rh={tree:.22,note:.46,graph:.32},ub=1100,cb=800;function ih(t){return!Number.isFinite(t)||t<cb?"narrow":t<ub?"medium":"wide"}function th(t){return t==="wide"?Pn:t==="medium"?["tree","note"]:["note"]}function oh(t,e,n){let r={tree:0,note:0,graph:0},i=0;for(let l of t){let u=e[l];r[l]=Number.isFinite(u)&&u>0?u:rh[l],i+=r[l]}for(let l of t)r[l]/=i;let o=0,a=0,s={tree:!1,note:!1,graph:!1};for(let l of t){let u=n[l];r[l]<u?(o+=u-r[l],r[l]=u,s[l]=!0):a+=r[l]-u}if(o>0&&a>0){let l=Math.min(o,a)/a;for(let u of t)s[u]||(r[u]-=(r[u]-n[u])*l)}return{tree:r.tree,note:r.note,graph:r.graph}}function ah(t,e){return oh(Pn,t,e)}function sa(t){let e=Number.isFinite(t)&&t>0?t:1,n={tree:oa.tree/e,note:oa.note/e,graph:oa.graph/e},r=n.tree+n.note+n.graph;if(r<=.9)return n;let i=.9/r;return{tree:n.tree*i,note:n.note*i,graph:n.graph*i}}function sh(t,e){return{fractions:ah(t,sa(e))}}function nh(t){return sh(rh,t)}function lh(t,e,n){let r=Number.isFinite(e)&&e>0?e:0,i=oh(th(n),t.fractions,sa(r));return th(n).map(o=>({id:o,width:i[o]*r}))}function db(t){return t==="tree"?["tree","note"]:["note","graph"]}function la(t,e,n,r){let i=Number.isFinite(r)&&r>0?r:0;if(i===0||!Number.isFinite(n)||n===0)return t;let[o,a]=db(e),s=sa(i),l=Math.max(-Math.max(0,t.fractions[o]-s[o]),Math.min(Math.max(0,t.fractions[a]-s[a]),n/i));return l===0?t:{fractions:ah({...t.fractions,[o]:t.fractions[o]+l,[a]:t.fractions[a]-l},s)}}var uh="pi-weave.layout.v1",aa=t=>Math.round(t*1e4)/1e4;function hb(t){return JSON.stringify({v:1,tree:aa(t.fractions.tree),note:aa(t.fractions.note),graph:aa(t.fractions.graph)})}function fb(t,e){if(t===null)return null;let n;try{n=JSON.parse(t)}catch{return null}if(typeof n!="object"||n===null||Array.isArray(n))return null;let r=n;if(r.v!==1)return null;let i={};for(let o of Pn){let a=r[o];if(typeof a!="number"||!Number.isFinite(a)||a<=0)return null;i[o]=a}return sh(i,e)}function ch(t,e){try{return fb(t.getItem(uh),e)??nh(e)}catch{return nh(e)}}function dh(t,e){try{return t.setItem(uh,hb(e)),!0}catch{return!1}}var pb={notes:0,repo:null,nodes:0},gb=["note"];function hh(t){if(t===null)return pb;let e=t.model.nodes;return{notes:e.filter(n=>gb.includes(n.kind)).length,repo:t.model.staleness?.state??null,nodes:e.length}}function mb(t){return t===null||t==="missing"?"unindexed":t}function fh(t){return[`vault:${t.notes}`,`repo:${mb(t.repo)}`,`${t.nodes} nodes`]}var vb={tree:{title:"Tree"},note:{title:"Note"},graph:{title:"Graph"}};function ph(t){return vb[t]}var ua={title:"Context"},gh="—";function mh(t,e,n){return{cwd:t===""?gh:t,selection:e??"nothing selected",stamp:n}}function vh(t){return t===null?gh:/T(\d{2}:\d{2}:\d{2})/.exec(t)?.[1]??t}var yh=["M21 12a9 9 0 1 1-2.64-6.36","M21 3v6h-6"],wh=6e4,bh="Search…";function ca(t){return t?"⌘K":"Ctrl K"}function xh(t){return`Search notes and repository (${t})`}function da(t){return/mac|iphone|ipad/i.test(t)}var yb={k:{type:"openSearch"}},_h={1:"tree",2:"note",3:"graph"},wb=new Set(["tree","graph"]);function bb(t){return t.ctrl!==t.meta&&!t.alt&&!t.shift}function xb(t){return!t.ctrl&&!t.meta&&!t.alt}var _b={"/":{type:"filterTree"},g:{type:"fitGraph"},"?":{type:"openHelp"},t:{type:"cycleTheme"}};function kh(t,e){if(e.overlay!==null)return t.key==="Escape"?{type:"closeOverlay"}:null;if(bb(t)){let n=yb[t.key.toLowerCase()];if(n!==void 0)return n;let r=_h[t.key];return r===void 0?null:{type:"focusColumn",column:r}}return t.key==="Escape"?e.hasSelection?{type:"clearSelection"}:null:!xb(t)||t.typing?null:_b[t.key]??null}var kb=["INPUT","TEXTAREA","SELECT"];function ha(t,e){return e?!0:t!==null&&kb.includes(t.toUpperCase())}function Eh(t){return{key:t.key,ctrl:t.ctrlKey,meta:t.metaKey,shift:t.shiftKey,alt:t.altKey,typing:ha(t.target?.tagName??null,t.target?.isContentEditable===!0)}}var Eb={tree:".weave-col-tree .weave-rows",note:".weave-col-note .weave-note-body",graph:".weave-col-graph .weave-graph-canvas"},Sb=".weave-col-tree .weave-filter";function Tb(t){let e=t;return typeof e?.focus=="function"?e:null}function Sh(t,e){let n=Tb(t.querySelector(e));return n===null?!1:(n.focus(),!0)}function Th(t,e){switch(t.type){case"openSearch":return e.setOverlay("search");case"openHelp":return e.setOverlay("help");case"closeOverlay":return e.setOverlay(null);case"focusColumn":return void e.focusSelector(Eb[t.column]);case"filterTree":return void e.focusSelector(Sb);case"fitGraph":return e.fitGraph();case"clearSelection":return e.clearSelection();case"cycleTheme":return e.cycleTheme()}}function Ah(t){return[{title:"Global",entries:[{combo:`${t}K`,what:"Search notes and the repository"},...Object.entries(_h).map(([e,n])=>({combo:`${t}${e}`,what:`Focus the ${n} column${wb.has(n)?" (when on screen)":""}`})),{combo:"?",what:"This help"},{combo:"t",what:"Cycle the colour theme (system / light / dark)"},{combo:"Esc",what:"Clear the selection, or close an overlay"}]},{title:"Tree",entries:[{combo:"/",what:"Filter the tree"},{combo:"j / ↓",what:"Next row"},{combo:"k / ↑",what:"Previous row"},{combo:"→",what:"Expand, or step into"},{combo:"←",what:"Collapse, or step out"},{combo:"Home / End",what:"First / last row"}]},{title:"Graph",entries:[{combo:"g",what:"Fit the whole graph"}]},{title:"Search",entries:[{combo:"↑ / ↓",what:"Move through results"},{combo:"↵",what:"Open the highlighted result"},{combo:"Esc",what:"Close the palette"}]}]}var fa="Keyboard shortcuts",Rh="esc close";var Ch={chevron:{d:["M5.75 4.25 9.5 8l-3.75 3.75"],filled:!1},vault:{d:["M8 2.6 13.4 8 8 13.4 2.6 8Z"],filled:!0},note:{d:["M4.5 2.75h4.75l2.25 2.25v8.25h-7Z","M9.25 2.75V5h2.25"],filled:!1},repository:{d:["M2.75 4.25h10.5v7.5H2.75Z","M2.75 6.75h10.5"],filled:!1},module:{d:["M2.75 4.25h4l1.5 1.75h5v5.75h-10.5Z"],filled:!1},package:{d:["M8 2.5 13.25 5v6L8 13.5 2.75 11V5Z","M2.75 5 8 7.5 13.25 5","M8 7.5v6"],filled:!1},entryPoint:{d:["M5.75 3.75v8.5L12.75 8Z"],filled:!0},gitState:{d:["M8 2.85 13.15 8 8 13.15 2.85 8Z"],filled:!1},external:{d:["M4.5 11.5l7-7","M6.75 4.5h4.75v4.75"],filled:!1},file:{d:["M4.5 2.75h7v10.5h-7Z"],filled:!1}};function In({name:t,class:e}){let n=Ch[t];return x("svg",{class:e,width:16,height:16,viewBox:`0 0 ${16} ${16}`,fill:n.filled?"currentColor":"none",stroke:n.filled?void 0:"currentColor","stroke-width":n.filled?void 0:n.width??1.5,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:n.d.map(r=>x("path",{d:r}))})}function Rb({view:t,recentIds:e,edit:n,onEdit:r,onRename:i,onSelect:o,onToggle:a,onMenu:s,onDrop:l}){let u=ko(t.id);return x("li",{id:t.domId,"data-row-id":t.id,class:`weave-row weave-row-${t.kind}${t.selected?" weave-row-on":""}${e.has(t.id)?" weave-row-new":""}`,role:"treeitem","aria-level":t.level,"aria-posinset":t.posinset,"aria-setsize":t.setsize,"aria-selected":t.selected,"aria-expanded":t.hasKids?t.expanded:void 0,style:Pu(t.depth),onClick:o,draggable:t.id.startsWith("note:"),onDragStart:c=>c.dataTransfer?.setData("text/plain",t.id),onDragOver:u===void 0?void 0:c=>c.preventDefault(),onDrop:u===void 0?void 0:c=>{c.preventDefault(),l(c.dataTransfer?.getData("text/plain")??"")},onContextMenu:c=>{c.preventDefault(),c.stopPropagation(),s(c.clientX,c.clientY)},children:[x("span",{class:"weave-twisty","aria-hidden":"true",onClick:c=>{c.stopPropagation(),a()},children:t.hasKids?x(In,{name:"chevron",class:t.expanded?"weave-icon weave-icon-open":"weave-icon"}):null}),x("span",{class:"weave-kind","aria-hidden":"true",children:x(In,{name:t.kindIcon,class:"weave-icon"})}),x("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),n===null?x("span",{class:"weave-label",children:t.label}):x("input",{class:"weave-tree-rename",value:n,autoFocus:!0,onClick:c=>c.stopPropagation(),onInput:c=>r(c.currentTarget.value),onBlur:c=>i(c.currentTarget.value),onKeyDown:c=>{c.stopPropagation(),c.key==="Enter"?c.currentTarget.blur():c.key==="Escape"&&i(null)}}),x("span",{class:"weave-meta",children:t.meta})]})}function Nh(t){let[e,n]=ne(_u),[r,i]=ne(null),[o,a]=ne(null),s=ku(t.graph,e),l=Uu(t.graph,s,e),u=async(h,d)=>{let f=await h;if(!f.ok)window.alert(f.message);else{let p=f.data.id??d;p!==void 0&&t.onSelect(p),t.onRefresh()}},c=async h=>{if(r===null)return;let d=Lr(r.id);i(null),d!==null&&(h==="rename"?a({id:r.id,label:r.label,value:r.label}):(!Su(d)||window.confirm(`Permanently delete folder “${r.label}” and everything inside it?`))&&await u(d.type==="note"?Ls(Xe,d.path):Ps(Xe,d.path),Eu(t.selectedId,d)?"vault":void 0))};return x("div",{class:"weave-tree",onKeyDown:h=>{let d=h.target,f=Cu(s,e,t.selectedId,h.key,ha(d?.tagName??null,d?.isContentEditable===!0));f.handled&&(h.preventDefault(),n(f.state),f.selectedId!==null&&t.onSelect(f.selectedId))},children:[x("div",{class:"weave-tree-controls",children:[x("input",{type:"search",class:"weave-filter",value:e.query,placeholder:Ou,"aria-label":zu,title:$u,onInput:h=>n(Tu(e,h.currentTarget.value))}),x("button",{type:"button",class:"weave-chip",title:Iu(e.provFilter),onClick:()=>n(Au(e)),children:["◧ ",Nr(e.provFilter)]}),x("button",{type:"button",class:"weave-chip",title:Mu(e.showInternals),onClick:()=>n(Ru(e)),children:["◧ ",Gu(e.showInternals)]})]}),l===null?x("ul",{class:"weave-rows",role:"tree",tabIndex:0,"aria-label":Fu,"aria-activedescendant":Du(s,t.selectedId)??void 0,children:Lu(s,t.selectedId,t.now).map(h=>x(Rb,{view:h,recentIds:t.recentIds,edit:o?.id===h.id?o.value:null,onEdit:d=>a(f=>f===null?null:{...f,value:d}),onRename:d=>{let f=o;a(null);let p=f===null?null:Lr(f.id),m=d?.trim(),v=f?.label;p!==null&&m&&v!==void 0&&m!==v&&window.confirm(`Rename “${v}”? Existing links to it may break.`)&&u(p.type==="note"?Cs(Xe,p.path,m):Ds(Xe,p.path,m))},onSelect:()=>{t.onSelect(h.id),h.hasKids&&n(d=>_o(d,h.id))},onToggle:()=>n(_o(e,h.id)),onMenu:(d,f)=>i({id:h.id,label:h.label,x:d,y:f}),onDrop:d=>{let f=ko(h.id);d.startsWith("note:")&&f!==void 0&&u(Ns(Xe,d.slice(5),f))}},h.id))}):x("p",{class:"weave-tree-empty",children:l}),x("p",{class:"weave-tree-count",children:Hu(s)}),r!==null&&Lr(r.id)!==null?x(qe,{children:[x("button",{type:"button",class:"weave-menu-backdrop","aria-label":"Close context menu",onClick:()=>i(null)}),x("div",{class:"weave-menu",role:"menu",style:{left:`${r.x}px`,top:`${r.y}px`},children:[x("button",{type:"button",role:"menuitem",onClick:()=>{c("rename")},children:"Rename…"}),x("button",{type:"button",role:"menuitem",class:"weave-menu-danger",onClick:()=>{c("delete")},children:"Delete"})]})]}):null]})}var Gn={links:"LINKS",backlinks:"BACKLINKS",tags:"TAGS",mentions:"MENTIONS"};function ei(t,e,n){return{id:t,target:e.id,label:Te(e),kind:e.kind,kindIcon:Eo(e.kind),provenance:e.provenance,provenanceGlyph:St(e.provenance),provenanceTitle:Kt(e.provenance),selected:e.id===n}}function Cb(t,e,n){let r=t.target;if(r===void 0)return null;let i=e.get(r);return i===void 0?null:ei(t.id,i,n)}function Nb(t){let e=new Map;for(let n of t.nodes)e.set(n.id,n);return e}var Lb=["link:links-to:"];function Db(t){return Lb.some(e=>t.id.startsWith(e))}function Pb(t){return t.id.startsWith("link:mentions:")}function Ib(t,e,n,r){let i=[];for(let[o,a]of Object.entries(t.tags)){if(!a.includes(e))continue;let s=[];for(let l of a){if(l===e)continue;let u=n.get(`note:${l}`);u!==void 0&&s.push(ei(`tag:${o}:${l}`,u,r))}i.push({tag:o,count:a.length,siblings:s})}return i}function Gb(t,e,n,r){let i=[];for(let o of t.edges){if(o.kind!=="mentions"||o.target!==e)continue;let a=n.get(o.source);a!==void 0&&i.push(ei(`mentioned-by:${o.source}`,a,r))}return i}function Mb(t){if(!t.startsWith("note:"))return null;let e=t.slice(5);return e===""?null:e}var Jr={loading:"Loading…",noSelection:"Select anything to see what it connects to.",unknown:"This node is not in the current graph.",isolated:"Nothing links to or from this yet."};function pa(t){return{subject:null,groups:[],tags:[],tagsCount:0,empty:t}}function Lh(t,e){if(t===null)return pa(Jr.loading);if(e===null)return pa(Jr.noSelection);let n=Et(t),r=vo(n,e);if(r===null)return pa(Jr.unknown);let i=Nb(n),o=[],a=(h,d)=>{d.length>0&&o.push({heading:h,count:d.length,rows:d})},s=h=>h.map(d=>Cb(d,i,e)).filter(d=>d!==null);a(Gn.links,s(r.links.filter(Db)));let l=wo(n.edges).get(e)??[];a(Gn.backlinks,l.map(h=>i.get(h)).filter(h=>h!==void 0).map(h=>ei(`backlink:${h.id}`,h,e))),a(Gn.mentions,[...s(r.links.filter(Pb)),...Gb(n,e,i,e)]);let u=Mb(e),c=u===null?[]:Ib(t,u,i,e);return o.length===0&&c.length===0?{subject:r.label,groups:[],tags:[],tagsCount:0,empty:Jr.isolated}:{subject:r.label,groups:o,tags:c,tagsCount:c.length,empty:null}}function Dh(){return{open:new Set,closed:new Set}}var Ob=8;function Ph(t,e,n,r){return r?!1:t.closed.has(e)?!0:t.open.has(e)?!1:n>Ob}function Fb(t){return t.some(e=>e.selected)}function Ih(t,e){let n=Ph(e,t.heading,t.count,Fb(t.rows));return{heading:t.heading,count:t.count,collapsed:n,rows:n?[]:t.rows}}function Gh(t,e){let n=Ph(e,Gn.tags,t.length,t.some(r=>r.siblings.some(i=>i.selected)));return{heading:Gn.tags,count:t.length,collapsed:n,rows:[]}}function Mh(t,e,n){let r=new Set(t.open),i=new Set(t.closed);return n?(r.add(e),i.delete(e)):(i.add(e),r.delete(e)),{open:r,closed:i}}function ti(t){return`weave-ctx-panel-${t.toLowerCase()}`}function Oh({row:t,onSelect:e}){return x("li",{class:`weave-ctx-row${t.selected?" weave-row-on":""}`,children:x("button",{type:"button",class:"weave-ctx-link",onClick:e,children:[x("span",{class:"weave-kind","aria-hidden":"true",children:x(In,{name:t.kindIcon,class:"weave-icon"})}),x("span",{class:`weave-prov weave-prov-${t.provenance??"none"}`,title:t.provenanceTitle,children:t.provenanceGlyph}),x("span",{class:"weave-label",children:t.label})]})})}function Fh({view:t,onToggle:e}){return x("h4",{class:"weave-ctx-head",children:x("button",{type:"button",class:"weave-ctx-heading","aria-expanded":!t.collapsed,"aria-controls":ti(t.heading),onClick:e,children:[x("span",{class:"weave-ctx-chevron","aria-hidden":"true",children:x(In,{name:"chevron",class:t.collapsed?"weave-icon":"weave-icon weave-icon-open"})}),t.heading,x("span",{class:"weave-ctx-count",children:t.count})]})})}function zb({view:t,onSelect:e,onToggle:n}){return x("section",{class:"weave-ctx-group",children:[x(Fh,{view:t,onToggle:n}),x("ul",{class:"weave-ctx-rows",id:ti(t.heading),hidden:t.collapsed,children:t.rows.map(r=>x(Oh,{row:r,onSelect:()=>e(r.target)},r.id))})]})}function $b({tag:t,onSelect:e}){return x("li",{class:"weave-ctx-tag",children:[x("span",{class:"weave-tag",children:["#",t.tag]}),x("ul",{class:"weave-ctx-rows",children:t.siblings.map(n=>x(Oh,{row:n,onSelect:()=>e(n.target)},n.id))})]})}function zh(t){let e=Lh(t.graph,t.selectedId),[n,r]=ne(Dh),i=a=>()=>r(Mh(n,a.heading,a.collapsed)),o=Gh(e.tags,n);return x("div",{class:"weave-rail","aria-label":ua.title,children:[x("h2",{class:"weave-col-title",children:ua.title}),e.empty===null?null:x("p",{class:"weave-ctx-empty",children:e.empty}),e.groups.map(a=>{let s=Ih(a,n);return x(zb,{view:s,onSelect:t.onSelect,onToggle:i(s)},a.heading)}),e.tags.length===0?null:x("section",{class:"weave-ctx-group",children:[x(Fh,{view:o,onToggle:i(o)}),x("ul",{class:"weave-ctx-tags",id:ti(o.heading),hidden:o.collapsed,children:e.tags.map(a=>x($b,{tag:a,onSelect:t.onSelect},a.tag))})]})]})}function $h(t){return x("div",{class:"weave-divider",role:"separator","aria-orientation":"vertical","aria-label":t.label,tabIndex:0,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),t.onDown(e.clientX)},onPointerMove:e=>t.onMove(e.clientX),onPointerUp:e=>{e.currentTarget.releasePointerCapture(e.pointerId),t.onUp()},onKeyDown:e=>t.onKey(e.key)})}function Ub({id:t,props:e}){let n=ph(t);return x("section",{class:`weave-col weave-col-${t}`,"aria-label":n.title,children:[x("h2",{class:"weave-col-title",children:n.title}),t==="tree"?x(Nh,{graph:e.graph,selectedId:e.selectedId,recentIds:e.recentIds,onSelect:e.onSelect,onRefresh:e.onRefresh,now:e.now}):null,t==="note"?x(eh,{note:e.note,graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,now:e.now,onOpen:e.onOpen}):null,t==="graph"?x(Xc,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect,renderer:e.renderer,storage:e.storage,host:e.host,scheme:e.scheme,bootFailed:e.bootFailed,fit:e.fit}):null,t==="graph"?x(zh,{graph:e.graph,selectedId:e.selectedId,onSelect:e.onSelect}):null]})}function Uh(t){let e=ee(null);return un(()=>{let n=e.current;if(n!==null)for(let{id:r,width:i}of t.resolved)n.style.setProperty(`--weave-col-${r}`,`${Math.round(i)}px`)},[t.resolved]),x("div",{class:"weave-grid",ref:e,"data-columns":t.resolved.length,children:t.resolved.map((n,r)=>{let i=r<t.resolved.length-1&&n.id!=="graph"?n.id:null;return[x(Ub,{id:n.id,props:t},`${n.id}-column`),i===null?null:x($h,{label:`Resize ${n.id} column`,onDown:o=>t.onDown(i,o),onMove:t.onMove,onUp:t.onUp,onKey:o=>t.onKey(i,o)},`${n.id}-divider`)]})})}function Hb(t){if(t===""||t==="#")return null;let e=t.slice(1),n=/^note[/:](.+)$/.exec(e);return n===null?null:`note:${n[1]}`}function Hh(t,e){let n=Hb(t);return n===null||e===null?null:e.model.nodes.some(r=>r.id===n)?n:null}function Bh(t){let e=t===null?null:t.startsWith("note:")?t.slice(5):null;return e===null||e===""?"":`#note/${e}`}function Bb(t,e,n){return{divider:t,origin:e,base:n}}function Wb(t,e,n){return la(t.base,t.divider,e-t.origin,n)}function Kb(t,e){return Pn.some(n=>t.base.fractions[n]!==e.fractions[n])}var Wh=24;function Vb(t){return t==="ArrowLeft"?-Wh:t==="ArrowRight"?Wh:0}function Kh(t){let e=null;return{onDown(n,r){e=Bb(n,r,t.layout())},onMove(n){e!==null&&t.setLayout(Wb(e,n,t.width()))},onUp(){let n=e;e=null,n!==null&&Kb(n,t.layout())&&t.persist(t.layout())},onKey(n,r){let i=la(t.layout(),n,Vb(r),t.width());i!==t.layout()&&(t.setLayout(i),t.persist(i))}}}var Vh="image/png",jh="iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAMKADAAQAAAABAAAAMAAAAADbN2wMAAALxElEQVRoBe1ZCXCU1R3/f+d+u5s9sleyOUlICBAMkQQQgpqBKqAoFQZFEYwWUAShjsco7dg4njRtPQcoXhSxWMGCimIYj1QqeICAcoQrd0iy2c1+u/vdZ9+m0xnFVCKw0+kMb+fb7/vevnnv//v/f//jvQVIYWtsbCn47uTJ3BQuAXgqJzdRM9CVyjVSCkACCUBIpfgAZCqnl5D8GJ5aBCm1ACALiGIqVZRqC7AIAGApRZBSCiUUBVN14/8YAJfAdN1MKU1TagEuwWEgp1T+1EYhRVUMhdNSmgdSagFeEHVJU/RUOkFKAThIWknLZNRUAkhFjKPSg2Muszocl/i8/mLT1M1IpO/rCBvaK/cePXGhwVxAANacYEHlkmEjymeguFNKUhShaToYhgG6rgJuAifL4oHjpxo3xdu/fAkBuSCWuSAAPNljLsvPH/lCusdfSVlIkFUFVCS0CQYkazkMuTGJEUAQJMrMEkTD3TvaWg/dJUab2s7XIsT5TkA6Cifl5434sCCvqEAS4sBzMdAVFdxYOjgxF6ShD6VTkBCjoEkiEKYBAX9WsaGT0yKh8DsAYvx8ZDhPADnW4SXlr+XnDh0WY3tBlgQwDQ10UQe/NQgOygkexoe4E4WE0AdgIkohWskiD440t9/EKX+cbd36PwNgd+ffMyR/2GJZjoOmySAryfITAxNHQkoyiLLYT6U2thHRB0djNPSuAY4lnyVQVLlMEMm9utp3zs59XmnSmeaelmZzgq7KkIjHgY3FQFOUfs4HHYUgawLQuAVspgdZRgcFAWRZFlRFRmMMtJvCMIKiZpyPBX5WHnA4hvkom/N6VVc+T4S/bXU4XCUCokZSaJokUd3JIDBqP4CuWDMIegRaIhIQyIFV1A+GCXbG2n/XVR2NN4AkiYokAE+g4mqapsrZRHSzFDvWPFhQPweAy+HxfZQdLBgtSVxPs8I/gdji1ZA2RVEAl98D106fAjzPw57P9gAb7QQLZQHVjIOAAKYHAjCheiLgyOY7360HmZdQiNWSlilM95c9npeT9yBJMxS0Q013DMYiAPxgQAzaiTOyxt/rcqXPa2tvApLA0zCcmsrQFIVhBmaxW+DJVQ/BroZdEOrugoUL58LB/Y0gCRLKAQZk5GTA0uXz4Z2t28Fuo+GeZTWwc+enIAhC8nerlbFeoagScbqrA3wejx8j3L0C3/XFYAAMygfs9pIyl9O1MhYNQzzGrgj1hrZKsoYbhorzXByurL4Mwt2nYcNL68DvcUKWzwlFQ7OQU8ugagoMLciEHL8Lcd6Etc+sAcxQYEzFJSAl95zID+KcBD294Q2JRGI5G2fB5fI8YnGUlAwGwGAohNMMU4cWc/Sx7KuG2vI8x8Jawjpso81mmZNmRTRBcV9B/PbmFcNL6zfD9voGmFRZDiamIfEwiERZmHbDIojHBQgOLQBJ1UBE1jGQdRTN0AVBXGfIJ+9FAstRlqqgKOttDEU/JQPMRn0/Wc2elUIMkzGEsTlXJXi+XUzEb3K48m7Jy7/0EcOQFUXRhtusNN7dE4aJl08EX4YXWFGFkqJC6Go/jaKO0p+JNeSweYUFkOb3wby5M5AlLPD2W+8ix1ZAkuWEw2FrzM4tu0/RGUaMs8+aOH4NTuIVkkmvBzWe+ClLDFhK+EpmVyL1lbsN/vWOrhM3khbrBo7nZjot+JFA5tBGTdcJUeIhnuDAjixgtzKQGcyCEWWjkBNz0Hz8GIR6QuByu4GiCYhGYuAPeKFg2HCw0BQc2PsN9PR0I+2bIKJ84XQ60BwOFJFIs635cLEO5FCLzb5D4rnZdXJz/ZHPDyxDfNz38pTxn5wJ5kcWmANziGYf9iFGuhbqBN7Js20WXZY/MOSWjZnZZS/abday1o6WQ5KsHHc60rOCmQGcZaMgoeza2dIKXW0toMgyijYYTKwaC5mZGdDe2g4CL0BHczN0oOcYyhcySmrZwWyQUaWXiLEf83w84fP6gjhppWN9B59XJThlc1C23KorJkEw94+KwE+4IT+4tqGh4Qeb7IEsgPmLZ69EaX4egSmfUTR2imacR+OhZi7T5XqPZXvtPT1dNarUvKmoZFqb00ZmtnR2ogJOA4eVAgrlA5Ig+rmvo7LBRB+CJPqppOs6SMixeVRqoAgGOUE/RFi+tbNt9xAgcmbl5Q3ZYrenR4pmVNxUfvVUXzwSzVVwwq243NNNTd/46rSJz53pEwNFIbP3xNtP2OhEFYqRR2UdX6OqYjdtd47ri/bSmirL/iFF3ZfPucfNxkInBIEDK00jpcu7E6KcYHmUlUUZBFlFOcAE3cRAkDTgBBlinAhokxZFkekf6e505AIqJBJsY119faD6uqmGpkiapPE2f0awCJXeB8W+wPOuuNzl23tgChL+2TOFT9JpIADJfmj77v0oup2wEDCpff+bewvGD98IFBWxEDiDwsf9hM8/05WT2xxLJEyaJmm7le7ho9FxkswvS/Dc/dFY/LlonNvSF49vY+Pc6hifWIpC8Dw+dqrS7XIj7zaocJQ1Kqdc0YZJ9PRwT2QJCrOU2+8Jjysd/envp08+FtBbr8RVaF710J2xfqEG+PqRD3x/THG+rUU0PLPtROE39uyMcWxXVycKLZM5Nmoc++dbS1csvnnrRx/vxVE9M8GTkV3qyw6Ee1u/qtOVyB50fajJvZs1Ofw3XQl/sF2OfDtz6W29TYfaF1hp+0IBhdFYLPrI8f31D+x88y+H4qz2G4vV6qXtrqdLKyrJ2b+YcJITbTNDVGjTvu3bf8D778s4kA98/3fIKps1BjOpsa5AuuXIod2vOBStHsXpqr6+SHX1pJrPWaqlINTW8QeU1aZnlZdR+eUlvyU0vY1kLCRptZiMg0F1EkHjBBgUQVQ27W+8dt+2nXYbSW5cNOf2Y8hDTr++7a9MU1vTG2Coh2PRo1WPPrZ1kSpKhkbInz39WM2+Hwh0xstZE5nOmx2YlamPhGWtIOeSxlioqV6K81W+YPbdLN1ZihEWLm/kqId0XT7sLyzo0riEDyfpRlRRNxk4jRJcQiEMtLtXyOt0IHYXlA45Xgiz4tmZubvwU60tkjdQ6khzLZIVExsz8tK9117+6Aw9xDxoIWweTQmNOEPeH72eFYCVIXHJNATAqBzd0Ce7fJmbuGhjKaIRf2Bn9lqAWqNi8WIqXUhvf3/VijXXPFCbyTC2+QppYSinN6wIHI2Z2DTM1Hc4KAPFePygE7PLoUhk7JMvLD+GJPoGyLxWmmb+XpI36kFRkGehAtxiqFo3SgtnPZL5r078H6gthzd345g6iTbk0ThmNuMYE1S4ozWSzNYlhU+Oo7stowRePJ18/qCutnvT75bVaR5fjeTyf6va019WJellKsxyAqcH/jR/7sHTEaVN541MtF/+N4UJc7MiHJ8f8GVUaqZqSlhstAnRisdfXHDWsvqsFkgKdfrQm+3olrwOF1feOLdk4q23B4cVvdawvhZ1AaBN1nBTV79MPpfOqaXdQmQ838OC1euTUbncjHP4nSoeWGF09d2VHLNu3Z3C8kWruTvueMqHXntfe3hD56HOYzWKIsefeWUJOrFIHgMMrp3ViQeapqRqbiVOWyfjJLlTZZwdjMrfAgb/itXmrqJJy0gMx47rUmSXf/pV3m1Lbm655f4X51oY5zgqLh7Red5u8PoXhElngsnkY5i4h6TwaswkGla/sfTrgdb7qb5zApCcsKTqDlTAkLertPNhAsMkq5pYzxDYJ1+9v2bX9xe8fuHKDJr2/nLL6vv+nOxfsOBJryli1zFGcKWN8hbzemiLyLX/6o0dted0OnHOAJLClFy1LEvBiMMYQSgMSHUUgUcoEpOApFmaolkGw3UrYbuR0I3dhKoLlEGmo2LDhTb4HGV4J1Fgv17RYr9+ddvit5LznUs7LwDJBUurby1C1aPW2LC+pbT67jTKTfssFOFFB1lOdJSF6lSKoHCStSgGj0qkMNrDhN97r7b/j7M5U2s9m+tr0XnLxXZRAxc1cFEDFzVwUQPnpoF/AbqLsVZFbswxAAAAAElFTkSuQmCC";function jb({onRefresh:t}){let[e,n]=ne(!1);return x("button",{type:"button",class:"weave-refresh",onClick:()=>{t(),n(!0)},onAnimationEnd:()=>n(!1),title:"Refetch everything","aria-busy":e?"true":void 0,children:x("svg",{class:e?"weave-refresh-glyph weave-refresh-spinning":"weave-refresh-glyph",viewBox:"0 0 24 24",width:14,height:14,fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:yh.map(r=>x("path",{d:r},r))})})}function qh(t){return x("header",{class:"weave-header",children:[x("span",{class:"weave-brand",children:[x("img",{class:"weave-brand-mark",src:`data:${Vh};base64,${jh}`,alt:"",width:18,height:18}),"pi-weave"]}),x("button",{type:"button",class:"weave-search",title:xh(t.shortcut),onClick:t.onSearch,children:[x("span",{class:"weave-search-text",children:bh}),x("kbd",{children:t.shortcut})]}),x("span",{class:"weave-summary",children:fh(t.summary).map(e=>x("span",{class:"weave-summary-part",children:e},e))}),x("button",{type:"button",class:"weave-theme",onClick:t.onTheme,title:t.theme.hint,"aria-label":t.theme.hint,children:t.theme.glyph}),x(jb,{onRefresh:t.onRefresh})]})}function qb({group:t}){return x("div",{children:[x("p",{class:"weave-key-group",children:t.title}),t.entries.map(e=>x("div",{class:"weave-key-row",children:[x("kbd",{class:"weave-key-combo",children:e.combo}),x("span",{class:"weave-key-what",children:e.what})]},e.combo))]})}function Yh(t){let e=Ur(),n=t.shortcut.slice(0,-1);return x("div",{class:"weave-scrim",onClick:t.onClose,children:x("div",{class:"weave-help",role:"dialog","aria-modal":"true","aria-label":fa,tabIndex:-1,ref:e.ref,onClick:r=>r.stopPropagation(),onKeyDown:r=>{e.onKeyDown(r)},children:[x("h2",{class:"weave-help-title",children:fa}),x("div",{class:"weave-keys",children:Ah(n).map(r=>x(qb,{group:r},r.title))}),x("p",{class:"weave-help-foot",children:[x("button",{type:"button",class:"weave-chip",onClick:t.onClose,children:"close"}),x("span",{class:"weave-help-hint",children:Rh})]})]})})}function Xh(t,e){let n=r=>{let i=kh(Eh(r),e.context());i!==null&&(r.preventDefault(),e.run(i))};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)}function Zh({model:t}){return x("footer",{class:"weave-status",children:[x("span",{class:"weave-status-cwd",title:t.cwd,children:t.cwd}),x("span",{class:"weave-status-sel",title:"the §1.3 context bus — one signal, every column",children:t.selection}),x("span",{class:"weave-status-stamp",title:"data as of",children:vh(t.stamp)})]})}var ga=["system","light","dark"],Qh="pi-weave.theme.v1";function Yb(t){return t==="system"||t==="light"||t==="dark"}function ni(t){try{let e=t.getItem(Qh);return Yb(e)?e:null}catch{return null}}function Jh(t,e){try{return t.setItem(Qh,e),!0}catch{return!1}}function ri(t){let e=ga.indexOf(t);return ga[(e+1)%ga.length]??"system"}function ef(t,e){return t==="system"?e:t}function ii(t){return t==="system"?null:t}var Xb={dark:"●",system:"◐",light:"○"};function tf(t){return{glyph:Xb[t],hint:`Colour theme: ${t} — click for ${ri(t)}`}}function Zb(t){t===null?delete document.documentElement.dataset.weaveTheme:document.documentElement.dataset.weaveTheme=t}function nf(t){let[e,n]=ne(Lc),[r,i]=ne(null),[o,a]=ne(t.initialWidth),[s,l]=ne(()=>ch(localStorage,t.initialWidth)),[u,c]=ne(()=>ni(localStorage)??"system"),[h,d]=ne(()=>ar(window)),f=ee(null),p=ee(null),m=ee({overlay:r,selectedId:e.selectedId,layout:s,width:o});m.current={overlay:r,selectedId:e.selectedId,layout:s,width:o},oe(()=>{let R=Ic({fetch:Xe,state:e,setState:n});return f.current=R,()=>R.stop()},[]),oe(()=>{let R=()=>a(window.innerWidth);return window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[]);let v=ee(!1),y=ee(location.hash);oe(()=>{v.current&&(Cc(localStorage,e.selectedId),history.replaceState(null,"",Bh(e.selectedId)))},[e.selectedId]),oe(()=>{if(v.current||e.graph===null||(v.current=!0,e.selectedId!==null))return;let R=Hh(y.current,e.graph);if(R!==null)f.current?.select(R);else{let P=Nc(e.graph,localStorage);P!==null&&f.current?.select(P)}},[e.graph]);let[w,k]=ne(()=>Date.now());oe(()=>{let R=setInterval(()=>k(Date.now()),wh);return()=>clearInterval(R)},[]),oe(()=>Zb(ii(u)),[u]),oe(()=>{Jh(localStorage,u)},[u]),oe(()=>Gs(window,d),[]),oe(()=>Xh(document,{context:()=>({overlay:m.current.overlay,hasSelection:m.current.selectedId!==null}),run:R=>Th(R,{setOverlay:i,focusSelector:P=>Sh(document,P),fitGraph:()=>p.current?.(),clearSelection:()=>{f.current?.select(null)},cycleTheme:()=>c(P=>ri(P))})}),[]);let _=Ye(()=>lh(s,o,ih(o)),[s,o]),L=Ye(()=>Kh({layout:()=>m.current.layout,width:()=>m.current.width,setLayout:l,persist:R=>{dh(localStorage,R)}}),[]);return x(qe,{children:[x(qh,{summary:hh(e.graph),shortcut:ca(da(t.platform)),onRefresh:()=>f.current?.refresh(),onSearch:()=>i("search"),theme:tf(u),onTheme:()=>c(R=>ri(R))}),x(Uh,{resolved:_,onDown:L.onDown,onMove:L.onMove,onUp:L.onUp,onKey:L.onKey,scheme:ef(u,h),bootFailed:e.graphFailed,graph:e.graph,note:e.note,selectedId:e.selectedId,recentIds:e.recentIds,onSelect:R=>{f.current?.select(R)},onRefresh:()=>f.current?.refresh(),onOpen:R=>{As(Xe,R)},now:w,renderer:fc,storage:localStorage,host:window,fit:p}),x(Zh,{model:mh(t.cwd,e.selectedId,e.graph?.model.generatedAt??null)}),r==="search"?x(Ac,{graph:e.graph,onSelect:R=>{f.current?.select(R)},onClose:()=>i(null),ports:{fetch:Xe}}):null,r==="help"?x(Yh,{shortcut:ca(da(t.platform)),onClose:()=>i(null)}):null]})}var rf=`
|
|
399
399
|
--weave-bg:#eff1f5;--weave-panel:#e6e9ef;--weave-raise:#ccd0da;--weave-fg:#4c4f69;--weave-dim:#56586a;
|
|
400
400
|
--weave-faint:#606274;--weave-line:#ccd0da;--weave-line-strong:#bcc0cc;
|
|
401
401
|
--weave-accent:#7113ec;--weave-ok:#28641b;--weave-warn:#7c4f10;--weave-bad:#b20d30;
|
|
402
402
|
--weave-new:rgba(113,19,236,.10);
|
|
403
403
|
--weave-page:#dce0e8;
|
|
404
|
-
`,
|
|
404
|
+
`,Qb=`
|
|
405
405
|
:root{
|
|
406
406
|
--weave-bg:#24273a;--weave-panel:#1e2030;--weave-raise:#363a4f;--weave-fg:#cad3f5;--weave-dim:#a5adcb;
|
|
407
407
|
--weave-faint:#939ab7;--weave-line:#363a4f;--weave-line-strong:#494d64;
|
|
@@ -463,11 +463,11 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
463
463
|
without a manual "dark" being dragged back into light by the OS. */
|
|
464
464
|
@media (prefers-color-scheme: light){
|
|
465
465
|
:root:not([data-weave-theme="dark"]){
|
|
466
|
-
${
|
|
466
|
+
${rf}
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
469
|
:root[data-weave-theme="light"]{
|
|
470
|
-
${
|
|
470
|
+
${rf}
|
|
471
471
|
}
|
|
472
472
|
body{font-size:var(--weave-px-base)}
|
|
473
473
|
#app{height:100%;display:grid;grid-template-rows:auto 1fr auto;background:var(--weave-bg)}
|
|
@@ -615,12 +615,18 @@ body{font-size:var(--weave-px-base)}
|
|
|
615
615
|
.weave-prov-agent{color:var(--weave-accent)}
|
|
616
616
|
.weave-prov-generated{color:var(--weave-faint)}
|
|
617
617
|
.weave-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis}
|
|
618
|
+
.weave-tree-rename{flex:1;min-width:0;height:20px;padding:0 4px;font:inherit;color:var(--weave-fg);background:var(--weave-panel);border:1px solid var(--weave-accent)}
|
|
618
619
|
.weave-meta{flex:none;font-size:var(--weave-px-caption);color:var(--weave-faint)}
|
|
619
620
|
.weave-tree-empty{flex:1;margin:0;padding:14px var(--weave-gutter);color:var(--weave-dim)}
|
|
620
621
|
.weave-tree-count{
|
|
621
622
|
margin:0;padding:3px var(--weave-gutter);font-size:var(--weave-px-caption);color:var(--weave-faint);
|
|
622
623
|
border-top:1px solid var(--weave-line);
|
|
623
624
|
}
|
|
625
|
+
.weave-menu-backdrop{position:fixed;inset:0;border:0;background:transparent;z-index:20}
|
|
626
|
+
.weave-menu{position:fixed;z-index:21;display:grid;min-width:120px;padding:4px;background:var(--weave-panel);border:1px solid var(--weave-line-strong)}
|
|
627
|
+
.weave-menu button{padding:6px 10px;border:0;background:transparent;color:var(--weave-fg);text-align:left}
|
|
628
|
+
.weave-menu button:hover{background:var(--weave-line)}
|
|
629
|
+
.weave-menu .weave-menu-danger{color:var(--weave-bad)}
|
|
624
630
|
|
|
625
631
|
/* icons ------------------------------------------------------------------
|
|
626
632
|
The sprite's only CSS: one colour (the glyph inherits the row's, so a
|
|
@@ -987,7 +993,7 @@ body{font-size:var(--weave-px-base)}
|
|
|
987
993
|
@keyframes weave-fade-in{from{opacity:0}}
|
|
988
994
|
@keyframes weave-overlay-in{from{opacity:0;transform:translateY(4px)}}
|
|
989
995
|
@media (prefers-reduced-motion: reduce){*{transition:none!important;animation:none!important}}
|
|
990
|
-
`,
|
|
996
|
+
`,Jb=["style[nonce]","style","script[nonce]","script[src]"];function ex(t){for(let e of Jb){let n=t.querySelector(e)?.nonce;if(typeof n=="string"&&n!=="")return n}return null}function of(t,e=Qb){let n=t.createElement("style"),r=ex(t);return r!==null&&(n.nonce=r),n.textContent=e,t.head.appendChild(n),r!==null}var af=document.getElementById("app");if(af!==null){of(document),tx();let t=cs(document.getElementById(us)?.textContent??null);ls(x(nf,{cwd:t.cwd,initialWidth:window.innerWidth,platform:navigator.platform}),af)}function tx(){let t=ii(ni(localStorage)??"system");t!==null&&(document.documentElement.dataset.weaveTheme=t)}})();
|
|
991
997
|
/*! Bundled license information:
|
|
992
998
|
|
|
993
999
|
dompurify/dist/purify.es.mjs:
|